p4est  1.0
Data Structures | Defines | Enumerations | Functions | Variables
src/p8est_connectivity.h File Reference

The coarse topological description of the forest. More...

#include <sc_io.h>
#include <p4est_base.h>
Include dependency graph for p8est_connectivity.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  p8est_connectivity_t
 This structure holds the 3D inter-tree connectivity information. More...
struct  p8est_edge_transform_t
struct  p8est_edge_info_t
struct  p8est_corner_transform_t
struct  p8est_corner_info_t

Defines

#define P8EST_DIM   3
 The spatial dimension.
#define P8EST_FACES   (2 * P8EST_DIM)
 The number of faces of an octant.
#define P8EST_CHILDREN   8
 The number of children of an octant.
#define P8EST_HALF   (P8EST_CHILDREN / 2)
 The number of children/corners touching one face.
#define P8EST_EDGES   12
 The number of edges around an octant.
#define P8EST_INSUL   27
 The size of insulation layer.
#define P8EST_FTRANSFORM   9
#define P8EST_STRING   "p8est"
 p8est identification string
#define P8EST_ONDISK_FORMAT   0x3000009

Enumerations

enum  p8est_connect_type_t { P8EST_CONNECT_FACE = 31, P8EST_CONNECT_EDGE = 32, P8EST_CONNECT_CORNER = 33, P8EST_CONNECT_FULL = P8EST_CONNECT_CORNER }
 Characterize a type of adjacency. More...
enum  p8est_connectivity_encode_t { P8EST_CONN_ENCODE_NONE = SC_IO_ENCODE_NONE, P8EST_CONN_ENCODE_LAST }
 Typedef for serialization method. More...

Functions

int p8est_connect_type_int (p8est_connect_type_t btype)
 Convert the p8est_connect_type_t into a number.
const char * p8est_connect_type_string (p8est_connect_type_t btype)
 Convert the p8est_connect_type_t into a const string.
size_t p8est_connectivity_memory_used (p8est_connectivity_t *conn)
 Calculate memory usage of a connectivity structure.
p8est_connectivity_tp8est_connectivity_new (p4est_topidx_t num_vertices, p4est_topidx_t num_trees, p4est_topidx_t num_edges, p4est_topidx_t num_ett, p4est_topidx_t num_corners, p4est_topidx_t num_ctt)
 Allocate a connectivity structure.
