Neko 1.99.9
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
time_based_controller Module Reference

Contains the time_based_controller_t type.

Data Types

type  time_based_controller_t
 A utility type for determining whether an action should be executed based on the current time value. Used to e.g. control whether we should write a file or execute a simcomp. More...
 

Functions/Subroutines

subroutine time_based_controller_init (this, start_time, end_time, control_mode, control_value, write_at_start, anchor_time, direction)
 Constructor.
 
subroutine time_based_controller_free (this)
 Destructor.
 
logical function time_based_controller_check (this, time, force)
 Check if the execution should be performed.
 
pure integer function next_index_after (this, time)
 The number of scheduled times at or before the given time, counted from first_index. Assigning it to next_index after an execution makes the next scheduled time the first one after the given time.
 
subroutine time_based_controller_register_execution (this, time)
 Increment nexecutions and advance next_index past the current time.
 
subroutine time_based_controller_set_counter (this, time)
 Set next_index to the first scheduled time not yet reached, and nexecutions to the number of executions performed up to the current time. Called when restarting a simulation.
 
pure real(kind=dp) function time_based_controller_tolerance (this, dt)
 The tolerance used when comparing the simulation time to a scheduled execution time.
 
pure real(kind=dp) function time_based_controller_next_time (this)
 The time of the next scheduled execution.
 

Variables

real(kind=dp), parameter, public time_tol = 0.1_dp
 Tolerance for comparing the simulation time to a scheduled time, as a fraction of the time step. A scheduled time t_k is considered reached at the first step with t >= t_k - TIME_TOL * dt, so that round-off in the accumulation of t does not postpone the execution by a full step. The tolerance is limited to the same fraction of the output interval, so that a time step longer than the interval (in particular the dt = 1 placeholder a variable time step run starts from) cannot make a scheduled time count as reached before the previous one has passed.
 
real(kind=dp), parameter, public span_tol = 1.0e-9_dp
 Relative tolerance for round-off in k * time_interval when comparing a scheduled time to start_time and end_time.
 

Function/Subroutine Documentation

◆ next_index_after()

pure integer function time_based_controller::next_index_after ( class(time_based_controller_t), intent(in)  this,
type(time_state_t), intent(in)  time 
)
private
Note
Scheduled times passed within a single step are all counted, so a time step larger than the output interval gives one execution per step and not one per passed scheduled time.

Definition at line 373 of file time_based_controller.f90.

Here is the caller graph for this function:

◆ time_based_controller_check()

logical function time_based_controller::time_based_controller_check ( class(time_based_controller_t), intent(in)  this,
type(time_state_t), intent(in)  time,
logical, intent(in), optional  force 
)
private
Parameters
timeThe current time state.
forceWhether to execute irrespective of the schedule. Optional, defaults to .false..

The result is .true. at the first time step at which the next scheduled time has been reached, within a tolerance of TIME_TOL * dt. A forced execution is performed unless the time is before start_time, or an execution has already been registered for the current time step. The latter keeps the forced execution at the end of a simulation from repeating a scheduled one at the same step. Forcing does override a never control, which is how output_at_end writes an output that is otherwise never written.

Definition at line 314 of file time_based_controller.f90.

◆ time_based_controller_free()

subroutine time_based_controller::time_based_controller_free ( class(time_based_controller_t), intent(inout)  this)
private

Definition at line 276 of file time_based_controller.f90.

◆ time_based_controller_init()

subroutine time_based_controller::time_based_controller_init ( class(time_based_controller_t), intent(inout)  this,
real(kind=dp), intent(in)  start_time,
real(kind=dp), intent(in)  end_time,
character(len=*), intent(in)  control_mode,
real(kind=dp), intent(in)  control_value,
logical, intent(in), optional  write_at_start,
real(kind=dp), intent(in), optional  anchor_time,
real(kind=dp), intent(in), optional  direction 
)
Parameters
start_timeThe first time at which an execution can be performed.
end_timeThe final simulation time.
control_modeThe way to interpret the control_value parameter.
control_valueThe value defining the execution frequency.
write_at_startWhether an execution is performed at start_time, whether or not it is one of the scheduled times. Optional, defaults to .true..
anchor_timeThe time the scheduled times are counted from. Optional, defaults to zero for simulationtime and to start_time for nsamples.
directionSign of the time step of the simulation, +1 or -1. Optional, defaults to the sign of end_time - start_time. That default is wrong for an output whose start_time lies beyond the end of the simulation, so pass the direction for an output with its own start time.

Definition at line 172 of file time_based_controller.f90.

◆ time_based_controller_next_time()

pure real(kind=dp) function time_based_controller::time_based_controller_next_time ( class(time_based_controller_t), intent(in)  this)
private
Note
Meaningless for the tsteps and never control modes, for which the end time of the simulation is returned.

Definition at line 493 of file time_based_controller.f90.

◆ time_based_controller_register_execution()

subroutine time_based_controller::time_based_controller_register_execution ( class(time_based_controller_t), intent(inout)  this,
type(time_state_t), intent(in)  time 
)
private
Parameters
timeThe current time state.

Definition at line 401 of file time_based_controller.f90.

Here is the call graph for this function:

◆ time_based_controller_set_counter()

subroutine time_based_controller::time_based_controller_set_counter ( class(time_based_controller_t), intent(inout)  this,
type(time_state_t), intent(in)  time 
)
private
Parameters
timeThe current time.

The comparison is the same as in check, so that exactly the executions performed by the run that wrote the checkpoint are counted as done, and none is repeated or skipped.

Definition at line 419 of file time_based_controller.f90.

◆ time_based_controller_tolerance()

pure real(kind=dp) function time_based_controller::time_based_controller_tolerance ( class(time_based_controller_t), intent(in)  this,
real(kind=dp), intent(in)  dt 
)
private
Parameters
dtThe size of the time step under consideration.

Definition at line 478 of file time_based_controller.f90.

Variable Documentation

◆ span_tol

real(kind=dp), parameter, public time_based_controller::span_tol = 1.0e-9_dp

Definition at line 53 of file time_based_controller.f90.

◆ time_tol

real(kind=dp), parameter, public time_based_controller::time_tol = 0.1_dp

Definition at line 49 of file time_based_controller.f90.