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

Interface routines with extended capabilities. More...

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

Go to the source code of this file.

Data Structures

struct  p4est_inspect
 Data pertaining to selecting, inspecting, and profiling algorithms. More...
 

Typedefs

typedef uint64_t p4est_lid_t
 A datatype to handle the linear id in 2D.
 
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. More...
 

Functions

int p4est_lid_compare (const p4est_lid_t *a, const p4est_lid_t *b)
 Compare the p4est_lid_t a and the p4est_lid_t b. More...
 
int p4est_lid_is_equal (const p4est_lid_t *a, const p4est_lid_t *b)
 Checks if the p4est_lid_t a and the p4est_lid_t b are equal. More...
 
void p4est_lid_init (p4est_lid_t *input, uint64_t high, uint64_t low)
 Initializes an unsigned 64 bit integer. More...
 
void p4est_lid_set_zero (p4est_lid_t *input)
 Initializes a linear index to zero. More...
 
void p4est_lid_set_one (p4est_lid_t *input)
 Initializes a linear index to one. More...
 
void p4est_lid_set_uint64 (p4est_lid_t *input, uint64_t u)
 Initializes a linear index to an unsigned 64 bit integer. More...
 
int p4est_lid_chk_bit (const p4est_lid_t *input, int bit_number)
 Returns the bit_number-th bit of input. More...
 
void p4est_lid_set_bit (p4est_lid_t *input, int bit_number)
 Sets the exponent-th bit of a to one. More...
 
void p4est_lid_copy (const p4est_lid_t *input, p4est_lid_t *output)
 Copies an initialized p4est_lid_t to a p4est_lid_t. More...
 
void p4est_lid_add (const p4est_lid_t *a, const p4est_lid_t *b, p4est_lid_t *result)
 Adds the uint128_t b to the uint128_t a. More...
 
void p4est_lid_sub (const p4est_lid_t *a, const p4est_lid_t *b, p4est_lid_t *result)
 Subtracts the p4est_lid_t b from the p4est_lid_t a. More...
 
void p4est_lid_bitwise_neg (const p4est_lid_t *a, p4est_lid_t *result)
 Calculates the bitwise negation of the uint128_t a. More...
 
void p4est_lid_bitwise_or (const p4est_lid_t *a, const p4est_lid_t *b, p4est_lid_t *result)
 Calculates the bitwise or of the uint128_t a and b. More...
 
void p4est_lid_bitwise_and (const p4est_lid_t *a, const p4est_lid_t *b, p4est_lid_t *result)
 Calculates the bitwise and of the uint128_t a and the uint128_t b. More...
 
void p4est_lid_shift_right (const p4est_lid_t *input, unsigned shift_count, p4est_lid_t *result)
 Calculates the bit right shift of uint128_t input by shift_count bits. More...
 
void p4est_lid_shift_left (const p4est_lid_t *input, unsigned shift_count, p4est_lid_t *result)
 Calculates the bit left shift of uint128_t input by shift_count bits. More...
 
void p4est_lid_add_inplace (p4est_lid_t *a, const p4est_lid_t *b)
 Adds the p4est_lid_t b to the p4est_lid_t a. More...
 
void p4est_lid_sub_inplace (p4est_lid_t *a, const p4est_lid_t *b)
 Subtracts the uint128_t b from the uint128_t a. More...
 
void p4est_lid_bitwise_or_inplace (p4est_lid_t *a, const p4est_lid_t *b)
 Calculates the bitwise or of the uint128_t a and the uint128_t b. More...
 
void p4est_lid_bitwise_and_inplace (p4est_lid_t *a, const p4est_lid_t *b)
 Calculates the bitwise and of the uint128_t a and the uint128_t b. More...
 
void p4est_quadrant_linear_id_ext128 (const p4est_quadrant_t *quadrant, int level, p4est_lid_t *id)
 Computes the linear position as p4est_lid_t of a quadrant in a uniform grid. More...
 
void p4est_quadrant_set_morton_ext128 (p4est_quadrant_t *quadrant, int level, const p4est_lid_t *id)
 Set quadrant Morton indices based on linear position given as p4est_lid_t in uniform grid. More...
 
p4est_tp4est_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. More...
 
p4est_mesh_tp4est_mesh_new_ext (p4est_t *p4est, p4est_ghost_t *ghost, int compute_tree_index, int compute_level_lists, p4est_connect_type_t btype)
 Create a new mesh. More...
 
