subroutine to find neighbours of cells
Typically every element requires information from its neighbors to perform an update of its state. All such required neighbors constitute a so called tem_stencil_module. tem_build_horizontalDependencies, or the connectivity of elements on the same refinement level in the tree, are therefore essential for the stencils in typical mesh-based numerical schemes. We now sketch the method to find the connectivity of elements in the mesh with the help of the described mesh layout. In a distributed mesh, the first distinction has to be made with respect to processor ownership.
: tem_find_depNeigh does not exist any more Is the element in question tem_find_depNeigh a local or remote element?
For all identify_local_element, their actual position in the sparse mesh has to be identified for a given treeID.
A tem_path_type comparison of two nodes to decide their relative position in the ordered list of elements has to take into account the hierarchy of the mesh.
As in the actual simulation only leaves will be present, and no overlap of refinement levels is allowed, this is a sufficient determination. However, such overlapping regions might be created to enable the interpolation between different levels with virtual elements. These special elements are distinguished anyway, so this does not pose any problem in the search for neighborhood relations.
An element can be either identified by its treeID or by a tuple with four integer entries for the spatial coordinates and the refinement level: . This coordinate fully describes the spatial shape and position of an element and is important to determine spatial relations between elements. Conversion between treeIDs and coordinates can be achieved by the routines - tem_CoordOfId Coordinate from TreeID - tem_IdOfCoord TreeID from Coordinate
The spatial indices are limited by the refinement level: . To avoid undefined coordinates, movements through the mesh by additions to indices are done in a modulo() safeguard resulting in an periodic universe cube. This enables the movement in the mesh in horizontal direction by index alteration and translation into a treeID again. The described procedure is completely reversible, enabling the construction of the treeID for any given coordinate. Thus, the conversion between this coordinate and the serialized treeID encoding is fully described by the topology of the octree and the chosen space-filling curve ordering of elements, as explained above.
With this method we can describe the neighborhood of any given element independently of the actual solver by a simple list of relative offsets. In contrast to the generic horizontal relation, the vertical relation between child and parent nodes in the tree requires an interpolation operator between different refinement levels. This interpolation usually has to take into account solver specific requirements, but is otherwise quite isolated from the numerical operation on each refinement level. The TreElM library offers the solver a level-wise view, as suggested by the properties described above. To find all required neighbors in the distributed octree, the solver merely has to provide its horizontal dependencies. These are described with the help of an element specific tem_stencil_module. A stencil is basically a set of element-offsets , describing the relative positions of all required elements for a given element.
In this routine, level descriptor is allocated,
all elements in tree are added into me%elem
as fluid type,
including their property, pntTID, stencil, neighID, sourceProc
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_levelDesc_type), | intent(out), | allocatable | :: | me(:) | neighbor list containing all the neighbours for the cells given in treeidsubset. Result of this routine |
|
type(tem_BC_prop_type), | intent(in) | :: | boundary | boundaries for the elements with bnd property set |
||
type(treelmesh_type), | intent(in) | :: | tree | subset of tree ids for which the neighbours will be specified |
||
type(tem_stencilHeader_type), | intent(in) | :: | stencils(:) | the given stencil |
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
type(tem_stencilElement_type), | private | :: | tStencil | ||||
integer, | private | :: | posInTree | ||||
integer, | private | :: | nElemsBnd | ||||
integer, | private | :: | iQQN | ||||
integer, | private | :: | iLevel | ||||
integer, | private | :: | nProcs | ||||
integer, | private | :: | hashpos | ||||
integer, | private | :: | x(4) | ||||
integer, | private | :: | nStencils | ||||
integer, | private | :: | iStencil | ||||
integer, | private | :: | elemPos | ||||
integer, | private | :: | nStencilElems | ||||
integer, | private | :: | indElem | ||||
integer, | private | :: | minLevel | ||||
integer, | private | :: | maxLevel | ||||
integer, | private | :: | QQN | ||||
integer, | private | :: | initlen | ||||
integer(kind=long_k), | private | :: | treeID | ||||
integer(kind=long_k), | private, | allocatable | :: | neighIDs(:) | |||
integer, | private | :: | addedPos | ||||
logical, | private | :: | wasAdded | ||||
integer, | private | :: | posInBCID |