p4est  2.8.643-dbc7-dirty
p4est is a software library for parallel adaptive mesh refinement.
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
p4est_connectivity.h File Reference

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

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

Go to the source code of this file.

Data Structures

struct  p4est_connectivity
 This structure holds the 2D inter-tree connectivity information. More...
 
struct  p4est_corner_transform_t
 
struct  p4est_corner_info_t
 
struct  p4est_neighbor_transform_t
 Generic interface for transformations beteen a tree and any of its neighbors. More...
 

Macros

#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. More...
 
#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_ONLY_P8_LAND(x)
 Only use logical AND term in 3D.
 
#define P4EST_ONLY_P8_COMMA(x)
 Only use comma and expression in 3D.
 
#define P4EST_DIM_POW(a)   ((a) * (a))
 Exponentiate with dimension.
 
#define P4EST_FTRANSFORM   9
 
#define P4EST_STRING   "p4est"
 p4est identification string
 
#define P4EST_ONDISK_FORMAT   0x2000009
 

Typedefs

typedef struct p4est_connectivity p4est_connectivity_t
 This structure holds the 2D inter-tree connectivity information. More...
 

Enumerations

enum  p4est_connect_type_t {
  P4EST_CONNECT_SELF = 20 ,
  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. More...
 
const char * p4est_connect_type_string (p4est_connect_type_t btype)
 Convert the p4est_connect_type_t into a const string. More...
 
size_t p4est_connectivity_memory_used (p4est_connectivity_t *conn)
 Calculate memory usage of a connectivity structure. More...
 
void p4est_neighbor_transform_coordinates (const p4est_neighbor_transform_t *nt, const p4est_qcoord_t self_coords[P4EST_DIM], p4est_qcoord_t neigh_coords[P4EST_DIM])
 Transform from self's coordinate system to neighbor's coordinate system. More...
 
void p4est_neighbor_transform_coordinates_reverse (const p4est_neighbor_transform_t *nt, const p4est_qcoord_t neigh_coords[P4EST_DIM], p4est_qcoord_t self_coords[P4EST_DIM])
 Transform from neighbor's coordinate system to self's coordinate system. More...
 
void p4est_connectivity_get_neighbor_transforms (p4est_connectivity_t *conn, p4est_topidx_t tree_id, p4est_connect_type_t boundary_type, int boundary_index, sc_array_t *neighbor_transform_array)
 
int p4est_connectivity_face_neighbor_face_corner (int fc, int f, int nf, int o)
 Transform a face corner across one of the adjacent faces into a neighbor tree. More...
 
int p4est_connectivity_face_neighbor_corner (int c, int f, int nf, int o)
 Transform a corner across one of the adjacent faces into a neighbor tree. More...
 
p4est_connectivity_tp4est_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. More...
 
p4est_connectivity_tp4est_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. More...
 
p4est_connectivity_tp4est_connectivity_bcast (p4est_connectivity_t *conn_in, int root, sc_MPI_Comm comm)
 Broadcast a connectivity structure that exists only on one process to all. More...
 
void p4est_connectivity_destroy (p4est_connectivity_t *connectivity)
 Destroy a connectivity structure. More...
 
void p4est_connectivity_set_attr (p4est_connectivity_t *conn, size_t bytes_per_tree)
 Allocate or free the attribute fields in a connectivity. More...
 
int p4est_connectivity_is_valid (p4est_connectivity_t *connectivity)
 Examine a connectivity structure. More...
 
int p4est_connectivity_is_equal (p4est_connectivity_t *conn1, p4est_connectivity_t *conn2)
 Check two connectivity structures for equality. More...
 
int p4est_connectivity_sink (p4est_connectivity_t *conn, sc_io_sink_t *sink)
 Write connectivity to a sink object. More...
 
sc_array_tp4est_connectivity_deflate (p4est_connectivity_t *conn, p4est_connectivity_encode_t code)
 Allocate memory and store the connectivity information there. More...
 
int p4est_connectivity_save (const char *filename, p4est_connectivity_t *connectivity)
 Save a connectivity structure to disk. More...
 
p4est_connectivity_tp4est_connectivity_source (sc_io_source_t *source)
 Read connectivity from a source object. More...
 
p4est_connectivity_tp4est_connectivity_inflate (sc_array_t *buffer)
 Create new connectivity from a memory buffer. More...
 
p4est_connectivity_tp4est_connectivity_load (const char *filename, size_t *bytes)
 Load a connectivity structure from disk. More...
 
p4est_connectivity_tp4est_connectivity_new_unitsquare (void)
 Create a connectivity structure for the unit square.
 
p4est_connectivity_tp4est_connectivity_new_periodic (void)
 Create a connectivity structure for an all-periodic unit square.
 
p4est_connectivity_tp4est_connectivity_new_rotwrap (void)
 Create a connectivity structure for a periodic unit square. More...
 
p4est_connectivity_tp4est_connectivity_new_twotrees (int l_face, int r_face, int orientation)
 Create a connectivity structure for two trees being rotated w.r.t. More...
 
p4est_connectivity_tp4est_connectivity_new_corner (void)
 Create a connectivity structure for a three-tree mesh around a corner.
 
p4est_connectivity_tp4est_connectivity_new_pillow (void)
 Create a connectivity structure for two trees on top of each other.
 
p4est_connectivity_tp4est_connectivity_new_moebius (void)
 Create a connectivity structure for a five-tree moebius band.
 
p4est_connectivity_tp4est_connectivity_new_star (void)
 Create a connectivity structure for a six-tree star.
 
p4est_connectivity_tp4est_connectivity_new_cubed (void)
 Create a connectivity structure for the six sides of a unit cube. More...
 
p4est_connectivity_tp4est_connectivity_new_disk_nonperiodic (void)
 Create a connectivity structure for a five-tree flat spherical disk. More...
 
p4est_connectivity_tp4est_connectivity_new_disk (int periodic_a, int periodic_b)
 Create a connectivity structure for a five-tree flat spherical disk. More...
 
p4est_connectivity_tp4est_connectivity_new_icosahedron ()
 Create a connectivity for mapping the sphere using an icosahedron. More...
 
p4est_connectivity_tp4est_connectivity_new_shell2d (void)
 Create a connectivity structure that builds a 2d spherical shell. More...
 
p4est_connectivity_tp4est_connectivity_new_disk2d (void)
 Create a connectivity structure that maps a 2d disk. More...
 
p4est_connectivity_tp4est_connectivity_new_brick (int mi, int ni, int periodic_a, int periodic_b)
 A rectangular m by n array of trees with configurable periodicity. More...
 
p4est_connectivity_tp4est_connectivity_new_byname (const char *name)
 Create connectivity structure from predefined catalogue. More...
 
p4est_connectivity_tp4est_connectivity_refine (p4est_connectivity_t *conn, int num_per_edge)
 Uniformly refine a connectivity. More...
 
void p4est_expand_face_transform (int iface, int nface, int ftransform[])
 Fill an array with the axis combination of a face neighbor transform. More...
 
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. More...
 
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. More...
 
void p4est_connectivity_complete (p4est_connectivity_t *conn)
 Internally connect a connectivity based on tree_to_vertex information. More...
 
void p4est_connectivity_reduce (p4est_connectivity_t *conn)
 Removes corner information of a connectivity such that enough information is left to run p4est_connectivity_complete successfully. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
p4est_connectivity_tp4est_connectivity_read_inp (const char *filename)
 Create a p4est connectivity from an ABAQUS input file. More...
 

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.
 

Detailed Description

The coarse topological description of the forest.

Macro Definition Documentation

◆ P4EST_CHILDREN

#define P4EST_CHILDREN   4

The number of children of a quadrant.

also the number of corners

Typedef Documentation

◆ p4est_connectivity_t

This structure holds the 2D inter-tree connectivity information.

Identification of arbitrary faces and corners is possible.

The arrays tree_to_* are stored in z ordering. For corners the order wrt. yx is 00 01 10 11. For faces the order is -x +x -y +y. They are allocated [0][0]..[0][3]..[num_trees-1][0]..[num_trees-1][3].

The values for tree_to_face are 0..7 where ttf % 4 gives the face number and ttf / 4 the face orientation code. The orientation is 0 for edges that are aligned in z-order, and 1 for edges that are running opposite in z-order.

It is valid to specify num_vertices as 0. In this case vertices and tree_to_vertex are set to NULL. Otherwise the vertex coordinates are stored in the array vertices as [0][0]..[0][2]..[num_vertices-1][0]..[num_vertices-1][2].

The corners are only stored when they connect trees. In this case tree_to_corner indexes into ctt_offset. Otherwise the tree_to_corner entry must be -1 and this corner is ignored. If num_corners == 0, tree_to_corner and corner_to_* arrays are set to NULL.

The arrays corner_to_* store a variable number of entries per corner. For corner c these are at position [ctt_offset[c]]..[ctt_offset[c+1]-1]. Their number for corner c is ctt_offset[c+1] - ctt_offset[c]. The entries encode all trees adjacent to corner c. The size of the corner_to_* arrays is num_ctt = ctt_offset[num_corners].

The *_to_attr arrays may have arbitrary contents defined by the user.

Enumeration Type Documentation

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

◆ p4est_connectivity_encode_t

Typedef for serialization method.

Enumerator
P4EST_CONN_ENCODE_LAST 

Invalid entry to close the list.

Function Documentation

◆ p4est_connect_type_int()

int p4est_connect_type_int ( p4est_connect_type_t  btype)

Convert the p4est_connect_type_t into a number.

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

◆ p4est_connect_type_string()

const char* p4est_connect_type_string ( p4est_connect_type_t  btype)

Convert the p4est_connect_type_t into a const string.

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

◆ p4est_connectivity_bcast()

p4est_connectivity_t* p4est_connectivity_bcast ( p4est_connectivity_t conn_in,
int  root,
sc_MPI_Comm  comm 
)

Broadcast a connectivity structure that exists only on one process to all.

On the other processors, it will be allocated using p4est_connectivity_new.

Parameters
[in]conn_inFor the root process the connectivity to be broadcast, for the other processes it must be NULL.
[in]rootThe rank of the process that provides the connectivity.
[in]commThe MPI communicator.
Returns
For the root process this is a pointer to conn_in. Else, a pointer to a newly allocated connectivity structure with the same values as conn_in on the root process.

◆ p4est_connectivity_complete()

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.

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 p4est_connectivity_is_valid (conn) but will be overwritten. The corner fields will be freed and allocated anew.

◆ p4est_connectivity_deflate()

sc_array_t* p4est_connectivity_deflate ( p4est_connectivity_t conn,
p4est_connectivity_encode_t  code 
)

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.

◆ p4est_connectivity_destroy()

void p4est_connectivity_destroy ( p4est_connectivity_t connectivity)

Destroy a connectivity structure.

Also destroy all attributes.

◆ p4est_connectivity_face_neighbor_corner()

int p4est_connectivity_face_neighbor_corner ( int  c,
int  f,
int  nf,
int  o 
)

Transform a corner across one of the adjacent faces into a neighbor tree.

This version expects the neighbor face and orientation separately.

Parameters
[in]cA corner number in 0..3.
[in]fA face number that touches the corner c.
[in]nfA neighbor face that is on the other side of f.
[in]oThe orientation between tree boundary faces f and nf.
Returns
The number of the corner seen from the neighbor tree.

◆ p4est_connectivity_face_neighbor_face_corner()

int p4est_connectivity_face_neighbor_face_corner ( int  fc,
int  f,
int  nf,
int  o 
)

Transform a face corner across one of the adjacent faces into a neighbor tree.

This version expects the neighbor face and orientation separately.

Parameters
[in]fcA face corner number in 0..1.
[in]fA face that the face corner number fc is relative to.
[in]nfA neighbor face that is on the other side of f.
[in]oThe orientation between tree boundary faces f and nf.
Returns
The face corner number relative to the neighbor's face.

◆ p4est_connectivity_inflate()

p4est_connectivity_t* p4est_connectivity_inflate ( sc_array_t buffer)

Create new connectivity from a memory buffer.

This function aborts on malloc errors.

Parameters
[in]bufferThe connectivity is created from this memory buffer.
Returns
The newly created connectivity, or NULL on format error of the buffered connectivity data.

◆ p4est_connectivity_is_equal()

int p4est_connectivity_is_equal ( p4est_connectivity_t conn1,
p4est_connectivity_t conn2 
)

Check two connectivity structures for equality.

Returns
Returns true if structures are equal, false otherwise.

◆ p4est_connectivity_is_equivalent()

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.

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

◆ p4est_connectivity_is_valid()

int p4est_connectivity_is_valid ( p4est_connectivity_t connectivity)

Examine a connectivity structure.

Returns
Returns true if structure is valid, false otherwise.

◆ p4est_connectivity_join_faces()

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.

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 p4est_connectivity_t to understand orientation).

