Load internal BC property for 1D Line.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(treelmesh_type), | intent(in) | :: | tree | |||
type(tem_BC_prop_type), | intent(inout) | :: | me |
Boundary condition construct to load the data into |
||
logical, | intent(in) | :: | xbounds |
Set boundaries east and west in X direction? |
||
integer, | intent(in), | optional | :: | nSides |
Required sides to set, defaults to 26. |
subroutine load_BC_intern_1D( tree, me, xbounds, nSides )
! ---------------------------------------------------------------------------
type(treelmesh_type), intent(in) :: tree
!> Boundary condition construct to load the data into
type(tem_BC_prop_type), intent(inout) :: me
!> Set boundaries east and west in X direction?
logical, intent(in) :: xbounds
!> Required sides to set, defaults to 26.
integer, intent(in), optional :: nSides
! ---------------------------------------------------------------------------
integer :: nelems
integer :: iElem
integer :: neigh_coord(4)
integer :: my_coord(4)
integer(kind=long_k) :: tID, west_ID, east_ID
integer(kind=long_k) :: firstID, lastID
! ---------------------------------------------------------------------------
if (present(nSides)) then
me%nSides = nSides
else
me%nSides = 26
end if
if (xbounds) then
me%nBCtypes = 2
else
me%nBCtypes = 0
end if
firstID = -1_long_k
lastID = -1_long_k
nElems = int(tree%global%nElems)
if (nElems < 2**tree%global%minLevel .or. xbounds) then
! If the line does not span the complete cube axis, set the first and
! last ID here. This will be used for a proper periodicity at the
! truncated end. Without truncation, these two IDs are negative and no
! element will match the test below, thus resulting in usual full cube
! behavior.
firstID = tem_firstIdAtLevel(tree%global%minlevel)
lastID = tem_IdOfCoord( &
& coord = [ nelems-1, 0, 0, tree%global%minlevel], &
& offset = firstID )
end if
allocate(me%BC_label(me%nBCtypes))
if (xbounds) then
me%BC_label(1) = 'west'
me%BC_label(2) = 'east'
end if
allocate(me%boundary_ID(me%nSides, me%Property%nElems))
me%boundary_ID = 0_long_k
do iElem=1,me%Property%nElems
tID = tree%treeID(me%Property%ElemID(iElem))
my_coord = tem_coordofID(tID)
! Neighbor in the west
if (tID /= firstID) then
neigh_coord = my_coord + [-1, 0, 0, 0]
west_ID = -tem_IdOfCoord(neigh_coord)
else
if (xbounds) then
west_ID = 1
else
west_ID = -lastID
end if
me%boundary_ID(q__W, iElem) = west_ID
end if
! Neighbor in the east
if (tID /= lastID) then
neigh_coord = my_coord + [1, 0, 0, 0]
east_ID = -tem_IdOfCoord(neigh_coord)
else
if (xbounds) then
east_ID = 2
else
east_ID = -firstID
end if
me%boundary_ID(q__E, iElem) = east_ID
end if
me%boundary_ID(q__B, iElem) = -tID
me%boundary_ID(q__T, iElem) = -tID
me%boundary_ID(q__S, iElem) = -tID
me%boundary_ID(q__N, iElem) = -tID
if (me%nSides > 6) then
me%boundary_ID(q_BS, iElem) = -tID
me%boundary_ID(q_TS, iElem) = -tID
me%boundary_ID(q_BN, iElem) = -tID
me%boundary_ID(q_TN, iElem) = -tID
! Neighbors in the west
me%boundary_ID(q_BW, iElem) = west_ID
me%boundary_ID(q_TW, iElem) = west_ID
me%boundary_ID(q_SW, iElem) = west_ID
me%boundary_ID(q_NW, iElem) = west_ID
! Neighbors in the east
me%boundary_ID(q_BE, iElem) = east_ID
me%boundary_ID(q_TE, iElem) = east_ID
me%boundary_ID(q_SE, iElem) = east_ID
me%boundary_ID(q_NE, iElem) = east_ID
if (me%nSides > 18) then
! Neighbors in the west
me%boundary_ID(qBSW, iElem) = west_ID
me%boundary_ID(qTSW, iElem) = west_ID
me%boundary_ID(qBNW, iElem) = west_ID
me%boundary_ID(qTNW, iElem) = west_ID
! Neighbors in the east
me%boundary_ID(qBSE, iElem) = east_ID
me%boundary_ID(qTSE, iElem) = east_ID
me%boundary_ID(qBNE, iElem) = east_ID
me%boundary_ID(qTNE, iElem) = east_ID
end if
end if
end do
end subroutine load_BC_intern_1D