p8est_connectivity_tp8est_connectivity_new_copy (p4est_topidx_t num_vertices, p4est_topidx_t num_trees, p4est_topidx_t num_edges, 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 *tte, const p4est_topidx_t *eoff, const p4est_topidx_t *ett, const int8_t *ete, 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 p8est_connectivity_destroy (p8est_connectivity_t *connectivity)
 Destroy a connectivity structure.
void p8est_connectivity_set_attr (p8est_connectivity_t *conn, int enable_tree_attr)
 Allocate or free the attribute fields in a connectivity.
int p8est_connectivity_is_valid (p8est_connectivity_t *connectivity)
 Examine a connectivity structure.
int p8est_connectivity_is_equal (p8est_connectivity_t *conn1, p8est_connectivity_t *conn2)
 Check two connectivity structures for equality.
int p8est_connectivity_sink (p8est_connectivity_t *conn, sc_io_sink_t *sink)
 Write connectivity to a sink object.
sc_array_t * p8est_connectivity_deflate (p8est_connectivity_t *conn, p8est_connectivity_encode_t code)
 Allocate memory and store the connectivity information there.
int p8est_connectivity_save (const char *filename, p8est_connectivity_t *connectivity)
 Save a connectivity structure to disk.
p8est_connectivity_tp8est_connectivity_source (sc_io_source_t *source)
 Read connectivity from a source object.
p8est_connectivity_tp8est_connectivity_inflate (sc_array_t *buffer)
 Create new connectivity from a memory buffer.
p8est_connectivity_tp8est_connectivity_load (const char *filename, size_t *bytes)
 Load a connectivity structure from disk.
p8est_connectivity_tp8est_connectivity_new_unitcube (void)
 Create a connectivity structure for the unit cube.
p8est_connectivity_tp8est_connectivity_new_periodic (void)
 Create a connectivity structure for an all-periodic unit cube.
p8est_connectivity_tp8est_connectivity_new_rotwrap (void)
 Create a connectivity structure for a mostly periodic unit cube.
p8est_connectivity_tp8est_connectivity_new_twocubes (void)
 Create a connectivity structure that contains two cubes.
p8est_connectivity_tp8est_connectivity_new_twowrap (void)
 Create a connectivity structure that contains two cubes where the two far ends are identified periodically.
p8est_connectivity_tp8est_connectivity_new_rotcubes (void)
 Create a connectivity structure that contains a few cubes.
p8est_connectivity_tp8est_connectivity_new_brick (int m, int n, int p, int periodic_a, int periodic_b, int periodic_c)
 An m by n by p array with periodicity in x, y, and z if periodic_a, periodic_b, and periodic_c are true, respectively.
p8est_connectivity_tp8est_connectivity_new_shell (void)
 Create a connectivity structure that builds a spherical shell.
p8est_connectivity_tp8est_connectivity_new_sphere (void)
 Create a connectivity structure that builds a solid sphere.
p8est_connectivity_tp8est_connectivity_new_byname (const char *name)
 Create connectivity structure from predefined catalogue.
void p8est_expand_face_transform (int iface, int nface, int ftransform[])
 Fill an array with the axis combination of a face neighbor transform.
p4est_topidx_t p8est_find_face_transform (p8est_connectivity_t *connectivity, p4est_topidx_t itree, int iface, int ftransform[])
 Fill an array with the axis combination of a face neighbor transform.
void p8est_find_edge_transform (p8est_connectivity_t *connectivity, p4est_topidx_t itree, int iedge, p8est_edge_info_t *ei)
 Fills an array with information about edge neighbors.
void p8est_find_corner_transform (p8est_connectivity_t *connectivity, p4est_topidx_t itree, int icorner, p8est_corner_info_t *ci)
 Fills an array with information about corner neighbors.
void p8est_connectivity_complete (p8est_connectivity_t *conn)
 Internally connect a connectivity based on tree_to_vertex information.
void p8est_connectivity_permute (p8est_connectivity_t *conn, sc_array_t *perm, int is_current_to_new)
 p8est_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 p8est_connectivity_reorder (MPI_Comm comm, int k, p8est_connectivity_t *conn, p8est_connect_type_t ctype)
 p8est_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 p8est_connectivity_join_faces (p8est_connectivity_t *conn, p4est_topidx_t tree_left, p4est_topidx_t tree_right, int face_left, int face_right, int orientation)
 p8est_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 p8est_connectivity_is_equivalent (p8est_connectivity_t *conn1, p8est_connectivity_t *conn2)
 p8est_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 p8est_edge_transform_tp8est_edge_array_index (sc_array_t *array, size_t it)
 Return a pointer to a p8est_edge_transform_t array element.
static p8est_corner_transform_tp8est_corner_array_index (sc_array_t *array, size_t it)
 Return a pointer to a p8est_corner_transform_t array element.
int p8est_connectivity_read_inp_stream (FILE *stream, p4est_topidx_t *num_vertices, p4est_topidx_t *num_trees, double *vertices, p4est_topidx_t *tree_to_vertex)
p8est_connectivity_tp8est_connectivity_read_inp (const char *filename)

Variables

const int p8est_face_corners [6][4]
 Store the corner numbers 0..7 for each tree face.
const int p8est_face_edges [6][4]
 Store the face numbers 0..12 for each tree face.
const int p8est_face_dual [6]
 Store the face numbers in the face neighbor's system.
const int p8est_face_permutations [8][4]
 Store only the 8 out of 24 possible permutations that occur.
const int p8est_face_permutation_sets [3][4]
 Store the 3 occurring sets of 4 permutations per face.
const int p8est_face_permutation_refs [6][6]
 For each face combination store the permutation set.
const int p8est_edge_faces [12][2]
 Store the face numbers 0..5 for each tree edge.
const int p8est_edge_corners [12][2]
 Store the corner numbers 0..8 for each tree edge.
const int p8est_edge_face_corners [12][6][2]
 Store the face corner numbers for the faces touching a tree edge.
const int p8est_corner_faces [8][3]
 Store the face numbers 0..5 for each tree corner.
const int p8est_corner_edges [8][3]
 Store the edge numbers 0..11 for each tree corner.
const int p8est_corner_face_corners [8][6]
 Store the face corner numbers for the faces touching a tree corner.
const int p8est_child_edge_faces [8][12]
 Store the faces for each child and edge, can be -1.
const int p8est_child_corner_faces [8][8]
 Store the faces for each child and corner, can be -1.
const int p8est_child_corner_edges [8][8]
 Store the edges for each child and corner, can be -1.

Detailed Description

The coarse topological description of the forest.


Define Documentation

#define P8EST_CHILDREN   8

The number of children of an octant.

also the nmber of corners

#define P8EST_FACES   (2 * P8EST_DIM)

The number of faces of an octant.

Note:
for uniform naming reasons, an octant is represented by the datatype p8est_quadrant_t

Enumeration Type Documentation

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, or 3) entities are adjacent if they share a face, corner or edge. p8est_connect_type_t is used to choose the desired behavior. This enum must fit into an int8_t.

