p4est 2.8.6
p4est is a software library for parallel adaptive mesh refinement.
Functions
p4est_bits.h File Reference

Routines for manipulating quadrants (neighbors, parents, children, etc.) More...

#include <p4est.h>
#include <sc_random.h>
Include dependency graph for p4est_bits.h:

Go to the source code of this file.

Functions

void p4est_quadrant_pad (p4est_quadrant_t *q)
 Write -1 into the pad8 and pad16 members of a quadrant. More...
 
void p4est_quadrant_print (int log_priority, const p4est_quadrant_t *q)
 Prints one line with quadrant's x, y and level. More...
 
int p4est_quadrant_is_equal (const p4est_quadrant_t *q1, const p4est_quadrant_t *q2)
 Test if two quadrants have equal Morton indices. More...
 
void p4est_quadrant_copy (const p4est_quadrant_t *q, p4est_quadrant_t *copy)
 Copy the Morton indices of the quadrant q. More...
 
int p4est_quadrant_overlaps (const p4est_quadrant_t *q1, const p4est_quadrant_t *q2)
 Test if two quadrants overlap. More...
 
int p4est_quadrant_is_equal_piggy (const p4est_quadrant_t *q1, const p4est_quadrant_t *q2)
 Test if two quadrants have equal Morton indices and the same tree id. More...
 
int p4est_quadrant_compare (const void *v1, const void *v2)
 Compare two quadrants in their Morton ordering. More...
 
int p4est_coordinates_compare (const p4est_qcoord_t v1[], const p4est_qcoord_t v2[])
 Compare two sets of coordinates in their Morton ordering. More...
 
int p4est_quadrant_disjoint (const void *v1, const void *v2)
 Compare two quadrants in their Morton ordering, with equivalence if the two quadrants overlap. More...
 
int p4est_quadrant_compare_piggy (const void *v1, const void *v2)
 Compare two quadrants in their Morton ordering and the which_tree member. More...
 
int p4est_quadrant_compare_local_num (const void *v1, const void *v2)
 Compare two quadrants with respect to their local_num in the piggy3 member. More...
 
int p4est_quadrant_equal_fn (const void *v1, const void *v2, const void *u)
 Test if two quadrants have equal Morton indices, callback version. More...
 
unsigned p4est_quadrant_hash_fn (const void *v, const void *u)
 Computes a hash value for a quadrant by the lookup3 method.
 
int p4est_node_equal_piggy_fn (const void *v1, const void *v2, const void *u)
 Test if two nodes are in the same tree and have equal Morton indices. More...
 
unsigned p4est_node_hash_piggy_fn (const void *v, const void *u)
 Compute hash value of a node based on its tree and Morton index. More...
 
void p4est_node_clamp_inside (const p4est_quadrant_t *n, p4est_quadrant_t *r)
 Clamp a node inside the unit tree if it sits on a high border. More...
 
void p4est_node_unclamp (p4est_quadrant_t *n)
 Move a clamped node out on the border. More...
 
void p4est_node_to_quadrant (const p4est_quadrant_t *n, int level, p4est_quadrant_t *q)
 Find the enclosing quadrant of a given node at a given level. More...
 
int p4est_quadrant_contains_node (const p4est_quadrant_t *q, const p4est_quadrant_t *n)
 Decide if a node is completely contained within a quadrant. More...
 
int p4est_quadrant_ancestor_id (const p4est_quadrant_t *q, int level)
 Compute the position of the ancestor of this child at level level within its siblings. More...
 
int p4est_quadrant_child_id (const p4est_quadrant_t *q)
 Compute the position of this child within its siblings. More...
 
int p4est_coordinates_is_inside_root (const p4est_qcoord_t coord[])
 Test if Morton indices are inside the unit tree. More...
 
int p4est_quadrant_is_inside_root (const p4est_quadrant_t *q)
 Test if a quadrant is inside the unit tree. More...
 
int p4est_quadrant_is_inside_3x3 (const p4est_quadrant_t *q)
 Test if a quadrant is inside the 3x3 box around the root tree. More...
 
int p4est_quadrant_is_outside_face (const p4est_quadrant_t *q)
 Test if a quadrant is outside a tree face boundary (no corner). More...
 
int p4est_quadrant_is_outside_corner (const p4est_quadrant_t *q)
 Test if a quadrant is outside a tree corner boundary. More...
 
int p4est_quadrant_is_node (const p4est_quadrant_t *q, int inside)
 Test if a quadrant is used to represent a mesh node. More...
 
int p4est_coordinates_is_valid (const p4est_qcoord_t coord[], int level)
 Test if Morton indices are valid and are inside the unit tree. More...
 
int p4est_quadrant_is_valid (const p4est_quadrant_t *q)
 Test if a quadrant has valid Morton indices and is inside the unit tree. More...
 
int p4est_quadrant_is_extended (const p4est_quadrant_t *q)
 Test if a quadrant has valid Morton indices in the 3x3 box around root. More...
 
int p4est_quadrant_is_sibling (const p4est_quadrant_t *q1, const p4est_quadrant_t *q2)
 Test if two quadrants are siblings. More...
 
int p4est_quadrant_is_sibling_D (const p4est_quadrant_t *q1, const p4est_quadrant_t *q2)
 Test if two quadrants are siblings. More...
 
int p4est_quadrant_is_family (const p4est_quadrant_t *q0, const p4est_quadrant_t *q1, const p4est_quadrant_t *q2, const p4est_quadrant_t *q3)
 Test if 4 quadrants are siblings in Morton ordering.
 
int p4est_quadrant_is_familyv (const p4est_quadrant_t q[])
 Test if 4 quadrants are siblings in Morton ordering, array version. More...
 
