|
Neko 1.99.9
A portable framework for high-order spectral element flow simulations
|
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...
Public Member Functions | |
| procedure, pass(this) | init (this, start_time, end_time, control_mode, control_value, write_at_start, anchor_time, direction) |
| Constructor. | |
| procedure, pass(this) | free (this) |
| Destructor. | |
| procedure, pass(this) | check (this, time, force) |
| Check if the execution should be performed. | |
| procedure, pass(this) | register_execution (this, time) |
Increment nexecutions and advance next_index. | |
| procedure, pass(this) | set_counter (this, time) |
Set next_index and nexecutions for the current time (restarts). | |
| procedure, pass(this) | next_time (this) |
| The time of the next scheduled execution. | |
| procedure, pass(this) | tolerance (this, dt) |
| The tolerance used when comparing times. | |
Public Attributes | |
| real(kind=dp) | frequency = 0.0_dp |
| Frequency of execution. | |
| real(kind=dp) | time_interval = 0.0_dp |
| Time interval between executions. Always positive. | |
| integer | nsteps = 0 |
| Number of time steps in between executions. | |
| real(kind=dp) | start_time = 0.0_dp |
| First time at which an execution can be performed. | |
| real(kind=dp) | end_time = 0.0_dp |
| Time after which nothing is scheduled anymore. | |
| integer | nexecutions = 0 |
| Number of times already executed. | |
| logical | never = .false. |
| Whether to never execute. | |
| character(len=:), allocatable | control_mode |
Control mode defining the meaning of control_value. Can be simulationtime, tsteps, nsamples or never. | |
| real(kind=dp) | control_value = 0.0_dp |
| Defines the frequency of writes. | |
| real(kind=dp) | anchor_time = 0.0_dp |
Time the scheduled times are counted from. Zero for simulationtime and start_time for nsamples. | |
| logical | write_at_start = .true. |
Whether an execution is performed at start_time, whether or not it is one of the scheduled times. Should be .false. for outputs for which an execution at the very first time step is meaningless, such as checkpoints and running statistics. | |
| integer(kind=i8) | first_index = 0 |
Index k of the first scheduled time. | |
| logical | start_is_scheduled = .false. |
Whether start_time is one of the scheduled times. | |
| logical | start_pending = .false. |
Whether the execution at start_time is still to be performed. Only set when write_at_start is true and start_time is not one of the scheduled times. | |
| integer | next_index = 0 |
Number of scheduled times already passed. The next scheduled time is t_k with k = first_index + next_index. | |
| real(kind=dp) | direction = 1.0_dp |
| Sign of the time step: +1 for a run forwards in time, -1 for a run backwards in time. | |
| integer | tstep_offset = 0 |
Value of tstep at which the current run started. Only used by the tsteps control mode, whose schedule is relative to the run. | |
| integer | last_tstep = -1 |
| Time step at which an execution was last registered, -1 if none. Guarantees that at most one execution is performed per time step, also when a forced execution coincides with a scheduled one. | |
The controller defines a schedule: the times (or time steps) at which the action is executed. For the time based control modes these are \( t_k = t_{anchor} + k \Delta t_{out} \) for the \( k \) with \( t_k \) in \( [t_{start}, t_{end}] \) and, if write_at_start is set, \( t_{start} \) itself.
A simulationtime schedule has anchor_time = 0, so that the executions are at whole multiples of the interval regardless of the start time. An nsamples schedule divides the interval from start_time to end_time, so its anchor is start_time.
The schedule depends only on the case parameters, not on the number of executions performed or on the time the run was started from. On a restart, set_counter sets next_index to the first scheduled time not yet reached, using the same comparison as check, so that no execution is repeated or skipped.
A simulation may march backwards in time (start time larger than the end time, negative time step), as for an adjoint problem. All comparisons are therefore made on the progress direction * (t - anchor_time), which increases during the run in either case.
check does not modify the controller and returns .false. for a time step at which an execution has already been registered, so it can be called several times per step. register_execution increments nexecutions and advances next_index.
Definition at line 86 of file time_based_controller.f90.
| procedure, pass(this) time_based_controller::time_based_controller_t::check | ( | class(time_based_controller_t), intent(in) | this, |
| type(time_state_t), intent(in) | time, | ||
| logical, intent(in), optional | force | ||
| ) |
| time | The current time state. |
| force | Whether 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 142 of file time_based_controller.f90.
| procedure, pass(this) time_based_controller::time_based_controller_t::free | ( | class(time_based_controller_t), intent(inout) | this | ) |
Definition at line 140 of file time_based_controller.f90.
| procedure, pass(this) time_based_controller::time_based_controller_t::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 | ||
| ) |
| start_time | The first time at which an execution can be performed. |
| end_time | The final simulation time. |
| control_mode | The way to interpret the control_value parameter. |
| control_value | The value defining the execution frequency. |
| write_at_start | Whether an execution is performed at start_time, whether or not it is one of the scheduled times. Optional, defaults to .true.. |
| anchor_time | The time the scheduled times are counted from. Optional, defaults to zero for simulationtime and to start_time for nsamples. |
| direction | Sign 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 138 of file time_based_controller.f90.
| procedure, pass(this) time_based_controller::time_based_controller_t::next_time | ( | class(time_based_controller_t), intent(in) | this | ) |
tsteps and never control modes, for which the end time of the simulation is returned. Definition at line 150 of file time_based_controller.f90.
| procedure, pass(this) time_based_controller::time_based_controller_t::register_execution | ( | class(time_based_controller_t), intent(inout) | this, |
| type(time_state_t), intent(in) | time | ||
| ) |
| time | The current time state. |
Definition at line 144 of file time_based_controller.f90.
| procedure, pass(this) time_based_controller::time_based_controller_t::set_counter | ( | class(time_based_controller_t), intent(inout) | this, |
| type(time_state_t), intent(in) | time | ||
| ) |
| time | The 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 147 of file time_based_controller.f90.
| procedure, pass(this) time_based_controller::time_based_controller_t::tolerance | ( | class(time_based_controller_t), intent(in) | this, |
| real(kind=dp), intent(in) | dt | ||
| ) |
| dt | The size of the time step under consideration. |
Definition at line 152 of file time_based_controller.f90.
| real(kind=dp) time_based_controller::time_based_controller_t::anchor_time = 0.0_dp |
Definition at line 108 of file time_based_controller.f90.
| character(len=:), allocatable time_based_controller::time_based_controller_t::control_mode |
Definition at line 103 of file time_based_controller.f90.
| real(kind=dp) time_based_controller::time_based_controller_t::control_value = 0.0_dp |
Definition at line 105 of file time_based_controller.f90.
| real(kind=dp) time_based_controller::time_based_controller_t::direction = 1.0_dp |
Definition at line 127 of file time_based_controller.f90.
| real(kind=dp) time_based_controller::time_based_controller_t::end_time = 0.0_dp |
Definition at line 96 of file time_based_controller.f90.
| integer(kind=i8) time_based_controller::time_based_controller_t::first_index = 0 |
Definition at line 115 of file time_based_controller.f90.
| real(kind=dp) time_based_controller::time_based_controller_t::frequency = 0.0_dp |
Definition at line 88 of file time_based_controller.f90.
| integer time_based_controller::time_based_controller_t::last_tstep = -1 |
Definition at line 134 of file time_based_controller.f90.
| logical time_based_controller::time_based_controller_t::never = .false. |
Definition at line 100 of file time_based_controller.f90.
| integer time_based_controller::time_based_controller_t::nexecutions = 0 |
Definition at line 98 of file time_based_controller.f90.
| integer time_based_controller::time_based_controller_t::next_index = 0 |
Definition at line 124 of file time_based_controller.f90.
| integer time_based_controller::time_based_controller_t::nsteps = 0 |
Definition at line 92 of file time_based_controller.f90.
| logical time_based_controller::time_based_controller_t::start_is_scheduled = .false. |
Definition at line 117 of file time_based_controller.f90.
| logical time_based_controller::time_based_controller_t::start_pending = .false. |
Definition at line 121 of file time_based_controller.f90.
| real(kind=dp) time_based_controller::time_based_controller_t::start_time = 0.0_dp |
Definition at line 94 of file time_based_controller.f90.
| real(kind=dp) time_based_controller::time_based_controller_t::time_interval = 0.0_dp |
Definition at line 90 of file time_based_controller.f90.
| integer time_based_controller::time_based_controller_t::tstep_offset = 0 |
Definition at line 130 of file time_based_controller.f90.
| logical time_based_controller::time_based_controller_t::write_at_start = .true. |
Definition at line 113 of file time_based_controller.f90.