Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | posInBCID | |||
integer(kind=long_k), | intent(in) | :: | boundary_ID(:,:) | |||
type(tem_stencilHeader_type), | intent(in) | :: | stencil | |||
integer, | intent(in) | :: | x(4) | |||
integer(kind=long_k), | intent(out) | :: | neighIDs(stencil%QQN) |
subroutine tem_calc_neighbors( posInBCID, boundary_ID, stencil, x, neighIDs )
! ---------------------------------------------------------------------------
integer, intent(in) :: posInBCID
integer(kind=long_k), intent(in) :: boundary_ID(:,:)
type( tem_stencilHeader_type ), intent(in) :: stencil
integer, intent(in) :: x(4)
integer(kind=long_k), intent(out) :: neighIDs(stencil%QQN)
! ---------------------------------------------------------------------------
integer(kind=long_k) :: bcID, tOffset
integer :: iQQN, iQQQ
logical :: noBC
! ---------------------------------------------------------------------------
neighIDs(:) = 0_long_k
tOffset = tem_FirstIdAtLevel( x(4) )
directionLoop: do iQQN = 1, stencil%QQN
iQQQ = stencil%map( iQQN )
noBC = .false.
if ( posInBCID > 0 .and. iQQQ > 0 ) then
! there is a boundary in the some direction
bcID = boundary_ID( iQQQ, posInBCID )
if ( bcID > 0 ) then
! Set the negative boundary ID as neighbor, so we don't need
! more arrays for boundary information
neighIDs(iQQN) = -bcID
else if ( bcID < 0 ) then
! Is a periodic neighbor! value is -treeID_periodicNeighbor
! Set the id given as treeID and make positive
neighIDs(iQQN) = abs( bcID )
else ! bcID == 0
noBC = .true.
end if
else ! posInBCID == 0
noBC = .true.
end if ! posInBCID > 0?
if ( noBC ) then
! NO boundary condition for this direction.
! Just store the neighboring treeID which will have to be
! found or reconstructed (might be an actual fluid element
! or ghost / halo)
neighIDs(iQQN) = tem_IdOfCoord( &
& [ x(1) + stencil%cxDir( 1, iQQN ), &
& x(2) + stencil%cxDir( 2, iQQN ), &
& x(3) + stencil%cxDir( 3, iQQN ), &
& x(4) ], tOffset)
end if
end do directionLoop
end subroutine tem_calc_neighbors