ExtremeFLOW / neko

/ᐠ. 。.ᐟ\ᵐᵉᵒʷˎˊ˗
https://neko.cfd/
Other
159 stars 28 forks source link

Add field_writer simcomp #1192

Closed timofeymukha closed 3 months ago

timofeymukha commented 3 months ago

This PR adds a new simcomp called field_writer, which basically dumps a given list of fields from the registry to an .fld file. Either a separate fld, or adding new fields to the fluid output. Intended use is custom fields from the user file. Quite useful for debugging as well. Also, I think I will try to have it as a component in other simcomps that output stuff, like vorticity and lambda2, to avoid code duplication.

Additionally, gives field_registry a face lift and adds the possibility to just do nothing when attempting to add a field, which already exists. Very often we have a construct which first checks that a field does not exists, and then adds it. This way, we can do it in 1 line.

vbaconnet commented 3 months ago

Amazing! Looking forward to using this asap :)

timofeymukha commented 3 months ago

Nice bonk from gfortran-10. The issue seems to be the intent in the field list appending.

  !> Append a field to the list.
  !! @param field The field to append.
  subroutine field_list_append(this, field)
    class(field_list_t), intent(inout) :: this
    class(field_t), intent(inout), target :: field
    type(field_ptr_t), allocatable :: tmp(:)
    integer :: len

    len = size(this%fields)

    allocate(tmp(len+1))
    tmp(1:len) = this%fields
    call move_alloc(tmp, this%fields)
    this%fields(len+1)%f => field

  end subroutine field_list_append

Can we change this to in for the field argument?

njansson commented 3 months ago

Nice bonk from gfortran-10. The issue seems to be the intent in the field list appending.

  !> Append a field to the list.
  !! @param field The field to append.
  subroutine field_list_append(this, field)
    class(field_list_t), intent(inout) :: this
    class(field_t), intent(inout), target :: field
    type(field_ptr_t), allocatable :: tmp(:)
    integer :: len

    len = size(this%fields)

    allocate(tmp(len+1))
    tmp(1:len) = this%fields
    call move_alloc(tmp, this%fields)
    this%fields(len+1)%f => field

  end subroutine field_list_append

Can we change this to in for the field argument?

Should be safe I would say