p4est  2.8.7
p4est is a software library for parallel adaptive mesh refinement.
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Data Structures | Typedefs | Enumerations | Functions
p4est_geometry.h File Reference

Transform from tree-local "reference" coordinate system to global "physical space" coordinates. More...

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

Go to the source code of this file.

Data Structures

struct  p4est_geometry
 Encapsulates a custom transformation from tree-local coordinates to user defined physical space. More...
 

Typedefs

typedef struct p4est_geometry p4est_geometry_t
 This object encapsulates a custom geometry transformation.
 
typedef void(* p4est_geometry_X_t) (p4est_geometry_t *geom, p4est_topidx_t which_tree, const double abc[3], double xyz[3])
 Forward transformation from the tree-local coordinates to physical space. More...
 
typedef void(* p4est_geometry_destroy_t) (p4est_geometry_t *geom)
 Destructor prototype for a user-allocated p4est_geometry_t. More...
 

Enumerations

enum  pillow_disk_config_t {
  FIG32A = 0 ,
  FIG32B = 1 ,
  FIG32C = 2 ,
  FIG32D = 3
}
 Characterize different mappings of the disk using a 1-tree connectivity. More...
 

Functions

void p4est_geometry_transform_coordinates (p4est_geometry_t *geom, p4est_topidx_t which_tree, p4est_qcoord_t coords_in[2], double coords_out[3])
 Transform a quadrant reference coordinate into the geometry. More...
 
void p4est_geometry_destroy (p4est_geometry_t *geom)
 Can be used to conveniently destroy a geometry structure. More...
 
p4est_geometry_tp4est_geometry_new_connectivity (p4est_connectivity_t *conn)
 Create a geometry structure based on the vertices in a connectivity. More...
 
void p4est_geometry_connectivity_X (p4est_geometry_t *geom, p4est_topidx_t which_tree, const double abc[3], double xyz[3])
 Geometric coordinate transformation for geometry created with p4est_geometry_new_connectivity. More...
 
p4est_geometry_tp4est_geometry_new_icosahedron (p4est_connectivity_t *conn, double R)
 Create a geometry for mapping the sphere using 2d connectivity icosahedron. More...
 
p4est_geometry_tp4est_geometry_new_shell2d (p4est_connectivity_t *conn, double R2, double R1)
 Create a geometry for mapping the annulus. More...
 
p4est_geometry_tp4est_geometry_new_disk2d (p4est_connectivity_t *conn, double R0, double R1)
 Create disk2d geometry associated to disk2d connectivity. More...
 
p4est_geometry_tp4est_geometry_new_sphere2d (p4est_connectivity_t *conn, double R)
 Create sphere geometry associated to cubed connectivity. More...
 
p4est_geometry_tp4est_geometry_new_pillow (p4est_connectivity_t *conn, double R)
 Create a geometry for mapping the sphere using 2d connectivity pillow. More...
 
p4est_geometry_tp4est_geometry_new_pillow_disk (p4est_connectivity_t *conn, double R, pillow_disk_config_t config)
 Create a geometry for mapping the disk using 2d connectivity unit. More...
 
void p4est_geometry_coordinates_lnodes (p4est_t *p4est, p4est_lnodes_t *lnodes, const double *refloc, p4est_geometry_t *geom, sc_array_t *coordinates, sc_array_t *element_coordinates)
 Compute node coordinates for a p4est_lnodes structure. More...
 

Detailed Description

Transform from tree-local "reference" coordinate system to global "physical space" coordinates.

These are used in p4est_vtk.h to write global coordinate meshes to disk.

We provide several example geometries for use. You may also implement your own geometry as you see fit.

Note
For geometry purposes, each tree has the local coordinate system $[0,1]^d$. For legacy/p8est compatibility reasons the local coordinates are always represented as a triple abc[3]. For a 2D quadtree mesh the local coordinates are abc[0] and abc[1] and the third coordinate abc[2] should be ignored.

Typedef Documentation

◆ p4est_geometry_destroy_t

typedef void(* p4est_geometry_destroy_t) (p4est_geometry_t *geom)

Destructor prototype for a user-allocated p4est_geometry_t.

It is invoked by p4est_geometry_destroy. If the user chooses to reserve the structure statically, there is no need to provide it.