int p4est_quadrant_is_familypv (p4est_quadrant_t *q[])
 Test if 4 quadrants are siblings in Morton ordering, array version. More...
 
int p4est_quadrant_is_parent (const p4est_quadrant_t *q, const p4est_quadrant_t *r)
 Test if a quadrant is the parent of another quadrant. More...
 
int p4est_quadrant_is_parent_D (const p4est_quadrant_t *q, const p4est_quadrant_t *r)
 Test if a quadrant is the parent of another quadrant. More...
 
int p4est_quadrant_is_ancestor (const p4est_quadrant_t *q, const p4est_quadrant_t *r)
 Test if a quadrant is an ancestor of another quadrant. More...
 
int p4est_quadrant_is_ancestor_D (const p4est_quadrant_t *q, const p4est_quadrant_t *r)
 Test if a quadrant is an ancestor of another quadrant. More...
 
int p4est_quadrant_is_next (const p4est_quadrant_t *q, const p4est_quadrant_t *r)
 Test if two quadrants follow each other in the tree with no holes. More...
 
int p4est_quadrant_is_next_D (const p4est_quadrant_t *q, const p4est_quadrant_t *r)
 Test if two quadrants follow each other in the tree with no holes. More...
 
int p4est_quadrant_overlaps_tree (p4est_tree_t *tree, const p4est_quadrant_t *q)
 Test if a quadrant has at least partial overlap with a tree.
 
int p4est_quadrant_is_inside_tree (p4est_tree_t *tree, const p4est_quadrant_t *q)
 Test if a quadrant is completely contained within a tree.
 
int p4est_quadrant_is_first_last (const p4est_quadrant_t *f, const p4est_quadrant_t *l, const p4est_quadrant_t *a)
 Whether two descendants of a quadrant are first and last, up to size. More...
 
void p4est_quadrant_enlarge_first (const p4est_quadrant_t *a, p4est_quadrant_t *q)
 Enlarge a quadrant as long as its first corner stays the same. More...
 
void p4est_quadrant_enlarge_last (const p4est_quadrant_t *a, p4est_quadrant_t *q)
 Enlarge a quadrant as long as its last corner stays the same. More...
 
void p4est_quadrant_ancestor (const p4est_quadrant_t *q, int level, p4est_quadrant_t *r)
 Compute the ancestor of a quadrant at a given level. More...
 
void p4est_quadrant_parent (const p4est_quadrant_t *q, p4est_quadrant_t *r)
 Compute the parent of a quadrant. More...
 
void p4est_quadrant_sibling (const p4est_quadrant_t *q, p4est_quadrant_t *r, int sibling_id)
 Compute a specific sibling of a quadrant. More...
 
void p4est_quadrant_child (const p4est_quadrant_t *q, p4est_quadrant_t *r, int child_id)
 Compute a specific child of a quadrant. More...
 
void p4est_quadrant_face_neighbor (const p4est_quadrant_t *q, int face, p4est_quadrant_t *r)
 Compute the face neighbor of a quadrant. More...
 
p4est_topidx_t p4est_quadrant_face_neighbor_extra (const p4est_quadrant_t *q, p4est_topidx_t t, int face, p4est_quadrant_t *r, int *nface, p4est_connectivity_t *conn)
 Compute the face neighbor of a quadrant, transforming across tree boundaries if necessary. More...
 
void p4est_quadrant_half_face_neighbors (const p4est_quadrant_t *q, int face, p4est_quadrant_t n[], p4est_quadrant_t nur[])
 Get the smaller face neighbors of q. More...
 
void p4est_quadrant_all_face_neighbors (const p4est_quadrant_t *q, int face, p4est_quadrant_t n[])
 Create all possible face neighbors of q. More...
 
void p4est_quadrant_corner_neighbor (const p4est_quadrant_t *q, int corner, p4est_quadrant_t *r)
 Compute the corner neighbor of a quadrant. More...
 
void p4est_quadrant_corner_neighbor_extra (const p4est_quadrant_t *q, p4est_locidx_t t, int corner, sc_array_t *quads, sc_array_t *treeids, sc_array_t *ncorners, p4est_connectivity_t *conn)
 Compute the corner neighbors of a quadrant, transforming across tree boundaries if necessary. More...
 
void p4est_quadrant_half_corner_neighbor (const p4est_quadrant_t *q, int corner, p4est_quadrant_t *r)
 Compute the half size corner neighbor of a quadrant. More...
 
void p4est_quadrant_corner_node (const p4est_quadrant_t *q, int corner, p4est_quadrant_t *r)
 Compute the corner node of a quadrant. More...
 
void p4est_quadrant_children (const p4est_quadrant_t *q, p4est_quadrant_t *c0, p4est_quadrant_t *c1, p4est_quadrant_t *c2, p4est_quadrant_t *c3)
 Compute the 4 children of a quadrant. More...
 
void p4est_quadrant_childrenv (const p4est_quadrant_t *q, p4est_quadrant_t c[])
 Compute the 4 children of a quadrant, array version. More...
 
void p4est_quadrant_childrenpv (const p4est_quadrant_t *q, p4est_quadrant_t *c[])
 Compute the 4 children of a quadrant, array version. More...
 
void p4est_quadrant_first_descendant (const p4est_quadrant_t *q, p4est_quadrant_t *fd, int level)
 Compute the first descendant of a quadrant on a given level. More...
 
void p4est_quadrant_last_descendant (const p4est_quadrant_t *q, p4est_quadrant_t *ld, int level)
 Compute the last descendant of a quadrant on a given level. More...
 
void p4est_quadrant_corner_descendant (const p4est_quadrant_t *q, p4est_quadrant_t *r, int c, int level)
 Compute the descendant of a quadrant touching a given corner. More...
 
