50 real(kind=
rp) :: frequency = 0.0_rp
52 real(kind=
rp) :: time_interval = 0.0_rp
56 real(kind=
rp) :: start_time = 0.0_rp
58 real(kind=
rp) :: end_time = 0.0_rp
60 integer :: nexecutions = 0
62 logical :: never = .false.
65 character(len=:),
allocatable :: control_mode
67 real(kind=
rp) :: control_value
75 procedure, pass(this) :: register_execution => &
78 procedure, pass(this) :: set_counter => &
83 interface assignment(=)
85 end interface assignment(=)
94 control_mode, control_value)
96 real(kind=
rp),
intent(in) :: start_time
97 real(kind=
rp),
intent(in) :: end_time
98 character(len=*),
intent(in) :: control_mode
99 real(kind=
rp),
intent(in) :: control_value
101 this%start_time = start_time
102 this%end_time = end_time
103 this%control_mode = control_mode
104 this%control_value = control_value
106 if (trim(control_mode) .eq.
'simulationtime')
then
107 this%time_interval = control_value
108 this%frequency = 1/this%time_interval
110 else if (trim(control_mode) .eq.
'nsamples')
then
111 if (control_value .le. 0)
then
115 this%frequency = control_value / (end_time - start_time)
116 this%time_interval = 1.0_rp / this%frequency
118 else if (trim(control_mode) .eq.
'tsteps')
then
119 this%nsteps = control_value
122 this%time_interval = 0
123 else if (trim(control_mode) .eq.
'never')
then
126 call neko_error(
"The control parameter must be simulationtime, nsamples&
127 & tsteps, or never, but received "//trim(control_mode))
143 logical,
intent(in),
optional :: force
150 t = time%t - time%start_time
154 if (
present(force))
then
163 else if (this%never)
then
165 else if (time%t - this%start_time .gt. this%end_time - this%start_time)
then
167 else if ( (this%nsteps .eq. 0) .and. &
168 (t .ge. this%nexecutions * this%time_interval - 0.1_rp * dt) )
then
170 else if (this%nsteps .gt. 0)
then
171 if (mod(tstep, this%nsteps) .eq. 0)
then
184 ctrl1%end_time = ctrl2%end_time
185 ctrl1%frequency = ctrl2%frequency
186 ctrl1%nsteps = ctrl2%nsteps
187 ctrl1%time_interval = ctrl2%time_interval
188 ctrl1%nexecutions = ctrl2%nexecutions
196 this%nexecutions = this%nexecutions + 1
206 if (this%nsteps .eq. 0)
then
207 this%nexecutions = int(((time%t - time%start_time) + 0.1_rp*time%dt) &
208 / this%time_interval) + 1
integer, parameter, public rp
Global precision used in computations.
Contains the time_based_controller_t type.
subroutine time_based_controller_set_counter(this, time)
Set the counter based on a time (for restarts)
subroutine time_based_controller_assignment(ctrl1, ctrl2)
Assignment operator. Simply copies attribute values.
subroutine time_based_controller_init(this, start_time, end_time, control_mode, control_value)
Constructor.
logical function time_based_controller_check(this, time, force)
Check if the execution should be performed.
subroutine time_based_controller_register_execution(this)
Increment nexectutions.
Module with things related to the simulation time.
A utility type for determining whether an action should be executed based on the current time value....
A struct that contains all info about the time, expand as needed.