p4est
1.0
|
Interface routines with extended capabilities. More...
Go to the source code of this file.
Data Structures | |
struct | p4est_inspect_t |
Data pertaining to selecting, inspecting, and profiling algorithms. More... | |
Typedefs | |
typedef void(* | p4est_replace_t )(p4est_t *p4est, p4est_topidx_t which_tree, int num_outgoing, p4est_quadrant_t *outgoing[], int num_incoming, p4est_quadrant_t *incoming[]) |
Callback function prototype to replace one set of quadrants with another. | |
Functions | |
p4est_t * | p4est_new_ext (sc_MPI_Comm mpicomm, p4est_connectivity_t *connectivity, p4est_locidx_t min_quadrants, int min_level, int fill_uniform, size_t data_size, p4est_init_t init_fn, void *user_pointer) |
Create a new forest. | |
void | p4est_refine_ext (p4est_t *p4est, int refine_recursive, int maxlevel, p4est_refine_t refine_fn, p4est_init_t init_fn, p4est_replace_t replace_fn) |
Refine a forest with a bounded refinement level and a replace option. | |
void | p4est_coarsen_ext (p4est_t *p4est, int coarsen_recursive, int callback_orphans, p4est_coarsen_t coarsen_fn, p4est_init_t init_fn, p4est_replace_t replace_fn) |
Coarsen a forest. | |
void | p4est_balance_ext (p4est_t *p4est, p4est_connect_type_t btype, p4est_init_t init_fn, p4est_replace_t replace_fn) |
2:1 balance the size differences of neighboring elements in a forest. | |
void | p4est_balance_subtree_ext (p4est_t *p4est, p4est_connect_type_t btype, p4est_topidx_t which_tree, p4est_init_t init_fn, p4est_replace_t replace_fn) |
p4est_gloidx_t | p4est_partition_ext (p4est_t *p4est, int partition_for_coarsening, p4est_weight_t weight_fn) |
Repartition the forest. | |
void | p4est_iterate_ext (p4est_t *p4est, p4est_ghost_t *ghost_layer, void *user_data, p4est_iter_volume_t iter_volume, p4est_iter_face_t iter_face, p4est_iter_corner_t iter_corner, int remote) |
p4est_iterate_ext adds the option remote: if this is false, then it is the same as p4est_iterate; if this is true, then corner callbacks are also called on corners for hanging faces touched by local quadrants. | |
void | p4est_save_ext (const char *filename, p4est_t *p4est, int save_data, int save_partition) |
Save the complete connectivity/p4est data to disk. | |
p4est_t * | p4est_load_ext (const char *filename, sc_MPI_Comm mpicomm, size_t data_size, int load_data, int autopartition, int broadcasthead, void *user_pointer, p4est_connectivity_t **connectivity) |
Load the complete connectivity/p4est structure from disk. | |
p4est_t * | p4est_source_ext (sc_io_source_t *src, sc_MPI_Comm mpicomm, size_t data_size, int load_data, int autopartition, int broadcasthead, void *user_pointer, p4est_connectivity_t **connectivity) |
The same as p4est_load_ext, but reading the connectivity/p4est from an open sc_io_source_t stream. |
Interface routines with extended capabilities.
typedef void(* p4est_replace_t)(p4est_t *p4est, p4est_topidx_t which_tree, int num_outgoing, p4est_quadrant_t *outgoing[], int num_incoming, p4est_quadrant_t *incoming[]) |
Callback function prototype to replace one set of quadrants with another.
This is used by extended routines when the quadrants of an existing, valid p4est are changed. The callback allows the user to make changes to newly initialized quadrants before the quadrants that they replace are destroyed.
[in] | num_outgoing | The number of outgoing quadrants. |
[in] | outgoing | The outgoing quadrants: after the callback, the user_data, if p4est->data_size is nonzero, will be destroyed. |
[in] | num_incoming | The number of incoming quadrants. |
[in,out] | incoming | The incoming quadrants: prior to the callback, the user_data, if p4est->data_size is nonzero, is allocated, and the p4est_init_t callback, if it has been provided, will be called. |
If the mesh is being refined, num_outgoing will be 1 and num_incoming will be 4, and vice versa if the mesh is being coarsened.
void p4est_balance_ext | ( | p4est_t * | p4est, |
p4est_connect_type_t | btype, | ||
p4est_init_t | init_fn, | ||
p4est_replace_t | replace_fn | ||
) |
2:1 balance the size differences of neighboring elements in a forest.
[in,out] | p4est | The p4est to be worked on. |
[in] | btype | Balance type (face or corner/full). Corner balance is almost never required when discretizing a PDE; just causes smoother mesh grading. |
[in] | init_fn | Callback function to initialize the user_data which is already allocated automatically. |
[in] | replace_fn | Callback function that allows the user to change incoming quadrants based on the quadrants they replace. |
void p4est_coarsen_ext | ( | p4est_t * | p4est, |
int | coarsen_recursive, | ||
int | callback_orphans, | ||
p4est_coarsen_t | coarsen_fn, | ||
p4est_init_t | init_fn, | ||
p4est_replace_t | replace_fn | ||
) |
Coarsen a forest.
[in,out] | p4est | The forest is changed in place. |
[in] | coarsen_recursive | Boolean to decide on recursive coarsening. |
[in] | callback_orphans | Boolean to enable calling coarsen_fn even on non-families. In this case, the second quadrant pointer in the argument list of the callback is NULL, subsequent pointers are undefined, and the return value is ignored. If coarsen_recursive is true, it is possible that a quadrant is called once or more as an orphan and eventually becomes part of a family. |
[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. |
[in] | replace_fn | Callback function that allows the user to change incoming quadrants based on the quadrants they replace. |
void p4est_iterate_ext | ( | p4est_t * | p4est, |
p4est_ghost_t * | ghost_layer, | ||
void * | user_data, | ||
p4est_iter_volume_t | iter_volume, | ||
p4est_iter_face_t | iter_face, | ||
p4est_iter_corner_t | iter_corner, | ||
int | remote | ||
) |
p4est_iterate_ext adds the option remote: if this is false, then it is the same as p4est_iterate; if this is true, then corner callbacks are also called on corners for hanging faces touched by local quadrants.
initialize arrays that keep track of where we are in the search
we have to loop over all trees and not just local trees because of the ghost layer
p4est_t* p4est_load_ext | ( | const char * | filename, |
sc_MPI_Comm | mpicomm, | ||
size_t | data_size, | ||
int | load_data, | ||
int | autopartition, | ||
int | broadcasthead, | ||
void * | user_pointer, | ||
p4est_connectivity_t ** | connectivity | ||
) |
Load the complete connectivity/p4est structure from disk.
It is possible to load the file with a different number of processors than has been used to write it. The partition will then be uniform.
[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] | autopartition | Ignore saved partition and make it uniform. |
[in] | broadcasthead | Have only rank 0 read headers and bcast them. |
[in] | user_pointer | Assign to the user_pointer member of the p4est before init_fn is called the first time. |
[out] | connectivity | Connectivity must be destroyed separately. |
p4est_t* p4est_new_ext | ( | sc_MPI_Comm | mpicomm, |
p4est_connectivity_t * | connectivity, | ||
p4est_locidx_t | min_quadrants, | ||
int | min_level, | ||
int | fill_uniform, | ||
size_t | data_size, | ||
p4est_init_t | init_fn, | ||
void * | user_pointer | ||
) |
Create a new forest.
This is a more general form of p4est_new. See the documentation of p4est_new for basic usage.
[in] | min_quadrants | Minimum initial quadrants per processor. Makes the refinement pattern mpisize-specific. |
[in] | min_level | The forest is refined at least to this level. May be negative or 0, then it has no effect. |
[in] | fill_uniform | If true, fill the forest with a uniform mesh instead of the coarsest possible one. The latter is partition-specific so that is usually not a good idea. |
p4est_gloidx_t p4est_partition_ext | ( | p4est_t * | p4est, |
int | partition_for_coarsening, | ||
p4est_weight_t | weight_fn | ||
) |
Repartition the forest.
The forest is partitioned between processors such that each processor has an approximately equal number of quadrants (or weight).
[in,out] | p4est | The forest that will be partitioned. |
[in] | partition_for_coarsening | If true, the partition is modified to allow one level of coarsening. |
[in] | weight_fn | A weighting function or NULL for uniform partitioning. |
void p4est_refine_ext | ( | p4est_t * | p4est, |
int | refine_recursive, | ||
int | maxlevel, | ||
p4est_refine_t | refine_fn, | ||
p4est_init_t | init_fn, | ||
p4est_replace_t | replace_fn | ||
) |
Refine a forest with a bounded refinement level and a replace option.
[in,out] | p4est | The forest is changed in place. |
[in] | refine_recursive | Boolean to decide on recursive refinement. |
[in] | maxlevel | Maximum allowed refinement level (inclusive). If this is negative the level is restricted only by the compile-time constant QMAXLEVEL in p4est.h. |
[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 or replace_fn gets called. |
[in] | init_fn | Callback function to initialize the user_data for newly created quadrants, which is guaranteed to be allocated. This function pointer may be NULL. |
[in] | replace_fn | Callback function that allows the user to change incoming quadrants based on the quadrants they replace; may be NULL. |
void p4est_save_ext | ( | const char * | filename, |
p4est_t * | p4est, | ||
int | save_data, | ||
int | save_partition | ||
) |
Save the complete connectivity/p4est 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. See p4est_load_ext for information on the autopartition parameter.
[in] | filename | Name of the file to write. |
[in] | p4est | Valid forest structure. |
[in] | save_data | If true, the element data is saved. Otherwise, a data size of 0 is saved. |
[in] | save_partition | If false, save file as if 1 core was used. If true, save core count and partition. Advantage: Partition can be recovered on loading with same mpisize and autopartition false. Disadvantage: Makes the file depend on mpisize. Either way the file can be loaded with autopartition true. |