37 use json_module,
only : json_file
45 logical :: if_variable_dt
46 real(kind=
rp) :: set_cfl
47 real(kind=
rp) :: max_dt
48 integer :: max_update_frequency
49 integer :: dt_last_change
50 real(kind=
rp) :: alpha
51 real(kind=
rp) :: max_dt_increase_factor, min_dt_decrease_factor
52 real(kind=
rp) :: dev_tol
67 type(json_file),
intent(inout) :: params
69 this%dt_last_change = 0
71 this%if_variable_dt, .false.)
75 this%max_dt, huge(0.0_rp))
77 this%max_update_frequency, 0)
81 this%max_dt_increase_factor, 1.2_rp)
83 this%min_dt_decrease_factor, 0.5_rp)
100 real(kind=
rp),
intent(inout) :: dt
101 real(kind=
rp),
intent(in) :: cfl
102 real(kind=
rp),
intent(inout) :: cfl_avrg
103 real(kind=
rp) :: dt_old, scaling_factor
104 character(len=LOG_SIZE) :: log_buf
105 integer,
intent(in):: tstep
107 if (this%if_variable_dt .eqv. .true.)
then
108 if (tstep .eq. 1)
then
110 dt = min(this%set_cfl/cfl*dt, this%max_dt)
113 cfl_avrg = this%alpha * cfl + (1-this%alpha) * cfl_avrg
115 if (abs(cfl_avrg - this%set_cfl) .ge. &
116 this%dev_tol * this%set_cfl .and. &
117 this%dt_last_change .ge. this%max_update_frequency)
then
119 if (this%set_cfl/cfl .ge. 1)
then
121 scaling_factor = min(this%max_dt_increase_factor, this%set_cfl/cfl)
124 scaling_factor =
max(this%min_dt_decrease_factor, this%set_cfl/cfl)
128 dt = scaling_factor * dt_old
129 dt = min(dt, this%max_dt)
131 write(log_buf,
'(A,E15.7,1x,A,E15.7)')
'Avrg CFL:', cfl_avrg, &
132 'set_cfl:', this%set_cfl
135 write(log_buf,
'(A,E15.7,1x,A,E15.7)')
'old dt:', dt_old, &
139 this%dt_last_change = 0
142 this%dt_last_change = this%dt_last_change + 1
Retrieves a parameter by name or assigns a provided default value. In the latter case also adds the m...
Utilities for retrieving parameters from the case files.
type(log_t), public neko_log
Global log stream.
integer, parameter, public log_size
integer, parameter, public rp
Global precision used in computations.
Implements type time_step_controller.
subroutine time_step_controller_init(this, params)
Constructor.
subroutine time_step_controller_set_dt(this, dt, cfl, cfl_avrg, tstep)
Set new dt based on cfl if requested.
Provides a tool to set time step dt.