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.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=long_k), | intent(in) | :: | TreeID |
ID in the complete tree to look up |
Level of the given TreeID
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