This module provides informations and operations on the topology of the complete linearized octree. It is completely independent of the actual sparse octree and therefore this module is independent of the Treelmesh_module.
Due to the breadth first numbering of the octree it is straight forward to move in vertical direction through the tree.
The parent of a node with a certain treeID is given by: Where the bracket denotes the integer floor rounding to the next smaller integer number. While the children of a given node can be obtained by: The numbering scheme begins at the root node with a treeID of 0 for this element, that covers the complete enclosed cubic domain. All further treeIDs are then given by the rules stated above. What remains to be defined is the actual spatial placement of the nodes in the tree as elements in the mesh. This is achieved by a space filling curve, that describes the numbering scheme of the 8 children for a given node.
Our choice here is the Morton ordering [6] (bibliography of treelm) , that allows an efficient computation of the index from the coordinates with the same orientation on each refinement level. For this ordering the coordinates of the children within their parent element are first noted as a three dimensional tuple, where each index might be 0 or 1. Now this tuple is interpreted as a single number of the basis 2 with three digits. The recursive in depth traversal results then in a concatenation of these numbers visited during the traversal. This concatenated number provides the sorting key for all elements on a given level according to the space filling curve.
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
integer(kind=long_k), | public, | parameter | :: | firstIdAtLevel(20) | = | [1_long_k, 9_long_k, 73_long_k, 585_long_k, 4681_long_k, 37449_long_k, 299593_long_k, 2396745_long_k, 19173961_long_k, 153391689_long_k, 1227133513_long_k, 9817068105_long_k, 78536544841_long_k, 628292358729_long_k, 5026338869833_long_k, 40210710958665_long_k, 321685687669321_long_k, 2573485501354569_long_k, 20587884010836553_long_k, 164703072086692425_long_k] |
This function delivers the parent ID of a given TreeID
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=long_k), | intent(in) | :: | TreeID |
current treeID |
result of function containing parent ID
This function provides the parent ID of a given tree ID on a given level.
The parent ID on a given level is calculated using the equation \f[ id_{l-1}=\frac{id_{l}-1}{8} \f] in a loop.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=long_k), | intent(in) | :: | TreeID |
treeID of which the pID is requested |
||
integer, | intent(in) | :: | level |
the level on which the pID is requested |
resulting parent ID
Paths of elements from the root node to themselves going through the hierarchy of the tree. Is used to compare to elements
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
integer, | public | :: | Level |
Levels counted from 1 This level is 1 higher than the actual level. |
|||
integer(kind=long_k), | public | :: | Node(globalMaxLevels+1) |
treeIDs from current leaf to root |
This function delivers the refinement level of a TreeID
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
This function delivers the refinement level of a TreeID
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | level |
level to check |
resulting first treeID
Last ID in the complete tree on a given level
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | level |
level to check |
resulting last treeID
This function delivers all sibling treeIDs of TreeID in an array
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=long_k), | intent(in) | :: | TreeID |
current treeID |
treeIDs siblings
This function delivers of TreeID, which child number it is from its parent
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=long_k), | intent(in) | :: | TreeID |
current treeID |
result of function containing child number
This function returns the complete path through the tree from a given treeID to the root (all parents).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=long_k), | intent(in) | :: | TreeID |
current treeID |
resulting path
This function delivers the direct children in the full tree for a given tree ID
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=long_k), | intent(in) | :: | TreeID |
given treeID |
Array for the treeIDs of the 8 direct children
Compare Position of two treeIDs in the linearized tree This is relatively expansive, therefore the result should be stored, if more than one comparison of the same treeIDs has to be done. Result: -1: left is lower than right 0: left is same than right 1: left is higher than right
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=long_k), | intent(in) | :: | left |
candidate treeID |
||
integer(kind=long_k), | intent(in) | :: | right |
candidate treeID |
relation between the treeIDs
Compare two Paths in the linearized tree Result: -1: left is lower than right 0: left is same than right 1: left is higher than right
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_path_type), | intent(in) | :: | left |
candidate path |
||
type(tem_path_type), | intent(in) | :: | right |
candidate path |
relation between the paths
The following function provides the spatial index triple for a given ID in the complete mesh, on its refinement level. The returned coordinates start at 0. The fourth entry is the level on which the coordinates are located in the tree. The steps are following: 1. calculate the refinement level, store to coord(4). 2. Calcualte the level offset. 3. the Morton index is obtained by subtracting the offset from treeID. 4. Apply bit interleaving rule to generate coordinates.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=long_k), | intent(in) | :: | TreeID |
input element ID |
||
integer(kind=long_k), | intent(in), | optional | :: | offset |
First Elem of current level, if known, to avoid recomputations |
coordinate of element return value
This function calculates the tree ID for a given x,y and z on the given refinement level. This ID in the complete tree does not have to be in the list of leafs (treeIDlist) An example of this procedure is following: 1. Convert coordinates into binary representation: (x,y,z) = (5,9,1) = (0101,1001,0001) 2. Interleaving the bits by 3 digits for each direction: x(0101): 0 1 0 1 y(1001): 1 0 0 1 z(0001): 0 0 0 1 Combining these bits results in a binary number: 010 001 000 111, which is 1095 when seen as a 10-base number. 3. This number is the cell position in a single level sorted element list. Its treeID can be obtained by adding the correspoding level offset.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | coord(4) |
3D Coordinates to translate |
||
integer(kind=long_k), | intent(in), | optional | :: | offset |
resulting treeID
This function delivers the parent ID of a given TreeID
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=long_k), | intent(in) | :: | TreeID |
current treeID |
result of function containing parent ID
This function provides the parent ID of a given tree ID on a given level.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=long_k), | intent(in) | :: | TreeID |
treeID of which the pID is requested |
||
integer, | intent(in) | :: | level |
the level on which the pID is requested |
resulting parent ID