Compute the current time step by means of CFL condition.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(integrand_ladvection), | intent(in) | :: | self | Advection field. |
||
real(kind=R_P), | intent(in) | :: | final_time | Maximum integration time. |
||
real(kind=R_P), | intent(in), | optional | :: | t | Time. |
Time step.
pure function compute_dt(self, final_time, t) result(Dt)
!< Compute the current time step by means of CFL condition.
class(integrand_ladvection), intent(in) :: self !< Advection field.
real(R_P), intent(in) :: final_time !< Maximum integration time.
real(R_P), intent(in), optional :: t !< Time.
real(R_P) :: Dt !< Time step.
associate(a=>self%a, Dx=>self%Dx, CFL=>self%CFL)
Dt = Dx * CFL / abs(a)
if (present(t)) then
if ((t + Dt) > final_time) Dt = final_time - t
endif
endassociate
endfunction compute_dt