◆ p4est_geometry_X_t

typedef void(* p4est_geometry_X_t) (p4est_geometry_t *geom, p4est_topidx_t which_tree, const double abc[3], double xyz[3])

Forward transformation from the tree-local coordinates to physical space.

Note
The two-dimensional connectivities built into p4est have 3D vertex coordinates that can be used in the transformation if so desired. However, connectivities are not in general required to have vertex coordinate information.
Parameters
[in]geomassociated geometry
[in]which_treetree id inside forest
[in]abctree-local coordinates: $[0,1]^d$. For 2D meshes abc[2] should never be accessed.
[out]xyzcartesian coordinates in physical space after geometry

Enumeration Type Documentation

◆ pillow_disk_config_t

Characterize different mappings of the disk using a 1-tree connectivity.

The different mappings correspond to the ones used to produce figure 3.2 in the following publication:

"Logically rectangular grids and finite volume methods for PDEs in circular and spherical domains", Calhoun et al, SIAM Review, volume 50, Issue 4, January 2008. https://doi.org/10.1137/060664094

Examples
simple/simple2.c.

Function Documentation

◆ p4est_geometry_connectivity_X()

void p4est_geometry_connectivity_X ( p4est_geometry_t geom,
p4est_topidx_t  which_tree,
const double  abc[3],
double  xyz[3] 
)

Geometric coordinate transformation for geometry created with p4est_geometry_new_connectivity.

This is defined by tri/binlinear interpolation from vertex coordinates.

May also be used as a building block in custom geometric coordinate transforms. See for example p4est_geometry_new_sphere2d or p4est_geometry_new_disk2d.

Parameters
[in]geomassociated geometry
[in]which_treetree id inside forest
[in]abctree-local reference coordinates : [0,1]^3. Note: abc[2] is only accessed by the P4_TO_P8 version
[out]xyzCartesian coordinates in physical space after geometry
Warning
The associated geometry is assumed to have a connectivity as its *user field, and this connectivity is assumed to have vertex information in its *tree_to_vertex field.

◆ p4est_geometry_coordinates_lnodes()

void p4est_geometry_coordinates_lnodes ( p4est_t p4est,
p4est_lnodes_t lnodes,
const double *  refloc,
p4est_geometry_t geom,
sc_array_t *  coordinates,
sc_array_t *  element_coordinates 
)

Compute node coordinates for a p4est_lnodes structure.

Presently we allow for an lnodes degree of 1 or 2. Cubic or higher degrees may be transparently enabled in the future.

The simple mode assigns one tree reference coordinate to each lnode. This may not be suitable for visualizing periodic connectivities.

In a more advanced mode indicated by NULL element_coordinates input, the coordinates are made unique by reference location: If a tree is periodic, for example, its corners reference the same lnode but will generate separate coordinate entries for proper visualization. There will be more coordinates generated than there are lnodes.

The coordinate numbers generated by the present version of the function are partition-dependent. This may be seen as a flaw. Looking into it.

Parameters
[in]p4estA valid forest structure.
[in]lnodesA valid p4est_lnodes structure of degree 1 or 2. Higher degrees not presently allowed. Must be derived from the p4est.
[in]reflocEventually used for cubic and upwards degrees. We will expect degree + 1 many values for the one-dimensional reference node spacing. Out of these, the indices from 1 to (degree - 1) / 2 inclusive will be accessed by this function. The others default by symmetry considerations.
[in]geomMay be NULL for generating the tree-reference coordinates, or a valid geometry object for transforming the reference into mapped space.
[in,out]coordinatesOn input, an array with entries of 3 double variables each. Resized in this function and populated with coordinate tuples. With a NULL geometry, these are in [0, 1]**2. Otherwise, they are mapped by the geometry.
[in,out]element_coordinatesThis may be NULL, in which case we generate one coordinate tuple for each lnode. Otherwise, this must be an array with entries of type p4est_locidx_t. Is resized to the same number of entries as lnodes->element_nodes. Its entries point into the coordinates array. The tree index of any given entry is implicit in that this array is derived from a p4est, where sets of (degree + 1)**2 entries each correspond to the forest elements in order.

◆ p4est_geometry_destroy()

void p4est_geometry_destroy ( p4est_geometry_t geom)

Can be used to conveniently destroy a geometry structure.

