Impose boundary conditions.
The boundary conditions are imposed on the primitive variables by means of the ghost cells approach.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(euler_1D_caf_nf), | intent(in) | :: | self | Euler field. |
||
real(kind=R_P), | intent(inout) | :: | primitive(1:self%Np,1-self%Ng:self%Ni+self%Ng) | Primitive variables [1:Np,1-Ng:Ni+Ng]. |
subroutine impose_boundary_conditions(self, primitive)
!--------------------------------------------------------------------------------------------------------------------------------
!< Impose boundary conditions.
!<
!< The boundary conditions are imposed on the primitive variables by means of the ghost cells approach.
!--------------------------------------------------------------------------------------------------------------------------------
class(euler_1D_caf_nf), intent(IN) :: self !< Euler field.
real(R_P), intent(INOUT) :: primitive(1:self%Np,1-self%Ng:self%Ni+self%Ng) !< Primitive variables [1:Np,1-Ng:Ni+Ng].
integer(I_P) :: i !< Space counter.
character(len=:), allocatable :: bc_type !< String containing BC type.
!--------------------------------------------------------------------------------------------------------------------------------
!--------------------------------------------------------------------------------------------------------------------------------
call self%synchronize
bc_type = trim(adjustl(self%BC_L))
if ('CON' == bc_type(1:3)) then ! connection between remote images
do i=1-self%Ng, 0
primitive(:, i) = self%conservative2primitive(U_L(:, self%Ni+i))
enddo
else
select case(bc_type(1:3))
case('TRA') ! trasmissive (non reflective) BC
do i=1-self%Ng, 0
primitive(:, i) = primitive(:, -i+1)
enddo
case('REF') ! reflective BC
do i=1-self%Ng, 0
primitive(:, i) = primitive(:, -i+1) ! all variables
primitive(self%Ns + 1, i) = -primitive(self%Ns + 1, -i+1) ! only velocity
enddo
endselect
endif
bc_type = trim(adjustl(self%BC_R))
if ('CON' == bc_type(1:3)) then ! connection between remote images
do i=self%Ni+1, self%Ni+self%Ng
primitive(:, i) = self%conservative2primitive(U_R(:, i-self%Ni))
enddo
else
select case(bc_type(1:3))
case('TRA') ! trasmissive (non reflective) BC
do i=self%Ni+1, self%Ni+self%Ng
primitive(:, i) = primitive(:, self%Ni-(i-self%Ni-1))
enddo
case('REF') ! reflective BC
do i=self%Ni+1, self%Ni+self%Ng
primitive(:, i) = primitive(:, self%Ni-(i-self%Ni-1)) ! all variables
primitive(self%Ns + 1, i) = -primitive(self%Ns + 1, self%Ni-(i-self%Ni-1)) ! only velocity
enddo
endselect
endif
return
!--------------------------------------------------------------------------------------------------------------------------------
endsubroutine impose_boundary_conditions