t8  1.2.0
t8code is a C library to manage a forest of adaptive space-trees of general element classes in parallel.
Functions
t8_dtri_bits.h File Reference

Definitions of triangle-specific functions. More...

#include <t8_element.h>
#include <t8_schemes/t8_default/t8_default_tri/t8_dtri.h>

Go to the source code of this file.

Functions

void t8_dtri_copy (const t8_dtri_t *t, t8_dtri_t *dest)
 Copy the values of one triangle to another. More...
 
int t8_dtri_compare (const t8_dtri_t *t1, const t8_dtri_t *t2)
 Compare two triangle in their linear order. More...
 
void t8_dtri_parent (const t8_dtri_t *t, t8_dtri_t *parent)
 Compute the parent of a triangle. More...
 
void t8_dtri_ancestor (const t8_dtri_t *t, int level, t8_dtri_t *ancestor)
 Compute the ancestor of a triangle at a given level. More...
 
void t8_dtri_compute_coords (const t8_dtri_t *elem, const int vertex, t8_dtri_coord_t coordinates[2])
 Compute the coordinates of a vertex of a triangle. More...
 
void t8_dtri_compute_vertex_ref_coords (const t8_dtri_t *elem, const int vertex, double coordinates[2])
 Compute the reference coordinates of a vertex of a triangle when the tree (level 0 triangle) is embedded in [0,1]^2. More...
 
void t8_dtri_compute_all_coords (const t8_dtri_t *elem, t8_dtri_coord_t coordinates[3][2])
 Compute the coordinates of the four vertices of a triangle. More...
 
void t8_dtri_child (const t8_dtri_t *t, int childid, t8_dtri_t *child)
 Compute the childid-th child in Morton order of a triangle. More...
 
void t8_dtri_childrenpv (const t8_dtri_t *t, t8_dtri_t *c[T8_DTRI_CHILDREN])
 Compute the 4 children of a triangle, array version. More...
 
int t8_dtri_is_familypv (const t8_dtri_t *f[])
 Check whether a collection of eight triangles is a family in Morton order. More...
 
void t8_dtri_sibling (const t8_dtri_t *elem, int sibid, t8_dtri_t *sibling)
 Compute a specific sibling of a triangle. More...
 
int t8_dtri_face_neighbour (const t8_dtri_t *t, int face, t8_dtri_t *n)
 Compute the face neighbor of a triangle. More...
 
void t8_dtri_nearest_common_ancestor (const t8_dtri_t *t1, const t8_dtri_t *t2, t8_dtri_t *r)
 Computes the nearest common ancestor of two triangles in the same tree. More...
 
void t8_dtri_children_at_face (const t8_dtri_t *tri, int face, t8_dtri_t *children[], int num_children, int *child_indices)
 Given a triangle and a face of the triangle, compute all children of the triangle that touch the face. More...
 
int t8_dtri_face_child_face (const t8_dtri_t *triangle, int face, int face_child)
 Given a face of a triangle and a child number of a child of that face, return the face number of the child of the triangle that matches the child face. More...
 
int t8_dtri_face_parent_face (const t8_dtri_t *triangle, int face)
 Given a face of an triangle return the face number of the parent of the triangle that matches the triangle's face. More...
 
int t8_dtri_tree_face (t8_dtri_t *t, int face)
 Given a triangle and a face of this triangle. More...
 
int t8_dtri_root_face_to_face (t8_dtri_t *t, int root_face)
 Given a triangle and a face of the root triangle. More...
 
void t8_dtri_transform_face (const t8_dtri_t *trianglein, t8_dtri_t *triangle2, int orientation, int sign, int is_smaller_face)
 Suppose we have two trees that share a common triangle f. More...
 
int t8_dtri_is_inside_root (t8_dtri_t *t)
 Test if a triangle lies inside of the root triangle, that is the triangle of level 0, anchor node (0,0) and type 0. More...
 
int t8_dtri_is_root_boundary (const t8_dtri_t *t, int face)
 Compute whether a given triangle shares a given face with its root tree. More...
 
int t8_dtri_is_equal (const t8_dtri_t *t1, const t8_dtri_t *t2)
 Test if two triangles have the same coordinates, type and level. More...
 
int t8_dtri_is_sibling (const t8_dtri_t *t1, const t8_dtri_t *t2)
 Test if two triangles are siblings. More...
 
int t8_dtri_is_parent (const t8_dtri_t *t, const t8_dtri_t *c)
 Test if a triangle is the parent of another triangle. More...
 
int t8_dtri_is_ancestor (const t8_dtri_t *t, const t8_dtri_t *c)
 Test if a triangle is an ancestor of another triangle. More...
 
t8_linearidx_t t8_dtri_linear_id (const t8_dtri_t *t, int level)
 Computes the linear position of a triangle in a uniform grid. More...
 
void t8_dtri_init_linear_id_with_level (t8_dtri_t *t, t8_linearidx_t id, const int start_level, const int end_level, t8_dtri_type_t parenttype)
 Same as init_linear_id, but we only consider the subtree. More...
 
void t8_dtri_init_linear_id (t8_dtri_t *t, t8_linearidx_t id, int level)
 Initialize a triangle as the triangle with a given global id in a uniform refinement of a given level. More...
 
void t8_dtri_init_root (t8_dtri_t *t)
 Initialize a triangle as the root triangle (type 0 at level 0) More...
 
void t8_dtri_successor (const t8_dtri_t *t, t8_dtri_t *s, int level)
 Computes the successor of a triangle in a uniform grid of level level. More...
 
void t8_dtri_first_descendant (const t8_dtri_t *t, t8_dtri_t *s, int level)
 Compute the first descendant of a triangle at a given level. More...
 
void t8_dtri_last_descendant (const t8_dtri_t *t, t8_dtri_t *s, int level)
 Compute the last descendant of a triangle at a given level. More...
 
void t8_dtri_corner_descendant (const t8_dtri_t *t, t8_dtri_t *s, int corner, int level)
 Compute the descendant of a triangle in a given corner. More...
 
void t8_dtri_predecessor (const t8_dtri_t *t, t8_dtri_t *s, int level)
 Computes the predecessor of a triangle in a uniform grid of level level. More...
 
int t8_dtri_ancestor_id (const t8_dtri_t *t, int level)
 Compute the position of the ancestor of this child at level level within its siblings. More...
 
int t8_dtri_child_id (const t8_dtri_t *t)
 Compute the position of the ancestor of this child at level level within its siblings. More...
 
int t8_dtri_get_level (const t8_dtri_t *t)
 Return the level of a triangle. More...
 
int t8_dtri_is_valid (const t8_dtri_t *t)
 Query whether all entries of a triangle are in valid ranges. More...
 
void t8_dtri_debug_print (const t8_dtri_t *t)
 Print a triangle. More...
 

Detailed Description

Definitions of triangle-specific functions.

Function Documentation

◆ t8_dtri_ancestor()

void t8_dtri_ancestor ( const t8_dtri_t t,
int  level,
t8_dtri_t ancestor 
)

Compute the ancestor of a triangle at a given level.

Parameters
[in]tInput triangle.
[in]levelA smaller level than t.
[in,out]ancestorExisting triangle whose data will be filled with the data of t's ancestor on level level.
Note
The triangle ancestor may point to the same triangle as t.

◆ t8_dtri_ancestor_id()

int t8_dtri_ancestor_id ( const t8_dtri_t t,
int  level 
)

Compute the position of the ancestor of this child at level level within its siblings.

Parameters
[in]ttriangle to be considered.
[in]levellevel to be considered.
Returns
Returns its child id in 0..3

◆ t8_dtri_child()

void t8_dtri_child ( const t8_dtri_t t,
int  childid,
t8_dtri_t child 
)

Compute the childid-th child in Morton order of a triangle.

Parameters
[in]tInput triangle.
[in,out]childidThe id of the child, 0..7 in Morton order.
[out]childExisting triangle whose data will be filled with the date of t's childid-th child.

◆ t8_dtri_child_id()

int t8_dtri_child_id ( const t8_dtri_t t)

Compute the position of the ancestor of this child at level level within its siblings.

Parameters
[in]ttriangle to be considered.
Returns
Returns its child id in 0..3

◆ t8_dtri_children_at_face()

void t8_dtri_children_at_face ( const t8_dtri_t tri,
int  face,
t8_dtri_t children[],
int  num_children,
int *  child_indices 
)

Given a triangle and a face of the triangle, compute all children of the triangle that touch the face.

Parameters
[in]triThe triangle.
[in]faceA face of tri.
[in,out]childrenAllocated triangles, in which the children of tri that share a face with face are stored. They will be stored in order of their child_id.
[in]num_childrenThe number of triangles in children. Must match the number of children that touch face.

◆ t8_dtri_childrenpv()

void t8_dtri_childrenpv ( const t8_dtri_t t,
t8_dtri_t c[T8_DTRI_CHILDREN] 
)

Compute the 4 children of a triangle, array version.

Parameters
[in]tInput triangle.
[in,out]cPointers to the 4 computed children in Morton order. t may point to the same quadrant as c[0].

◆ t8_dtri_compare()

int t8_dtri_compare ( const t8_dtri_t t1,
const t8_dtri_t t2 
)

Compare two triangle in their linear order.

Parameters
[in]t1Triangle one.
[in]t2Triangle two.
Returns
Returns negativ if t1 < t2, zero if t1 = t2, positive if t1 > t2

◆ t8_dtri_compute_all_coords()

void t8_dtri_compute_all_coords ( const t8_dtri_t elem,
t8_dtri_coord_t  coordinates[3][2] 
)

Compute the coordinates of the four vertices of a triangle.

Parameters
[in]elemInput triangle.
[out]coordinatesAn array of 4x3 t8_dtri_coord_t that will be filled with the coordinates of t's vertices.

◆ t8_dtri_compute_coords()

void t8_dtri_compute_coords ( const t8_dtri_t elem,
const int  vertex,
t8_dtri_coord_t  coordinates[2] 
)

Compute the coordinates of a vertex of a triangle.

Parameters
[in]elemInput triangle.
[in]vertexThe number of the vertex.
[out]coordinatesAn array of 2 t8_dtri_coord_t that will be filled with the coordinates of the vertex.

◆ t8_dtri_compute_vertex_ref_coords()

void t8_dtri_compute_vertex_ref_coords ( const t8_dtri_t elem,
const int  vertex,
double  coordinates[2] 
)

Compute the reference coordinates of a vertex of a triangle when the tree (level 0 triangle) is embedded in [0,1]^2.

Parameters
[in]elemInput triangle.
[in]vertexThe number of the vertex.
[out]coordinatesAn array of 2 double that will be filled with the reference coordinates of the vertex.

◆ t8_dtri_copy()

void t8_dtri_copy ( const t8_dtri_t t,
t8_dtri_t dest 
)

Copy the values of one triangle to another.

Parameters
[in]tTriangle whose values will be copied.
[in,out]destExisting triangle whose data will be filled with the data of t. *

◆ t8_dtri_corner_descendant()

void t8_dtri_corner_descendant ( const t8_dtri_t t,
t8_dtri_t s,
int  corner,
int  level 
)

Compute the descendant of a triangle in a given corner.

Parameters
[in]tTriangle whose descendant is computed.
[out]sExisting triangle whose data will be filled with the data of t's descendant in corner.
[in]cornerThe corner in which the descendant should lie.
[in]levelThe refinement level of the descendant. Must be greater or equal to t's level.

◆ t8_dtri_debug_print()

void t8_dtri_debug_print ( const t8_dtri_t t)

Print a triangle.

Parameters
[in]ttriangle to be considered.

◆ t8_dtri_face_child_face()

int t8_dtri_face_child_face ( const t8_dtri_t triangle,
int  face,
int  face_child 
)

Given a face of a triangle and a child number of a child of that face, return the face number of the child of the triangle that matches the child face.

Parameters
[in]triangleThe triangle.
[in]faceThen number of the face.
[in]face_childThe child number of a child of the face triangle.
Returns
The face number of the face of a child of triangle that conincides with face_child.

◆ t8_dtri_face_neighbour()

int t8_dtri_face_neighbour ( const t8_dtri_t t,
int  face,
t8_dtri_t n 
)

Compute the face neighbor of a triangle.

Parameters
[in]tInput triangle.
[in]faceThe face across which to generate the neighbor.
[in,out]nExisting triangle whose data will be filled.
Note
t may point to the same triangle as n.

◆ t8_dtri_face_parent_face()

int t8_dtri_face_parent_face ( const t8_dtri_t triangle,
int  face 
)

Given a face of an triangle return the face number of the parent of the triangle that matches the triangle's face.

Or return -1 if no face of the parent matches the face.

Parameters
[in]triangleThe triangle.
[in]faceThen number of the face.
Returns
If face of elem is also a face of elem's parent, the face number of this face. Otherwise -1.

◆ t8_dtri_first_descendant()

void t8_dtri_first_descendant ( const t8_dtri_t t,
t8_dtri_t s,
int  level 
)

Compute the first descendant of a triangle at a given level.

This is the descendant of the triangle in a uniform maxlevel refinement that has the smaller id.

Parameters
[in]tTriangle whose descendant is computed.
[in]levelA given level. Must be grater or equal to t's level.
[out]sExisting triangle whose data will be filled with the data of t's first descendant.

◆ t8_dtri_get_level()

int t8_dtri_get_level ( const t8_dtri_t t)

Return the level of a triangle.

Parameters
[in]ttriangle to be considered.
Returns
The level of t.

◆ t8_dtri_init_linear_id()

void t8_dtri_init_linear_id ( t8_dtri_t t,
t8_linearidx_t  id,
int  level 
)

Initialize a triangle as the triangle with a given global id in a uniform refinement of a given level.

  • Parameters
    [in,out]tExisting triangle whose data will be filled.
    [in]idIndex to be considered.
    [in]levellevel of uniform grid to be considered.

◆ t8_dtri_init_linear_id_with_level()

void t8_dtri_init_linear_id_with_level ( t8_dtri_t t,
t8_linearidx_t  id,
const int  start_level,
const int  end_level,
t8_dtri_type_t  parenttype 
)

Same as init_linear_id, but we only consider the subtree.

Used for computing the index of a tetrahedron lying in a pyramid

Parameters
[in,out]tExisting triangle whose data will be filled
[in]idIndex to be considered
[in]start_levelThe level of the root of the subtree
[in]end_levelLevel of uniform grid to be considered
[in]parenttypeThe type of the parent.

◆ t8_dtri_init_root()

void t8_dtri_init_root ( t8_dtri_t t)

Initialize a triangle as the root triangle (type 0 at level 0)

Parameters
[in,out]tExisting triangle whose data will be filled.

◆ t8_dtri_is_ancestor()

int t8_dtri_is_ancestor ( const t8_dtri_t t,
const t8_dtri_t c 
)

Test if a triangle is an ancestor of another triangle.

Parameters
[in]ttriangle to be tested.
[in]cDescendent triangle.
Returns
true if t is equal to or an ancestor of c.

◆ t8_dtri_is_equal()

int t8_dtri_is_equal ( const t8_dtri_t t1,
const t8_dtri_t t2 
)

Test if two triangles have the same coordinates, type and level.

Returns
true if t1 describes the same triangle as t2.

◆ t8_dtri_is_familypv()

int t8_dtri_is_familypv ( const t8_dtri_t f[])

Check whether a collection of eight triangles is a family in Morton order.

Parameters
[in]fAn array of eight triangles.
Returns
Nonzero if f is a family of triangles.

◆ t8_dtri_is_inside_root()

int t8_dtri_is_inside_root ( t8_dtri_t t)

Test if a triangle lies inside of the root triangle, that is the triangle of level 0, anchor node (0,0) and type 0.

Parameters
[in]tInput triangle.
Returns
true If t lies inside of the root triangle.

◆ t8_dtri_is_parent()

int t8_dtri_is_parent ( const t8_dtri_t t,
const t8_dtri_t c 
)

Test if a triangle is the parent of another triangle.

Parameters
[in]ttriangle to be tested.
[in]cPossible child triangle.
Returns
true if t is the parent of c.

◆ t8_dtri_is_root_boundary()

int t8_dtri_is_root_boundary ( const t8_dtri_t t,
int  face 
)

Compute whether a given triangle shares a given face with its root tree.

Parameters
[in]tThe input triangle.
[in]faceA face of t.
Returns
True if face is a subface of the triangle's root element.

◆ t8_dtri_is_sibling()

int t8_dtri_is_sibling ( const t8_dtri_t t1,
const t8_dtri_t t2 
)

Test if two triangles are siblings.

Parameters
[in]t1First triangle to be tested.
[in]t2Second triangle to be tested.
Returns
true if t1 is equal to or a sibling of t2. *

◆ t8_dtri_is_valid()

int t8_dtri_is_valid ( const t8_dtri_t t)

Query whether all entries of a triangle are in valid ranges.

Parameters
[in]ttriangle to be considered.
Returns
True, if t is a valid triangle and it is safe to call any function on t. False otherwise.

◆ t8_dtri_last_descendant()

void t8_dtri_last_descendant ( const t8_dtri_t t,
t8_dtri_t s,
int  level 
)

Compute the last descendant of a triangle at a given level.

This is the descendant of the triangle in a uniform maxlevel refinement that has the biggest id.

Parameters
[in]tTriangle whose descendant is computed.
[in]levelA given level. Must be grater or equal to t's level.
[out]sExisting triangle whose data will be filled with the data of t's last descendant.

◆ t8_dtri_linear_id()

t8_linearidx_t t8_dtri_linear_id ( const t8_dtri_t t,
int  level 
)

