add_ghostFromFiner Subroutine

private recursive subroutine add_ghostFromFiner(elemID, levelDesc, minLevel, tree, updated, foundPos, stencil)

Add parentID as GhostFromFiner. Then set its BC from its children. If any children do NOT exist, recursively call this routine to add them as GhostFromFiner.

Arguments

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

requested treeID

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

the level descriptor to be filled

integer, intent(in) :: minLevel

minimum level fluid element in the tree

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

tree information

logical, intent(out) :: updated

was the current element updated in this call?

integer, intent(out) :: foundPos
type(tem_stencilHeader_type), intent(in) :: stencil

current stencil definition


Calls

proc~~add_ghostfromfiner~~CallsGraph proc~add_ghostfromfiner add_ghostFromFiner proc~add_ghostfromfiner->proc~add_ghostfromfiner interface~append~11 append proc~add_ghostfromfiner->interface~append~11 interface~positionofval~5 positionofval proc~add_ghostfromfiner->interface~positionofval~5 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_levelof tem_LevelOf proc~add_ghostfromfiner->proc~tem_levelof proc~tem_pathof tem_PathOf proc~add_ghostfromfiner->proc~tem_pathof proc~tem_posofpath tem_PosOfPath proc~add_ghostfromfiner->proc~tem_posofpath proc~append_ga_dynlong append_ga_dynlong interface~append~11->proc~append_ga_dynlong proc~append_ga_dynlong_vec append_ga_dynlong_vec interface~append~11->proc~append_ga_dynlong_vec proc~posofval_label posofval_label interface~positionofval~5->proc~posofval_label proc~tem_find_bcs_fromfiner->interface~append~11 interface~init~24 init proc~tem_find_bcs_fromfiner->interface~init~24 proc~stenciltochild stencilToChild proc~tem_find_bcs_fromfiner->proc~stenciltochild proc~update_childneighborid update_childNeighborID proc~tem_find_bcs_fromfiner->proc~update_childneighborid proc~init_ga2d_real init_ga2d_real interface~init~24->proc~init_ga2d_real interface~expand~9 expand proc~append_ga_dynlong->interface~expand~9 proc~append_ga_dynlong_vec->interface~expand~9 interface~sortedposofval~5 sortedposofval proc~posofval_label->interface~sortedposofval~5 interface~tem_parentof tem_ParentOf proc~update_childneighborid->interface~tem_parentof proc~tem_idofcoord tem_IdOfCoord proc~update_childneighborid->proc~tem_idofcoord proc~expand_ga_dynlong expand_ga_dynlong interface~expand~9->proc~expand_ga_dynlong proc~sortposofval_label sortposofval_label interface~sortedposofval~5->proc~sortposofval_label proc~tem_directparent tem_directParent interface~tem_parentof->proc~tem_directparent proc~tem_parentatlevel tem_ParentAtLevel interface~tem_parentof->proc~tem_parentatlevel

Called by

proc~~add_ghostfromfiner~~CalledByGraph proc~add_ghostfromfiner add_ghostFromFiner proc~add_ghostfromfiner->proc~add_ghostfromfiner proc~identify_local_element identify_local_element proc~identify_local_element->proc~add_ghostfromfiner 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~request_remotehalos request_remoteHalos proc~request_remotehalos->proc~identify_halo proc~build_levelelements build_levelElements proc~build_levelelements->proc~identify_elements proc~communicate_elements communicate_elements proc~communicate_elements->proc~request_remotehalos proc~create_allparentneighbors create_allParentNeighbors proc~create_allparentneighbors->proc~identify_elements proc~identify_additionalneigh identify_additionalNeigh proc~identify_additionalneigh->proc~identify_elements proc~identify_stencilneigh identify_stencilNeigh proc~identify_stencilneigh->proc~identify_elements

Source Code

  recursive subroutine add_ghostFromFiner( elemID, levelDesc, minLevel,     &
    &                                      tree, updated, foundPos, stencil )
    ! -------------------------------------------------------------------- !
    !> requested treeID
    integer(kind=long_k), intent(in) :: elemID
    !> 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
    ! position of elemID in elem%tID list
    integer, intent(out) :: foundPos
    !> was the current element updated in this call?
    logical, intent(out) :: updated
    !> current stencil definition
    type( tem_stencilHeader_type ), intent(in) :: stencil
    ! -------------------------------------------------------------------- !
    integer :: iChild, level
    integer(kind=long_k) :: children(8), property
    logical :: wasAdded, childUpdated
    integer :: childPos(8)
    type(tem_path_type) :: childPath
    ! -------------------------------------------------------------------- !
    ! Set as not updated by default
    updated = .false.

    ! Create the ghostFromFiner
    level = tem_LevelOf( elemID )
    call append( me         = levelDesc( level )%elem, &
      &          tID        = elemID,                  &
      &          eType      = eT_ghostFromFiner,       &
      &          property   = 0_long_k,                &
      &          sourceProc = tree%global%myPart+1,    &
      &          pos        = foundPos,                &
      &          wasAdded   = wasAdded                 )

    if( wasAdded ) then

      updated = .true.
      children = tem_directChildren( elemID )
      childPos = 0 ! reset child positions. non-existing children are 0
      ! reset property
      property = 0_long_k
      ! if added elemID is more than level coarser than available child treeID
      ! in original treeID list then add all children between level and
      ! neighLevel
      do iChild = 1, 8

        ! Return position in the treeIDlist
        childPath  = tem_PathOf( children( iChild ))
        childPos( iChild ) = tem_PosOfPath( childPath, tree%pathList )

        if( childPos( iChild ) < 0 ) then
           ! This child does NOT exists, recusively add it as a ghostFromFiner.
           call add_ghostFromFiner( elemID    = children( iChild ),    &
             &                      levelDesc = levelDesc,             &
             &                      minLevel  = minlevel,              &
             &                      tree      = tree,                  &
             &                      foundPos  = childPos( iChild ),    &
             &                      updated   = childUpdated,          &
             &                      stencil   = stencil                )
           ! Unify all properties of the children
           property = ieor( property,                  &
             &              levelDesc(level+1)         &
             &                %elem                    &
             &                %property                &
             &                %val( childPos(iChild) ) )
           updated = ( updated .or. childUpdated )
        else
          ! This child is a Fluid, i.e. already exists in element list
          childPos( iChild ) = PositionOfVal( &
            &   levelDesc( level+1 )%elem%tID, children(iChild) )
        end if
      end do ! iChild = 1, 8

      ! Now reconstruct current element's neighborhood
      ! based on the children's information
      call tem_find_BCs_fromFiner( childPos     = childPos,   &
        &                          sourceLevel  = level + 1,  &
        &                          targetLevel  = level,      &
        &                          targetPos    = foundPos,   &
        &                          levelDesc    = levelDesc,  &
        &                          minLevel     = minLevel,   &
        &                          stencil      = stencil     )

    else
      ! ghostFromFiner element was not added
      ! Hence, we found available information which now has to be returned
      updated = .false.
    end if

  end subroutine add_ghostFromFiner