p4est
1.0
|
The coarse topological description of the forest. More...
Go to the source code of this file.
Data Structures | |
struct | p4est_connectivity_t |
This structure holds the 2D inter-tree connectivity information. More... | |
struct | p4est_corner_transform_t |
struct | p4est_corner_info_t |
Defines | |
#define | P4EST_DIM 2 |
The spatial dimension. | |
#define | P4EST_FACES (2 * P4EST_DIM) |
The number of faces of a quadrant. | |
#define | P4EST_CHILDREN 4 |
The number of children of a quadrant. | |
#define | P4EST_HALF (P4EST_CHILDREN / 2) |
The number of children/corners touching one face. | |
#define | P4EST_INSUL 9 |
The size of insulation layer. | |
#define | P4EST_FTRANSFORM 9 |
#define | P4EST_STRING "p4est" |
p4est identification string | |
#define | P4EST_ONDISK_FORMAT 0x2000009 |
Enumerations | |
enum | p4est_connect_type_t { P4EST_CONNECT_FACE = 21, P4EST_CONNECT_CORNER = 22, P4EST_CONNECT_FULL = P4EST_CONNECT_CORNER } |
Characterize a type of adjacency. More... | |
enum | p4est_connectivity_encode_t { P4EST_CONN_ENCODE_NONE = SC_IO_ENCODE_NONE, P4EST_CONN_ENCODE_LAST } |
Typedef for serialization method. More... | |
Functions | |
int | p4est_connect_type_int (p4est_connect_type_t btype) |
Convert the p4est_connect_type_t into a number. | |
const char * | p4est_connect_type_string (p4est_connect_type_t btype) |
Convert the p4est_connect_type_t into a const string. | |
size_t | p4est_connectivity_memory_used (p4est_connectivity_t *conn) |
Calculate memory usage of a connectivity structure. | |
p4est_connectivity_t * | p4est_connectivity_new (p4est_topidx_t num_vertices, p4est_topidx_t num_trees, p4est_topidx_t num_corners, p4est_topidx_t num_ctt) |
Allocate a connectivity structure. | |
p4est_connectivity_t * | p4est_connectivity_new_copy (p4est_topidx_t num_vertices, p4est_topidx_t num_trees, p4est_topidx_t num_corners, const double *vertices, const p4est_topidx_t *ttv, const p4est_topidx_t *ttt, const int8_t *ttf, const p4est_topidx_t *ttc, const p4est_topidx_t *coff, const p4est_topidx_t *ctt, const int8_t *ctc) |
Allocate a connectivity structure and populate from constants. | |
void | p4est_connectivity_destroy (p4est_connectivity_t *connectivity) |
Destroy a connectivity structure. | |
void | p4est_connectivity_set_attr (p4est_connectivity_t *conn, int enable_tree_attr) |
Allocate or free the attribute fields in a connectivity. | |
int | p4est_connectivity_is_valid (p4est_connectivity_t *connectivity) |
Examine a connectivity structure. | |
int | p4est_connectivity_is_equal (p4est_connectivity_t *conn1, p4est_connectivity_t *conn2) |
Check two connectivity structures for equality. | |
int | p4est_connectivity_sink (p4est_connectivity_t *conn, sc_io_sink_t *sink) |
Write connectivity to a sink object. | |
sc_array_t * | p4est_connectivity_deflate (p4est_connectivity_t *conn, p4est_connectivity_encode_t code) |
Allocate memory and store the connectivity information there. | |
int | p4est_connectivity_save (const char *filename, p4est_connectivity_t *connectivity) |
Save a connectivity structure to disk. | |
p4est_connectivity_t * | p4est_connectivity_source (sc_io_source_t *source) |
Read connectivity from a source object. | |
p4est_connectivity_t * | p4est_connectivity_inflate (sc_array_t *buffer) |
Create new connectivity from a memory buffer. | |
p4est_connectivity_t * | p4est_connectivity_load (const char *filename, size_t *bytes) |
Load a connectivity structure from disk. | |
p4est_connectivity_t * | p4est_connectivity_new_unitsquare (void) |
Create a connectivity structure for the unit square. | |
p4est_connectivity_t * | p4est_connectivity_new_periodic (void) |
Create a connectivity structure for an all-periodic unit square. | |
p4est_connectivity_t * | p4est_connectivity_new_rotwrap (void) |
Create a connectivity structure for a periodic unit square. | |
p4est_connectivity_t * | p4est_connectivity_new_corner (void) |
Create a connectivity structure for a three-tree mesh around a corner. | |
p4est_connectivity_t * | p4est_connectivity_new_pillow (void) |
Create a connectivity structure for two trees on top of each other. | |
p4est_connectivity_t * | p4est_connectivity_new_moebius (void) |
Create a connectivity structure for a five-tree moebius band. | |
p4est_connectivity_t * | p4est_connectivity_new_star (void) |
Create a connectivity structure for a six-tree star. | |
p4est_connectivity_t * | p4est_connectivity_new_cubed (void) |
Create a connectivity structure for the six sides of a unit cube. | |
p4est_connectivity_t * | p4est_connectivity_new_disk (void) |
Create a connectivity structure for a five-tree flat spherical disk. | |
p4est_connectivity_t * | p4est_connectivity_new_brick (int mi, int ni, int periodic_a, int periodic_b) |
An m by n array with periodicity in x and y if periodic_a and periodic_b are true, respectively. | |
p4est_connectivity_t * | p4est_connectivity_new_byname (const char *name) |
Create connectivity structure from predefined catalogue. | |
void | p4est_expand_face_transform (int iface, int nface, int ftransform[]) |
Fill an array with the axis combination of a face neighbor transform. | |
p4est_topidx_t | p4est_find_face_transform (p4est_connectivity_t *connectivity, p4est_topidx_t itree, int iface, int ftransform[]) |
Fill an array with the axis combinations of a tree neighbor transform. | |
void | p4est_find_corner_transform (p4est_connectivity_t *connectivity, p4est_topidx_t itree, int icorner, p4est_corner_info_t *ci) |
Fills an array with information about corner neighbors. | |
void | p4est_connectivity_complete (p4est_connectivity_t *conn) |
Internally connect a connectivity based on tree_to_vertex information. | |
void | p4est_connectivity_permute (p4est_connectivity_t *conn, sc_array_t *perm, int is_current_to_new) |
p4est_connectivity_permute Given a permutation perm of the trees in a connectivity conn, permute the trees of conn in place and update conn to match. | |
void | p4est_connectivity_reorder (MPI_Comm comm, int k, p4est_connectivity_t *conn, p4est_connect_type_t ctype) |
p4est_connectivity_reorder This function takes a connectivity conn and a parameter k, which will typically be the number of processes, and reorders the trees such that if every processes is assigned (num_trees / k) trees, the communication volume will be minimized. | |
void | p4est_connectivity_join_faces (p4est_connectivity_t *conn, p4est_topidx_t tree_left, p4est_topidx_t tree_right, int face_left, int face_right, int orientation) |
p4est_connectivity_join_faces This function takes an existing valid connectivity conn and modifies it by joining two tree faces that are currently boundary faces. | |
int | p4est_connectivity_is_equivalent (p4est_connectivity_t *conn1, p4est_connectivity_t *conn2) |
p4est_connectivity_is_equivalent This function compares two connectivities for equivalence: it returns true if they are the same connectivity, or if they have the same topology. | |
static p4est_corner_transform_t * | p4est_corner_array_index (sc_array_t *array, size_t it) |
Return a pointer to a p4est_corner_transform_t array element. | |
int | p4est_connectivity_read_inp_stream (FILE *stream, p4est_topidx_t *num_vertices, p4est_topidx_t *num_trees, double *vertices, p4est_topidx_t *tree_to_vertex) |
Read an ABAQUS input file from a file stream. | |
p4est_connectivity_t * | p4est_connectivity_read_inp (const char *filename) |
Create a p4est connectivity from an ABAQUS input file. | |
Variables | |
const int | p4est_face_corners [4][2] |
Store the corner numbers 0..4 for each tree face. | |
const int | p4est_face_dual [4] |
Store the face numbers in the face neighbor's system. | |
const int | p4est_corner_faces [4][2] |
Store the face numbers 0..3 for each tree corner. | |
const int | p4est_corner_face_corners [4][4] |
Store the face corner numbers for the faces touching a tree corner. | |
const int | p4est_child_corner_faces [4][4] |
Store the faces for each child and corner, can be -1. |
The coarse topological description of the forest.
#define P4EST_CHILDREN 4 |
The number of children of a quadrant.
also the nmber of corners
enum p4est_connect_type_t |
Characterize a type of adjacency.
Several functions involve relationships between neighboring trees and/or quadrants, and their behavior depends on how one defines adjacency: 1) entities are adjacent if they share a face, or 2) entities are adjacent if they share a face or corner. p4est_connect_type_t is used to choose the desired behavior. This enum must fit into an int8_t.
int p4est_connect_type_int | ( | p4est_connect_type_t | btype | ) |
Convert the p4est_connect_type_t into a number.
[in] | btype | The balance type to convert. |
const char* p4est_connect_type_string | ( | p4est_connect_type_t | btype | ) |
Convert the p4est_connect_type_t into a const string.
[in] | btype | The balance type to convert. |
void p4est_connectivity_complete | ( | p4est_connectivity_t * | conn | ) |
Internally connect a connectivity based on tree_to_vertex information.
Periodicity that is not inherent in the list of vertices will be lost.
[in,out] | conn | The connectivity needs to have proper vertices and tree_to_vertex fields. The tree_to_tree and tree_to_face fields must be allocated and satisfy p4est_connectivity_is_valid (conn) but will be overwritten. The corner fields will be freed and allocated anew. |
sc_array_t* p4est_connectivity_deflate | ( | p4est_connectivity_t * | conn, |
p4est_connectivity_encode_t | code | ||
) |
Allocate memory and store the connectivity information there.
[in] | conn | The connectivity structure to be exported to memory. |
[in] | code | Encoding and compression method for serialization. |
void p4est_connectivity_destroy | ( | p4est_connectivity_t * | connectivity | ) |
Destroy a connectivity structure.
Also destroy all attributes.
p4est_connectivity_t* p4est_connectivity_inflate | ( | sc_array_t * | buffer | ) |
Create new connectivity from a memory buffer.
[in] | buffer | The connectivity is created from this memory buffer. |
int p4est_connectivity_is_equal | ( | p4est_connectivity_t * | conn1, |
p4est_connectivity_t * | conn2 | ||
) |
Check two connectivity structures for equality.
int p4est_connectivity_is_equivalent | ( | p4est_connectivity_t * | conn1, |
p4est_connectivity_t * | conn2 | ||
) |
p4est_connectivity_is_equivalent This function compares two connectivities for equivalence: it returns true if they are the same connectivity, or if they have the same topology.
The definition of topological sameness is strict: there is no attempt made to determine whether permutation and/or rotation of the trees makes the connectivities equivalent.
[in] | conn1 | a valid connectivity |
[out] | conn2 | a valid connectivity |
int p4est_connectivity_is_valid | ( | p4est_connectivity_t * | connectivity | ) |
Examine a connectivity structure.
void p4est_connectivity_join_faces | ( | p4est_connectivity_t * | conn, |
p4est_topidx_t | tree_left, | ||
p4est_topidx_t | tree_right, | ||
int | face_left, | ||
int | face_right, | ||
int | orientation | ||
) |
p4est_connectivity_join_faces This function takes an existing valid connectivity conn and modifies it by joining two tree faces that are currently boundary faces.
[in,out] | conn | connectivity that will be altered. |
[in] | tree_left | tree that will be on the left side of the joined faces. |
[in] | tree_right | tree that will be on the right side of the joined faces. |
[in] | face_left | face of tree_left that will be joined. |
[in] | face_right | face of tree_right that will be joined. |
[in] | orientation | the orientation of face_left and face_right once joined (see the description of p4est_connectivity_t to understand orientation). |
p4est_connectivity_t* p4est_connectivity_load | ( | const char * | filename, |
size_t * | bytes | ||
) |
Load a connectivity structure from disk.
[in] | filename | Name of the file to read. |
[in,out] | bytes | Size in bytes of connectivity on disk or NULL. |
size_t p4est_connectivity_memory_used | ( | p4est_connectivity_t * | conn | ) |
Calculate memory usage of a connectivity structure.
[in] | conn | Connectivity structure. |
p4est_connectivity_t* p4est_connectivity_new | ( | p4est_topidx_t | num_vertices, |
p4est_topidx_t | num_trees, | ||
p4est_topidx_t | num_corners, | ||
p4est_topidx_t | num_ctt | ||
) |
Allocate a connectivity structure.
The attribute fields are initialized to NULL.
[in] | num_vertices | Number of total vertices (i.e. geometric points). |
[in] | num_trees | Number of trees in the forest. |
[in] | num_corners | Number of tree-connecting corners. |
[in] | num_ctt | Number of total trees in corner_to_tree array. |
p4est_connectivity_t* p4est_connectivity_new_byname | ( | const char * | name | ) |
Create connectivity structure from predefined catalogue.
[in] | name | Invokes connectivity_new_* function. brick23 brick (2, 3, 0, 0) corner corner cubed cubed disk disk moebius moebius periodic periodic pillow pillow rotwrap rotwrap star star unit unitsquare |
p4est_connectivity_t* p4est_connectivity_new_copy | ( | p4est_topidx_t | num_vertices, |
p4est_topidx_t | num_trees, | ||
p4est_topidx_t | num_corners, | ||
const double * | vertices, | ||
const p4est_topidx_t * | ttv, | ||
const p4est_topidx_t * | ttt, | ||
const int8_t * | ttf, | ||
const p4est_topidx_t * | ttc, | ||
const p4est_topidx_t * | coff, | ||
const p4est_topidx_t * | ctt, | ||
const int8_t * | ctc | ||
) |
Allocate a connectivity structure and populate from constants.
The attribute fields are initialized to NULL.
[in] | num_vertices | Number of total vertices (i.e. geometric points). |
[in] | num_trees | Number of trees in the forest. |
[in] | num_corners | Number of tree-connecting corners. |
[in] | coff | Corner-to-tree offsets (num_corners + 1 values). |
Create a connectivity structure for the six sides of a unit cube.
The ordering of the trees is as follows: 0 1 2 3 <-- 3: axis-aligned top side 4 5. This choice has been made for maximum symmetry (see tree_to_* in .c file).
Create a connectivity structure for a five-tree flat spherical disk.
The ordering of the trees is as follows: 4 1 2 3 0.
Create a connectivity structure for a periodic unit square.
The left and right faces are identified, and bottom and top opposite.
void p4est_connectivity_permute | ( | p4est_connectivity_t * | conn, |
sc_array_t * | perm, | ||
int | is_current_to_new | ||
) |
p4est_connectivity_permute Given a permutation perm of the trees in a connectivity conn, permute the trees of conn in place and update conn to match.
[in,out] | conn | The connectivity whose trees are permuted. |
[in] | perm | A permutation array, whose elements are size_t's. |
[in] | is_current_to_new | if true, the jth entry of perm is the new index for the entry whose current index is j, otherwise the jth entry of perm is the current index of the tree whose index will be j after the permutation. |
p4est_connectivity_t* p4est_connectivity_read_inp | ( | const char * | filename | ) |
Create a p4est connectivity from an ABAQUS input file.
This utility function reads a basic ABAQUS file supporting element type with the prefix C2D4, CPS4, and S4 in 2D and of type C3D8 reading them as bilinear quadrilateral and trilinear hexahedral trees respectively.
A basic 2D mesh is given below. The *Node
section gives the vertex number and x, y, and z components for each vertex. The *Element
section gives the 4 vertices in 2D (8 vertices in 3D) of each element in counter clockwise order. So in 2D the nodes are given as:
4 3 +-------------------+ | | | | | | | | | | | | +-------------------+ 1 2
and in 3D they are given as:
8 7 +---------------------+ |\ |\ | \ | \ | \ | \ | \ | \ | 5+---------------------+6 | | | | +----|----------------+ | 4\ | 3 \ | \ | \ | \ | \ | \| \| +---------------------+ 1 2
*Heading box.inp *Node 1, -5, -5, 0 2, 5, -5, 0 3, 5, 5, 0 4, -5, 5, 0 5, 0, -5, 0 6, 5, 0, 0 7, 0, 5, 0 8, -5, 0, 0 9, 1, -1, 0 10, 0, 0, 0 11, -2, 1, 0 *Element, type=CPS4, ELSET=Surface1 1, 1, 10, 11, 8 2, 3, 10, 9, 6 3, 9, 10, 1, 5 4, 7, 4, 8, 11 5, 11, 10, 3, 7 6, 2, 6, 9, 5
This function reads a mesh from filename and returns an associated p4est connectivity.
[in] | filename | file to read the connectivity from |
int p4est_connectivity_read_inp_stream | ( | FILE * | stream, |
p4est_topidx_t * | num_vertices, | ||
p4est_topidx_t * | num_trees, | ||
double * | vertices, | ||
p4est_topidx_t * | tree_to_vertex | ||
) |
Read an ABAQUS input file from a file stream.
This utility function reads a basic ABAQUS file supporting element type with the prefix C2D4, CPS4, and S4 in 2D and of type C3D8 reading them as bilinear quadrilateral and trilinear hexahedral trees respectively.
A basic 2D mesh is given below. The *Node
section gives the vertex number and x, y, and z components for each vertex. The *Element
section gives the 4 vertices in 2D (8 vertices in 3D) of each element in counter clockwise order. So in 2D the nodes are given as:
4 3 +-------------------+ | | | | | | | | | | | | +-------------------+ 1 2
and in 3D they are given as:
8 7 +---------------------+ |\ |\ | \ | \ | \ | \ | \ | \ | 5+---------------------+6 | | | | +----|----------------+ | 4\ | 3 \ | \ | \ | \ | \ | \| \| +---------------------+ 1 2
*Heading box.inp *Node 1, -5, -5, 0 2, 5, -5, 0 3, 5, 5, 0 4, -5, 5, 0 5, 0, -5, 0 6, 5, 0, 0 7, 0, 5, 0 8, -5, 0, 0 9, 1, -1, 0 10, 0, 0, 0 11, -2, 1, 0 *Element, type=CPS4, ELSET=Surface1 1, 1, 10, 11, 8 2, 3, 10, 9, 6 3, 9, 10, 1, 5 4, 7, 4, 8, 11 5, 11, 10, 3, 7 6, 2, 6, 9, 5
This code can be called two ways. The first, when vertex==NULL
and tree_to_vertex==NULL
, is used to count the number of tress and vertices in the connectivity to be generated by the .inp mesh in the stream. The second, when
vertices!=NULL
and tree_to_vertex!=NULL
, fill vertices
and tree_to_vertex
.
[in,out] | stream | file stream to read the connectivity from |
[out] | num_vertices | the number of vertices in the connectivity |
[out] | num_trees | the number of trees in the connectivity |
[out] | vertices | the list of vertices of the connectivity |
[out] | tree_to_vertex | the tree_to_vertex map of the connectivity |
void p4est_connectivity_reorder | ( | MPI_Comm | comm, |
int | k, | ||
p4est_connectivity_t * | conn, | ||
p4est_connect_type_t | ctype | ||
) |
p4est_connectivity_reorder This function takes a connectivity conn and a parameter k, which will typically be the number of processes, and reorders the trees such that if every processes is assigned (num_trees / k) trees, the communication volume will be minimized.
This is intended for use with connectivities that contain a large number of trees. This should be done BEFORE a p4est is created using the connectivity. This is done in place: any data structures that use indices to refer to trees before this procedure will be invalid. Note that this routine calls metis and not parmetis because the connectivity is copied on every process. A communicator is required because I'm not positive that metis is deterministic. ctype determines when an edge exist between two trees in the dual graph used by metis in the reordering.
[in] | comm | MPI communicator. |
[in] | k | if k > 0, the number of pieces metis will use to guide the reordering; if k = 0, the number of pieces will be determined from the MPI communicator. |
[in,out] | conn | connectivity that will be reordered. |
[in] | ctype | determines when an edge exists in the dual graph of the connectivity structure. |
int p4est_connectivity_save | ( | const char * | filename, |
p4est_connectivity_t * | connectivity | ||
) |
Save a connectivity structure to disk.
[in] | filename | Name of the file to write. |
[in] | connectivity | Valid connectivity structure. |
void p4est_connectivity_set_attr | ( | p4est_connectivity_t * | conn, |
int | enable_tree_attr | ||
) |
Allocate or free the attribute fields in a connectivity.
[in,out] | conn | The conn->*_to_attr fields must either be NULL or previously be allocated by this function. |
[in] | enable_tree_attr | If false, tree_to_attr is freed (NULL is ok). If true, it must be NULL and is allocated. |
int p4est_connectivity_sink | ( | p4est_connectivity_t * | conn, |
sc_io_sink_t * | sink | ||
) |
Write connectivity to a sink object.
[in] | conn | The connectivity to be written. |
[in,out] | sink | The connectivity is written into this sink. |
p4est_connectivity_t* p4est_connectivity_source | ( | sc_io_source_t * | source | ) |
Read connectivity from a source object.
[in,out] | source | The connectivity is read from this source. |
static p4est_corner_transform_t* p4est_corner_array_index | ( | sc_array_t * | array, |
size_t | it | ||
) | [inline, static] |
Return a pointer to a p4est_corner_transform_t array element.
void p4est_expand_face_transform | ( | int | iface, |
int | nface, | ||
int | ftransform[] | ||
) |
Fill an array with the axis combination of a face neighbor transform.
[in] | iface | The number of the originating face. |
[in] | nface | Encoded as nface = r * 4 + nf, where nf = 0..3 is the neigbbor's connecting face number and r = 0..1 is the relative orientation to the neighbor's face. This encoding matches p4est_connectivity_t. |
[out] | ftransform | This array holds 9 integers. [0,2] The coordinate axis sequence of the origin face, the first referring to the tangential and the second to the normal. A permutation of (0, 1). [3,5] The coordinate axis sequence of the target face. [6,8] Edge reversal flag for tangential axis (boolean); face code in [0, 3] for the normal coordinate q: 0: q' = -q 1: q' = q + 1 2: q' = q - 1 3: q' = 2 - q [1,4,7] 0 (unused for compatibility with 3D). |
void p4est_find_corner_transform | ( | p4est_connectivity_t * | connectivity, |
p4est_topidx_t | itree, | ||
int | icorner, | ||
p4est_corner_info_t * | ci | ||
) |
Fills an array with information about corner neighbors.
[in] | itree | The number of the originating tree. |
[in] | icorner | The number of the originating corner. |
[in,out] | ci | A p4est_corner_info_t structure with initialized array. |
p4est_topidx_t p4est_find_face_transform | ( | p4est_connectivity_t * | connectivity, |
p4est_topidx_t | itree, | ||
int | iface, | ||
int | ftransform[] | ||
) |
Fill an array with the axis combinations of a tree neighbor transform.
[in] | itree | The number of the originating tree. |
[in] | iface | The number of the originating tree's face. |
[out] | ftransform | This 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 t; face code for axis n. [1,4,7] 0 (unused for compatibility with 3D). |
const int p4est_child_corner_faces[4][4] |
Store the faces for each child and corner, can be -1.
const int p4est_corner_face_corners[4][4] |
Store the face corner numbers for the faces touching a tree corner.
const int p4est_corner_faces[4][2] |
Store the face numbers 0..3 for each tree corner.
const int p4est_face_corners[4][2] |
Store the corner numbers 0..4 for each tree face.
const int p4est_face_dual[4] |
Store the face numbers in the face neighbor's system.