ug4
ug::prism_rules Namespace Reference

Functions

int CollapseEdge (int *newIndsOut, int v0, int v1)
 Creates new volume elements that result from collapsing the edge between v0 and v1 into v0. More...
 
template<class TCmp >
int ConvertToTetrahedra (int *newIndsOut, TCmp cmp)
 fills an array of integers describing tetrahedra that shall replace the prism More...
 
void FlipPrism (int vrtsOut[NUM_VERTICES], const int vrts[NUM_VERTICES])
 
bool IsRegularRefRule (const int edgeMarks)
 returns true if the specified edgeMarks would lead to a regular refinement More...
 
int Refine (int *newIndsOut, int *newEdgeVrts, bool &newCenterOut, vector3 *, bool *isSnapPoint)
 
void RotatePrism (int vrtsOut[NUM_VERTICES], int steps)
 Output are the vertices of a prism rotated around its vertical axis. More...
 

Variables

const int BOTTOM_FACE = 0
 
const int EDGE_FROM_VRTS [6][6]
 Associates the index of the connecting edge with each tuple of vertices. More...
 
const int EDGE_VRT_INDS [][2]
 the local vertex indices of the given edge More...
 
const int FACE_CONTAINS_EDGE [][9]
 tells whether the i-th face contains the j-th edge More...
 
const int FACE_EDGE_INDS [5][4]
 returns the j-th edge of the i-th face More...
 
const int FACE_FROM_EDGES [][9]
 given two edges, the table returns the face, which contains both (or -1) More...
 
const int FACE_FROM_VRTS [6][6][6]
 Associates the index of the connecting face with each triple of vertices. More...
 
const int FACE_VRT_INDS [][4]
 the local vertex indices of the given face More...
 
const int IS_BOTTOM_EDGE [9] = {1, 1, 1, 0, 0, 0, 0, 0, 0}
 
const int IS_SIDE_EDGE [9] = {0, 0, 0, 1, 1, 1, 0, 0, 0}
 
const int IS_TOP_EDGE [9] = {0, 0, 0, 0, 0, 0, 1, 1, 1}
 
const int MAX_NUM_COLLAPSE_INDS_OUT = 6
 
const int MAX_NUM_CONVERT_TO_TETS_INDS_OUT = 15
 
const int MAX_NUM_INDS_OUT = 128
 
const int NUM_EDGES = 9
 
const int NUM_FACES = 5
 
const int NUM_QUADS = 3
 
const int NUM_TRIS = 2
 
const int NUM_VERTICES = 6
 
const int OPPOSED_FACE [NUM_FACES] = {4, -1, -1, -1, 0}
 the index of the face opposed to the given one. -1 if no face is opposed More...
 
const int OPPOSED_OBJECT [][NUM_VERTICES] = {{1, 7}, {1, 8}, {1, 6}, {1, 1}, {1, 2}, {1, 0}}
 
const int QUADS [3] = {1, 2, 3}
 
const int TOP_FACE = 4
 
const int TRIS [2] = {0, 4}
 

Function Documentation

◆ CollapseEdge()

int ug::prism_rules::CollapseEdge ( int *  newIndsOut,
int  v0,
int  v1 
)

Creates new volume elements that result from collapsing the edge between v0 and v1 into v0.

Note that the returned array may be empty.

Parameters
newIndsOutArray which has to be of size MAX_NUM_COLLAPSE_INDS_OUT. When the algorithm is done, the array will contain sequences of integers: {{gridObjectID, ind1, ind2, ...}, ...}. gridObjectID is a constant enumerated in GridObjectID and describes the type of the grid-object that is built from the following set of corner indices.
Returns
the size of the resulting element list 'newIndsOut'.

References EDGE_FROM_VRTS, FACE_FROM_EDGES, FACE_VRT_INDS, and ug::GOID_PYRAMID.

◆ ConvertToTetrahedra()

template<class TCmp >
int ug::prism_rules::ConvertToTetrahedra ( int *  newIndsOut,
TCmp  cmp 
)

fills an array of integers describing tetrahedra that shall replace the prism

The method requires a compare-operator that defines a strict (global) ordering on the vertices of the prism. Note that this operator should return consistent results for all vertices in a given grid. The ordering is used to decide along which diagonal each quadrilateral is split. Each new diagonal will start at the smallest vertex of the corresponding quadrilateral, regarding the given ordering.

