tem_convergence_load Subroutine

public subroutine tem_convergence_load(me, conf, parent, steady_state)

Load the convergence definition table The convergence object must be part of a convergence object, for which the format has been set to format = 'convergence' In the convergence table, you then must define a norm:

  • simple: just check against the state value of the last check, and reach convergence if below the defined threshold
  • average: build the average over a defined set of last checks with nvals stop, if the difference to the current state value is below the given threshold
  • nvals: define, how many last checks should be taken into account for averaging procedure

The error is by default calculated to be a relative error. If an absolute error is desired, choose absolute=true in the convergence object

The stopping criterion is defined as a general condition object, where the threshold and the operator has to be given

  condition = { threshold = 1.E-6, operator = '<' }

A sample convergence object with a convergence definition can look as follows (within time_control table):

  abort_criteria = {
   stop_file = 'stop',
   steady_state = true,
   convergence = {
     variable = {'pressure','velocity'},
     shape = {kind = 'all'},
     time_control = {
       min = {iter=0},
       max = {iter=tmax},
       interval = {iter=10*dt}},
     reduction = {'average','average'},
     norm='average', nvals = 100, absolute = true,
     condition = {
        { threshold = 1.e-15, operator = '<=' },
        { threshold = 1.e-12, operator = '<=' }
     }
   }
  }

Or another sample:

  abort_criteria = {
    stop_file     = 'stop',
    steady_state  = true,
    convergence   = {
      variable = {'pressure_phy'},
      shape = {
        {kind = 'canoND', object = {origin ={0.15-dx,0.2,zpos} }},
        {kind = 'canoND', object = {origin ={0.25+dx,0.2,zpos} }}
      },
      time_control = {min = 0, max = tmax, interval = 10*dt},
      reduction = {'average'},
      norm      = 'average',
      nvals     = 50,
      absolute  = true,
      condition = { threshold = 1.e-10, operator = '<=' }
    }
  }

Arguments

Type IntentOptional Attributes Name
type(tem_convergence_type), intent(out), allocatable :: me(:)

list of the convergence entities to create

type(flu_State) :: conf

general control parameters handle of the lua config file

integer, optional :: parent

if the convergence table is a child-table of some other table, use the parent as a reference

logical, intent(inout) :: steady_state

Steady flag in abort_criteria to check for convergence


Calls

proc~~tem_convergence_load~~CallsGraph proc~tem_convergence_load tem_convergence_load aot_table_close aot_table_close proc~tem_convergence_load->aot_table_close aot_table_length aot_table_length proc~tem_convergence_load->aot_table_length aot_table_open aot_table_open proc~tem_convergence_load->aot_table_open proc~tem_horizontalspacer tem_horizontalSpacer proc~tem_convergence_load->proc~tem_horizontalspacer proc~tem_load_convergenceheader tem_load_convergenceHeader proc~tem_convergence_load->proc~tem_load_convergenceheader proc~tem_load_convergenceheader->aot_table_close aot_get_val aot_get_val proc~tem_load_convergenceheader->aot_get_val interface~tem_load_shape tem_load_shape proc~tem_load_convergenceheader->interface~tem_load_shape proc~tem_abort tem_abort proc~tem_load_convergenceheader->proc~tem_abort proc~tem_load_condition tem_load_condition proc~tem_load_convergenceheader->proc~tem_load_condition proc~tem_load_reduction_spatial tem_load_reduction_spatial proc~tem_load_convergenceheader->proc~tem_load_reduction_spatial proc~tem_timecontrol_dump tem_timeControl_dump proc~tem_load_convergenceheader->proc~tem_timecontrol_dump proc~tem_timecontrol_load tem_timeControl_load proc~tem_load_convergenceheader->proc~tem_timecontrol_load proc~upper_to_lower upper_to_lower proc~tem_load_convergenceheader->proc~upper_to_lower proc~tem_load_shape_single tem_load_shape_single interface~tem_load_shape->proc~tem_load_shape_single proc~tem_load_shapes tem_load_shapes interface~tem_load_shape->proc~tem_load_shapes mpi_abort mpi_abort proc~tem_abort->mpi_abort proc~tem_load_condition->aot_table_close proc~tem_load_condition->aot_table_length proc~tem_load_condition->aot_table_open proc~tem_load_cond_single tem_load_cond_single proc~tem_load_condition->proc~tem_load_cond_single proc~tem_load_reduction_spatial->aot_table_close proc~tem_load_reduction_spatial->aot_table_length proc~tem_load_reduction_spatial->aot_table_open proc~tem_load_reduction_single tem_load_reduction_single proc~tem_load_reduction_spatial->proc~tem_load_reduction_single proc~tem_time_dump tem_time_dump proc~tem_timecontrol_dump->proc~tem_time_dump proc~tem_timecontrol_load->aot_table_close proc~tem_timecontrol_load->aot_table_open proc~tem_timecontrol_load->aot_get_val proc~tem_time_default_zero tem_time_default_zero proc~tem_timecontrol_load->proc~tem_time_default_zero proc~tem_time_load tem_time_load proc~tem_timecontrol_load->proc~tem_time_load proc~tem_time_needs_reduce tem_time_needs_reduce proc~tem_timecontrol_load->proc~tem_time_needs_reduce proc~tem_time_never tem_time_never proc~tem_timecontrol_load->proc~tem_time_never