void p4est_nearest_common_ancestor (const p4est_quadrant_t *q1, const p4est_quadrant_t *q2, p4est_quadrant_t *r)
 Computes the nearest common ancestor of two quadrants in the same tree. More...
 
void p4est_nearest_common_ancestor_D (const p4est_quadrant_t *q1, const p4est_quadrant_t *q2, p4est_quadrant_t *r)
 Computes the nearest common ancestor of two quadrants in the same tree. More...
 
void p4est_quadrant_transform_face (const p4est_quadrant_t *q, p4est_quadrant_t *r, const int ftransform[])
 Transforms a quadrant/node across a face between trees. More...
 
void p4est_coordinates_transform_face (const p4est_qcoord_t coords_in[], p4est_qcoord_t coords_out[], const int ftransform[])
 Transforms coordinates across a face between trees. More...
 
int p4est_quadrant_touches_corner (const p4est_quadrant_t *q, int corner, int inside)
 Checks if a quadrant touches a corner (diagonally inside or outside).
 
void p4est_quadrant_transform_corner (p4est_quadrant_t *q, int icorner, int inside)
 Move a quadrant inside or diagonally outside a corner position. More...
 
void p4est_quadrant_shift_corner (const p4est_quadrant_t *q, p4est_quadrant_t *r, int corner)
 Shifts a quadrant until it touches the specified corner from the inside. More...
 
uint64_t p4est_quadrant_linear_id (const p4est_quadrant_t *quadrant, int level)
 Computes the linear position of a quadrant in a uniform grid. More...
 
void p4est_quadrant_set_morton (p4est_quadrant_t *quadrant, int level, uint64_t id)
 Set quadrant Morton indices based on linear position in uniform grid. More...
 
void p4est_quadrant_successor (const p4est_quadrant_t *quadrant, p4est_quadrant_t *result)
 Compute the successor according to the Morton index in a uniform mesh. More...
 
void p4est_quadrant_predecessor (const p4est_quadrant_t *quadrant, p4est_quadrant_t *result)
 Compute the predecessor according to the Morton index in a uniform mesh. More...
 
void p4est_quadrant_srand (const p4est_quadrant_t *q, sc_rand_state_t *rstate)
 Initialize a random number generator by quadrant coordinates. More...
 
void p4est_neighbor_transform_quadrant (const p4est_neighbor_transform_t *nt, const p4est_quadrant_t *self_quad, p4est_quadrant_t *neigh_quad)
 Transform a quadrant from self's coordinate system to neighbor's coordinate system. More...
 
void p4est_neighbor_transform_quadrant_reverse (const p4est_neighbor_transform_t *nt, const p4est_quadrant_t *neigh_quad, p4est_quadrant_t *self_quad)
 Transform a quadrant from a neighbors's coordinate system to self's coordinate system. More...
 
int p4est_quadrant_is_ancestor_face (const p4est_quadrant_t *descendant, const p4est_quadrant_t *ancestor, int face)
 Check if a descendant shares a face with a (strict) ancestor. More...
 
int p4est_quadrant_is_ancestor_corner (const p4est_quadrant_t *descendant, const p4est_quadrant_t *ancestor, int corner)
 Check if a descendant shares a corner with a (strict) ancestor. More...
 

Detailed Description

Routines for manipulating quadrants (neighbors, parents, children, etc.)

Function Documentation

◆ p4est_coordinates_compare()

int p4est_coordinates_compare ( const p4est_qcoord_t  v1[],
const p4est_qcoord_t  v2[] 
)

Compare two sets of coordinates in their Morton ordering.

Coordinates are signed, but the sorted order will treat them as unsigned, with negative coordinates being greater than positive coordinates because of their representation in twos-complement.

Parameters
[in]v1,v2Two sets of 2d coordinates.
Returns
Returns < 0 if v1 < v2, 0 if v1 == v2, > 0 if v1 > v2

◆ p4est_coordinates_is_inside_root()

int p4est_coordinates_is_inside_root ( const p4est_qcoord_t  coord[])

Test if Morton indices are inside the unit tree.

Parameters
[in]coord2d coordinates.
Returns
Returns true if (coord[0],coord[1]) is inside the unit tree.

◆ p4est_coordinates_is_valid()

int p4est_coordinates_is_valid ( const p4est_qcoord_t  coord[],
int  level 
)

Test if Morton indices are valid and are inside the unit tree.

Parameters
[in]coord2d coordinates.
[in]levellevel
Returns
Returns true if (coord[0],coord[1],level) is valid.

◆ p4est_coordinates_transform_face()

void p4est_coordinates_transform_face ( const p4est_qcoord_t  coords_in[],
p4est_qcoord_t  coords_out[],
const int  ftransform[] 
)

Transforms coordinates across a face between trees.

Parameters
[in]coords_inInput coordinates.
[out]coords_outOutput coordinates.
[in]ftransformThis array holds 9 integers. [0,2] The coordinate axis sequence of the origin face. [3,5] The coordinate axis sequence of the target face. [6,8] Edge reverse flag for axis 0; face code for 1. [1,4,7] 0 (unused for compatibility with 3D).

◆ p4est_nearest_common_ancestor()

void p4est_nearest_common_ancestor ( const p4est_quadrant_t q1,
const p4est_quadrant_t q2,
p4est_quadrant_t r 
)

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

Parameters
[in]q1First input quadrant.
[in]q2Second input quadrant.
[in,out]rExisting quadrant whose Morton index will be filled. Its user_data will be untouched.
Note
q1, q2, r may point to the same quadrant. The user_data of r is never modified.

◆ p4est_nearest_common_ancestor_D()