◆ p4est_connectivity_load()

p4est_connectivity_t* p4est_connectivity_load ( const char *  filename,
size_t *  bytes 
)

Load a connectivity structure from disk.

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

◆ p4est_connectivity_memory_used()

size_t p4est_connectivity_memory_used ( p4est_connectivity_t conn)

Calculate memory usage of a connectivity structure.

Parameters
[in]connConnectivity structure.
Returns
Memory used in bytes.

◆ p4est_connectivity_new()

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.

Parameters
[in]num_verticesNumber of total vertices (i.e. geometric points).
[in]num_treesNumber of trees in the forest.
[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.

◆ p4est_connectivity_new_brick()

p4est_connectivity_t* p4est_connectivity_new_brick ( int  mi,
int  ni,
int  periodic_a,
int  periodic_b 
)

A rectangular m by n array of trees with configurable periodicity.

The brick is periodic in x and y if periodic_a and periodic_b are true, respectively.

◆ p4est_connectivity_new_byname()

p4est_connectivity_t* p4est_connectivity_new_byname ( const char *  name)

Create connectivity structure from predefined catalogue.

Parameters
[in]nameInvokes 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
Returns
An initialized connectivity if name is defined, NULL else.

◆ p4est_connectivity_new_copy()

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.

Parameters
[in]num_verticesNumber of total vertices (i.e. geometric points).
[in]num_treesNumber of trees in the forest.
[in]num_cornersNumber of tree-connecting corners.
[in]coffCorner-to-tree offsets (num_corners + 1 values). This must always be non-NULL; in trivial cases it is just a pointer to a p4est_topix value of 0.
Returns
The connectivity is checked for validity.

◆ p4est_connectivity_new_cubed()

p4est_connectivity_t* p4est_connectivity_new_cubed ( void  )

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

◆ p4est_connectivity_new_disk()

p4est_connectivity_t* p4est_connectivity_new_disk ( int  periodic_a,
int  periodic_b 
)

Create a connectivity structure for a five-tree flat spherical disk.

This disk can just as well be used as a square to test non-Cartesian maps. Without any mapping this connectivity covers the square [-3, 3]**2.

Note
The API of this function has changed to accept two arguments. You can query the #define P4EST_CONN_DISK_PERIODIC to check whether the new version with the argument is in effect.

The ordering of the trees is as follows: 4 1 2 3 0.

The outside x faces may be identified topologically. The outside y faces may be identified topologically. Both identifications may be specified simultaneously. The general shape and periodicity are the same as those obtained with p4est_connectivity_new_brick (1, 1, periodic_a, periodic_b).

When setting periodic_a and periodic_b to false, the result is the same as that of p4est_connectivity_new_disk_nonperiodic.

Parameters
[in]periodic_aBool to make disk periodic in x direction.
[in]periodic_bBool to make disk periodic in y direction.
Returns
Initialized and usable connectivity.

◆ p4est_connectivity_new_disk2d()

p4est_connectivity_t* p4est_connectivity_new_disk2d ( void  )

Create a connectivity structure that maps a 2d disk.

This is a 5 trees connectivity meant to be used together with p4est_geometry_new_disk2d to map the disk.

◆ p4est_connectivity_new_disk_nonperiodic()

p4est_connectivity_t* p4est_connectivity_new_disk_nonperiodic ( void  )

Create a connectivity structure for a five-tree flat spherical disk.

This disk can just as well be used as a square to test non-Cartesian maps. Without any mapping this connectivity covers the square [-3, 3]**2.

Returns
Initialized and usable connectivity.

◆ p4est_connectivity_new_icosahedron()

p4est_connectivity_t* p4est_connectivity_new_icosahedron ( )

Create a connectivity for mapping the sphere using an icosahedron.

The regular icosadron is a polyhedron with 20 faces, each of which is an equilateral triangle. To build the p4est connectivity, we group faces 2 by 2 to from 10 quadrangles, and thus 10 trees.

This connectivity is meant to be used together with p4est_geometry_new_icosahedron to map the sphere.

The flat connectivity looks like that: Vextex numbering:

A00 A01 A02 A03 A04 / \ / \ / \ / \ / \ A05—A06—A07—A08—A09—A10 \ / \ / \ / \ / \ / \ A11—A12—A13—A14—A15—A16 \ / \ / \ / \ / \ / A17 A18 A19 A20 A21

Origin in A05.

Tree numbering:

0 2 4 6 8 1 3 5 7 9

◆ p4est_connectivity_new_rotwrap()

p4est_connectivity_t* p4est_connectivity_new_rotwrap ( void  )

Create a connectivity structure for a periodic unit square.

The left and right faces are identified, and bottom and top opposite.

◆ p4est_connectivity_new_shell2d()

p4est_connectivity_t* p4est_connectivity_new_shell2d ( void  )

Create a connectivity structure that builds a 2d spherical shell.

p8est_connectivity_new_shell

◆ p4est_connectivity_new_twotrees()

p4est_connectivity_t* p4est_connectivity_new_twotrees ( int  l_face,
int  r_face,
int  orientation 
)

Create a connectivity structure for two trees being rotated w.r.t.

each other in a user-defined way

Parameters
[in]l_faceindex of left face
[in]r_faceindex of right face
[in]orientationorientation of trees w.r.t. each other

◆ p4est_connectivity_permute()

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.

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.

◆ p4est_connectivity_read_inp()

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.

Parameters
[in]filenamefile to read the connectivity from
Returns
an allocated connectivity associated with the mesh in filename or NULL if an error occurred.

◆ p4est_connectivity_read_inp_stream()

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 trees 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 this case num_vertices and num_trees need to be set to the maximum number of entries allocated in vertices and tree_to_vertex.

Parameters
[in,out]streamfile stream to read the connectivity from
[in,out]num_verticesthe number of vertices in the connectivity
[in,out]num_treesthe number of trees in the connectivity
[out]verticesthe list of vertices of the connectivity
[out]tree_to_vertexthe tree_to_vertex map of the connectivity
Returns
0 if successful and nonzero if not

◆ p4est_connectivity_reduce()

void p4est_connectivity_reduce ( p4est_connectivity_t conn)

Removes corner information of a connectivity such that enough information is left to run p4est_connectivity_complete successfully.

The reduced connectivity still passes p4est_connectivity_is_valid.

Parameters
[in,out]connThe connectivity to be reduced.

◆ p4est_connectivity_refine()

p4est_connectivity_t* p4est_connectivity_refine ( p4est_connectivity_t conn,
int  num_per_edge 
)

Uniformly refine a connectivity.

This is useful if you would like to uniformly refine by something other than a power of 2.

Parameters
[in]connA valid connectivity
[in]num_per_edgeThe number of new trees in each direction. Must use no more than P4EST_OLD_QMAXLEVEL bits.
Returns
a refined connectivity.

◆ p4est_connectivity_save()

int p4est_connectivity_save ( const char *  filename,
p4est_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.

◆ p4est_connectivity_set_attr()

void p4est_connectivity_set_attr ( p4est_connectivity_t conn,
size_t  bytes_per_tree 
)

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]bytes_per_treeIf 0, tree_to_attr is freed (being NULL is ok). If positive, requested space is allocated.

◆ p4est_connectivity_sink()

int p4est_connectivity_sink ( p4est_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.

◆ p4est_connectivity_source()

p4est_connectivity_t* p4est_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.

◆ p4est_expand_face_transform()

void p4est_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 * 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]ftransformThis 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).

