Compute the current time step by means of CFL condition.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(euler_1D), | intent(in) | :: | self | Euler field. |
||
integer(kind=I_P), | intent(in) | :: | Nmax | Maximun number of iterates. |
||
real(kind=R_P), | intent(in) | :: | Tmax | Maximum time (ignored if Nmax>0). |
||
real(kind=R_P), | intent(in) | :: | t | Time. |
||
real(kind=R_P), | intent(in) | :: | CFL | CFL value. |
Time step.
Nodes of different colours represent the following:
Solid arrows point from a procedure to one which it calls. Dashed arrows point from an interface to procedures which implement that interface. This could include the module procedures in a generic interface or the implementation in a submodule of an interface in a parent module.
pure function compute_dt(self, Nmax, Tmax, t, CFL) result(Dt)
!--------------------------------------------------------------------------------------------------------------------------------
!< Compute the current time step by means of CFL condition.
!--------------------------------------------------------------------------------------------------------------------------------
class(euler_1D), intent(IN) :: self !< Euler field.
integer(I_P), intent(IN) :: Nmax !< Maximun number of iterates.
real(R_P), intent(IN) :: Tmax !< Maximum time (ignored if Nmax>0).
real(R_P), intent(IN) :: t !< Time.
real(R_P), intent(IN) :: CFL !< CFL value.
real(R_P) :: Dt !< Time step.
real(R_P), allocatable :: P(:) !< Primitive variables.
real(R_P) :: vmax !< Maximum propagation speed of signals.
integer(I_P) :: i !< Counter.
!--------------------------------------------------------------------------------------------------------------------------------
!--------------------------------------------------------------------------------------------------------------------------------
associate(Ni=>self%Ni, Ns=>self%Ns, Dx=>self%Dx)
vmax = 0._R_P
do i=1, Ni
P = self%conservative2primitive(self%U(:, i))
vmax = max(abs(P(Ns+1)) + a(p=P(Ns+2), r=P(Ns+3), g=P(Ns+4)), vmax)
enddo
Dt = Dx * CFL / vmax
if (Nmax<=0) then
if ((t + Dt) > Tmax) Dt = Tmax - t
endif
return
endassociate
!--------------------------------------------------------------------------------------------------------------------------------
endfunction compute_dt