void p4est_nearest_common_ancestor_D ( const p4est_quadrant_t q1,
const p4est_quadrant_t q2,
p4est_quadrant_t r 
)

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

Descriptive, slower version of p4est_nearest_common_ancestor. For debugging and educationial purposes only.

◆ p4est_neighbor_transform_quadrant()

void p4est_neighbor_transform_quadrant ( const p4est_neighbor_transform_t nt,
const p4est_quadrant_t self_quad,
p4est_quadrant_t neigh_quad 
)

Transform a quadrant from self's coordinate system to neighbor's coordinate system.

Parameters
[in]ntA neighbor transform.
[in]self_quadInput quadrant in self coordinates.
[out]neigh_coordsQuad transformed into neighbor coordinates.
Note
This transform gives meaningful results when self_quad is inside the tree root or touches the interface between the two trees in the transform.

◆ p4est_neighbor_transform_quadrant_reverse()

void p4est_neighbor_transform_quadrant_reverse ( const p4est_neighbor_transform_t nt,
const p4est_quadrant_t neigh_quad,
p4est_quadrant_t self_quad 
)

Transform a quadrant from a neighbors's coordinate system to self's coordinate system.

Parameters
[in]ntA neighbor transform.
[in]neigh_coordsInput quadrant in neighbor coordinates.
[out]self_coordsQuad transformed into self coordinates.
Note
This transform gives meaningful results when neigh_quad is inside the tree root or touches the interface between the two trees in the transform.

◆ p4est_node_clamp_inside()

void p4est_node_clamp_inside ( const p4est_quadrant_t n,
p4est_quadrant_t r 
)

Clamp a node inside the unit tree if it sits on a high border.

Parameters
[in]nNode to be clamped. Must not yet be clamped.
[out]rExisting node overwritten by the clamped result.

◆ p4est_node_equal_piggy_fn()

int p4est_node_equal_piggy_fn ( const void *  v1,
const void *  v2,
const void *  u 
)

Test if two nodes are in the same tree and have equal Morton indices.

Parameters
[in]v1Pointer to a clamped or unclamped node, depending on u.
[in]v2Pointer to a clamped or unclamped node, depending on u.
[in]uUser data, points to an int holding the clamped-flag.

◆ p4est_node_hash_piggy_fn()

unsigned p4est_node_hash_piggy_fn ( const void *  v,
const void *  u 
)

Compute hash value of a node based on its tree and Morton index.

Parameters
[in]vPointer to a clamped or unclamped node, depending on u.
[in]uUser data, points to an int holding the clamped-flag.

◆ p4est_node_to_quadrant()

void p4est_node_to_quadrant ( const p4est_quadrant_t n,
int  level,
p4est_quadrant_t q 
)

Find the enclosing quadrant of a given node at a given level.

Parameters
[in]nClamped node.
[in]levelLevel of the quadrant to be created.
[out]qOutput quadrant, n == q is permitted.

◆ p4est_node_unclamp()

void p4est_node_unclamp ( p4est_quadrant_t n)

Move a clamped node out on the border.

Parameters
[in]nNode to be unclamped in-place.

◆ p4est_quadrant_all_face_neighbors()

void p4est_quadrant_all_face_neighbors ( const p4est_quadrant_t q,
int  face,
p4est_quadrant_t  n[] 
)

Create all possible face neighbors of q.

Gets the face neighbors, possible assuming the 2-1 constraint. If the larger or smaller quadrants do not exist than they are returned as initialized by P4EST_QUADRANT_INIT.

The order of n[0] through n[3] are given in Morton ordering.

Parameters
[in]qThe quadrant whose face neighbors will be constructed.
[in]faceThe face across which to generate the neighbors.
[out]n[0]..n[1]Filled with the smaller possible face neighbors, which are half of the size if they exist or initialized to P4EST_QUADRANT_INIT.
[out]n[2]Filled with the face neighbor, which is the same size.
[out]n[3]Filled with the face neighbor, which is twice the size if it exists or initialized to P4EST_QUADRANT_INIT.

◆ p4est_quadrant_ancestor()

void p4est_quadrant_ancestor ( const p4est_quadrant_t q,
int  level,
p4est_quadrant_t r 
)

Compute the ancestor of a quadrant at a given level.

Parameters
[in]qInput quadrant.
[in]levelA smaller level than q.
[in,out]rExisting quadrant whose Morton index will be filled with the ancestor of q at the given level.
Note
The quadrant q may point to the same quadrant as r. The user_data of r are never modified.

◆ p4est_quadrant_ancestor_id()

int p4est_quadrant_ancestor_id ( const p4est_quadrant_t q,
int  level 
)

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

Returns
Returns its child id in 0..3

◆ p4est_quadrant_child()

void p4est_quadrant_child ( const p4est_quadrant_t q,
p4est_quadrant_t r,
int  child_id 
)

Compute a specific child of a quadrant.

Parameters
[in]qInput quadrant.
[in,out]rExisting quadrant whose Morton index will be filled with the coordinates of its child no. child_id.
[in]child_idThe id of the child computed, 0..3.

◆ p4est_quadrant_child_id()

int p4est_quadrant_child_id ( const p4est_quadrant_t q)

Compute the position of this child within its siblings.

Returns
Returns its child id in 0..3
Examples
simple/simple2.c.

◆ p4est_quadrant_children()

void p4est_quadrant_children ( const p4est_quadrant_t q,
p4est_quadrant_t c0,
p4est_quadrant_t c1,
p4est_quadrant_t c2,
p4est_quadrant_t c3 
)

Compute the 4 children of a quadrant.

Parameters
[in]qInput quadrant.
[in,out]c0First computed child. q may point to the same quadrant as c0.
Note
The user_data of c0, c1, c2, c3 is never modified.

