p4est 2.8.6
p4est is a software library for parallel adaptive mesh refinement.
Data Structures | Functions
p8est_mesh.h File Reference

Forest topology in a conventional mesh format. More...

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

Go to the source code of this file.

Data Structures

struct  p8est_mesh_params_t
 This structure contains the different parameters of mesh creation. More...
 
struct  p8est_mesh_t
 This structure contains complete mesh information on a 2:1 balanced forest. More...
 
struct  p8est_mesh_face_neighbor_t
 This structure can be used as the status of a face neighbor iterator. More...
 

Functions

size_t p8est_mesh_memory_used (p8est_mesh_t *mesh)
 Calculate the memory usage of the mesh structure. More...
 
void p8est_mesh_params_init (p8est_mesh_params_t *params)
 Initialize a default p8est_mesh_params_t structure. More...
 
p8est_mesh_tp8est_mesh_new (p8est_t *p8est, p8est_ghost_t *ghost, p8est_connect_type_t btype)
 Create a p8est_mesh structure. More...
 
p8est_mesh_tp8est_mesh_new_params (p8est_t *p8est, p8est_ghost_t *ghost, p8est_mesh_params_t *params)
 Create a new mesh. More...
 
void p8est_mesh_destroy (p8est_mesh_t *mesh)
 Destroy a p8est_mesh structure. More...
 
p8est_quadrant_tp8est_mesh_get_quadrant (p8est_t *p4est, p8est_mesh_t *mesh, p4est_locidx_t qid)
 Access a process-local quadrant inside a forest. More...
 
p4est_locidx_t p8est_mesh_get_neighbors (p8est_t *p4est, p8est_ghost_t *ghost, p8est_mesh_t *mesh, p4est_locidx_t curr_quad_id, p4est_locidx_t direction, sc_array_t *neighboring_quads, sc_array_t *neighboring_encs, sc_array_t *neighboring_qids)
 Lookup neighboring quads of quadrant in a specific direction. More...
 
p8est_quadrant_tp8est_mesh_quadrant_cumulative (p8est_t *p8est, p8est_mesh_t *mesh, p4est_locidx_t cumulative_id, p4est_topidx_t *which_tree, p4est_locidx_t *quadrant_id)
 Find a quadrant based on its cumulative number in the local forest. More...
 
void p8est_mesh_face_neighbor_init2 (p8est_mesh_face_neighbor_t *mfn, p8est_t *p8est, p8est_ghost_t *ghost, p8est_mesh_t *mesh, p4est_topidx_t which_tree, p4est_locidx_t quadrant_id)
 Initialize a mesh neighbor iterator by quadrant index. More...
 
void p8est_mesh_face_neighbor_init (p8est_mesh_face_neighbor_t *mfn, p8est_t *p8est, p8est_ghost_t *ghost, p8est_mesh_t *mesh, p4est_topidx_t which_tree, p8est_quadrant_t *quadrant)
 Initialize a mesh neighbor iterator by quadrant pointer. More...
 
p8est_quadrant_tp8est_mesh_face_neighbor_next (p8est_mesh_face_neighbor_t *mfn, p4est_topidx_t *ntree, p4est_locidx_t *nquad, int *nface, int *nrank)
 Move the iterator forward to loop around neighbors of the quadrant. More...
 
void * p8est_mesh_face_neighbor_data (p8est_mesh_face_neighbor_t *mfn, void *ghost_data)
 Get the user data for the current face neighbor. More...
 

Detailed Description

Forest topology in a conventional mesh format.

A typical workflow starts with p8est_mesh_params_init to initialize a p8est_mesh_params_t, followed by eventual user-dependent changes to the parameters.

Next a p8est_mesh_t is created with p8est_mesh_new_params.

Now, the user can create a p8est_mesh_face_neighbor_t with p8est_mesh_face_neighbor_init and loop over a quadrants face neighbors by repeated calls to p8est_mesh_face_neighbor_next.

Once done, the mesh has to be destroyed with p8est_mesh_destroy.

Function Documentation

◆ p8est_mesh_destroy()

void p8est_mesh_destroy ( p8est_mesh_t mesh)