p4est_tp4est_copy_ext (p4est_t *input, int copy_data, int duplicate_mpicomm)
 Make a deep copy of a p4est. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
p4est_gloidx_t p4est_partition_for_coarsening (p4est_t *p4est, p4est_locidx_t *num_quadrants_in_proc)
 Correct partition to allow one level of coarsening. More...
 
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. More...
 
p4est_tp4est_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. More...
 
p4est_tp4est_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.
 
void p4est_get_plex_data_ext (p4est_t *p4est, p4est_ghost_t **ghost, p4est_lnodes_t **lnodes, p4est_connect_type_t ctype, int overlap, p4est_locidx_t *first_local_quad, sc_array_t *out_points_per_dim, sc_array_t *out_cone_sizes, sc_array_t *out_cones, sc_array_t *out_cone_orientations, sc_array_t *out_vertex_coords, sc_array_t *out_children, sc_array_t *out_parents, sc_array_t *out_childids, sc_array_t *out_leaves, sc_array_t *out_remotes, int custom_numbering)
 Create the data necessary to create a PETsc DMPLEX representation of a forest, as well as the accompanying lnodes and ghost layer. More...
 

Detailed Description

Interface routines with extended capabilities.

Typedef Documentation

◆ p4est_replace_t

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.

Parameters
[in]num_outgoingThe number of outgoing quadrants.
[in]outgoingThe outgoing quadrants: after the callback, the user_data, if p4est->data_size is nonzero, will be destroyed.
[in]num_incomingThe number of incoming quadrants.
[in,out]incomingThe 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.

Function Documentation

◆ p4est_balance_ext()

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.

Parameters
[in,out]p4estThe p4est 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]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.

◆ p4est_coarsen_ext()

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.