◆ p4est_quadrant_childrenpv()

void p4est_quadrant_childrenpv ( const p4est_quadrant_t q,
p4est_quadrant_t c[] 
)

Compute the 4 children of a quadrant, array version.

Parameters
[in]qInput quadrant.
[in,out]cPointers to the 4 computed children in z-order. q may point to the same quadrant as c[0].
Note
The user_data of c[i] is never modified.

◆ p4est_quadrant_childrenv()

void p4est_quadrant_childrenv ( const p4est_quadrant_t q,
p4est_quadrant_t  c[] 
)

Compute the 4 children of a quadrant, array version.

Parameters
[in]qInput quadrant.
[in,out]cThe 4 computed children in z-order. q may point to the same quadrant as c[0].
Note
The user_data of c[i] is never modified.

◆ p4est_quadrant_compare()

int p4est_quadrant_compare ( const void *  v1,
const void *  v2 
)

Compare two quadrants in their Morton ordering.

Both quadrants must be valid.

Returns
Returns < 0 if v1 < v2, 0 if v1 == v2, > 0 if v1 > v2

◆ p4est_quadrant_compare_local_num()

int p4est_quadrant_compare_local_num ( const void *  v1,
const void *  v2 
)

Compare two quadrants with respect to their local_num in the piggy3 member.

Returns
Returns < 0 if v1 < v2, 0 if v1 == v2, > 0 if v1 > v2

◆ p4est_quadrant_compare_piggy()

int p4est_quadrant_compare_piggy ( const void *  v1,
const void *  v2 
)

Compare two quadrants in their Morton ordering and the which_tree member.

Both quadrants must be extended (superset of valid, see below).

Returns
Returns < 0 if v1 < v2, 0 if v1 == v2, > 0 if v1 > v2

◆ p4est_quadrant_contains_node()

int p4est_quadrant_contains_node ( const p4est_quadrant_t q,
const p4est_quadrant_t n 
)

Decide if a node is completely contained within a quadrant.

Parameters
[in]qValid quadrant.
[in]nClamped node.

◆ p4est_quadrant_copy()

void p4est_quadrant_copy ( const p4est_quadrant_t q,
p4est_quadrant_t copy 
)

Copy the Morton indices of the quadrant q.

Parameters
[in]qAn extended quadrant.
[in,out]copyAn existing quadrant that Morton indices will be set to the Morton indices of q.

◆ p4est_quadrant_corner_descendant()

void p4est_quadrant_corner_descendant ( const p4est_quadrant_t q,
p4est_quadrant_t r,
int  c,
int  level 
)

Compute the descendant of a quadrant touching a given corner.

Parameters
[in]qInput quadrant.
[in,out]rExisting quadrant whose Morton index will be filled. Its user_data will be untouched.
[in]cThe corner of q that r touches.
[in]levelThe size of r.

◆ p4est_quadrant_corner_neighbor()

void p4est_quadrant_corner_neighbor ( const p4est_quadrant_t q,
int  corner,
p4est_quadrant_t r 
)

Compute the corner neighbor of a quadrant.

Parameters
[in]qInput quadrant, must be valid.
[in]cornerThe corner across which to generate the neighbor.
[in,out]rExisting quadrant whose Morton index will be filled.
Note
q may point to the same quadrant as r.

◆ p4est_quadrant_corner_neighbor_extra()

void p4est_quadrant_corner_neighbor_extra ( const p4est_quadrant_t q,
p4est_locidx_t  t,
int  corner,
sc_array_t *  quads,
sc_array_t *  treeids,
sc_array_t *  ncorners,
p4est_connectivity_t conn 
)

Compute the corner neighbors of a quadrant, transforming across tree boundaries if necessary.

Only computes neighbors that are not face or edge neighbors.

Parameters
[in]qInput quadrant, must be valid.
[in]tTree that contains q.
[in]cornerThe corner across which to generate the neighbor.
[in,out]quadsAn initialized but empty array where the corner neighbors will be placed.
[in,out]treeidsAn initialized but empty array where the ids of the trees containing the corner neighbors will be placed.
[in,out]ncornersif not NULL, filled with the corners of quads that neighbor q.
[in]connThe connectivity structure for the forest.

◆ p4est_quadrant_corner_node()

void p4est_quadrant_corner_node ( const p4est_quadrant_t q,
int  corner,
p4est_quadrant_t r 
)

Compute the corner node of a quadrant.

Parameters
[in]qInput quadrant, must be valid.
[in]cornerThe corner across which to generate the neighbor.
[in,out]rNode that will not be clamped inside.
Note
q may point to the same quadrant as r.

◆ p4est_quadrant_disjoint()

int p4est_quadrant_disjoint ( const void *  v1,
const void *  v2 
)

Compare two quadrants in their Morton ordering, with equivalence if the two quadrants overlap.

Returns
Returns < 0 if v1 < v2 and v1 and v2 do not overlap, 0 if v1 and v2 overlap, > 0 if v1 > v2 and v1 and v2 do not overlap.

◆ p4est_quadrant_enlarge_first()

void p4est_quadrant_enlarge_first ( const p4est_quadrant_t a,
p4est_quadrant_t q 
)

Enlarge a quadrant as long as its first corner stays the same.

We limit the enlargement by containing it in an ancestor quadrant.

Parameters
[in]aExtended quadrant. On input and output, equal to or strict ancestor of the quadrant q to be modified.
[in,out]qOn input and output, an extended quadrant and also equal or a strict descendant of a. Possibly enlarged by this function.

◆ p4est_quadrant_enlarge_last()

void p4est_quadrant_enlarge_last ( const p4est_quadrant_t a,
p4est_quadrant_t q 
)

Enlarge a quadrant as long as its last corner stays the same.

We limit the enlargement by containing it in an ancestor quadrant.

Parameters
[in]aExtended quadrant. On input and output, equal to or strict ancestor of the quadrant q to be modified.
[in,out]qOn input and output, an extended quadrant and also equal or a strict descendant of a. Possibly enlarged by this function.

◆ p4est_quadrant_equal_fn()

int p4est_quadrant_equal_fn ( const void *  v1,
const void *  v2,
const void *  u 
)

Test if two quadrants have equal Morton indices, callback version.

Returns
true if v1 describes the same quadrant as v2.

◆ p4est_quadrant_face_neighbor()

void p4est_quadrant_face_neighbor ( const p4est_quadrant_t q,
int  face,
p4est_quadrant_t r 
)

Compute the face neighbor of a quadrant.

Parameters
[in]qInput quadrant, must be valid.
[in]faceThe face across which to generate the neighbor.
[in,out]rExisting quadrant whose Morton index will be filled.
Note
q may point to the same quadrant as r.

◆ p4est_quadrant_face_neighbor_extra()

p4est_topidx_t p4est_quadrant_face_neighbor_extra ( const p4est_quadrant_t q,
p4est_topidx_t  t,
int  face,
p4est_quadrant_t r,
int *  nface,
p4est_connectivity_t conn 
)

Compute the face neighbor of a quadrant, transforming across tree boundaries if necessary.

Parameters
[in]qInput quadrant, must be valid.
[in]tTree that contains q.
[in]faceThe face across which to generate the neighbor.
[in,out]rExisting quadrant whose Morton index will be filled. By convention, if there is no tree across face, r has the same Morton index as q.
[in,out]nfaceif not NULL, set to the face of r that neighbors q. nface is encoded with orientation information in the same manner as the tree_to_face array in the p4est_connectivity_t struct.
[in]connThe connectivity structure for the forest.
Returns
Returns the tree that contains r. By convention, if there is no tree across face, then -1 is returned.

◆ p4est_quadrant_first_descendant()

void p4est_quadrant_first_descendant ( const p4est_quadrant_t q,
p4est_quadrant_t fd,
int  level 
)

Compute the first descendant of a quadrant on a given level.

Parameters
[in]qInput quadrant.
[out]fdFirst descendant of q on level level.
[in]levelLevel must be greater equal than q's level.

◆ p4est_quadrant_half_corner_neighbor()

void p4est_quadrant_half_corner_neighbor ( const p4est_quadrant_t q,
int  corner,
p4est_quadrant_t r 
)

Compute the half size corner neighbor of a quadrant.

Parameters
[in]qThe quadrant whose corner neighbor will be constructed.
[in]cornerThe corner across which to generate the neighbor.
[out]rMorton index filled with the half size corner neighbor.

◆ p4est_quadrant_half_face_neighbors()

void p4est_quadrant_half_face_neighbors ( const p4est_quadrant_t q,
int  face,
p4est_quadrant_t  n[],
p4est_quadrant_t  nur[] 
)

Get the smaller face neighbors of q.

Gets the smaller face neighbors, which are half of the size assuming the 2-1 constant.

The order of the n[i] is given in the Morton ordering.

Parameters
[in]qThe quadrant whose face neighbors will be constructed.
[in]faceThe face across which to generate the neighbors.
[out]n[0]..n[1]Filled with the four smaller face neighbors.
[out]nur[0]..nur[1]If not NULL, filled with smallest quadrants that fit in the upper right corners of n.

◆ p4est_quadrant_is_ancestor()

int p4est_quadrant_is_ancestor ( const p4est_quadrant_t q,
const p4est_quadrant_t r 
)

Test if a quadrant is an ancestor of another quadrant.

Parameters
[in]qQuadrant to be tested.
[in]rDescendent quadrant.
Returns
true if q is unequal to and an ancestor of r.
Examples
simple/simple2.c.

◆ p4est_quadrant_is_ancestor_corner()

int p4est_quadrant_is_ancestor_corner ( const p4est_quadrant_t descendant,
const p4est_quadrant_t ancestor,
int  corner 
)

Check if a descendant shares a corner with a (strict) ancestor.

Parameters
[in]descendantThe descendant in question.
[in]ancestorThe ancestor must not be equal to the descendant.
[in]cornerThe corner of the descendant.
Returns
true if descendant face touches ancestor corner, false otherwise.

◆ p4est_quadrant_is_ancestor_D()

int p4est_quadrant_is_ancestor_D ( const p4est_quadrant_t q,
const p4est_quadrant_t r 
)

Test if a quadrant is an ancestor of another quadrant.

Descriptive, slower version of p4est_quadrant_is_ancestor. Contrary to p4est_quadrant_is_ancestor, it aborts for inter-tree q, r. For debugging and educational purposes only.

◆ p4est_quadrant_is_ancestor_face()

int p4est_quadrant_is_ancestor_face ( const p4est_quadrant_t descendant,
const p4est_quadrant_t ancestor,
int  face 
)

Check if a descendant shares a face with a (strict) ancestor.

Parameters
[in]descendantThe descendant in question.
[in]ancestorThe ancestor must not be equal to the descendant.
[in]faceThe face of the descendant.
Returns
true if descendant face touches ancestor face, false otherwise.

◆ p4est_quadrant_is_equal()

int p4est_quadrant_is_equal ( const p4est_quadrant_t q1,
const p4est_quadrant_t q2 
)

Test if two quadrants have equal Morton indices.

Returns
true if q1 describes the same quadrant as q2.
Examples
simple/simple2.c.

◆ p4est_quadrant_is_equal_piggy()

