74 type(json_file),
intent(inout) :: params
76 this%dt_last_change = -1
78 this%is_variable_dt, .false.)
79 if (this%is_variable_dt)
then
83 this%init_dt, huge(0.0_rp))
85 this%max_dt, huge(0.0_rp))
89 this%max_update_frequency, 0)
91 this%min_update_frequency, huge(0))
95 this%max_dt_increase_factor, 1.2_rp)
97 this%min_dt_decrease_factor, 0.5_rp)
114 real(kind=
rp),
intent(in) :: cfl
115 real(kind=
rp) :: dt_old, scaling_factor, global_min_dt
116 character(len=LOG_SIZE) :: log_buf
120 if (.not. this%is_variable_dt)
return
123 if (this%dt_last_change .eq. 0)
then
127 if (this%dt_last_change .eq. -1)
then
131 time%dt = min(this%cfl_trg / cfl * time%dt, this%init_dt)
132 time%dt =
max(min(time%dt, this%max_dt), this%min_dt)
133 this%dt_last_change = 0
138 this%cfl_avg = this%alpha * cfl + (1 - this%alpha) * this%cfl_avg
140 if (abs(this%cfl_avg - this%cfl_trg) .ge. this%dev_tol * this%cfl_trg &
141 .and. this%dt_last_change .ge. this%max_update_frequency &
142 .or. this%dt_last_change .ge. this%min_update_frequency)
then
144 if (this%cfl_trg/cfl .ge. 1)
then
146 scaling_factor = min(this%max_dt_increase_factor, this%cfl_trg/cfl)
149 scaling_factor =
max(this%min_dt_decrease_factor, this%cfl_trg/cfl)
153 time%dt = scaling_factor * dt_old
154 time%dt =
max(min(time%dt, this%max_dt), this%min_dt)
156 write(log_buf,
'(A,E15.7,1x,A,E15.7)') &
157 'Average CFL:', this%cfl_avg, &
158 'Target CFL:', this%cfl_trg
161 write(log_buf,
'(A,E15.7,1x,A,E15.7)')
'Old dt:', dt_old, &
165 this%dt_last_change = 0
168 this%dt_last_change = this%dt_last_change + 1
174 global_min_dt = time%dt
179 if (time%dt .gt. global_min_dt)
then
180 time%dt = global_min_dt
181 this%dt_last_change = 0