tem_calc_neighbors Subroutine

private subroutine tem_calc_neighbors(posInBCID, boundary_ID, stencil, x, neighIDs)

Arguments

Type IntentOptional 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)

Calls

proc~~tem_calc_neighbors~~CallsGraph proc~tem_calc_neighbors tem_calc_neighbors proc~tem_firstidatlevel tem_FirstIdAtLevel proc~tem_calc_neighbors->proc~tem_firstidatlevel proc~tem_idofcoord tem_IdOfCoord proc~tem_calc_neighbors->proc~tem_idofcoord

Called by

proc~~tem_calc_neighbors~~CalledByGraph proc~tem_calc_neighbors tem_calc_neighbors proc~tem_init_elemlevels tem_init_elemLevels proc~tem_init_elemlevels->proc~tem_calc_neighbors proc~tem_create_leveldesc tem_create_levelDesc proc~tem_create_leveldesc->proc~tem_init_elemlevels proc~tem_dimbydim_construction tem_dimByDim_construction proc~tem_dimbydim_construction->proc~tem_create_leveldesc proc~tem_build_face_info tem_build_face_info proc~tem_build_face_info->proc~tem_dimbydim_construction

Source Code

  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