identify_local_element Subroutine

private subroutine identify_local_element(targetID, levelDesc, tree, minLevel, elemPos, nesting, updated, stencil, skip_add_additionalGhost)

Determine if the target element (local) targetID is fluid or ghost in the local process If fluid: do nothing, as it will be added later on anyway (or already is) ghostFromFiner (coarser than requested): add all virtual children, i.e. all levels between requested treeID and found one. ghostFromCoarser (finer than requested): not existing( localPos=0): add to halo

Arguments

Type IntentOptional Attributes Name
integer(kind=long_k), intent(in) :: targetID

neighboring treeID

type(tem_levelDesc_type), intent(inout) :: levelDesc(minLevel:)

the level descriptor to be filled

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

tree information

integer, intent(in) :: minLevel

minimum level fluid element in the tree

integer, intent(out) :: elemPos

targetID element position in the levelDesc % elem list

integer, intent(in) :: nesting

nesting level

logical, intent(out) :: updated

was the element updated in this call?

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

current stencil definition

logical, intent(in), optional :: skip_add_additionalGhost

logical, optional, if true no ghosts are added


Calls

proc~~identify_local_element~~CallsGraph proc~identify_local_element identify_local_element interface~append~29 append proc~identify_local_element->interface~append~29 interface~positionofval~5 positionofval proc~identify_local_element->interface~positionofval~5 proc~add_all_virtual_children add_all_virtual_children proc~identify_local_element->proc~add_all_virtual_children proc~add_ghostfromfiner add_ghostFromFiner proc~identify_local_element->proc~add_ghostfromfiner proc~tem_levelof tem_LevelOf proc~identify_local_element->proc~tem_levelof proc~tem_pathof tem_PathOf proc~identify_local_element->proc~tem_pathof proc~tem_posofpath tem_PosOfPath proc~identify_local_element->proc~tem_posofpath proc~tem_tidinfo tem_tIDinfo proc~identify_local_element->proc~tem_tidinfo proc~append_ga_dynlong append_ga_dynlong interface~append~29->proc~append_ga_dynlong proc~append_ga_dynlong_vec append_ga_dynlong_vec interface~append~29->proc~append_ga_dynlong_vec proc~posofval_label posofval_label interface~positionofval~5->proc~posofval_label proc~add_all_virtual_children->interface~append~29 proc~add_all_virtual_children->interface~positionofval~5 proc~add_all_virtual_children->proc~add_all_virtual_children proc~add_all_virtual_children->proc~tem_levelof interface~init~20 init proc~add_all_virtual_children->interface~init~20 proc~tem_childnumber tem_childNumber proc~add_all_virtual_children->proc~tem_childnumber proc~tem_coordofid tem_CoordOfId proc~add_all_virtual_children->proc~tem_coordofid proc~tem_find_bcs_fromcoarser tem_find_BCs_fromCoarser proc~add_all_virtual_children->proc~tem_find_bcs_fromcoarser proc~tem_idofcoord tem_IdOfCoord proc~add_all_virtual_children->proc~tem_idofcoord proc~add_ghostfromfiner->interface~append~29 proc~add_ghostfromfiner->interface~positionofval~5 proc~add_ghostfromfiner->proc~add_ghostfromfiner proc~add_ghostfromfiner->proc~tem_levelof proc~add_ghostfromfiner->proc~tem_pathof proc~add_ghostfromfiner->proc~tem_posofpath proc~tem_directchildren tem_directChildren proc~add_ghostfromfiner->proc~tem_directchildren proc~tem_find_bcs_fromfiner tem_find_BCs_fromFiner proc~add_ghostfromfiner->proc~tem_find_bcs_fromfiner proc~tem_baryofid tem_BaryOfId proc~tem_tidinfo->proc~tem_baryofid proc~tem_tidinfo->proc~tem_coordofid proc~tem_elemsize tem_ElemSize proc~tem_tidinfo->proc~tem_elemsize proc~init_ga2d_real init_ga2d_real interface~init~20->proc~init_ga2d_real interface~expand~25 expand proc~append_ga_dynlong->interface~expand~25 proc~append_ga_dynlong_vec->interface~expand~25 interface~sortedposofval~5 sortedposofval proc~posofval_label->interface~sortedposofval~5 proc~tem_baryofid->proc~tem_coordofid proc~tem_elemsizelevel tem_ElemSizeLevel proc~tem_baryofid->proc~tem_elemsizelevel proc~tem_coordofid->proc~tem_levelof proc~tem_elemsize->proc~tem_levelof proc~tem_elemsize->proc~tem_elemsizelevel proc~childtostencil childToStencil proc~tem_find_bcs_fromcoarser->proc~childtostencil proc~tem_find_bcs_fromfiner->interface~append~29 proc~tem_find_bcs_fromfiner->interface~init~20 proc~stenciltochild stencilToChild proc~tem_find_bcs_fromfiner->proc~stenciltochild proc~update_childneighborid update_childNeighborID proc~tem_find_bcs_fromfiner->proc~update_childneighborid proc~expand_ga_dynlong expand_ga_dynlong interface~expand~25->proc~expand_ga_dynlong proc~sortposofval_label sortposofval_label interface~sortedposofval~5->proc~sortposofval_label proc~update_childneighborid->proc~tem_idofcoord interface~tem_parentof tem_ParentOf proc~update_childneighborid->interface~tem_parentof