Typedef for serialization method.

Enumerator:
P8EST_CONN_ENCODE_LAST 

Invalid entry to close the list.


Function Documentation

Convert the p8est_connect_type_t into a number.

Parameters:
[in]btypeThe balance type to convert.
Returns:
Returns 1, 2 or 3.

Convert the p8est_connect_type_t into a const string.

Parameters:
[in]btypeThe balance type to convert.
Returns:
Returns a pointer to a constant string.

Internally connect a connectivity based on tree_to_vertex information.

Periodicity that is not inherent in the list of vertices will be lost.

Parameters:
[in,out]connThe 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 p8est_connectivity_is_valid (conn) but will be overwritten. The edge and corner fields will be freed and allocated anew.

Allocate memory and store the connectivity information there.

Parameters:
[in]connThe connectivity structure to be exported to memory.
[in]codeEncoding and compression method for serialization.
Returns:
Newly created array that contains the information.

Destroy a connectivity structure.

Also destroy all attributes.

Create new connectivity from a memory buffer.

Parameters:
[in]bufferThe connectivity is created from this memory buffer.
Returns:
The newly created connectivity, or NULL on error.

Check two connectivity structures for equality.

Returns:
Returns true if structures are equal, false otherwise.

p8est_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.

Parameters:
[in]conn1a valid connectivity
[out]conn2a valid connectivity

Examine a connectivity structure.

Returns:
Returns true if structure is valid, false otherwise.
void p8est_connectivity_join_faces ( p8est_connectivity_t conn,
p4est_topidx_t  tree_left,
p4est_topidx_t  tree_right,
int  face_left,
int  face_right,
int  orientation 
)

p8est_connectivity_join_faces This function takes an existing valid connectivity conn and modifies it by joining two tree faces that are currently boundary faces.

Parameters:
[in,out]connconnectivity that will be altered.
[in]tree_lefttree that will be on the left side of the joined faces.
[in]tree_righttree that will be on the right side of the joined faces.
[in]face_leftface of tree_left that will be joined.
[in]face_rightface of tree_right that will be joined.
[in]orientationthe orientation of face_left and face_right once joined (see the description of p8est_connectivity_t to understand orientation).
p8est_connectivity_t* p8est_connectivity_load ( const char *  filename,
size_t *  bytes 
)

Load a connectivity structure from disk.

Parameters:
[in]filenameName of the file to read.
[out]bytesSize in bytes of connectivity on disk or NULL.
Returns:
Returns valid connectivity, or NULL on file error.

Calculate memory usage of a connectivity structure.

Parameters:
[in]connConnectivity structure.
Returns:
Memory used in bytes.
p8est_connectivity_t* p8est_connectivity_new ( p4est_topidx_t  num_vertices,
p4est_topidx_t  num_trees,
p4est_topidx_t  num_edges,
p4est_topidx_t  num_ett,
p4est_topidx_t  num_corners,
p4est_topidx_t  num_ctt 
)

