Set initial state as a square wave.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(integrand_ladvection), | intent(inout) | :: | self | Advection field. |
subroutine set_square_wave_initial_state(self)
!< Set initial state as a square wave.
class(integrand_ladvection), intent(inout) :: self !< Advection field.
real(R_P) :: x !< Cell center x-abscissa values.
integer(I_P) :: i !< Space counter.
if (allocated(self%u)) deallocate(self%u) ; allocate(self%u(1:self%Ni))
do i=1, self%Ni
x = self%Dx * i - 0.5_R_P * self%Dx
if (x < 0.25_R_P) then
self%u(i) = 0._R_P
elseif (0.25_R_P <= x .and. x < 0.75_R_P) then
self%u(i) = 1._R_P
else
self%u(i) = 0._R_P
endif
enddo
endsubroutine set_square_wave_initial_state