Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(treelmesh_type), | intent(in) | :: | inTree |
Global mesh from which the elements are identified and then stored to |
||
integer, | intent(in) | :: | minLevel |
level range of target elements |
||
integer, | intent(in) | :: | maxLevel |
level range of target elements |
||
integer, | intent(out) | :: | countElems(globalMaxLevels) |
How many elements there will be for each level in the track |
||
type(dyn_intarray_type), | intent(inout) | :: | map2global |
growing array. Elements positions in inTree%treeID |
subroutine tem_shape_initByLevels( inTree, minLevel, maxLevel, countElems, &
& map2global )
! ---------------------------------------------------------------------------
!> Global mesh from which the elements are identified and then stored to
type( treelmesh_type ), intent(in) :: inTree
!> level range of target elements
integer, intent(in) :: minLevel, maxLevel
!> How many elements there will be for each level in the track
integer, intent(out) :: countElems( globalMaxLevels )
!> growing array. Elements positions in inTree%treeID
type(dyn_intArray_type), intent(inout) :: map2global
! ---------------------------------------------------------------------------
integer(kind=long_k) :: myID, minID, maxID
integer :: tLevel, dPos, iElem, loc_min, loc_max
logical :: wasAdded
! ---------------------------------------------------------------------------
loc_min = minLevel
loc_max = maxLevel
if ( minLevel > maxLevel ) then
! take inverse
loc_min = maxLevel
loc_max = minLevel
end if
if ( minLevel < 1 ) loc_min = 1
if ( maxLevel > globalMaxLevels ) loc_max = globalMaxLevels
call tem_log(3, 'Initializing shapes by elements between level '&
& //trim(tem_toStr(loc_min))//' and '//trim(tem_toStr(loc_max)) )
! the treeID range is the first ID on min level and the last ID on max level
minID = tem_firstIdAtLevel( loc_min )
maxID = tem_lastIdAtLevel( loc_max )
! Loop over all elements in inTree
do iElem = 1, inTree%nElems
myID = inTree%treeID(iElem)
if( (myID >= minID) .and. (myID <= maxID) ) then
! Append to treeID list (note that already existing ones are
! omitted)
call append( me = map2global, &
& pos = dPos, &
& val = iElem, &
& wasAdded = wasAdded )
! Count up if it was added
if( wasAdded ) then
tLevel = tem_levelOf( inTree%treeID(iElem) )
countElems( tLevel ) = countElems( tLevel ) + 1
end if ! wasAdded
end if
end do ! iElem
end subroutine tem_shape_initByLevels