identify_stencilNeigh Subroutine

public recursive subroutine identify_stencilNeigh(iElem, iLevel, iStencil, tree, pathFirst, pathLast, levelDesc, proc, stencil, nesting)

Invoke the identify_elements for each neighbor of the stencil and store the positions of the encountered elements

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: iElem

element position in levelDesc to identify

integer, intent(in) :: iLevel

element level

integer, intent(in) :: iStencil

stencil within the element to act on

type(treelmesh_type), intent(in) :: tree

tree information

type(tem_path_type), intent(in) :: pathFirst(:)

first treeID path in every process

type(tem_path_type), intent(in) :: pathLast(:)

last treeID path in every process

type(tem_levelDesc_type), intent(inout) :: levelDesc(tree%global%minLevel:)

the level descriptor to be filled

type(tem_comm_env_type), intent(in) :: proc

process

type(tem_stencilHeader_type), intent(in) :: stencil

current stencil definition

integer, intent(in) :: nesting

nesting level


Source Code

  recursive subroutine identify_stencilNeigh( iElem, iLevel, iStencil, tree,  &
    &                                         pathFirst, pathLast, levelDesc, &
    &                                         proc, stencil, nesting          )
    ! -------------------------------------------------------------------- !
    !> element position in levelDesc to identify
    integer, intent(in)                      :: iElem
    !> element level
    integer, intent(in)                      :: iLevel
    !> stencil within the element to act on
    integer, intent(in)                      :: iStencil
    !> tree information
    type(treelmesh_type), intent(in)         :: tree
    !> first treeID path in every process
    type(tem_path_type), intent(in)          :: pathFirst(:)
    !> last treeID path in every process
    type(tem_path_type), intent(in)          :: pathLast(:)
    !> the level descriptor to be filled
    type(tem_levelDesc_type), intent(inout)  :: levelDesc(tree%global%minLevel:)
    !> process
    type(tem_comm_env_type), intent(in)      :: proc
    !> current stencil definition
    type(tem_stencilHeader_type), intent(in) :: stencil
    !> nesting level
    integer, intent(in)                      :: nesting
    ! -------------------------------------------------------------------- !
    integer :: iStencilElem, elemPos
    integer :: neighIDpos
    integer(kind=long_k) :: neighID
    ! -------------------------------------------------------------------- !
    ! identify all the compute neighbors of the current element
    do iStencilElem = 1, stencil%QQN
      neighIDpos = levelDesc(iLevel)%elem%stencil%val(iElem)          &
        &                           %val(iStencil)%tIDpos(iStencilElem)
      if( neighIDpos > 0 ) then
        neighID = &
          & levelDesc( iLevel )%elem%neighID%val(iElem)%val(neighIDpos)
        ! This call might add new halo elements
        if ( neighID > 0_long_k ) then
          call identify_elements( TreeID     = neighID,   &
            &                     tree       = tree,      &
            &                     pathFirst  = pathFirst, &
            &                     pathLast   = pathLast,  &
            &                     levelDesc  = levelDesc, &
            &                     elemPos    = elemPos,   &
            &                     proc       = proc,      &
            &                     stencil    = stencil,   &
            &                     nesting    = nesting    )
        else ! neighID < 0
          elemPos = 0
        end if
      else ! neighIDpos < 0
        elemPos = 0
      end if ! neighIDpos > 0

      ! And add the encountered neighbor elements to the current element's
      ! stencil neighbors
      levelDesc(iLevel)%elem%stencil%val(iElem)              &
        &              %val(iStencil)%totalPos(iStencilElem) = elemPos
    end do

  end subroutine identify_stencilNeigh