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:
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 = '<=' }
}
}
Type | Intent | Optional | 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 |
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