Construct an initialized Burgers field.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(burgers), | intent(inout) | :: | self | Burgers field. |
||
real(kind=R_P), | intent(in), | dimension(1:Ni) | :: | initial_state | Initial state of Burgers field domain. |
|
integer(kind=I_P), | intent(in) | :: | Ni | Number of grid nodes. |
||
real(kind=R_P), | intent(in) | :: | h | Space step discretization. |
||
real(kind=R_P), | intent(in) | :: | nu | Viscosity. |
||
integer(kind=I_P), | intent(in), | optional | :: | steps | Time steps stored. |
subroutine init(self, initial_state, Ni, h, nu, steps)
!---------------------------------------------------------------------------------------------------------------------------------
!< Construct an initialized Burgers field.
!---------------------------------------------------------------------------------------------------------------------------------
class(burgers), intent(INOUT) :: self !< Burgers field.
integer(I_P), intent(IN) :: Ni !< Number of grid nodes.
real(R_P), dimension(1:Ni), intent(IN) :: initial_state !< Initial state of Burgers field domain.
real(R_P), intent(IN) :: h !< Space step discretization.
real(R_P), intent(IN) :: nu !< Viscosity.
integer(I_P), optional, intent(IN) :: steps !< Time steps stored.
integer(I_P) :: s !< Time steps counter.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
self%dims = size(initial_state)
self%steps = 0 ; if (present(steps)) self%steps = steps
if (allocated(self%U)) deallocate(self%U) ; allocate(self%U(1:Ni))
if (self%steps>0) then
if (allocated(self%previous)) deallocate(self%previous) ; allocate(self%previous(1:Ni, 1:self%steps))
endif
self%U = initial_state
if (self%steps>0) then
do s=1, self%steps
self%previous(:, s) = initial_state
enddo
endif
self%Ni = Ni
self%h = h
self%nu = nu
return
!---------------------------------------------------------------------------------------------------------------------------------
endsubroutine init