The specified compare function (or compare operator) 'bool cmp (int i0, int i1)' will be called with two local corner indices and has to return true, if vertex at the first corner shall be considered smaller (globally) than the vertex at the second corner.

The idea and implementation follows: Dompierre et al., "How to Subdivide Pyramids, Prisms and Hexahedra into Tetrahedra"

Parameters
newIndsOutArray which has to be of size MAX_NUM_CONVERT_TO_TETS_INDS_OUT. When the algorithm is done, the array will contain sequences of integers: {{gridObjectID, ind1, ind2, ...}, ...}. gridObjectID is a constant enumerated in GridObjectID and describes the type of the grid-object that is built from the following set of corner indices.
cmpA function object that induces a strict ordering on the corners of the prism. The method shall return true if the vertex at the first corner-index shall be considered smaller than the vertex at the second corner index. If multiple prisms shall be converted to tetrahedra, it is important that the given ordering is global, i.e., if a pair of vertices is present in two connected prisms, the 'cmp' operator has to return the same value.
Returns
the number of entries written to newIndsOut or 0, if the refinement could not be performed.

References ug::GOID_TETRAHEDRON.

Referenced by ug::ConvertToTetrahedra().

◆ FlipPrism()

void ug::prism_rules::FlipPrism ( int  vrtsOut[NUM_VERTICES],
const int  vrts[NUM_VERTICES] 
)

Referenced by Refine().

◆ IsRegularRefRule()

bool ug::prism_rules::IsRegularRefRule ( const int  edgeMarks)

returns true if the specified edgeMarks would lead to a regular refinement

A regular refinement leads to new elements which are all similar to the original element. I.e. which are of the same type and which have similar angles.

Note
this method does not perform refinement. Use 'Refine' with the specified edges instead.
Parameters
edgeMarksIf the i-th edge shall be refined, the expression 'edgeMarks & (1<<i) != 0' has to be true. You can specify multiple refine-edges using or-combinations. E.g., 'edgeMarks = (1<<i) | (1<<j)' would indicate that the i-th and the j-th edge shall be refined.

◆ Refine()

int ug::prism_rules::Refine ( int *  newIndsOut,
int *  newEdgeVrts,
bool &  newCenterOut,
vector3 corners = NULL,
bool *  isSnapPoint = NULL 
)

returns an array of integers, which contains the indices of the objects resulting from the refinement of a pyramid.

Parameters
newIndsOutArray which has to be of size MAX_NUM_INDS_OUT. When the algorithm is done, the array will contain sequences of integers: {{gridObjectID, ind1, ind2, ...}, ...}. gridObjectID is a constant enumerated in GridObjectID and describes the type of the grid-object that is built from the following set of corner indices. Old vertices are referenced by their local index. Vertices created on an edge are indexed by the index of the edge + NUM_VERTICES. Vertices created on a face are referenced by NUM_VERTICES + NUM_EDGES + index_of_face. If an inner vertex has to be created, it is referenced by NUM_VERTICES + NUM_EDGES + NUM_FACES (in this case newCenterOut is set to true).
newEdgeVrtsArray of size NUM_EDGES, which has to contain 1 for each edge, which shall be refined and 0 for each edge, which won't be refined.
newCenterOutIf the refinement-rule requires a center vertex, then this parameter will be set to true. If not, it is set to false.
cornersIgnored.
isSnapPoint(optional) An array of size NUM_VERTICES. If all entries are set to 'false' the behaviour is the same as if the array wasn't specified. If a corner of a quadrilateral is a snap-point and if edges of that quadrilateral are refined, then only new edges connected to the snap-point are introduced. Note that only special snap-point constellations are supported.
Returns
the number of entries written to newIndsOut or 0, if the refinement could not be performed.

References BOTTOM_FACE, EDGE_FROM_VRTS, EDGE_VRT_INDS, FACE_CONTAINS_EDGE, FACE_EDGE_INDS, FACE_FROM_EDGES, FACE_VRT_INDS, FlipPrism(), ug::GOID_HEXAHEDRON, ug::GOID_PRISM, ug::GOID_PYRAMID, ug::GOID_TETRAHEDRON, IS_BOTTOM_EDGE, IS_SIDE_EDGE, IS_TOP_EDGE, NUM_EDGES, NUM_FACES, NUM_QUADS, NUM_VERTICES, p, QUADS, ug::shared_rules::RecursiveRefine(), RotatePrism(), UG_ASSERT, and UG_LOG.

