tem_LevelOf Function

public elemental function tem_LevelOf(TreeID) result(res)

This function delivers the refinement level of a TreeID

The refinement level of a \ref treelmesh_module::treelmesh_type::treeid "treeID" is found by repeatedly computing the parents with the equation used in the [tem_ParentOf function] (@ref tem_parentatlevel) and counting the iterations, until the universal root is reached.

Arguments

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

ID in the complete tree to look up

Return Value integer

Level of the given TreeID


Called by

proc~~tem_levelof~~CalledByGraph proc~tem_levelof tem_LevelOf proc~add_all_virtual_children add_all_virtual_children proc~add_all_virtual_children->proc~tem_levelof proc~add_ghostfromfiner add_ghostFromFiner proc~add_ghostfromfiner->proc~tem_levelof proc~derivelevel deriveLevel proc~derivelevel->proc~tem_levelof proc~identify_elements identify_elements proc~identify_elements->proc~tem_levelof proc~identify_halo identify_halo proc~identify_halo->proc~tem_levelof proc~identify_local_element identify_local_element proc~identify_local_element->proc~tem_levelof proc~single_process_element single_process_element proc~single_process_element->proc~tem_levelof proc~tem_adapt_dump_newmesh tem_adapt_dump_newMesh proc~tem_adapt_dump_newmesh->proc~tem_levelof proc~tem_build_levelpointer tem_build_levelPointer proc~tem_build_levelpointer->proc~tem_levelof proc~tem_cano_checkneigh tem_cano_checkNeigh proc~tem_cano_checkneigh->proc~tem_levelof proc~tem_cano_initsubtree tem_cano_initSubTree proc~tem_cano_initsubtree->proc~tem_levelof proc~tem_coordofid tem_CoordOfId proc~tem_coordofid->proc~tem_levelof proc~tem_elemsize tem_ElemSize proc~tem_elemsize->proc~tem_levelof proc~tem_load_weights tem_load_weights proc~tem_load_weights->proc~tem_levelof proc~tem_parentatlevel tem_ParentAtLevel proc~tem_parentatlevel->proc~tem_levelof proc~tem_reduction_spatial_append tem_reduction_spatial_append proc~tem_reduction_spatial_append->proc~tem_levelof proc~tem_shape_initbylevels tem_shape_initByLevels proc~tem_shape_initbylevels->proc~tem_levelof proc~tem_shape_initpropelements tem_shape_initPropElements proc~tem_shape_initpropelements->proc~tem_levelof proc~tem_shape_subtreefromgeominters tem_shape_subTreeFromGeomInters proc~tem_shape_subtreefromgeominters->proc~tem_levelof

Source Code

  elemental function tem_LevelOf( TreeID ) result(res)
    ! ---------------------------------------------------------------------------
    !> ID in the complete tree to look up
    integer(kind=long_k), intent(in) :: TreeID
    !> Level of the given TreeID
    integer :: res
    ! ---------------------------------------------------------------------------
    integer(kind=long_k) :: tElem
    integer :: level
    ! ---------------------------------------------------------------------------

    level = 0
    tElem = TreeID
    do while (tElem /= 0)
      ! bit operation is more efficient than division
      ! tElem = (tElem-1) / 8
      tElem = ishft( (tElem-1), -3 )
      level = level + 1
    end do
    res = level

  ! end function tem_LevelOf_singleTreeID
  end function tem_LevelOf