Allocate a connectivity structure.

The attribute fields are initialized to NULL.

Parameters:
[in]num_verticesNumber of total vertices (i.e. geometric points).
[in]num_treesNumber of trees in the forest.
[in]num_edgesNumber of tree-connecting edges.
[in]num_ettNumber of total trees in edge_to_tree array.
[in]num_cornersNumber of tree-connecting corners.
[in]num_cttNumber of total trees in corner_to_tree array.
Returns:
A connectivity structure with allocated arrays.

Create connectivity structure from predefined catalogue.

Parameters:
[in]nameInvokes connectivity_new_* function. brick235 brick (2, 3, 5, 0, 0, 0) periodic periodic rotcubes rotcubes rotwrap rotwrap shell shell sphere sphere twocubes twocubes twowrap twowrap unit unitcube
Returns:
An initialized connectivity if name is defined, NULL else.
p8est_connectivity_t* p8est_connectivity_new_copy ( p4est_topidx_t  num_vertices,
p4est_topidx_t  num_trees,
p4est_topidx_t  num_edges,
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 tte,
const p4est_topidx_t eoff,
const p4est_topidx_t ett,
const int8_t *  ete,
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.

Parameters:
[in]num_verticesNumber of total vertices (i.e. geometric points).
[in]num_treesNumber of trees in the forest.
[in]num_edgesNumber of tree-connecting edges.
[in]num_cornersNumber of tree-connecting corners.
[in]eoffEdge-to-tree offsets (num_edges + 1 values).
[in]coffCorner-to-tree offsets (num_corners + 1 values).
Returns:
The connectivity is checked for validity.

Create a connectivity structure that contains a few cubes.

These are rotated against each other to stress the topology routines.

Create a connectivity structure for a mostly periodic unit cube.

The left and right faces are identified, and bottom and top rotated. Front and back are not identified.

Create a connectivity structure that builds a spherical shell.

It is made up of six connected parts [-1,1]x[-1,1]x[1,2]. This connectivity reuses vertices and relies on a geometry transformation. It is thus not suitable for p8est_connectivity_complete.

Create a connectivity structure that builds a solid sphere.

It is made up of two layers and a cube in the center. This connectivity reuses vertices and relies on a geometry transformation. It is thus not suitable for p8est_connectivity_complete.

void p8est_connectivity_permute ( p8est_connectivity_t conn,
sc_array_t *  perm,
int  is_current_to_new 
)

p8est_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.

Parameters:
[in,out]connThe connectivity whose trees are permuted.
[in]permA permutation array, whose elements are size_t's.
[in]is_current_to_newif 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.
void p8est_connectivity_reorder ( MPI_Comm  comm,
int  k,
p8est_connectivity_t conn,
p8est_connect_type_t  ctype 
)

p8est_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 p8est 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.

Parameters:
[in]commMPI communicator.
[in]kif 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]connconnectivity that will be reordered.
[in]ctypedetermines when an edge exists in the dual graph of the connectivity structure.
int p8est_connectivity_save ( const char *  filename,
p8est_connectivity_t connectivity 
)

Save a connectivity structure to disk.

Parameters:
[in]filenameName of the file to write.
[in]connectivityValid connectivity structure.
Returns:
Returns 0 on success, nonzero on file error.
void p8est_connectivity_set_attr ( p8est_connectivity_t conn,
int  enable_tree_attr 
)

Allocate or free the attribute fields in a connectivity.

Parameters:
[in,out]connThe conn->*_to_attr fields must either be NULL or previously be allocated by this function.
[in]enable_tree_attrIf false, tree_to_attr is freed (NULL is ok). If true, it must be NULL and is allocated.
int p8est_connectivity_sink ( p8est_connectivity_t conn,
sc_io_sink_t *  sink 
)

Write connectivity to a sink object.