Destroy a p8est_mesh structure.

Parameters
[in]meshMesh structure previously created by p8est_mesh_new.

◆ p8est_mesh_face_neighbor_data()

void * p8est_mesh_face_neighbor_data ( p8est_mesh_face_neighbor_t mfn,
void *  ghost_data 
)

Get the user data for the current face neighbor.

Parameters
[in]mfnInternal status of the iterator.
[in]ghost_dataData for the ghost quadrants that has been synchronized with p4est_ghost_exchange_data.
Returns
A pointer to the user data for the current neighbor.

◆ p8est_mesh_face_neighbor_init()

void p8est_mesh_face_neighbor_init ( p8est_mesh_face_neighbor_t mfn,
p8est_t p8est,
p8est_ghost_t ghost,
p8est_mesh_t mesh,
p4est_topidx_t  which_tree,
p8est_quadrant_t quadrant 
)

Initialize a mesh neighbor iterator by quadrant pointer.

Parameters
[out]mfnA p8est_mesh_face_neighbor_t to be initialized.
[in]p8estForest to be worked with.
[in]ghostGhost layer of the forest.
[in]meshA mesh derived from the forest.
[in]which_treeTree of quadrant whose neighbors are looped over.
[in]quadrantPointer to quadrant contained in which_tree.

◆ p8est_mesh_face_neighbor_init2()

void p8est_mesh_face_neighbor_init2 ( p8est_mesh_face_neighbor_t mfn,
p8est_t p8est,
p8est_ghost_t ghost,
p8est_mesh_t mesh,
p4est_topidx_t  which_tree,
p4est_locidx_t  quadrant_id 
)

Initialize a mesh neighbor iterator by quadrant index.

Parameters
[out]mfnA p8est_mesh_face_neighbor_t to be initialized.
[in]p8estForest to be worked with.
[in]ghostGhost layer of the forest.
[in]meshA mesh derived from the forest.
[in]which_treeTree of quadrant whose neighbors are looped over.
[in]quadrant_idIndex relative to which_tree of quadrant.

◆ p8est_mesh_face_neighbor_next()

p8est_quadrant_t * p8est_mesh_face_neighbor_next ( p8est_mesh_face_neighbor_t mfn,
p4est_topidx_t ntree,
p4est_locidx_t nquad,
int *  nface,
int *  nrank 
)

Move the iterator forward to loop around neighbors of the quadrant.

Parameters
[in,out]mfnInternal status of the iterator.
[out]ntreeIf not NULL, the tree number of the neighbor.
[out]nquadIf not NULL, the quadrant number within tree. For ghosts instead the number in ghost layer.
[out]nfaceIf not NULL, neighbor's face encoding as in quad_to_face array of p8est_mesh_t.
[out]nrankIf not NULL, the owner process of the neighbor.
Returns
Either a real quadrant or one from the ghost layer. Returns NULL when the iterator is done.

◆ p8est_mesh_get_neighbors()

p4est_locidx_t p8est_mesh_get_neighbors ( p8est_t p4est,
p8est_ghost_t ghost,
p8est_mesh_t mesh,
p4est_locidx_t  curr_quad_id,
p4est_locidx_t  direction,
sc_array_t *  neighboring_quads,
sc_array_t *  neighboring_encs,
sc_array_t *  neighboring_qids 
)

Lookup neighboring quads of quadrant in a specific direction.

