p4est
1.0
|
The top-level 3D p8est interface. More...
#include <p8est_connectivity.h>
Go to the source code of this file.
Data Structures | |
struct | p8est_quadrant_t |
The 3D quadrant (i.e. More... | |
union | p8est_quadrant_t::p8est_quadrant_data |
struct | p8est_tree_t |
The p8est tree datatype. More... | |
struct | p8est_t |
The p8est forest datatype. More... | |
Defines | |
#define | P8EST_MAXLEVEL 19 |
The finest level of the octree for representing nodes. | |
#define | P8EST_QMAXLEVEL 18 |
The finest level of the octree for representing octants. | |
#define | P8EST_ROOT_LEN ((p4est_qcoord_t) 1 << P8EST_MAXLEVEL) |
The length of a side of the root quadrant. | |
#define | P8EST_QUADRANT_LEN(l) ((p4est_qcoord_t) 1 << (P8EST_MAXLEVEL - (l))) |
The length of a quadrant of level l. | |
#define | P8EST_LAST_OFFSET(l) (P8EST_ROOT_LEN - P8EST_QUADRANT_LEN (l)) |
The offset of the highest (farthest from the origin) quadrant at level l. | |
#define | P8EST_QUADRANT_INIT(q) ((void) memset ((q), -1, sizeof (p8est_quadrant_t))) |
set statically allocated quadrant to defined values | |
Typedefs | |
typedef void(* | p8est_init_t )(p8est_t *p8est, p4est_topidx_t which_tree, p8est_quadrant_t *quadrant) |
Callback function prototype to initialize the quadrant's user data. | |
typedef int(* | p8est_refine_t )(p8est_t *p8est, p4est_topidx_t which_tree, p8est_quadrant_t *quadrant) |
Callback function prototype to decide for refinement. | |
typedef int(* | p8est_coarsen_t )(p8est_t *p8est, p4est_topidx_t which_tree, p8est_quadrant_t *quadrants[]) |
Callback function prototype to decide for coarsening. | |
typedef int(* | p8est_weight_t )(p8est_t *p8est, p4est_topidx_t which_tree, p8est_quadrant_t *quadrant) |
Callback function prototype to calculate weights for partitioning. | |
Functions | |
size_t | p8est_memory_used (p8est_t *p8est) |
Calculate memory usage of a forest structure. | |
void | p8est_qcoord_to_vertex (p8est_connectivity_t *connectivity, p4est_topidx_t treeid, p4est_qcoord_t x, p4est_qcoord_t y, p4est_qcoord_t z, double vxyz[3]) |
Transform a quadrant coordinate into the space spanned by tree vertices. | |
p8est_t * | p8est_new (sc_MPI_Comm mpicomm, p8est_connectivity_t *connectivity, size_t data_size, p8est_init_t init_fn, void *user_pointer) |
Create a new forest. | |
void | p8est_destroy (p8est_t *p8est) |
Destroy a p8est. | |
p8est_t * | p8est_copy (p8est_t *input, int copy_data) |
Make a deep copy of a p8est. | |
void | p8est_reset_data (p8est_t *p8est, size_t data_size, p8est_init_t init_fn, void *user_pointer) |
Reset user pointer and element data. | |
void | p8est_refine (p8est_t *p8est, int refine_recursive, p8est_refine_t refine_fn, p8est_init_t init_fn) |
Refine a forest. | |
void | p8est_coarsen (p8est_t *p8est, int coarsen_recursive, p8est_coarsen_t coarsen_fn, p8est_init_t init_fn) |
Coarsen a forest. | |
void | p8est_balance (p8est_t *p8est, p8est_connect_type_t btype, p8est_init_t init_fn) |
2:1 balance the size differences of neighboring elements in a forest. | |
void | p8est_partition (p8est_t *p8est, int allow_for_coarsening, p8est_weight_t weight_fn) |
Equally partition the forest. | |
unsigned | p8est_checksum (p8est_t *p8est) |
Compute the checksum for a forest. | |
void | p8est_save (const char *filename, p8est_t *p8est, int save_data) |
Save the complete connectivity/p8est data to disk. | |
p8est_t * | p8est_load (const char *filename, sc_MPI_Comm mpicomm, size_t data_size, int load_data, void *user_pointer, p8est_connectivity_t **connectivity) |
Load the complete connectivity/p8est structure from disk. | |
static p8est_tree_t * | p8est_tree_array_index (sc_array_t *array, p4est_topidx_t it) |
Return a pointer to an array element indexed by a p4est_topidx_t. | |
static p8est_quadrant_t * | p8est_quadrant_array_index (sc_array_t *array, size_t it) |
Return a pointer to a quadrant array element indexed by a size_t. | |
static p8est_quadrant_t * | p8est_quadrant_array_push (sc_array_t *array) |
Call sc_array_push for a quadrant array. | |
static p8est_quadrant_t * | p8est_quadrant_mempool_alloc (sc_mempool_t *mempool) |
Call sc_mempool_alloc for a mempool creating quadrants. | |
static p8est_quadrant_t * | p8est_quadrant_list_pop (sc_list_t *list) |
Call sc_list pop for a quadrant array. | |
Variables | |
void * | P8EST_DATA_UNINITIALIZED |
const int | p8est_num_ranges |
The top-level 3D p8est interface.
typedef int(* p8est_coarsen_t)(p8est_t *p8est, p4est_topidx_t which_tree, p8est_quadrant_t *quadrants[]) |
Callback function prototype to decide for coarsening.
[in] | p8est | the forest |
[in] | which_tree | the tree containing quadrant |
[in] | quadrants | Pointers to 8 siblings in Morton ordering. |
typedef void(* p8est_init_t)(p8est_t *p8est, p4est_topidx_t which_tree, p8est_quadrant_t *quadrant) |
Callback function prototype to initialize the quadrant's user data.
[in] | p8est | the forest |
[in] | which_tree | the tree containing quadrant |
[in,out] | quadrant | the quadrant to be initialized: if data_size > 0, the data to be initialized is at quadrant->p.user_data; otherwise, the non-pointer user data (such as quadrant->p.user_int) can be initialized |
typedef int(* p8est_refine_t)(p8est_t *p8est, p4est_topidx_t which_tree, p8est_quadrant_t *quadrant) |
Callback function prototype to decide for refinement.
[in] | p8est | the forest |
[in] | which_tree | the tree containing quadrant |
[in] | quadrant | the quadrant that may be refined |
typedef int(* p8est_weight_t)(p8est_t *p8est, p4est_topidx_t which_tree, p8est_quadrant_t *quadrant) |
Callback function prototype to calculate weights for partitioning.
[in] | p8est | the forest |
[in] | which_tree | the tree containing quadrant |
void p8est_balance | ( | p8est_t * | p8est, |
p8est_connect_type_t | btype, | ||
p8est_init_t | init_fn | ||
) |
2:1 balance the size differences of neighboring elements in a forest.
[in,out] | p8est | The p8est to be worked on. |
[in] | btype | Balance type (face, edge, or corner/full). Examples: Finite volume or discontinous Galerkin methods only require face balance. Continuous finite element methods usually require edge balance. Corner balance is almost never required mathematically; it just produces a smoother mesh grading. |
[in] | init_fn | Callback function to initialize the user_data which is already allocated automatically. |
unsigned p8est_checksum | ( | p8est_t * | p8est | ) |
Compute the checksum for a forest.
Based on quadrant arrays only. It is independent of partition and mpisize.
void p8est_coarsen | ( | p8est_t * | p8est, |
int | coarsen_recursive, | ||
p8est_coarsen_t | coarsen_fn, | ||
p8est_init_t | init_fn | ||
) |
Coarsen a forest.
[in,out] | p8est | The forest is changed in place. |
[in] | coarsen_recursive | Boolean to decide on recursive coarsening. |
[in] | coarsen_fn | Callback function that returns true if a family of quadrants shall be coarsened |
[in] | init_fn | Callback function to initialize the user_data which is already allocated automatically. |
p8est_t* p8est_copy | ( | p8est_t * | input, |
int | copy_data | ||
) |
Make a deep copy of a p8est.
The connectivity is not duplicated. Copying of quadrant user data is optional. If old and new data sizes are 0, the user_data field is copied regardless. The inspect member of the copy is set to NULL.
[in] | copy_data | If true, data are copied. If false, data_size is set to 0. |
void p8est_destroy | ( | p8est_t * | p8est | ) |
Destroy a p8est.
p8est_t* p8est_load | ( | const char * | filename, |
sc_MPI_Comm | mpicomm, | ||
size_t | data_size, | ||
int | load_data, | ||
void * | user_pointer, | ||
p8est_connectivity_t ** | connectivity | ||
) |
Load the complete connectivity/p8est structure from disk.
This is a collective operation that all MPI processes need to call. All processes read from the same file, so the filename given needs to be identical over all parallel invocations.
By default, a file can only be loaded with the same number of processors that it was stored with. The defaults can be changed with p8est_load_ext() in p8est_extended.h.
[in] | filename | Name of the file to read. |
[in] | mpicomm | A valid MPI communicator. |
[in] | data_size | Size of data for each quadrant which can be zero. Then user_data_pool is set to NULL. If data_size is zero, load_data is ignored. |
[in] | load_data | If true, the element data is loaded. This is only permitted if the saved data size matches. If false, the stored data size is ignored. |
[in] | user_pointer | Assign to the user_pointer member of the p8est before init_fn is called the first time. |
[out] | connectivity | Connectivity must be destroyed separately. |
size_t p8est_memory_used | ( | p8est_t * | p8est | ) |
Calculate memory usage of a forest structure.
The connectivity structure is not counted since it is not owned; use p8est_connectivity_memory_usage (p8est->connectivity).
[in] | p8est | Forest structure. |
p8est_t* p8est_new | ( | sc_MPI_Comm | mpicomm, |
p8est_connectivity_t * | connectivity, | ||
size_t | data_size, | ||
p8est_init_t | init_fn, | ||
void * | user_pointer | ||
) |
Create a new forest.
The new forest consists of equi-partitioned root quadrants. When there are more processors than trees, some processors are empty.
[in] | mpicomm | A valid MPI communicator. |
[in] | connectivity | This is the connectivity information that the forest is built with. Note the p8est does not take ownership of the memory. |
[in] | data_size | This is the size of data for each quadrant which can be zero. Then user_data_pool is set to NULL. |
[in] | init_fn | Callback function to initialize the user_data which is already allocated automatically. |
[in] | user_pointer | Assign to the user_pointer member of the p8est before init_fn is called the first time. |
void p8est_partition | ( | p8est_t * | p8est, |
int | allow_for_coarsening, | ||
p8est_weight_t | weight_fn | ||
) |
Equally partition the forest.
The partition can be by element count or by a user-defined weight.
The forest will be partitioned between processors such that they have an approximately equal number of quadrants (or sum of weights).
[in,out] | p8est | The forest that will be partitioned. |
[in] | allow_for_coarsening | Slightly modify partition such that quadrant families are not split between ranks. |
[in] | weight_fn | A weighting function or NULL for uniform partitioning. |
void p8est_qcoord_to_vertex | ( | p8est_connectivity_t * | connectivity, |
p4est_topidx_t | treeid, | ||
p4est_qcoord_t | x, | ||
p4est_qcoord_t | y, | ||
p4est_qcoord_t | z, | ||
double | vxyz[3] | ||
) |
Transform a quadrant coordinate into the space spanned by tree vertices.
[in] | connectivity | Connectivity must provide the vertices. |
[in] | treeid | Identify the tree that contains x, y, z. |
[in] | x,y,z | Quadrant coordinates relative to treeid. |
[out] | vxyz | Transformed coordinates in vertex space. |
static p8est_quadrant_t* p8est_quadrant_array_index | ( | sc_array_t * | array, |
size_t | it | ||
) | [inline, static] |
Return a pointer to a quadrant array element indexed by a size_t.
static p8est_quadrant_t* p8est_quadrant_array_push | ( | sc_array_t * | array | ) | [inline, static] |
Call sc_array_push for a quadrant array.
static p8est_quadrant_t* p8est_quadrant_list_pop | ( | sc_list_t * | list | ) | [inline, static] |
Call sc_list pop for a quadrant array.
static p8est_quadrant_t* p8est_quadrant_mempool_alloc | ( | sc_mempool_t * | mempool | ) | [inline, static] |
Call sc_mempool_alloc for a mempool creating quadrants.
void p8est_refine | ( | p8est_t * | p8est, |
int | refine_recursive, | ||
p8est_refine_t | refine_fn, | ||
p8est_init_t | init_fn | ||
) |
Refine a forest.
[in,out] | p8est | The forest is changed in place. |
[in] | refine_recursive | Boolean to decide on recursive refinement. |
[in] | refine_fn | Callback function that must return true if a quadrant shall be refined. If refine_recursive is true, refine_fn is called for every existing and newly created quadrant. Otherwise, it is called for every existing quadrant. It is possible that a refinement request made by the callback is ignored. To catch this case, you can examine whether init_fn gets called, or use p8est_refine_ext in p8est_extended.h and examine whether replace_fn gets called. |
[in] | init_fn | Callback function to initialize the user_data of newly created quadrants, which is already allocated. This function pointer may be NULL. |
void p8est_reset_data | ( | p8est_t * | p8est, |
size_t | data_size, | ||
p8est_init_t | init_fn, | ||
void * | user_pointer | ||
) |
Reset user pointer and element data.
When the data size is changed the quadrant data is freed and allocated. The initialization callback is invoked on each quadrant. Old user_data content is disregarded.
[in] | data_size | This is the size of data for each quadrant which can be zero. Then user_data_pool is set to NULL. |
[in] | init_fn | Callback function to initialize the user_data which is already allocated automatically. May be NULL. |
[in] | user_pointer | Assign to the user_pointer member of the p8est before init_fn is called the first time. |
void p8est_save | ( | const char * | filename, |
p8est_t * | p8est, | ||
int | save_data | ||
) |
Save the complete connectivity/p8est data to disk.
This is a collective operation that all MPI processes need to call. All processes write into the same file, so the filename given needs to be identical over all parallel invocations.
By default, we write the current processor count and partition into the file header. This makes the file depend on mpisize. For changing this see p8est_save_ext() in p8est_extended.h.
[in] | filename | Name of the file to write. |
[in] | p8est | Valid forest structure. |
[in] | save_data | If true, the element data is saved. Otherwise, a data size of 0 is saved. |
static p8est_tree_t* p8est_tree_array_index | ( | sc_array_t * | array, |
p4est_topidx_t | it | ||
) | [inline, static] |
Return a pointer to an array element indexed by a p4est_topidx_t.
[in] | index | needs to be in [0]..[elem_count-1]. |