Parameters
[in,out]p4estThe 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. With coarsen_recursive false and callback_orphans true, it is guaranteed that every quadrant is passed exactly once into the coarsen_fn callback.
[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.

◆ p4est_copy_ext()

p4est_t * p4est_copy_ext ( p4est_t input,
int  copy_data,
int  duplicate_mpicomm 
)

Make a deep copy of a p4est.

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. The revision counter of the copy is set to zero.

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 p4est that does not depend on the input, except for borrowing the same connectivity. Its revision counter is 0.

◆ p4est_get_plex_data_ext()

void p4est_get_plex_data_ext ( p4est_t p4est,
p4est_ghost_t **  ghost,
p4est_lnodes_t **  lnodes,
p4est_connect_type_t  ctype,
int  overlap,
p4est_locidx_t first_local_quad,
sc_array_t *  out_points_per_dim,
sc_array_t *  out_cone_sizes,
sc_array_t *  out_cones,
sc_array_t *  out_cone_orientations,
sc_array_t *  out_vertex_coords,
sc_array_t *  out_children,
sc_array_t *  out_parents,
sc_array_t *  out_childids,
sc_array_t *  out_leaves,
sc_array_t *  out_remotes,
int  custom_numbering 
)

Create the data necessary to create a PETsc DMPLEX representation of a forest, as well as the accompanying lnodes and ghost layer.

The forest must be at least face balanced (see p4est_balance()). See test/test_plex2.c for example usage.

All arrays should be initialized to hold sizeof (p4est_locidx_t), except for out_remotes, which should be initialized to hold (2 * sizeof (p4est_locidx_t)).

Parameters
[in]p4estthe forest
[out]ghostthe ghost layer
[out]lnodesthe lnodes
[in]ctypethe type of adjacency for the overlap
[in]overlapthe number of layers of overlap (zero is acceptable)
[out]first_local_quadthe local quadrants are assigned contiguous plex indices, starting with this index
[in,out]out_points_per_dimfilled with argument for DMPlexCreateFromDAG()
[in,out]out_cone_sizesfilled with argument for DMPlexCreateFromDAG()
[in,out]out_conesfilled with argument for DMPlexCreateFromDAG()
[in,out]out_cone_orientationsfilled with argument for DMPlexCreateFromDAG()
[in,out]out_vertex_coordsfilled with argument for DMPlexCreateFromDAG()
[in,out]out_childrenfilled with argument for DMPlexSetTree()
[in,out]out_parentsfilled with argument for DMPlexSetTree()
[in,out]out_childidsfilled with argument for DMPlexSetTree()
[in,out]out_leavesfilled with argument for PetscSFSetGraph()
[in,out]out_remotesfilled with argument for PetscSFSetGraph()
[in]custom_numberingWhether or use the default numbering (0) of DMPlex child ids or the custom (1).

◆ p4est_lid_add()

void p4est_lid_add ( const p4est_lid_t a,
const p4est_lid_t b,
p4est_lid_t result 
)

Adds the uint128_t b to the uint128_t a.

result == a or result == b is not allowed. a == b is allowed.

Parameters
[in]aA pointer to a p4est_lid_t.
[in]bA pointer to a p4est_lid_t.
[out]resultA pointer to a p4est_lid_t. The sum a + b will be saved in result.

◆ p4est_lid_add_inplace()

void p4est_lid_add_inplace ( p4est_lid_t a,
const p4est_lid_t b 
)

Adds the p4est_lid_t b to the p4est_lid_t a.

The result is saved in a. a == b is allowed.

Parameters
[in,out]aA pointer to a p4est_lid_t. a will be overwritten by a + b.
[in]bA pointer to a p4est_lid_t.

◆ p4est_lid_bitwise_and()

void p4est_lid_bitwise_and ( const p4est_lid_t a,
const p4est_lid_t b,
p4est_lid_t result 
)

Calculates the bitwise and of the uint128_t a and the uint128_t b.

a == result is allowed. Furthermore, a == result and/or b == result is allowed.

Parameters
[in]aA pointer to a p4est_lid_t.
[in]bA pointer to a p4est_lid_t.
[out]resultA pointer to a p4est_lid_t. The bitwise and of a and b will be saved. in result.

◆ p4est_lid_bitwise_and_inplace()

void p4est_lid_bitwise_and_inplace ( p4est_lid_t a,
const p4est_lid_t b 
)

Calculates the bitwise and of the uint128_t a and the uint128_t b.

a == b is allowed.

Parameters
[in,out]aA pointer to a p4est_lid_t. The bitwise and will be saved in a.
[in]bA pointer to a p4est_lid_t.

◆ p4est_lid_bitwise_neg()

void p4est_lid_bitwise_neg ( const p4est_lid_t a,
p4est_lid_t result 
)

Calculates the bitwise negation of the uint128_t a.

a == result is allowed.

Parameters
[in]aA pointer to a p4est_lid_t.
[out]resultA pointer to a p4est_lid_t. The bitwise negation of a will be saved in result.

◆ p4est_lid_bitwise_or()

void p4est_lid_bitwise_or ( const p4est_lid_t a,
const p4est_lid_t b,
p4est_lid_t result 
)

Calculates the bitwise or of the uint128_t a and b.

a == result is allowed. Furthermore, a == result and/or b == result is allowed.

Parameters
[in]aA pointer to a p4est_lid_t.
[in]bA pointer to a p4est_lid_t.
[out]resultA pointer to a p4est_lid_t. The bitwise or of a and b will be saved in result.

◆ p4est_lid_bitwise_or_inplace()

void p4est_lid_bitwise_or_inplace ( p4est_lid_t a,
const p4est_lid_t b 
)

Calculates the bitwise or of the uint128_t a and the uint128_t b.

a == b is allowed.

Parameters
[in,out]aA pointer to a p4est_lid_t. The bitwise or will be saved in a.
[in]bA pointer to a p4est_lid_t.

◆ p4est_lid_chk_bit()

int p4est_lid_chk_bit ( const p4est_lid_t input,
int  bit_number 
)

Returns the bit_number-th bit of input.

This function checks a bit of an existing, initialized value.

Parameters
[in]inputA pointer to a p4est_lid_t.
[in]bit_numberThe bit (counted from the right hand side) that is checked by logical and. Require 0 <= bit_number < 64.
Returns
True if bit is set, false if not.

◆ p4est_lid_compare()

int p4est_lid_compare ( const p4est_lid_t a,
const p4est_lid_t b 
)

Compare the p4est_lid_t a and the p4est_lid_t b.

Parameters
[in]aA pointer to a p4est_lid_t.
[in]bA pointer to a p4est_lid_t.
Returns
Returns -1 if a < b, 1 if a > b and 0 if a == b.

◆ p4est_lid_copy()

void p4est_lid_copy ( const p4est_lid_t input,
p4est_lid_t output 
)

Copies an initialized p4est_lid_t to a p4est_lid_t.

Parameters
[in]inputA pointer to the p4est_lid_t that is copied.
[in,out]outputA pointer to a p4est_lid_t. The low bits of output will be set to the low bits of input and high bits are ignored.

◆ p4est_lid_init()

void p4est_lid_init ( p4est_lid_t input,
uint64_t  high,
uint64_t  low 
)

Initializes an unsigned 64 bit integer.

high is just a a placeholder to use the same interface in 3D.

Parameters
[in,out]inputA pointer to a p4est_lid_t that will be initialized.
[in]highThe given high bits must be zero.
[in]lowThe given low bits to initialize input.

◆ p4est_lid_is_equal()

int p4est_lid_is_equal ( const p4est_lid_t a,
const p4est_lid_t b 
)

Checks if the p4est_lid_t a and the p4est_lid_t b are equal.

Parameters
[in]aA pointer to a p4est_lid_t.
[in]bA pointer to a p4est_lid_t.
Returns
Returns a true value if a and b are equal, false otherwise

◆ p4est_lid_set_bit()

void p4est_lid_set_bit ( p4est_lid_t input,
int  bit_number 
)

Sets the exponent-th bit of a to one.

This function modifies an existing, initialized value.

Parameters
[in,out]inputA pointer to a p4est_lid_t.
[in]bit_numberThe bit (counted from the right hand side) that is set to one by logical or. Require 0 <= bit_number < 64.

◆ p4est_lid_set_one()

void p4est_lid_set_one ( p4est_lid_t input)

Initializes a linear index to one.

Parameters
[out]inputA pointer to a p4est_lid_t that will be initialized.

◆ p4est_lid_set_uint64()

void p4est_lid_set_uint64 ( p4est_lid_t input,
uint64_t  u 
)

Initializes a linear index to an unsigned 64 bit integer.

Parameters
[out]inputA pointer to a p4est_lid_t that will be initialized.

◆ p4est_lid_set_zero()

void p4est_lid_set_zero ( p4est_lid_t input)

Initializes a linear index to zero.

Parameters
[out]inputA pointer to a p4est_lid_t that will be initialized.

◆ p4est_lid_shift_left()

void p4est_lid_shift_left ( const p4est_lid_t input,
unsigned  shift_count,
p4est_lid_t result 
)

Calculates the bit left shift of uint128_t input by shift_count bits.

We shift in zeros from the right. If shift_count >= 64, result is 0. All bits left from the 63th bit (counted zero based from the right hand side) drop out. input == result is allowed.

Parameters
[in]inputA pointer to a p4est_lid_t.
[in]shift_countBits to shift. shift_count >= 0.
[in,out]resultA pointer to a p4est_lid_t. The left shifted number will be saved in result.

◆ p4est_lid_shift_right()

void p4est_lid_shift_right ( const p4est_lid_t input,
unsigned  shift_count,
p4est_lid_t result 
)

Calculates the bit right shift of uint128_t input by shift_count bits.

We shift in zeros from the left. If shift_count >= 64, result is 0. All bits right from the zeroth bit (counted from the right hand side) drop out. input == result is allowed.

Parameters
[in]inputA pointer to a p4est_lid_t.
[in]shift_countBits to shift. shift_count >= 0.
[in,out]resultA pointer to a p4est_lid_t. The right shifted number will be saved in result.

◆ p4est_lid_sub()

void p4est_lid_sub ( const p4est_lid_t a,
const p4est_lid_t b,
p4est_lid_t result 
)

Subtracts the p4est_lid_t b from the p4est_lid_t a.

This function assumes that the result is >= 0. result == a or result == b is not allowed. a == b is allowed.

Parameters
[in]aA pointer to a p4est_lid_t.
[in]bA pointer to a p4est_lid_t.
[out]resultA pointer to a p4est_lid_t. The difference a - b will be saved in result.

◆ p4est_lid_sub_inplace()

void p4est_lid_sub_inplace ( p4est_lid_t a,
const p4est_lid_t b 
)

Subtracts the uint128_t b from the uint128_t a.

The result is saved in a. a == b is allowed. This function assumes that the result is >= 0.

Parameters
[in,out]aA pointer to a p4est_lid_t. a will be overwritten by a - b.
[in]bA pointer to a p4est_lid_t.

◆ p4est_load_ext()

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.

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 p4est 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.

◆ p4est_mesh_new_ext()

p4est_mesh_t * p4est_mesh_new_ext ( p4est_t p4est,
p4est_ghost_t ghost,
int  compute_tree_index,
int  compute_level_lists,
p4est_connect_type_t  btype 
)

Create a new mesh.

This function sets a subset of the mesh creation parameters. For full control use p4est_mesh_new_params.

Parameters
[in]p4estA forest that is fully 2:1 balanced.
[in]ghostThe ghost layer created from the provided p4est.
[in]compute_tree_indexBoolean to decide whether to allocate and compute the quad_to_tree list.
[in]compute_level_listsBoolean to decide whether to compute the level lists in quad_level.
[in]btypeFlag indicating the connection types (face, corner) stored in the mesh.
Returns
A fully allocated mesh structure.

◆ p4est_new_ext()

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. The forest created is either uniformly refined at a given level or created with the coarsest possible refinement that fits the exact partition that would have been created in the uniform mode. The latter, coarse refinement depends on the number of MPI processes! The initial level is currently limited to P4EST_OLD_QMAXLEVEL. Regardless, p4est_refine can go as deep as P4EST_QMAXLEVEL.

Parameters
[in]mpicommA valid MPI communicator.
[in]connectivityThis is the connectivity information that the forest is built with. Note the forest does not take ownership of the memory.
[in]min_quadrantsMinimum initial quadrants per processor. Makes the refinement pattern mpisize-specific. For maximum reproducibility, set this to 0.
[in]min_levelThe forest is refined at most to this level. Later coarsening and refinement is unaffected. May be negative or 0, then it has no effect.
[in]fill_uniformIf true, fill the forest with a uniform mesh instead of the coarsest possible one. The latter is partition-specific, which is not a good idea wrt. reproducibility.
[in]data_sizeThe size of data for each quadrant.
[in]init_fnCallback function to initialize the user_data which is internally allocated using data_size.
[in]user_pointerAssigned to the user_pointer member of the forest before init_fn is called the first time.
Returns
Valid p4est object.
Examples
simple/simple2.c.

◆ p4est_partition_ext()

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).