Parameters
[in]p4estForest to be worked with.
[in]ghostGhost quadrants.
[in]meshMesh structure.
[in]curr_quad_idProcess-local ID of current quad.
[in]directionDirection in which to look for adjacent quadrants is encoded as follows: 0 .. 5 neighbor(-s) across f_i, 6 .. 17 neighbor(-s) across e_{i-6} 18 .. 25 neighbor(-s) across c_{i-18}
[out]neighboring_quadsArray containing neighboring quad(-s) Needs to be empty, contains p4est_quadrant_t*. May be NULL, then neighboring_qids must not be NULL.
[out]neighboring_encsArray containing encodings for neighboring quads as described below Needs to be empty, contains int. CAUTION: Note, that the encodings differ from the encodings saved in the mesh. Positive values are for local quadrants, negative values indicate ghost quadrants. Faces: 1 .. 24 => same size neighbor (r * 6 + nf) + 1; nf = 0 .. 5 face index; r = 0 .. 3 relative orientation 25 .. 120 => double size neighbor 25 + h * 24 + r * 6 + nf; h = 0 .. 3 number of the subface; r, nf as above 121 .. 144 => half size neighbors 121 + r * 6 + nf; r, nf as above Edges: 1 .. 24 => same size neighbor r * 12 + ne + 1; ne = 0 .. 11 edge index; r = 0 .. 1 relative orientation 25 .. 72 => double size neighbor 25 + h * 24 + r * 12 + ne; h = 0 .. 1 number of the subedge; r, ne as above 73 .. 96 => half size neighbors 73 + r * 12 + ne; r, ne as above Corners: 1 .. 8 => nc + 1; nc = 0 .. 7 corner index
[out]neighboring_qidsArray containing quadrant ids for neighboring quadrants. May be NULL, then no neighboring qids are collected. If non-NULL the array needs to be empty and will contain int.

◆ p8est_mesh_get_quadrant()

p8est_quadrant_t * p8est_mesh_get_quadrant ( p8est_t p4est,
p8est_mesh_t mesh,
p4est_locidx_t  qid 
)

Access a process-local quadrant inside a forest.

Needs a mesh with populated quad_to_tree array. This is a special case of p8est_mesh_quadrant_cumulative.

Parameters
[in]p4estThe forest.
[in]meshThe mesh.
[in]qidProcess-local id of the quadrant (cumulative over trees).
Returns
A pointer to the requested quadrant.

◆ p8est_mesh_memory_used()

size_t p8est_mesh_memory_used ( p8est_mesh_t mesh)

Calculate the memory usage of the mesh structure.

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

◆ p8est_mesh_new()

p8est_mesh_t * p8est_mesh_new ( p8est_t p8est,
p8est_ghost_t ghost,
p8est_connect_type_t  btype 
)

Create a p8est_mesh structure.

This function does not populate the quad_to_tree and quad_level fields and ignores corner neighbors across edge-hanging corners. To populate them, use p8est_mesh_new_params.

Parameters
[in]p8estA forest that is fully 2:1 balanced.
[in]ghostThe ghost layer created from the provided p4est.
[in]btypeDetermines the highest codimension of neighbors.
Returns
A fully allocated mesh structure.

◆ p8est_mesh_new_params()

p8est_mesh_t * p8est_mesh_new_params ( p8est_t p8est,
p8est_ghost_t ghost,
p8est_mesh_params_t params 
)

Create a new mesh.

Parameters
[in]p8estA forest that is fully 2:1 balanced.
[in]ghostThe ghost layer created from the provided p4est.
[in]paramsThe mesh creation parameters. If NULL, the function defaults to the parameters of p8est_mesh_params_init.
Returns
A fully allocated mesh structure.

◆ p8est_mesh_params_init()

void p8est_mesh_params_init ( p8est_mesh_params_t params)

Initialize a default p8est_mesh_params_t structure.

The parameters are set to create the most basic mesh structure, without tree index and level lists and considering only face connections.

◆ p8est_mesh_quadrant_cumulative()

p8est_quadrant_t * p8est_mesh_quadrant_cumulative ( p8est_t p8est,
p8est_mesh_t mesh,
p4est_locidx_t  cumulative_id,
p4est_topidx_t which_tree,
p4est_locidx_t quadrant_id 
)

Find a quadrant based on its cumulative number in the local forest.

If the quad_to_tree field of the mesh structure exists, this is O(1). Otherwise, we perform a binary search over the processor-local trees.

Parameters
[in]p8estForest to be worked with.
[in]meshA mesh derived from the forest.
[in]cumulative_idCumulative index over all trees of quadrant. Must refer to a local (non-ghost) quadrant.
[in,out]which_treeIf not NULL, the input value can be -1 or an initial guess for the quadrant's tree and output is the tree of returned quadrant.
[out]quadrant_idIf not NULL, the number of quadrant in tree.
Returns
The identified quadrant.