Class t8_default_scheme_quad
Defined in File t8_default_quad.hxx
Inheritance Relationships
Base Type
public t8_default_scheme_common< T8_ECLASS_QUAD, t8_default_scheme_quad >(Template Class t8_default_scheme_common)
Class Documentation
-
class t8_default_scheme_quad : public t8_default_scheme_common<T8_ECLASS_QUAD, t8_default_scheme_quad>
Default implementation of the scheme for the quad element class.
Public Functions
-
inline t8_default_scheme_quad() noexcept
Constructor which calls the specialized constructor for the base.
-
inline ~t8_default_scheme_quad()
Destructor.
-
size_t get_element_size(void) const
Return the size of a quad element.
- Returns:
The size of an element of class quad.
-
void element_new(int length, t8_element_t **elem) const
Allocate memory for an array of quadrilaterals and initialize them.
See also
See also
Note
Not every element that is created in t8code will be created by a call to this function. However, if an element is not created using element_new, then it is guaranteed that element_init is called on it.
Note
In debugging mode, an element that was created with element_new must pass element_is_valid.
Note
If an element was created by element_new then element_init may not be called for it. Thus, element_new should initialize an element in the same way as a call to element_init would.
- Parameters:
length – [in] The number of quad elements to be allocated.
elem – [inout] On input an array of length many unallocated element pointers. On output all these pointers will point to an allocated and initialized element.
-
void element_init(int length, t8_element_t *elem) const
Initialize an array of allocated quad elements.
See also
See also
Note
In debugging mode, an element that was passed to element_init must pass element_is_valid.
Note
If an element was created by element_new then element_init may not be called for it. Thus, element_new should initialize an element in the same way as a call to element_init would. Thus, if called_new is true this function should usually do nothing.
- Parameters:
length – [in] The number of quad elements to be initialized.
elem – [inout] On input an array of length many allocated elements.
-
int element_get_level(const t8_element_t *elem) const
Return the refinement level of an element.
- Parameters:
elem – [in] The element whose level should be returned.
- Returns:
The level of elem.
-
int get_maxlevel(void) const
Return the maximum allowed level for this element class.
- Returns:
The maximum allowed level for elements of this class.
-
void element_copy(const t8_element_t *source, t8_element_t *dest) const
Copy all entries of source to dest.
dest must be an existing element. No memory is allocated by this function.
Note
source and dest may point to the same element.
- Parameters:
source – [in] The element whose entries will be copied to dest.
dest – [inout] This element’s entries will be overwritten with the entries of source.
-
int element_compare(const t8_element_t *elem1, const t8_element_t *elem2) const
Compare two elements.
- Parameters:
elem1 – [in] The first element.
elem2 – [in] The second element.
- Returns:
negative if elem1 < elem2, zero if elem1 equals elem2 and positive if elem1 > elem2. If elem2 is a copy of elem1 then the elements are equal.
-
int element_is_equal(const t8_element_t *elem1, const t8_element_t *elem2) const
Check if two elements are equal.
- Parameters:
elem1 – [in] The first element.
elem2 – [in] The second element.
- Returns:
1 if the elements are equal, 0 if they are not equal
-
void element_get_parent(const t8_element_t *elem, t8_element_t *parent) const
Compute the parent of a given element elem and store it in parent.
parent needs to be an existing element. No memory is allocated by this function. elem and parent can point to the same element, then the entries of elem are overwritten by the ones of its parent.
- Parameters:
elem – [in] The element whose parent will be computed.
parent – [inout] This element’s entries will be overwritten by those of elem’s parent. The storage for this element must exist and match the element class of the parent. For a pyramid, for example, it may be either a tetrahedron or a pyramid depending on elem’s childid.
-
void element_get_sibling(const t8_element_t *elem, int sibid, t8_element_t *sibling) const
Compute a specific sibling of a given quad element elem and store it in sibling.
sibling needs to be an existing element. No memory is allocated by this function. elem and sibling can point to the same element, then the entries of elem are overwritten by the ones of its sibid -th sibling.
- Parameters:
elem – [in] The element whose sibling will be computed.
sibid – [in] The id of the sibling computed.
sibling – [inout] This element’s entries will be overwritten by those of elem’s sibid-th sibling. The storage for this element must exist and match the element class of the sibling.
-
int element_get_num_faces(const t8_element_t *elem) const
Compute the number of faces of a given element.
- Parameters:
elem – [in] The element.
- Returns:
The number of faces of elem.
-
int element_get_max_num_faces(const t8_element_t *elem) const
Compute the maximum number of faces of a given element and all of its descendants.
- Parameters:
elem – [in] The element.
- Returns:
The maximum number of faces of elem and its descendants.
-
int element_get_num_children(const t8_element_t *elem) const
Return the number of children of an element when it is refined.
- Parameters:
elem – [in] The element whose number of children is returned.
- Returns:
The number of children of elem if it is to be refined.
-
int element_get_num_face_children(const t8_element_t *elem, int face) const
Return the number of children of an element’s face when the element is refined.
- Parameters:
elem – [in] The element whose face is considered.
face – [in] A face of elem.
- Returns:
The number of children of face if elem is to be refined.
-
int element_get_face_corner(const t8_element_t *element, int face, int corner) const
Return the corner number of an element’s face corner.
- Parameters:
element – [in] The element.
face – [in] A face index for element.
corner – [in] A corner index for the face 0 <= corner < num_face_corners.
- Returns:
The corner number of the corner-th vertex of face.
-
int element_get_corner_face(const t8_element_t *element, int corner, int face) const
Return the face numbers of the faces sharing an element’s corner.
- Parameters:
element – [in] The element.
corner – [in] A corner index for the face.
face – [in] A face index for corner.
- Returns:
The face number of the face-th face at corner.
-
void element_get_child(const t8_element_t *elem, int childid, t8_element_t *child) const
Construct the child element of a given number.
- Parameters:
elem – [in] This must be a valid element, bigger than maxlevel.
childid – [in] The number of the child to construct.
child – [inout] The storage for this element must exist and match the element class of the child. On output, a valid element. It is valid to call this function with elem = child.
-
void element_get_children(const t8_element_t *elem, int length, t8_element_t *c[]) const
Construct all children of a given element.
See also
- Parameters:
elem – [in] This must be a valid element, bigger than maxlevel.
length – [in] The length of the output array c must match the number of children.
c – [inout] The storage for these length elements must exist and match the element class in the children’s ordering. On output, all children are valid. It is valid to call this function with elem = c[0].
-
int element_get_child_id(const t8_element_t *elem) const
Compute the child id of an element.
- Parameters:
elem – [in] This must be a valid element.
- Returns:
The child id of elem.
-
int element_get_ancestor_id(const t8_element_t *elem, int level) const
Compute the ancestor id of an element, that is the child id at a given level.
Note
The ancestor id at elem.level is the same as the child id.
- Parameters:
elem – [in] This must be a valid element.
level – [in] A refinement level. Must satisfy level <= elem.level
- Returns:
The child_id of elem in regard to its level ancestor.
-
int elements_are_family(t8_element_t *const *fam) const
Query whether a given set of elements is a family or not.
Note
level 0 elements do not form a family.
- Parameters:
fam – [in] An array of as many elements as an element of class scheme has siblings.
- Returns:
Zero if fam is not a family, nonzero if it is.
-
void element_get_nca(const t8_element_t *elem1, const t8_element_t *elem2, t8_element_t *nca) const
Compute the nearest common ancestor of two elements.
That is, the element with highest level that still has both given elements as descendants.
- Parameters:
elem1 – [in] The first of the two input elements.
elem2 – [in] The second of the two input elements.
nca – [inout] The storage for this element must exist and match the element class of the child. On output the unique nearest common ancestor of elem1 and elem2.
-
t8_element_shape_t element_get_face_shape(const t8_element_t *elem, int face) const
Compute the shape of the face of an element.
- Parameters:
elem – [in] The element.
face – [in] A face of elem.
- Returns:
The element shape of the face.
-
void element_get_children_at_face(const t8_element_t *elem, int face, t8_element_t *children[], int num_children, int *child_indices) const
Given an element and a face of the element, compute all children of the element that touch the face.
- Parameters:
elem – [in] The element.
face – [in] A face of elem.
children – [inout] Allocated elements, in which the children of elem that share a face with face are stored. They will be stored in order of their linear id.
num_children – [in] The number of elements in children. Must match the number of children that touch face. element_get_num_face_children
child_indices – [inout] If not NULL, an array of num_children integers must be given, on output its i-th entry is the child_id of the i-th face_child. It is valid to call this function with elem = children[0].
-
int element_face_get_child_face(const t8_element_t *elem, int face, int face_child) const
Given a face of an element and a child number of a child of that face, return the face number of the child of the element that matches the child face.
x ---- x x x x ---- x | | | | | | | <-- f | | | x | x--x | | | | | x ---- x x x ---- x elem face face_child Returns the face number f
- Parameters:
elem – [in] The element.
face – [in] Then number of the face.
face_child – [in] A number 0 <= face_child < num_face_children, specifying a child of elem that shares a face with face. These children are counted in linear order. This coincides with the order of children from a call to element_get_children_at_face.
- Returns:
The face number of the face of a child of elem that coincides with face_child.
-
int element_face_get_parent_face(const t8_element_t *elem, int face) const
Given a face of an element return the face number of the parent of the element that matches the element’s face.
Or return -1 if no face of the parent matches the face.
Note
For the root element this function always returns face.
- Parameters:
elem – [in] The element.
face – [in] Then 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.
-
int element_get_tree_face(const t8_element_t *elem, int face) const
Given an element and a face of this element.
If the face lies on the tree boundary, return the face number of the tree face. If not the return value is arbitrary.
- Parameters:
elem – [in] The element.
face – [in] The index of a face of elem.
- Returns:
The index of the tree face that face is a subface of, if face is on a tree boundary. Any arbitrary integer if is not at a tree boundary.
-
void element_transform_face(const t8_element_t *elem1, t8_element_t *elem2, int orientation, int sign, int is_smaller_face) const
Suppose we have two trees that share a common face f.
Given an element e that is a subface of f in one of the trees and given the orientation of the tree connection, construct the face element of the respective tree neighbor that logically coincides with e but lies in the coordinate system of the neighbor tree.
See also
Note
elem1 and elem2 may point to the same element.
- Parameters:
elem1 – [in] The face element.
elem2 – [inout] On return the face element elem1 with respect to the coordinate system of the other tree.
orientation – [in] The orientation of the tree-tree connection.
sign – [in] Depending on the topological orientation of the two tree faces, either 0 (both faces have opposite orientation) or 1 (both faces have the same top. orientation). t8_eclass_face_orientation
is_smaller_face – [in] Flag to declare whether elem1 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.
-
int element_extrude_face(const t8_element_t *face, t8_element_t *elem, int root_face, const t8_scheme *scheme) const
Given a boundary face inside a root tree’s face construct the element inside the root tree that has the given face as a face.
- Parameters:
face – [in] A face element.
elem – [inout] An allocated element. The entries will be filled with the data of the element that has face as a face and lies within the root tree.
root_face – [in] The index of the face of the root tree in which face lies.
scheme – [in] The scheme collection with a scheme for the eclass of the face.
- Returns:
The face number of the face of elem that coincides with face.
-
void element_get_first_descendant_face(const t8_element_t *elem, int face, t8_element_t *first_desc, int level) const
Construct the first descendant of an element at a given level that touches a given face.
- Parameters:
elem – [in] The input element.
face – [in] A face of elem.
first_desc – [inout] An allocated element. This element’s data will be filled with the data of the first descendant of elem that shares a face with face.
level – [in] The level, at which the first descendant is constructed
-
void element_get_last_descendant_face(const t8_element_t *elem, int face, t8_element_t *last_desc, int level) const
Construct the last descendant of an element at a given level that touches a given face.
- Parameters:
elem – [in] The input element.
face – [in] A face of elem.
last_desc – [inout] An allocated element. This element’s data will be filled with the data of the last descendant of elem that shares a face with face.
level – [in] The level, at which the last descendant is constructed
-
void element_get_boundary_face(const t8_element_t *elem, int face, t8_element_t *boundary, const t8_scheme *scheme) const
Construct the boundary element at a specific face.
- Parameters:
elem – [in] The input element.
face – [in] The index of the face of which to construct the boundary element.
boundary – [inout] An allocated element of dimension of element minus 1. The entries will be filled with the entries of the face of element.
scheme – [in] The scheme containing an eclass scheme for the boundary face.
-
int element_is_root_boundary(const t8_element_t *elem, int face) const
Compute whether a given element shares a given face with its root tree.
- Parameters:
elem – [in] The input element.
face – [in] A face of elem.
- Returns:
True if face is a subface of the element’s root element.
-
int element_get_face_neighbor_inside(const t8_element_t *elem, t8_element_t *neigh, int face, int *neigh_face) const
Construct the face neighbor of a given element if this face neighbor is inside the root tree.
Return 0 otherwise.
- Parameters:
elem – [in] The element to be considered.
neigh – [inout] If the face neighbor of elem along face is inside the root tree, this element’s data is filled with the data of the face neighbor. Otherwise the data can be modified arbitrarily.
face – [in] The number of the face along which the neighbor should be constructed.
neigh_face – [out] The number of face as viewed from neigh. An arbitrary value, if the neighbor is not inside the root tree.
- Returns:
True if neigh is inside the root tree. False if not. In this case neigh’s data can be arbitrary on output.
-
void element_set_linear_id(t8_element_t *elem, int level, t8_linearidx_t id) const
Initialize the entries of an allocated element according to a given linear id in a uniform refinement.
- Parameters:
elem – [inout] The element whose entries will be set.
level – [in] The level of the uniform refinement to consider.
id – [in] The linear id. id must fulfil 0 <= id < ‘number of leaves in the uniform refinement’
-
t8_linearidx_t element_get_linear_id(const t8_element_t *elem, int level) const
Compute the linear id of a given element in a hypothetical uniform refinement of a given level.
- Parameters:
elem – [in] The element whose id we compute.
level – [in] The level of the uniform refinement to consider.
- Returns:
The linear id of the element.
-
void element_get_first_descendant(const t8_element_t *elem, t8_element_t *desc, int level) const
Compute the first descendant of a given element.
- Parameters:
elem – [in] The element whose descendant is computed.
desc – [out] The first element in a uniform refinement of elem of the given level.
level – [in] The level, at which the descendant is computed.
-
void element_get_last_descendant(const t8_element_t *elem, t8_element_t *desc, int level) const
Compute the last descendant of a given element.
- Parameters:
elem – [in] The element whose descendant is computed.
desc – [out] The last element in a uniform refinement of elem of the given level.
level – [in] The level, at which the descendant is computed.
-
void element_construct_successor(const t8_element_t *elem, t8_element_t *succ) const
Construct the successor in a uniform refinement of a given element.
- Parameters:
elem – [in] The element whose successor should be constructed.
succ – [inout] The successor element whose entries will be set.
-
void element_get_anchor(const t8_element_t *elem, int anchor[3]) const
Get the integer coordinates of the anchor node of an element.
The default scheme implements the Morton type SFCs. In these SFCs the elements are positioned in a cube [0,1]^(dL) with dimension d (=0,1,2,3) and L the maximum refinement level. All element vertices have integer coordinates in this cube and the anchor node is the first of all vertices (index 0). It also has the lowest x,y and z coordinates.
- Parameters:
elem – [in] The element.
anchor – [out] The integer coordinates of the anchor node in the cube [0,1]^(dL)
-
void element_get_vertex_integer_coords(const t8_element_t *elem, int vertex, int coords[]) const
Compute the integer coordinates of a given element vertex.
The default scheme implements the Morton type SFCs. In these SFCs the elements are positioned in a cube [0,1]^(dL) with dimension d (=0,1,2,3) and L the maximum refinement level. All element vertices have integer coordinates in this cube.
- Parameters:
elem – [in] The element to be considered.
vertex – [in] The id of the vertex whose coordinates shall be computed.
coords – [out] An array of at least as many integers as the element’s dimension whose entries will be filled with the coordinates of vertex.
-
void element_get_vertex_reference_coords(const t8_element_t *elem, const int vertex, double coords[]) const
Compute the coordinates of a given element vertex inside a reference tree that is embedded into [0,1]^d (d = dimension).
Warning
coords should be zero-initialized, as only the first d coords will be set, but when used elsewhere all coords might be used.
- Parameters:
elem – [in] The element to be considered.
vertex – [in] The id of the vertex whose coordinates shall be computed.
coords – [out] An array of at least as many doubles as the element’s dimension whose entries will be filled with the coordinates of vertex.
-
void element_get_reference_coords(const t8_element_t *elem, const double *ref_coords, const size_t num_coords, double *out_coords) const
Convert points in the reference space of an element to points in the reference space of the tree.
- Parameters:
elem – [in] The element.
ref_coords – [in] The coordinates \( [0,1]^\mathrm{dim} \) of the point in the reference space of the element.
num_coords – [in] Number of \( dim\)-sized coordinates to evaluate.
out_coords – [out] The coordinates of the points in the reference space of the tree.
-
int refines_irregular(void) const
Returns true, if there is one element in the tree, that does not refine into 2^dim children.
Returns false otherwise.
- Returns:
0, because quads refine regularly
-
int element_is_valid(const t8_element_t *element) const
Query whether a given element can be considered as ‘valid’ and it is safe to perform any of the above algorithms on it.
Note
An element that is constructed with element_new must pass this test.
Note
An element for which element_init was called must pass this test.
Note
This function is used for debugging to catch certain errors. These can for example occur when an element points to a region of memory which should not be interpreted as an element.
Note
We recommend to use the assertion T8_ASSERT (element_is_valid (elem)) in the implementation of each of the functions in this file.
- Parameters:
element – [in] The element to be checked.
- Returns:
True if element is safe to use. False otherwise.
-
void element_to_string(const t8_element_t *elem, char *debug_string, const int string_size) const
Print a given element.
For a example for a triangle print the coordinates and the level of the triangle. This function is only available in the debugging configuration.
- Parameters:
elem – [in] The element to print
debug_string – [in] String printed to debug
string_size – [in] String size of debug_string.
-
void set_to_root(t8_element_t *elem) const
Fills an element with the root element.
- Parameters:
elem – [inout] The element to be filled with root.
-
void element_MPI_Pack(t8_element_t **const elements, const unsigned int count, void *send_buffer, int buffer_size, int *position, sc_MPI_Comm comm) const
Pack multiple elements into contiguous memory, so they can be sent via MPI.
- Parameters:
elements – [in] Array of elements that are to be packed
count – [in] Number of elements to pack
send_buffer – [inout] Buffer in which to pack the elements
buffer_size – [in] size of the buffer (in order to check that we don’t access out of range)
position – [inout] the position of the first byte that is not already packed
comm – [in] MPI Communicator
-
void element_MPI_Pack_size(const unsigned int count, sc_MPI_Comm comm, int *pack_size) const
Determine an upper bound for the size of the packed message of count elements.
- Parameters:
count – [in] Number of elements to pack
comm – [in] MPI Communicator
pack_size – [out] upper bound on the message size
-
void element_MPI_Unpack(void *recvbuf, const int buffer_size, int *position, t8_element_t **elements, const unsigned int count, sc_MPI_Comm comm) const
Unpack multiple elements from contiguous memory that was received via MPI.
- Parameters:
recvbuf – [in] Buffer from which to unpack the elements
buffer_size – [in] size of the buffer (in order to check that we don’t access out of range)
position – [inout] the position of the first byte that is not already packed
elements – [in] Array of initialised elements that is to be filled from the message
count – [in] Number of elements to unpack
comm – [in] MPI Communicator
-
inline t8_default_scheme_quad() noexcept