◆ RotatePrism()

void ug::prism_rules::RotatePrism ( int  vrtsOut[NUM_VERTICES],
int  steps 
)

Output are the vertices of a prism rotated around its vertical axis.

Referenced by Refine().

Variable Documentation

◆ BOTTOM_FACE

const int ug::prism_rules::BOTTOM_FACE = 0

Referenced by Refine().

◆ EDGE_FROM_VRTS

const int ug::prism_rules::EDGE_FROM_VRTS[6][6]
Initial value:
=
{{-1, 0, 2, 3, -1, -1}, {0, -1, 1, -1, 4, -1},
{2, 1, -1, -1, -1, 5}, {3, -1, -1, -1, 6, 8},
{-1, 4, -1, 6, -1, 7}, {-1, -1, 5, 8, 7, -1}}

Associates the index of the connecting edge with each tuple of vertices.

Use two vertex indices to index into this table to retrieve the index of their connecting edge.

Referenced by CollapseEdge(), and Refine().

◆ EDGE_VRT_INDS

const int ug::prism_rules::EDGE_VRT_INDS[][2]
Initial value:
= { {0, 1}, {1, 2}, {2, 0},
{0, 3}, {1, 4}, {2, 5},
{3, 4}, {4, 5}, {5, 3}}

the local vertex indices of the given edge

Referenced by Refine().

◆ FACE_CONTAINS_EDGE

const int ug::prism_rules::FACE_CONTAINS_EDGE[][9]
Initial value:
=
{{1, 1, 1, 0, 0, 0, 0, 0, 0}, {1, 0, 0, 1, 1, 0, 1, 0, 0},
{0, 1, 0, 0, 1, 1, 0, 1, 0}, {0, 0, 1, 1, 0, 1, 0, 0, 1},
{0, 0, 0, 0, 0, 0, 1, 1, 1}}

tells whether the i-th face contains the j-th edge

Referenced by Refine().

◆ FACE_EDGE_INDS

const int ug::prism_rules::FACE_EDGE_INDS[5][4]
Initial value:
= {{0, 1, 2, -1}, {3, 6, 4, 0}, {4, 7, 5, 1},
{5, 8, 3, 2}, {8, 7, 6, -1}}

returns the j-th edge of the i-th face

Referenced by Refine().

◆ FACE_FROM_EDGES

const int ug::prism_rules::FACE_FROM_EDGES[][9]
Initial value:
=
{{0, 0, 0, 1, 1, -1, 1, -1, -1}, {0, 0, 0, -1, 2, 2, -1, 2, -1},
{0, 0, 0, 3, -1, 3, -1, -1, 3}, {1, -1, 3, 1, 1, 3, 1, -1, 3},
{1, 2, -1, 1, 1, 2, 1, 2, -1}, {-1, 2, 3, 3, 2, 2, -1, 2, 3},
{1, -1, -1, 1, 1, -1, 1, 4, 4}, {-1, 2, -1, -1, 2, 2, 4, 2, 4},
{-1, -1, 3, 3, -1, 3, 4, 4, 3}}

given two edges, the table returns the face, which contains both (or -1)

Referenced by CollapseEdge(), and Refine().

◆ FACE_FROM_VRTS

