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 logical :: never = .false.
62 character(len=:),
allocatable :: control_mode
64 real(kind=
rp) :: control_value
72 procedure, pass(this) :: register_execution => &
75 procedure, pass(this) :: set_counter => &
80 interface assignment(=)
82 end interface assignment(=)
93 real(kind=
rp),
intent(in) :: end_time
94 character(len=*),
intent(in) :: control_mode
95 real(kind=
rp),
intent(in) :: control_value
97 this%end_time = end_time
98 this%control_mode = control_mode
99 this%control_value = control_value
101 if (trim(control_mode) .eq.
'simulationtime')
then
102 this%time_interval = control_value
103 this%frequency = 1/this%time_interval
105 else if (trim(control_mode) .eq.
'nsamples')
then
106 if (control_value .le. 0)
then
110 this%frequency = control_value / end_time
111 this%time_interval = 1.0_rp / this%frequency
113 else if (trim(control_mode) .eq.
'tsteps')
then
114 this%nsteps = control_value
117 this%time_interval = 0
118 else if (trim(control_mode) .eq.
'never')
then
121 call neko_error(
"The control parameter must be simulationtime, nsamples&
122 & tsteps, or never, but received "//trim(control_mode))
135 real(kind=
rp),
intent(in) :: t
136 integer,
intent(in) :: tstep
137 logical,
intent(in),
optional :: force
141 if (
present(force))
then
150 else if (this%never)
then
152 else if ( (this%nsteps .eq. 0) .and. &
153 (t .ge. this%nexecutions * this%time_interval) )
then
155 else if (this%nsteps .gt. 0)
then
156 if (mod(tstep, this%nsteps) .eq. 0)
then
169 ctrl1%end_time = ctrl2%end_time
170 ctrl1%frequency = ctrl2%frequency
171 ctrl1%nsteps = ctrl2%nsteps
172 ctrl1%time_interval = ctrl2%time_interval
173 ctrl1%nexecutions = ctrl2%nexecutions
181 this%nexecutions = this%nexecutions + 1
189 real(kind=
rp),
intent(in) :: t
191 if (this%nsteps .eq. 0)
then
192 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_init(this, end_time, control_mode, control_value)
Constructor.
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.
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....