Called by

proc~~tem_convergence_load~~CalledByGraph proc~tem_convergence_load tem_convergence_load proc~tem_abortcriteria_load tem_abortCriteria_load proc~tem_abortcriteria_load->proc~tem_convergence_load proc~tem_simcontrol_load tem_simControl_load proc~tem_simcontrol_load->proc~tem_abortcriteria_load proc~tem_load_general tem_load_general proc~tem_load_general->proc~tem_simcontrol_load

Source Code

  subroutine tem_convergence_load(me, conf, parent, steady_state)
    ! ---------------------------------------------------------------------------
    !> list of the convergence entities to create
    type( tem_convergence_type ), allocatable, intent(out) :: me(:)
    !> general control parameters
    !> handle of the lua config file
    type( flu_state ) :: conf
    !> if the convergence table is a child-table of some other table,
    !! use the parent as a reference
    integer, optional :: parent
    !> Steady flag in abort_criteria to check for convergence
    logical, intent(inout) :: steady_state
    ! ---------------------------------------------------------------------------
    integer :: conv_handle, sub_handle
    integer :: iConv, nConv
    ! ---------------------------------------------------------------------------

    ! Read the number of convergences in the lua file
    call aot_table_open( L       = conf,          &
      &                  thandle = conv_handle,   &
      &                  key     = 'convergence', &
      &                  parent  = parent         )

    if (conv_handle == 0) then
      write(logUnit(1),*) 'WARNING: Abort criteria, steady state is true but'
      write(logUnit(1),*) '         No Convergence table is defined with '
      write(logUnit(1),*) '         conditions to check for steady state'
      write(logUnit(1),*) 'NOTE: Steady state is deactivated'
      steady_state = .false.
      call aot_table_close(L=conf, thandle=conv_handle)
      call tem_horizontalSpacer(fUnit=logUnit(1))
      return
    end if

    write(logUnit(1),*) 'Loading convergence for steady state...'
    ! Check whether convergence had a subtable
    ! If no, then it is a single table, load single convergence entry
    ! else load multiple tables, open convergence subtable
    call aot_table_open( L       = conf,        &
      &                  parent  = conv_handle, &
      &                  thandle = sub_handle,  &
      &                  pos     = 1            )

    ! Only single table
    if (sub_handle == 0) then
      nConv = 1
      write(logUnit(1),*) 'Convergence is a single table'
      allocate( me( nConv ) )
      call tem_load_convergenceHeader( conf       = conf,        &
        &                              sub_handle = conv_handle, &
        &                              me         = me(1)        )
      call aot_table_close(L=conf, thandle=sub_handle)
    else ! Multiple table
      call aot_table_close(L=conf, thandle=sub_handle)
      nConv = aot_table_length(L=conf, thandle=conv_handle)
      ! Allocate the defined number of convergence entities
      allocate( me( nConv ))
      write(logUnit(1),*) 'Number of Convergence entities: ', nConv

      ! Loop over all the definitions and assign the variables from the lua
      ! file on the tem_convergence_type.
      ! Inside this routine it will open convergence subtable. Each subtable
      ! contains one or more convergence variables the stuff is done in the
      ! routine tem_load_convergenceHeader
      do iConv = 1, nConv
        write(logUnit(3),*) 'Loading convergence ', iConv
        call aot_table_open( L       = conf,        &
          &                  parent  = conv_handle, &
          &                  thandle = sub_handle,  &
          &                  pos     = iConv      )
        call tem_load_convergenceHeader( conf           = conf,       &
          &                              sub_handle     = sub_handle, &
          &                              me             = me(iConv)   )
        call aot_table_close(L=conf, thandle=sub_handle)
        write(logUnit(3),*) 'Done'
      end do
    end if ! sub_handle

    call aot_table_close(L=conf, thandle=conv_handle) ! close convergence table
    call tem_horizontalSpacer(fUnit=logUnit(1))

  end subroutine tem_convergence_load