const int ug::prism_rules::FACE_FROM_VRTS[6][6][6]
Initial value:
=
{{{-1, -1, -1, -1, -1, -1}, {-1, -1, 0, 1, 1, -1},
{-1, 0, -1, 3, -1, 3}, {-1, 1, 3, -1, 1, 3},
{-1, 1, -1, 1, -1, -1}, {-1, -1, 3, 3, -1, -1}},
{{-1, -1, 0, 1, 1, -1}, {-1, -1, -1, -1, -1, -1},
{0, -1, -1, -1, 2, 2}, {1, -1, -1, -1, 1, -1},
{1, -1, 2, 1, -1, 2}, {-1, -1, 2, -1, 2, -1}},
{{-1, 0, -1, 3, -1, 3}, {0, -1, -1, -1, 2, 2},
{-1, -1, -1, -1, -1, -1}, {3, -1, -1, -1, -1, 3},
{-1, 2, -1, -1, -1, 2}, {3, 2, -1, 3, 2, -1}},
{{-1, 1, 3, -1, 1, 3}, {1, -1, -1, -1, 1, -1},
{3, -1, -1, -1, -1, 3}, {-1, -1, -1, -1, -1, -1},
{1, 1, -1, -1, -1, 4}, {3, -1, 3, -1, 4, -1}},
{{-1, 1, -1, 1, -1, -1}, {1, -1, 2, 1, -1, 2},
{-1, 2, -1, -1, -1, 2}, {1, 1, -1, -1, -1, 4},
{-1, -1, -1, -1, -1, -1}, {-1, 2, 2, 4, -1, -1}},
{{-1, -1, 3, 3, -1, -1}, {-1, -1, 2, -1, 2, -1},
{3, 2, -1, 3, 2, -1}, {3, -1, 3, -1, 4, -1},
{-1, 2, 2, 4, -1, -1}, {-1, -1, -1, -1, -1, -1}}}

Associates the index of the connecting face with each triple of vertices.

Use three vertex indices to index into this table to retrieve the index of their connecting face.

◆ FACE_VRT_INDS

const int ug::prism_rules::FACE_VRT_INDS[][4]
Initial value:
= { {0, 1, 2, -1}, {0, 3, 4, 1},
{1, 4, 5, 2}, {2, 5, 3, 0},
{3, 5, 4, -1}}

the local vertex indices of the given face

Referenced by CollapseEdge(), ug::CreateHexahedronFromPrisms(), and Refine().

◆ IS_BOTTOM_EDGE

const int ug::prism_rules::IS_BOTTOM_EDGE[9] = {1, 1, 1, 0, 0, 0, 0, 0, 0}

Referenced by Refine().

◆ IS_SIDE_EDGE

const int ug::prism_rules::IS_SIDE_EDGE[9] = {0, 0, 0, 1, 1, 1, 0, 0, 0}

Referenced by Refine().

◆ IS_TOP_EDGE

const int ug::prism_rules::IS_TOP_EDGE[9] = {0, 0, 0, 0, 0, 0, 1, 1, 1}

Referenced by Refine().

◆ MAX_NUM_COLLAPSE_INDS_OUT

const int ug::prism_rules::MAX_NUM_COLLAPSE_INDS_OUT = 6

◆ MAX_NUM_CONVERT_TO_TETS_INDS_OUT

const int ug::prism_rules::MAX_NUM_CONVERT_TO_TETS_INDS_OUT = 15

Referenced by ug::ConvertToTetrahedra().

◆ MAX_NUM_INDS_OUT

const int ug::prism_rules::MAX_NUM_INDS_OUT = 128

◆ NUM_EDGES

const int ug::prism_rules::NUM_EDGES = 9

Referenced by Refine().

◆ NUM_FACES

const int ug::prism_rules::NUM_FACES = 5

Referenced by Refine().

◆ NUM_QUADS

const int ug::prism_rules::NUM_QUADS = 3

Referenced by Refine().

◆ NUM_TRIS

const int ug::prism_rules::NUM_TRIS = 2

◆ NUM_VERTICES

const int ug::prism_rules::NUM_VERTICES = 6

Referenced by Refine().

◆ OPPOSED_FACE

const int ug::prism_rules::OPPOSED_FACE[NUM_FACES] = {4, -1, -1, -1, 0}

the index of the face opposed to the given one. -1 if no face is opposed

◆ OPPOSED_OBJECT

const int ug::prism_rules::OPPOSED_OBJECT[][NUM_VERTICES] = {{1, 7}, {1, 8}, {1, 6}, {1, 1}, {1, 2}, {1, 0}}

for each vertex, a pair containing the object type (0: vrt, 1: edge, 2: face) and an index into the associated array, which describe the object which lies on the opposite side of the prism, to a given vertex.

◆ QUADS

const int ug::prism_rules::QUADS[3] = {1, 2, 3}

◆ TOP_FACE

const int ug::prism_rules::TOP_FACE = 4

◆ TRIS

const int ug::prism_rules::TRIS[2] = {0, 4}