49 real(kind=
rp) :: frequency = 0
51 real(kind=
rp) :: time_interval = 0
55 real(kind=
rp) :: end_time = 0
57 integer :: nexecutions = 0
59 real(kind=
rp) :: start_time
61 logical :: never = .false.
64 character(len=:),
allocatable :: control_mode
66 real(kind=
rp) :: control_value
74 procedure, pass(this) :: register_execution => &
77 procedure, pass(this) :: set_counter => &
82 interface assignment(=)
82 interface assignment(=)
…
84 end interface assignment(=)
94 control_value, start_time)
96 real(kind=
rp),
intent(in) :: end_time
97 character(len=*),
intent(in) :: control_mode
98 real(kind=
rp),
intent(in) :: control_value
99 real(kind=
rp),
intent(in),
optional :: start_time
101 this%end_time = end_time
102 this%control_mode = control_mode
103 this%control_value = control_value
104 if (
present(start_time))
then
105 this%start_time = start_time
107 this%start_time = 0.0_rp
110 if (trim(control_mode) .eq.
'simulationtime')
then
111 this%time_interval = control_value
112 this%frequency = 1/this%time_interval
114 else if (trim(control_mode) .eq.
'nsamples')
then
115 if (control_value .le. 0)
then
119 this%frequency = control_value / end_time
120 this%time_interval = 1.0_rp / this%frequency
122 else if (trim(control_mode) .eq.
'tsteps')
then
123 this%nsteps = control_value
126 this%time_interval = 0
127 else if (trim(control_mode) .eq.
'never')
then
130 call neko_error(
"The control parameter must be simulationtime, nsamples&
131 & tsteps, or never, but received "//trim(control_mode))
144 real(kind=
rp),
intent(in) :: t
145 integer,
intent(in) :: tstep
146 logical,
intent(in),
optional :: force
150 if (
present(force))
then
159 else if (this%never)
then
161 else if (t .lt. this%start_time)
then
163 else if ( (this%nsteps .eq. 0) .and. &
164 (t .ge. this%nexecutions * this%time_interval) )
then
166 else if (this%nsteps .gt. 0)
then
167 if (mod(tstep, this%nsteps) .eq. 0)
then
180 ctrl1%end_time = ctrl2%end_time
181 ctrl1%frequency = ctrl2%frequency
182 ctrl1%nsteps = ctrl2%nsteps
183 ctrl1%time_interval = ctrl2%time_interval
184 ctrl1%nexecutions = ctrl2%nexecutions
192 this%nexecutions = this%nexecutions + 1
200 real(kind=
rp),
intent(in) :: t
202 if (this%nsteps .eq. 0)
then
203 this%nexecutions = int(t / this%time_interval) + 1
integer, parameter, public rp
Global precision used in computations.
Contains the time_based_controller_t type.
subroutine time_based_controller_assignment(ctrl1, ctrl2)
Assignment operator. Simply copies attribute values.
subroutine time_based_controller_set_counter(this, t)
Set the counter based on a time (for restarts)
subroutine time_based_controller_register_execution(this)
Increment nexectutions.
subroutine time_based_controller_init(this, end_time, control_mode, control_value, start_time)
Constructor.
logical function time_based_controller_check(this, t, tstep, force)
Check if the execution should be performed.
A utility type for determening whether an action should be executed based on the current time value....