int p4est_quadrant_is_equal_piggy ( const p4est_quadrant_t q1,
const p4est_quadrant_t q2 
)

Test if two quadrants have equal Morton indices and the same tree id.

Returns
true if q1 describes the same quadrant as q2 and the p.which_tree fields are equal.

◆ p4est_quadrant_is_extended()

int p4est_quadrant_is_extended ( const p4est_quadrant_t q)

Test if a quadrant has valid Morton indices in the 3x3 box around root.

Parameters
[in]qQuadrant to be tested.
Returns
Returns true if q is extended.

◆ p4est_quadrant_is_familypv()

int p4est_quadrant_is_familypv ( p4est_quadrant_t q[])

Test if 4 quadrants are siblings in Morton ordering, array version.

Parameters
[in]qArray of 4 pointers to quadrants.

◆ p4est_quadrant_is_familyv()

int p4est_quadrant_is_familyv ( const p4est_quadrant_t  q[])

Test if 4 quadrants are siblings in Morton ordering, array version.

Parameters
[in]qArray of 4 quadrants.

◆ p4est_quadrant_is_first_last()

int p4est_quadrant_is_first_last ( const p4est_quadrant_t f,
const p4est_quadrant_t l,
const p4est_quadrant_t a 
)

Whether two descendants of a quadrant are first and last, up to size.

Parameters
[in]fAn extended quadrant, need not be of maximum level.
[in]lAn extended quadrant, need not be of maximum level. It must be greater equal f in the space filling curve.
[in]aAn extended quadrant, equal to or ancestor of f, and likewise to/of l.
Returns
Whether the first corner of f equals that of a and the last corner of l equals that of a.

◆ p4est_quadrant_is_inside_3x3()

int p4est_quadrant_is_inside_3x3 ( const p4est_quadrant_t q)

Test if a quadrant is inside the 3x3 box around the root tree.

Parameters
[in]qQuadrant to be tested.
Returns
Returns true if q is inside the unit tree.

◆ p4est_quadrant_is_inside_root()

int p4est_quadrant_is_inside_root ( const p4est_quadrant_t q)

Test if a quadrant is inside the unit tree.

Parameters
[in]qQuadrant to be tested.
Returns
Returns true if q is inside the unit tree.

◆ p4est_quadrant_is_next()

int p4est_quadrant_is_next ( const p4est_quadrant_t q,
const p4est_quadrant_t r 
)

Test if two quadrants follow each other in the tree with no holes.

Parameters
[in]qA quadrant
[in]rAnother quadrant
Returns
true if q is immediately before r in the tree.
Note
for every q there are between 0 and P4EST_MAXLEVEL+1 possible nexts.

◆ p4est_quadrant_is_next_D()

int p4est_quadrant_is_next_D ( const p4est_quadrant_t q,
const p4est_quadrant_t r 
)

Test if two quadrants follow each other in the tree with no holes.

Descriptive, slower version of p4est_quadrant_is_next. For debugging and educational purposes only.

◆ p4est_quadrant_is_node()

int p4est_quadrant_is_node ( const p4est_quadrant_t q,
int  inside 
)

Test if a quadrant is used to represent a mesh node.

Parameters
[in]qQuadrant to be tested.
[in]insideIf true, boundary nodes must be clamped inside. If false, nodes must align with the quadrant grid.
Returns
Returns true if q is a node.

◆ p4est_quadrant_is_outside_corner()

int p4est_quadrant_is_outside_corner ( const p4est_quadrant_t q)

Test if a quadrant is outside a tree corner boundary.

Parameters
[in]qQuadrant to be tested.
Returns
Returns true if q is outside across a unit tree corner.

◆ p4est_quadrant_is_outside_face()

int p4est_quadrant_is_outside_face ( const p4est_quadrant_t q)

Test if a quadrant is outside a tree face boundary (no corner).

Parameters
[in]qQuadrant to be tested.
Returns
Returns true if q is outside across a unit tree face.

◆ p4est_quadrant_is_parent()

int p4est_quadrant_is_parent ( const p4est_quadrant_t q,
const p4est_quadrant_t r 
)

Test if a quadrant is the parent of another quadrant.

Parameters
[in]qQuadrant to be tested.
[in]rPossible child quadrant.
Returns
true if q is the parent of r.

◆ p4est_quadrant_is_parent_D()

int p4est_quadrant_is_parent_D ( const p4est_quadrant_t q,
const p4est_quadrant_t r 
)

Test if a quadrant is the parent of another quadrant.

Descriptive, slower version of p4est_quadrant_is_parent. For debugging and educational purposes only.

◆ p4est_quadrant_is_sibling()

int p4est_quadrant_is_sibling ( const p4est_quadrant_t q1,
const p4est_quadrant_t q2 
)

Test if two quadrants are siblings.

Parameters
[in]q1First quadrant to be tested.
[in]q2Second quadrant to be tested.
Returns
true if q1 is unequal to and a sibling of q2.

◆ p4est_quadrant_is_sibling_D()

int p4est_quadrant_is_sibling_D ( const p4est_quadrant_t q1,
const p4est_quadrant_t q2 
)

Test if two quadrants are siblings.

Descriptive, slower version of p4est_quadrant_is_sibling. For debugging and educational purposes only.

◆ p4est_quadrant_is_valid()

int p4est_quadrant_is_valid ( const p4est_quadrant_t q)

Test if a quadrant has valid Morton indices and is inside the unit tree.

Parameters
[in]qQuadrant to be tested.
Returns
Returns true if q is valid.

◆ p4est_quadrant_last_descendant()

void p4est_quadrant_last_descendant ( const p4est_quadrant_t q,
p4est_quadrant_t ld,
int  level 
)

Compute the last descendant of a quadrant on a given level.

