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=I4P), | intent(in) | :: | steps_max | Maximun number of time steps. |
||
| real(kind=R8P), | intent(in) | :: | t_max | Maximum integration time. |
||
| real(kind=R8P), | intent(in) | :: | t | Time. |
||
| real(kind=R8P), | intent(in) | :: | CFL | CFL value. |
Time step.
pure function compute_dt(self, steps_max, t_max, t, CFL) result(Dt)
!< Compute the current time step by means of CFL condition.
class(euler_1d), intent(in) :: self !< Euler field.
integer(I4P), intent(in) :: steps_max !< Maximun number of time steps.
real(R8P), intent(in) :: t_max !< Maximum integration time.
real(R8P), intent(in) :: t !< Time.
real(R8P), intent(in) :: CFL !< CFL value.
real(R8P) :: Dt !< Time step.
type(vector) :: u !< Velocity vector.
real(R8P) :: a !< Speed of sound.
real(R8P) :: vmax !< Maximum propagation speed of signals.
integer(I4P) :: i !< Counter.
associate(Ni=>self%Ni, Dx=>self%Dx)
vmax = 0._R8P
do i=1, Ni
u = self%U(i)%velocity()
a = self%eos%speed_of_sound(density=self%U(i)%density, pressure=self%U(i)%pressure(eos=self%eos))
vmax = max(vmax, u%normL2() + a)
enddo
Dt = Dx * CFL / vmax
if (steps_max <= 0 .and. t_max > 0._R8P) then
if ((t + Dt) > t_max) Dt = t_max - t
endif
endassociate
endfunction compute_dt