Called by

proc~~identify_local_element~~CalledByGraph proc~identify_local_element identify_local_element proc~identify_halo identify_halo proc~identify_halo->proc~identify_local_element proc~single_process_element single_process_element proc~single_process_element->proc~identify_local_element proc~identify_elements identify_elements proc~identify_elements->proc~single_process_element proc~identify_elements->proc~identify_elements proc~create_allparentneighbors create_allParentNeighbors proc~identify_elements->proc~create_allparentneighbors proc~identify_stencilneigh identify_stencilNeigh proc~identify_elements->proc~identify_stencilneigh proc~request_remotehalos request_remoteHalos proc~request_remotehalos->proc~identify_halo proc~request_remotehalos->proc~create_allparentneighbors proc~request_remotehalos->proc~identify_stencilneigh proc~build_levelelements build_levelElements proc~build_levelelements->proc~identify_elements proc~identify_additionalneigh identify_additionalNeigh proc~build_levelelements->proc~identify_additionalneigh proc~communicate_elements communicate_elements proc~communicate_elements->proc~request_remotehalos proc~create_allparentneighbors->proc~identify_elements proc~create_allparentneighbors->proc~identify_stencilneigh proc~identify_additionalneigh->proc~identify_elements proc~identify_stencilneigh->proc~identify_elements proc~tem_find_allelements tem_find_allElements proc~tem_find_allelements->proc~build_levelelements proc~tem_find_allelements->proc~communicate_elements proc~tem_find_allelements->proc~identify_additionalneigh