◆ p4est_find_corner_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.

Parameters
[in]itreeThe number of the originating tree.
[in]icornerThe number of the originating corner.
[in,out]ciA p4est_corner_info_t structure with initialized array.

◆ p4est_find_face_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.

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 axis t; face code for axis n. [1,4,7] 0 (unused for compatibility with 3D).
Returns
The face neighbor tree if it exists, -1 otherwise.

◆ p4est_neighbor_transform_coordinates()

void p4est_neighbor_transform_coordinates ( const p4est_neighbor_transform_t nt,
const p4est_qcoord_t  self_coords[P4EST_DIM],
p4est_qcoord_t  neigh_coords[P4EST_DIM] 
)

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

Parameters
[in]ntA neighbor transform.
[in]self_coordsInput quadrant coordinates in self coordinates.
[out]neigh_coordsCoordinates transformed into neighbor coordinates.

◆ p4est_neighbor_transform_coordinates_reverse()

void p4est_neighbor_transform_coordinates_reverse ( const p4est_neighbor_transform_t nt,
const p4est_qcoord_t  neigh_coords[P4EST_DIM],
p4est_qcoord_t  self_coords[P4EST_DIM] 
)

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

Parameters
[in]ntA neighbor transform.
[in]neigh_coordsInput quadrant coordinates in self coordinates.
[out]self_coordsCoordinates transformed into neighbor coordinates.