Parameters
[in]qInput quadrant.
[out]ldLast descendant of q on level level.
[in]levelLevel must be greater equal than q's level.

◆ p4est_quadrant_linear_id()

uint64_t p4est_quadrant_linear_id ( const p4est_quadrant_t quadrant,
int  level 
)

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

The grid and quadrant levels need not coincide. If they do, this is the inverse of p4est_quadrant_set_morton.

Parameters
[in]quadrantQuadrant whose linear index will be computed. If the quadrant is smaller than the grid (has a higher quadrant->level), the result is computed from its ancestor at the grid's level. If the quadrant has a smaller level than the grid (it is bigger than a grid cell), the grid cell sharing its lower left corner is used as reference.
[in]levelThe level of the regular grid compared to which the linear position is to be computed.
Returns
Returns the linear position of this quadrant on a grid.
Note
The user_data of quadrant is never modified.

◆ p4est_quadrant_overlaps()

int p4est_quadrant_overlaps ( const p4est_quadrant_t q1,
const p4est_quadrant_t q2 
)

Test if two quadrants overlap.

Returns
true if q1 and q2 are equal or one is the ancestor of the other.

◆ p4est_quadrant_pad()

void p4est_quadrant_pad ( p4est_quadrant_t q)

Write -1 into the pad8 and pad16 members of a quadrant.

This helps with valgrind cleanliness if a quadrant is sent over MPI.

◆ p4est_quadrant_parent()

void p4est_quadrant_parent ( const p4est_quadrant_t q,
p4est_quadrant_t r 
)

Compute the parent of a quadrant.

Parameters
[in]qInput quadrant.
[in,out]rExisting quadrant whose Morton index will be filled with the Morton index of the parent of q. Its user_data will be untouched.
Note
q may point to the same quadrant as r. The user_data of r is never modified.

◆ p4est_quadrant_predecessor()

void p4est_quadrant_predecessor ( const p4est_quadrant_t quadrant,
p4est_quadrant_t result 
)

Compute the predecessor according to the Morton index in a uniform mesh.

Parameters
[in]quadrantQuadrant whose Morton predecessor will be computed. Must not be the first (bottom left) quadrant in the tree.
[in,out]resultThe coordinates and level of the predecessor of quadrant will be saved in result.

◆ p4est_quadrant_print()

void p4est_quadrant_print ( int  log_priority,
const p4est_quadrant_t q 
)

Prints one line with quadrant's x, y and level.

Parameters
[in]log_prioritysee logpriorities in sc.h for the meanings of numerical priority values
[in]qquadrant to print

◆ p4est_quadrant_set_morton()

void p4est_quadrant_set_morton ( p4est_quadrant_t quadrant,
int  level,
uint64_t  id 
)

Set quadrant Morton indices based on linear position in uniform grid.

This is the inverse operation of p4est_quadrant_linear_id.

Parameters
[in,out]quadrantQuadrant whose Morton indices will be set.
[in]levelLevel of the grid and of the resulting quadrant.
[in]idLinear index of the quadrant on a uniform grid.
Note
The user_data of quadrant is never modified.

◆ p4est_quadrant_shift_corner()

void p4est_quadrant_shift_corner ( const p4est_quadrant_t q,
p4est_quadrant_t r,
int  corner 
)

Shifts a quadrant until it touches the specified corner from the inside.

Parameters
[in]qValid input quadrant.
[in,out]rQuadrant whose Morton index will be filled.
[in]cornerCorner index.

◆ p4est_quadrant_sibling()

void p4est_quadrant_sibling ( const p4est_quadrant_t q,
p4est_quadrant_t r,
int  sibling_id 
)

Compute a specific sibling of a quadrant.

Parameters
[in]qInput quadrant.
[in,out]rExisting quadrant whose Morton index will be filled with the coordinates of sibling no. sibling_id of q.
[in]sibling_idThe id of the sibling computed, 0..3.

◆ p4est_quadrant_srand()

void p4est_quadrant_srand ( const p4est_quadrant_t q,
sc_rand_state_t *  rstate 
)

Initialize a random number generator by quadrant coordinates.

This serves to generate partition-independent and reproducible samples.

Parameters
[in]qValid quadrant.
[out]rstateNew state of random number generator.

◆ p4est_quadrant_successor()

void p4est_quadrant_successor ( const p4est_quadrant_t quadrant,
p4est_quadrant_t result 
)

Compute the successor according to the Morton index in a uniform mesh.

Parameters
[in]quadrantQuadrant whose Morton successor will be computed. Must not be the last (top right) quadrant in the tree.
[in,out]resultThe coordinates and level of the successor of quadrant will be saved in result.

◆ p4est_quadrant_transform_corner()

void p4est_quadrant_transform_corner ( p4est_quadrant_t q,
int  icorner,
int  inside 
)

Move a quadrant inside or diagonally outside a corner position.

Parameters
[in,out]qThis quadrant only requires a valid level.
[in]icornerNumber of the corner in 0..3.
[int]inside Boolean flag for inside or diagonally outside.

◆ p4est_quadrant_transform_face()

void p4est_quadrant_transform_face ( const p4est_quadrant_t q,
p4est_quadrant_t r,
const int  ftransform[] 
)

Transforms a quadrant/node across a face between trees.

Parameters
[in]qInput quadrant/non-clamped node.
[in,out]rQuadrant/node whose Morton index will be filled.
[in]ftransformThis array holds 9 integers. [0,2] The coordinate axis sequence of the origin face. [3,5] The coordinate axis sequence of the target face. [6,8] Edge reverse flag for axis 0; face code for 1. [1,4,7] 0 (unused for compatibility with 3D).
Note
q and r may NOT point to the same quadrant structure.