71 type(json_file),
intent(inout) :: params
73 this%dt_last_change = -1
75 this%is_variable_dt, .false.)
76 if (this%is_variable_dt)
then
80 this%max_dt, huge(0.0_rp))
84 this%max_update_frequency, 0)
86 this%min_update_frequency, huge(0))
90 this%max_dt_increase_factor, 1.2_rp)
92 this%min_dt_decrease_factor, 0.5_rp)
109 real(kind=
rp),
intent(in) :: cfl
110 real(kind=
rp) :: dt_old, scaling_factor
111 character(len=LOG_SIZE) :: log_buf
114 if (.not. this%is_variable_dt)
return
117 if (this%dt_last_change .eq. 0)
then
121 if (this%dt_last_change .eq. -1)
then
124 time%dt =
max(min(this%cfl_trg / cfl * time%dt, &
125 this%max_dt), this%min_dt)
126 this%dt_last_change = 0
131 this%cfl_avg = this%alpha * cfl + (1 - this%alpha) * this%cfl_avg
133 if (abs(this%cfl_avg - this%cfl_trg) .ge. this%dev_tol * this%cfl_trg &
134 .and. this%dt_last_change .ge. this%max_update_frequency &
135 .or. this%dt_last_change .ge. this%min_update_frequency)
then
137 if (this%cfl_trg/cfl .ge. 1)
then
139 scaling_factor = min(this%max_dt_increase_factor, this%cfl_trg/cfl)
142 scaling_factor =
max(this%min_dt_decrease_factor, this%cfl_trg/cfl)
146 time%dt = scaling_factor * dt_old
147 time%dt =
max(min(time%dt, this%max_dt), this%min_dt)
149 write(log_buf,
'(A,E15.7,1x,A,E15.7)') &
150 'Average CFL:', this%cfl_avg, &
151 'Target CFL:', this%cfl_trg
154 write(log_buf,
'(A,E15.7,1x,A,E15.7)')
'Old dt:', dt_old, &
158 this%dt_last_change = 0
161 this%dt_last_change = this%dt_last_change + 1