Computes the linear position of a triangle in a uniform grid.

Parameters
[in]ttriangle whose id will be computed.
[in]levellevel of uniform grid to be considered.
Returns
Returns the linear position of this triangle on a grid of level level.
Note
This id is not the Morton index.

◆ t8_dtri_nearest_common_ancestor()

void t8_dtri_nearest_common_ancestor ( const t8_dtri_t t1,
const t8_dtri_t t2,
t8_dtri_t r 
)

Computes the nearest common ancestor of two triangles in the same tree.

Parameters
[in]t1First input triangle.
[in]t2Second input triangle.
[in,out]rExisting triangle whose data will be filled.
Note
t1, t2, r may point to the same quadrant.

◆ t8_dtri_parent()

void t8_dtri_parent ( const t8_dtri_t t,
t8_dtri_t parent 
)

Compute the parent of a triangle.

Parameters
[in]elemInput triangle.
[in,out]parentExisting triangle whose data will be filled with the data of elem's parent.
Note
elem may point to the same triangle as parent.

◆ t8_dtri_predecessor()

void t8_dtri_predecessor ( const t8_dtri_t t,
t8_dtri_t s,
int  level 
)

Computes the predecessor of a triangle in a uniform grid of level level.

Parameters
[in]ttriangle whose id will be computed.
[in,out]sExisting triangle whose data will be filled with the data of t's predecessor on level level.
[in]levellevel of uniform grid to be considered.

◆ t8_dtri_root_face_to_face()

int t8_dtri_root_face_to_face ( t8_dtri_t t,
int  root_face 
)

Given a triangle and a face of the root triangle.

If the triangle lies on the tree boundary, return the corresponding face number of the triangle. If not the return value is arbitrary.

Parameters
[in]tThe triangle.
[in]faceThe index of a face of the root element.
Returns
The index of the face of t that is a subface of face, if t is on the tree boundary. Any arbitrary integer if t is not at a tree boundary.
Note
For boundary triangles, this function is the inverse of t8_dtri_tree_face

◆ t8_dtri_sibling()

void t8_dtri_sibling ( const t8_dtri_t elem,
int  sibid,
t8_dtri_t sibling 
)

Compute a specific sibling of a triangle.

Parameters
[in]elemInput triangle.
[in,out]siblingExisting triangle whose data will be filled with the data of sibling no. sibling_id of elem.
[in]sibidThe id of the sibling computed, 0..7 in Bey order.

◆ t8_dtri_successor()

void t8_dtri_successor ( const t8_dtri_t t,
t8_dtri_t s,
int  level 
)

Computes the successor of a triangle in a uniform grid of level level.

Parameters
[in]ttriangle whose id will be computed.
[in,out]sExisting triangle whose data will be filled with the data of t's successor on level level.
[in]levellevel of uniform grid to be considered.

◆ t8_dtri_transform_face()

void t8_dtri_transform_face ( const t8_dtri_t trianglein,
t8_dtri_t triangle2,
int  orientation,
int  sign,
int  is_smaller_face 
)

Suppose we have two trees that share a common triangle f.

Given a triangle e that is a subface of f in one of the trees and given the orientation of the tree connection, construct the face triangle of the respective tree neighbor that logically coincides with e but lies in the coordinate system of the neighbor tree.

Parameters
[in]triangleinThe face triangle.
[in,out]triangle2On return the face triangle triangle1 with respective to the coordinate system of the other tree.
[in]orientationThe orientation of the tree-tree connection.
See also
t8_cmesh_set_join
Parameters
[in]signDepending on the topological orientation of the two tree faces, either 0 (both faces have opposite orientation) or 1 (both faces have the same top. orientattion). t8_eclass_face_orientation
[in]is_smaller_faceFlag to declare whether triangle1 belongs to the smaller face. A face f of tree T is smaller than f' of T' if either the eclass of T is smaller or if the classes are equal and f<f'. The orientation is defined in relation to the smaller face.
Note
trianglein and triangle2 may point to the same element.

◆ t8_dtri_tree_face()

int t8_dtri_tree_face ( t8_dtri_t t,
int  face 
)

Given a triangle and a face of this triangle.

If the face lies on the tree boundary, return the face number of the tree face. If not the return value is arbitrary.

Parameters
[in]tThe triangle.
[in]faceThe index of a face of t.
Returns
The index of the tree face that face is a subface of, if face is on a tree boundary. Any arbitrary integer if t is not at a tree boundary.
Note
For boundary triangles, this function is the inverse of t8_dtri_root_face_to_face