The user is free not to call this function at all if they handle the memory of the p4est_geometry_t in their own way.

Examples
simple/simple2.c, and userdata/userdata2.c.

◆ p4est_geometry_new_connectivity()

p4est_geometry_t* p4est_geometry_new_connectivity ( p4est_connectivity_t conn)

Create a geometry structure based on the vertices in a connectivity.

The transformation is constructed using bilinear interpolation.

Parameters
[in]connA connectivity with vertex coordinate information. We do not take ownership and expect this structure to stay alive.
Returns
Geometry structure; use with p4est_geometry_destroy.
Examples
userdata/userdata2.c.

◆ p4est_geometry_new_disk2d()

p4est_geometry_t* p4est_geometry_new_disk2d ( p4est_connectivity_t conn,
double  R0,
double  R1 
)

Create disk2d geometry associated to disk2d connectivity.

Parameters
[in]connThe result of p4est_connectivity_new_disk2d.
[in]R0radius of the inner circle.
[in]R1radius of the outer circle (external border).

This geometry is meant to be used with the disk2d connectivity, which is a 5-tree connectivity to map the spherical disk.

Examples
simple/simple2.c, and userdata/userdata2.c.

◆ p4est_geometry_new_icosahedron()

p4est_geometry_t* p4est_geometry_new_icosahedron ( p4est_connectivity_t conn,
double  R 
)

Create a geometry for mapping the sphere using 2d connectivity icosahedron.

Parameters
[in]connThe result of p4est_connectivity_new_icosahedron.
[in]RThe radius of the sphere.
Examples
simple/simple2.c, and userdata/userdata2.c.

◆ p4est_geometry_new_pillow()

p4est_geometry_t* p4est_geometry_new_pillow ( p4est_connectivity_t conn,
double  R 
)

Create a geometry for mapping the sphere using 2d connectivity pillow.

Parameters
[in]connThe result of p4est_connectivity_new_pillow.
[in]RThe radius of the sphere.
Examples
simple/simple2.c.

◆ p4est_geometry_new_pillow_disk()

p4est_geometry_t* p4est_geometry_new_pillow_disk ( p4est_connectivity_t conn,
double  R,
pillow_disk_config_t  config 
)

Create a geometry for mapping the disk using 2d connectivity unit.

See companion routine p8est_geometry_new_pillow_sphere which maps the 3d solid sphere using 1-tree unit connectivity.

Parameters
[in]connThe result of p4est_connectivity_new_unitsquare.
[in]RThe radius of the disk.
[in]configThe configuration to identify a mapping variant.
Examples
simple/simple2.c.

◆ p4est_geometry_new_shell2d()

p4est_geometry_t* p4est_geometry_new_shell2d ( p4est_connectivity_t conn,
double  R2,
double  R1 
)

Create a geometry for mapping the annulus.

This a direct adaptation of geometric shell in 3d.

Parameters
[in]connThe result of p4est_connectivity_new_shell2d.
[in]R1radius of the inner circle (internal border).
[in]R2radius of the outer circle (external border).
Examples
simple/simple2.c.

◆ p4est_geometry_new_sphere2d()

p4est_geometry_t* p4est_geometry_new_sphere2d ( p4est_connectivity_t conn,
double  R 
)

Create sphere geometry associated to cubed connectivity.

Parameters
[in]connThe result of p4est_connectivity_new_cubed.
[in]Rradius of the sphere

This geometry is meant to be used with the cubed connectivity p4est_connectivity_new_cubed, which is a 6-tree connectivity, to map the sphere.

Examples
simple/simple2.c.

◆ p4est_geometry_transform_coordinates()

void p4est_geometry_transform_coordinates ( p4est_geometry_t geom,
p4est_topidx_t  which_tree,
p4est_qcoord_t  coords_in[2],
double  coords_out[3] 
)

Transform a quadrant reference coordinate into the geometry.

Parameters
[in]geomProperly initialized geometry object.
[in]which_treeValid tree number relative to the connectivity that is underlying the geometry.
[in]coords_inValid quadrant reference coordinates. They must be in [0, P4EST_ROOT_LEN]^2.
[out]coords_outCoordinates in the physical geometry.
Examples
simple/simple2.c, and userdata/userdata_run2.c.