Source Code

  subroutine identify_local_element( targetID, levelDesc, tree, minLevel, &
    &                                elemPos, nesting, updated, stencil,  &
    &                                skip_add_additionalGhost             )
    ! -------------------------------------------------------------------- !
    !> neighboring treeID
    integer(kind=long_k), intent(in) :: targetID
    !> minimum level fluid element in the tree
    integer, intent(in) :: minLevel
    !> the level descriptor to be filled
    type(tem_levelDesc_type), intent(inout) :: levelDesc(minLevel:)
    !> tree information
    type(treelmesh_type), intent(in) :: tree
    !> nesting level
    integer, intent(in) :: nesting
    !> current stencil definition
    type(tem_stencilHeader_type), intent(in) :: stencil
    !> targetID element position in the levelDesc % elem list
    integer, intent(out) :: elemPos
    !> was the element updated in this call?
    logical, intent(out) :: updated
    !> logical, optional, if true no ghosts are added
    logical, intent(in), optional :: skip_add_additionalGhost
    ! -------------------------------------------------------------------- !
    integer :: localPos, targetLevel, dPos, fluidLevel
    integer(kind=long_k) :: fluidID
    type(tem_path_type) :: targetPath
    logical :: l_skip_add_additionalGhost
    ! -------------------------------------------------------------------- !

    if (present(skip_add_additionalGhost)) then
      l_skip_add_additionalGhost = skip_add_additionalGhost
    else
      l_skip_add_additionalGhost = .false.
    end if

    ! Set the element updated flag as a default to false
    updated = .false.

    ! Position of neighbor treeID
    targetLevel = tem_LevelOf( targetID )
    targetPath  = tem_PathOf( targetID )

    ! Return position of targetID in the treeIDlist
    localPos = tem_PosOfPath( targetPath, tree%pathList )

    ! By localPos we can determine how the element (might) exist locally:
    ! - fluid
    ! - ghostFromCoarser
    ! - ghostFromFiner
    if (localPos > 0) then
      ! Path exist. It may be GhostFromCoarser or FLUID
      fluidID = tree%treeID( localPos )
      fluidLevel = tem_LevelOf( fluidID )

      if (fluidLevel == targetLevel) then
        ! It is a FLUID. Already exists in element list
        updated = .false.
        elemPos = PositionOfVal( me  = levelDesc( targetLevel )%elem%tID, &
          &                      val = targetID                           )

      else if (fluidLevel < targetLevel) then
        if (.not. l_skip_add_additionalGhost) then
          ! Target element is a GhostFromCoarser.
          ! Target element is a descendant of Fluid element.
          ! ---------------
          ! |             |
          ! |             |
          ! |             |
          ! |      F      |
          ! |-----        |
          ! | T  |        |
          ! |    |        |
          ! ---------------
          ! Add all the descendants of Fluid down to target( including
          ! intermediate levels).
          call add_all_virtual_children(                           &
            &    sourceID       = fluidID,                         &
            &    foundPos       = localPos,                        &
            &    elemPath       = targetPath,                      &
            &    sourceProperty = tree%ElemPropertyBits(localPos), &
            &    targetLevel    = targetLevel,                     &
            &    levelDesc      = levelDesc,                       &
            &    minlevel       = minLevel,                        &
            &    nesting        = nesting,                         &
            &    updated        = updated,                         &
            &    tree           = tree,                            &
            &    Stencil        = stencil                          )
        end if
      end if ! on same level?

    else if (localPos < 0) then
      if (.not. l_skip_add_additionalGhost) then
        ! ghostFromFiner
        ! Find all existing fluid cells within requested targetID position
        ! Add all the parents between requested targetID and available child ID in
        ! treeID list
        call add_ghostFromFiner( elemID     = targetID,  &
          &                      levelDesc  = levelDesc, &
          &                      minLevel   = minlevel,  &
          &                      tree       = tree,      &
          &                      foundPos   = dPos,      &
          &                      updated    = updated,   &
          &                      stencil    = stencil    )
      end if

    else ! localPos == 0

      write(dbgUnit(6),*) 'Warning: element not existing ', targetID,    &
        &                 'adding to nonexisting ...'
      call tem_tIDinfo( me = targetID, tree = tree, nUnit = dbgUnit(6) )
      ! This case occurs, when a remote halo was added, which was not existing
      ! before.
      ! Halos are added in the transfer_treeIDs routine
      call append( me         = levelDesc( targetLevel )%elem, &
        &          tID        = targetID,                      &
        &          eType      = eT_nonExisting,                &
        &          sourceProc = tree%global%myPart+1,          &
        &          pos        = dPos                           )

    endif ! localPos > 0? coarser ghost or fluid?

    ! position of added targetID in the levelDesc elem list
    elemPos = PositionOfVal( me  = levelDesc( targetLevel )%elem%tID, &
      &                      val = targetID                           )

  end subroutine identify_local_element