Parameters
[in,out]p4estThe 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. A weighting function with constant weight 1 on each quadrant is equivalent to weight_fn == NULL but other constant weightings may result in different uniform partitionings.
Returns
The global number of shipped quadrants

◆ p4est_partition_for_coarsening()

p4est_gloidx_t p4est_partition_for_coarsening ( p4est_t p4est,
p4est_locidx_t num_quadrants_in_proc 
)

Correct partition to allow one level of coarsening.

Parameters
[in]p4estforest whose partition is corrected
[in,out]num_quadrants_in_procpartition that will be corrected
Returns
absolute number of moved quadrants

◆ p4est_quadrant_linear_id_ext128()

void p4est_quadrant_linear_id_ext128 ( const p4est_quadrant_t quadrant,
int  level,
p4est_lid_t id 
)

Computes the linear position as p4est_lid_t of a quadrant in a uniform grid.

The grid and quadrant levels need not coincide. If they do, this is the inverse of p4est_quadrant_set_morton.

Parameters
[in]quadrantQuadrant whose linear index will be computed. If the quadrant is smaller than the grid (has a higher quadrant->level), the result is computed from its ancestor at the grid's level. If the quadrant has a smaller level than the grid (it is bigger than a grid cell), the grid cell sharing its lower left corner is used as reference.
[in]levelThe level of the regular grid compared to which the linear position is to be computed.
[in,out]idA pointer to an allocated or static p4est_lid_t. id will be the linear position of this quadrant on a uniform grid.
Note
The user_data of quadrant is never modified.

◆ p4est_quadrant_set_morton_ext128()

void p4est_quadrant_set_morton_ext128 ( p4est_quadrant_t quadrant,
int  level,
const p4est_lid_t id 
)

Set quadrant Morton indices based on linear position given as p4est_lid_t in uniform grid.

This is the inverse operation of p4est_quadrant_linear_id.

Parameters
[in,out]quadrantQuadrant whose Morton indices will be set.
[in]levelLevel of the grid and of the resulting quadrant.
[in]idLinear index of the quadrant on a uniform grid.
Note
The user_data of quadrant is never modified.

◆ p4est_refine_ext()

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.

Parameters
[in,out]p4estThe 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.

◆ p4est_save_ext()

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.

Parameters
[in]filenameName of the file to write.
[in]p4estValid 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.