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
Type | Intent | Optional | 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 |
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