Parameters:
[in]connThe connectivity to be written.
[in,out]sinkThe connectivity is written into this sink.
Returns:
0 on success, nonzero on error.
p8est_connectivity_t* p8est_connectivity_source ( sc_io_source_t *  source)

Read connectivity from a source object.

Parameters:
[in,out]sourceThe connectivity is read from this source.
Returns:
The newly created connectivity, or NULL on error.
static p8est_corner_transform_t* p8est_corner_array_index ( sc_array_t *  array,
size_t  it 
) [inline, static]

Return a pointer to a p8est_corner_transform_t array element.

static p8est_edge_transform_t* p8est_edge_array_index ( sc_array_t *  array,
size_t  it 
) [inline, static]

Return a pointer to a p8est_edge_transform_t array element.

void p8est_expand_face_transform ( int  iface,
int  nface,
int  ftransform[] 
)

Fill an array with the axis combination of a face neighbor transform.

Parameters:
[in]ifaceThe number of the originating face.
[in]nfaceEncoded as nface = r * 6 + nf, where nf = 0..5 is the neigbbor's connecting face number and r = 0..3 is the relative orientation to the neighbor's face. This encoding matches p8est_connectivity_t.
[out]ftransformThis array holds 9 integers. [0]..[2] The coordinate axis sequence of the origin face, the first two referring to the tangentials and the third to the normal. A permutation of (0, 1, 2). [3]..[5] The coordinate axis sequence of the target face. [6]..[8] Edge reversal flags for tangential axes (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
void p8est_find_corner_transform ( p8est_connectivity_t connectivity,
p4est_topidx_t  itree,
int  icorner,
p8est_corner_info_t ci 
)

Fills an array with information about corner neighbors.

Parameters:
[in]itreeThe number of the originating tree.
[in]icornerThe number of the originating corner.
[in,out]ciA p8est_corner_info_t structure with initialized array.
void p8est_find_edge_transform ( p8est_connectivity_t connectivity,
p4est_topidx_t  itree,
int  iedge,
p8est_edge_info_t ei 
)

Fills an array with information about edge neighbors.

Parameters:
[in]itreeThe number of the originating tree.
[in]iedgeThe number of the originating edge.
[in,out]eiA p8est_edge_info_t structure with initialized array.
p4est_topidx_t p8est_find_face_transform ( p8est_connectivity_t connectivity,
p4est_topidx_t  itree,
int  iface,
int  ftransform[] 
)

Fill an array with the axis combination of a face neighbor transform.

Parameters:
[in]itreeThe number of the originating tree.
[in]ifaceThe number of the originating tree's face.
[out]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 axes t1, t2; face code for n.
Returns:
The face neighbor tree if it exists, -1 otherwise.

Variable Documentation

const int p8est_child_corner_edges[8][8]

Store the edges for each child and corner, can be -1.

const int p8est_child_corner_faces[8][8]

Store the faces for each child and corner, can be -1.

const int p8est_child_edge_faces[8][12]

Store the faces for each child and edge, can be -1.

const int p8est_corner_edges[8][3]

Store the edge numbers 0..11 for each tree corner.

const int p8est_corner_face_corners[8][6]

Store the face corner numbers for the faces touching a tree corner.

const int p8est_corner_faces[8][3]

Store the face numbers 0..5 for each tree corner.

const int p8est_edge_corners[12][2]

Store the corner numbers 0..8 for each tree edge.

const int p8est_edge_face_corners[12][6][2]

Store the face corner numbers for the faces touching a tree edge.

const int p8est_edge_faces[12][2]

Store the face numbers 0..5 for each tree edge.

const int p8est_face_corners[6][4]

Store the corner numbers 0..7 for each tree face.

const int p8est_face_dual[6]

Store the face numbers in the face neighbor's system.

const int p8est_face_edges[6][4]

Store the face numbers 0..12 for each tree face.

const int p8est_face_permutation_refs[6][6]

For each face combination store the permutation set.

The order is [my_face][neighbor_face]

const int p8est_face_permutation_sets[3][4]

Store the 3 occurring sets of 4 permutations per face.

const int p8est_face_permutations[8][4]

Store only the 8 out of 24 possible permutations that occur.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines