p4est 2.8.6
p4est is a software library for parallel adaptive mesh refinement.
Functions
p6est_extended.h File Reference

Interface routines with extended capabilities. More...

#include <p6est.h>
Include dependency graph for p6est_extended.h:

Go to the source code of this file.

Functions

p6est_tp6est_new_ext (sc_MPI_Comm mpicomm, p6est_connectivity_t *connectivity, p4est_locidx_t min_quadrants, int min_level, int min_zlevel, int num_zroot, int fill_uniform, size_t data_size, p6est_init_t init_fn, void *user_pointer)
 Create a new forest. More...
 
p6est_tp6est_copy_ext (p6est_t *input, int copy_data, int duplicate_mpicomm)
 Make a deep copy of a p6est. More...
 
void p6est_save_ext (const char *filename, p6est_t *p6est, int save_data, int save_partition)
 Save the complete connectivity/p6est data to disk. More...
 
p6est_tp6est_load_ext (const char *filename, sc_MPI_Comm mpicomm, size_t data_size, int load_data, int autopartition, int broadcasthead, void *user_pointer, p6est_connectivity_t **connectivity)
 Load the complete connectivity/p6est structure from disk. More...
 
void p6est_refine_columns_ext (p6est_t *p6est, int refine_recursive, int maxlevel, p6est_refine_column_t refine_fn, p6est_init_t init_fn, p6est_replace_t replace_fn)
 Horizontally refine a forest with a bounded refinement level and a replace option. More...
 
void p6est_refine_layers_ext (p6est_t *p6est, int refine_recursive, int maxlevel, p6est_refine_layer_t refine_fn, p6est_init_t init_fn, p6est_replace_t replace_fn)
 Vertically refine a forest with a bounded refinement level and a replace option. More...
 
void p6est_coarsen_columns_ext (p6est_t *p6est, int coarsen_recursive, int callback_orphans, p6est_coarsen_column_t coarsen_fn, p6est_init_t init_fn, p6est_replace_t replace_fn)
 Horizontally coarsen a forest. More...
 
void p6est_coarsen_layers_ext (p6est_t *p6est, int coarsen_recursive, int callback_orphans, p6est_coarsen_layer_t coarsen_fn, p6est_init_t init_fn, p6est_replace_t replace_fn)
 Vertically coarsen a forest. More...
 
p4est_gloidx_t p6est_partition_ext (p6est_t *p6est, int partition_for_coarsening, p6est_weight_t weight_fn)
 Repartition the forest. More...
 
void p6est_balance_ext (p6est_t *p6est, p8est_connect_type_t btype, int max_diff, int min_diff, p6est_init_t init_fn, p6est_replace_t replace_fn)
 2:1 balance the size differences of neighboring elements in a forest. More...
 

Detailed Description

Interface routines with extended capabilities.

Function Documentation

◆ p6est_balance_ext()

void p6est_balance_ext ( p6est_t p6est,
p8est_connect_type_t  btype,
int  max_diff,
int  min_diff,
p6est_init_t  init_fn,
p6est_replace_t  replace_fn 
)

2:1 balance the size differences of neighboring elements in a forest.

Parameters
[in,out]p6estThe p6est to be worked on.
[in]btypeBalance type (face or corner/full). Corner balance is almost never required when discretizing a PDE; just causes smoother mesh grading.
[in]max_diffThe maximum difference between the horizontal refinement level and the vertical refinement level
[in]min_diffThe minimum difference between the horizontal refinement level and the vertical refinement level
[in]init_fnCallback function to initialize the user_data which is already allocated automatically.
[in]replace_fnCallback function that allows the user to change incoming quadrants based on the quadrants they replace.

◆ p6est_coarsen_columns_ext()

void p6est_coarsen_columns_ext ( p6est_t p6est,
int  coarsen_recursive,
int  callback_orphans,
p6est_coarsen_column_t  coarsen_fn,
p6est_init_t  init_fn,
p6est_replace_t  replace_fn 
)

Horizontally coarsen a forest.

Parameters
[in,out]p6estThe forest is changed in place.
[in]coarsen_recursiveBoolean to decide on recursive coarsening.
[in]callback_orphansBoolean 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_fnCallback function that returns true if a family of quadrants shall be coarsened.
[in]init_fnCallback function to initialize the user_data which is already allocated automatically.
[in]replace_fnCallback function that allows the user to change incoming quadrants based on the quadrants they replace.

◆ p6est_coarsen_layers_ext()

void p6est_coarsen_layers_ext ( p6est_t p6est,
int  coarsen_recursive,
int  callback_orphans,
p6est_coarsen_layer_t  coarsen_fn,
p6est_init_t  init_fn,
p6est_replace_t  replace_fn 
)

Vertically coarsen a forest.

Parameters
[in,out]p6estThe forest is changed in place.
[in]coarsen_recursiveBoolean to decide on recursive coarsening.
[in]callback_orphansBoolean 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_fnCallback function that returns true if a family of quadrants shall be coarsened.
[in]init_fnCallback function to initialize the user_data which is already allocated automatically.
[in]replace_fnCallback function that allows the user to change incoming quadrants based on the quadrants they replace.

◆ p6est_copy_ext()

p6est_t * p6est_copy_ext ( p6est_t input,
int  copy_data,
int  duplicate_mpicomm 
)

Make a deep copy of a p6est.

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.

Parameters
[in]copy_dataIf true, data are copied. If false, data_size is set to 0.
[in]duplicate_mpicommIf true, MPI communicator is copied.
Returns
Returns a valid p6est that does not depend on the input.

◆ p6est_load_ext()

p6est_t * p6est_load_ext ( const char *  filename,
sc_MPI_Comm  mpicomm,
size_t  data_size,
int  load_data,
int  autopartition,
int  broadcasthead,
void *  user_pointer,
p6est_connectivity_t **  connectivity 
)

Load the complete connectivity/p6est 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.

Parameters
[in]filenameName of the file to read.
[in]mpicommA valid MPI communicator.
[in]data_sizeSize 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_dataIf 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]autopartitionIgnore saved partition and make it uniform.
[in]broadcastheadHave only rank 0 read headers and bcast them.
[in]user_pointerAssign to the user_pointer member of the p6est before init_fn is called the first time.
[out]connectivityConnectivity must be destroyed separately.
Returns
Returns a valid forest structure. A pointer to a valid connectivity structure is returned through the last argument.
Note
Aborts on file errors or invalid file contents.

◆ p6est_new_ext()

p6est_t * p6est_new_ext ( sc_MPI_Comm  mpicomm,
p6est_connectivity_t connectivity,
p4est_locidx_t  min_quadrants,
int  min_level,
int  min_zlevel,
int  num_zroot,
int  fill_uniform,
size_t  data_size,
p6est_init_t  init_fn,
void *  user_pointer 
)

Create a new forest.

This is a more general form of p6est_new(). See the documentation of p6est_new() for basic usage.

Parameters
[in]min_quadrantsMinimum initial quadrants per processor. Makes the refinement pattern mpisize-specific.
[in]min_levelThe forest is horizontally refined at least to this level. May be negative or 0, then it has no effect.
[in]min_zlevelThe forest is vertically refined at least to this level. May be negative or 0, then it has no effect.
[in]num_zrootThe number of "root" vertical layers (used when non-power-of-2 layers are desired)
[in]fill_uniformIf 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.

◆ p6est_partition_ext()

p4est_gloidx_t p6est_partition_ext ( p6est_t p6est,
int  partition_for_coarsening,
p6est_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).

Parameters
[in,out]p6estThe forest that will be partitioned.
[in]partition_for_coarseningIf true, the partition is modified to allow one level of coarsening.
[in]weight_fnA weighting function or NULL for uniform partitioning.
Returns
The global number of shipped quadrants

◆ p6est_refine_columns_ext()

void p6est_refine_columns_ext ( p6est_t p6est,
int  refine_recursive,
int  maxlevel,
p6est_refine_column_t  refine_fn,
p6est_init_t  init_fn,
p6est_replace_t  replace_fn 
)

Horizontally refine a forest with a bounded refinement level and a replace option.

Parameters
[in,out]p6estThe forest is changed in place.
[in]refine_recursiveBoolean to decide on recursive refinement.
[in]maxlevelMaximum allowed refinement level (inclusive). If this is negative the level is restricted only by the compile-time constant QMAXLEVEL in p4est.h.
[in]refine_fnCallback 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_fnCallback function to initialize the user_data for newly created quadrants, which is guaranteed to be allocated. This function pointer may be NULL.
[in]replace_fnCallback function that allows the user to change incoming quadrants based on the quadrants they replace; may be NULL.

◆ p6est_refine_layers_ext()

void p6est_refine_layers_ext ( p6est_t p6est,
int  refine_recursive,
int  maxlevel,
p6est_refine_layer_t  refine_fn,
p6est_init_t  init_fn,
p6est_replace_t  replace_fn 
)

Vertically refine a forest with a bounded refinement level and a replace option.

Parameters
[in,out]p6estThe forest is changed in place.
[in]refine_recursiveBoolean to decide on recursive refinement.
[in]maxlevelMaximum allowed refinement level (inclusive). If this is negative the level is restricted only by the compile-time constant QMAXLEVEL in p4est.h.
[in]refine_fnCallback 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_fnCallback function to initialize the user_data for newly created quadrants, which is guaranteed to be allocated. This function pointer may be NULL.
[in]replace_fnCallback function that allows the user to change incoming quadrants based on the quadrants they replace; may be NULL.

◆ p6est_save_ext()

void p6est_save_ext ( const char *  filename,
p6est_t p6est,
int  save_data,
int  save_partition 
)

Save the complete connectivity/p6est 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 p6est_load_ext() for information on the autopartition parameter.

Parameters
[in]filenameName of the file to write.
[in]p6estValid forest structure.
[in]save_dataIf true, the element data is saved. Otherwise, a data size of 0 is saved.
[in]save_partitionIf 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.
Note
Aborts on file errors.