API reference
Higher-level API provided by P4est.jl
P4est.init
— MethodP4est.init(log_handler, log_threshold)
Calls p4est_init
if it has not already been called, otherwise do nothing. Thus, P4est.init
can safely be called multiple times.
To use the default log handler and suppress most output created by default by p4est
, call this function as
P4est.init(C_NULL, SC_LP_ERROR)
before calling other functions from p4est
.
P4est.package_id
— MethodP4est.package_id()
Returns the value of the global variable p4est_package_id
which can be used to check whether p4est
has been initialized.
P4est.path_p4est_library
— MethodP4est.path_p4est_library()
Return the path of the p4est
library that is used, when a system-provided library is configured via the preferences. Otherwise P4est_jll
is returned, which means that the default p4est version from P4est_jll.jl is used.
P4est.path_sc_library
— MethodP4est.path_sc_library()
Return the path of the sc
library that is used, when a system-provided library is configured via the preferences. Otherwise P4est_jll
is returned, which means that the default sc version from P4est_jll.jl is used.
P4est.preferences_set_correctly
— MethodP4est.preferences_set_correctly()
Returns false
if a system-provided MPI installation is set via the MPIPreferences, but not a system-provided p4est
installation. In this case, P4est.jl is not usable.
P4est.set_library_p4est!
— FunctionP4est.set_library_p4est!(path; force = true)
Set the path
to a system-provided p4est
installation. Restart the Julia session after executing this function so that the changes take effect. Calling this function is necessary when you want to use a system-provided p4est
installation.
P4est.set_library_sc!
— FunctionP4est.set_library_sc!(path; force = true)
Set the path
to a system-provided sc
installation. Restart the Julia session after executing this function so that the changes take effect. Calling this function is necessary, when you want to use a system-provided p4est
installation on Windows or when you want to use another sc
installation than the one that libp4est.so
already links to.
P4est.uses_mpi
— MethodP4est.uses_mpi()
Is intended to return true
if the
p4estlibrary was compiled with MPI enabled. Since P4est.jl currently only supports
p4estwith MPI enabled, this may always return
true`.
P4est.version
— MethodP4est.version()
Returns the version of the underlying p4est
library (not of P4est.jl).
PointerWrapper provided by P4est.jl
Everything documented here is also export
ed from P4est.jl and available when using P4est
.
P4est.PointerWrappers.PointerWrapper
— TypePointerWrapper(p::Ptr)
Wrap the pointer p
to conveniently access the data of the underlying struct
. Fields of the struct
(or the struct
itself) can be dereferenced for reading/writing using []
. As opposed to using unsafe_load
/unsafe_store
on the struct
directly, the []
operator only accesses the memory for the requested field, thereby avoiding to having to load/store the entire struct when accessing only a single field. This can be helpful especially when accessing data in nested structures.
Example
julia> using P4est, MPI
julia> MPI.Init()
MPI.ThreadLevel(2)
julia> connectivity = p4est_connectivity_new_brick(2, 2, 0, 0)
Ptr{p4est_connectivity} @0x000060000378b010
julia> p4est = p4est_new_ext(MPI.COMM_WORLD, connectivity, 0, 0, true, 0, C_NULL, C_NULL)
Into p4est_new with min quadrants 0 level 0 uniform 1
New p4est with 4 trees on 1 processors
Initial level 0 potential global quadrants 4 per tree 1
Done p4est_new with 4 total quadrants
Ptr{P4est.LibP4est.p4est} @0x0000600002b9d7b0
julia> p4est_pw = PointerWrapper(p4est)
PointerWrapper{P4est.LibP4est.p4est}(Ptr{P4est.LibP4est.p4est} @0x0000600002b9d7b0)
julia> p4est_pw.connectivity.num_trees[]
4
Wrapper of the C API of p4est
Everything documented here is also export
ed from P4est.jl and available when using P4est
.
P4est.LibP4est.p4est_coarsen_t
— TypeCallback function prototype to decide for coarsening.
Parameters
p4est
:[in] the forestwhich_tree
:[in] the tree containing quadrantquadrants
:[in] Pointers to 4 siblings in Morton ordering.
Returns
nonzero if the quadrants shall be replaced with their parent.
P4est.LibP4est.p4est_comm_tag
— Typep4est_comm_tag
Tags for MPI messages
P4est.LibP4est.p4est_comm_tag_t
— TypeTags for MPI messages
P4est.LibP4est.p4est_connect_type_t
— Typep4est_connect_type_t
Characterize a type of adjacency.
Several functions involve relationships between neighboring trees and/or quadrants, and their behavior depends on how one defines adjacency: 1) entities are adjacent if they share a face, or 2) entities are adjacent if they share a face or corner. p4est_connect_type_t
is used to choose the desired behavior. This enum must fit into an int8_t.
P4est.LibP4est.p4est_connectivity
— Typep4est_connectivity
This structure holds the 2D inter-tree connectivity information. Identification of arbitrary faces and corners is possible.
The arrays tree_to_* are stored in z ordering. For corners the order wrt. yx is 00 01 10 11. For faces the order is -x +x -y +y. They are allocated [0][0]..[0][3]..[num_trees-1][0]..[num_trees-1][3].
The values for tree_to_face are 0..7 where ttf % 4 gives the face number and ttf / 4 the face orientation code. The orientation is 0 for edges that are aligned in z-order, and 1 for edges that are running opposite in z-order.
It is valid to specify num_vertices as 0. In this case vertices and tree_to_vertex are set to NULL. Otherwise the vertex coordinates are stored in the array vertices as [0][0]..[0][2]..[num_vertices-1][0]..[num_vertices-1][2].
The corners are only stored when they connect trees. In this case tree_to_corner indexes into ctt_offset. Otherwise the tree_to_corner entry must be -1 and this corner is ignored. If num_corners == 0, tree_to_corner and corner_to_* arrays are set to NULL.
The arrays corner_to_* store a variable number of entries per corner. For corner c these are at position [ctt_offset[c]]..[ctt_offset[c+1]-1]. Their number for corner c is ctt_offset[c+1] - ctt_offset[c]. The entries encode all trees adjacent to corner c. The size of the corner_to_* arrays is num_ctt = ctt_offset[num_corners].
The *_to_attr arrays may have arbitrary contents defined by the user.
Field | Note |
---|---|
num_vertices | the number of vertices that define the embedding of the forest (not the topology) |
num_trees | the number of trees |
num_corners | the number of corners that help define topology |
vertices | an array of size (3 * num_vertices) |
tree_to_vertex | embed each tree into c++ R^3 for e.g. visualization (see p4est_vtk.h) |
tree_attr_bytes | bytes per tree in tree_to_attr |
tree_to_attr | not touched by p4est |
tree_to_tree | (4 * num_trees) neighbors across faces |
tree_to_face | (4 * num_trees) face to face+orientation (see description) |
tree_to_corner | (4 * num_trees) or NULL (see description) |
ctt_offset | corner to offset in cornertotree and cornertocorner |
corner_to_tree | list of trees that meet at a corner |
corner_to_corner | list of tree-corners that meet at a corner |
P4est.LibP4est.p4est_connectivity_encode_t
— Typep4est_connectivity_encode_t
Typedef for serialization method.
Enumerator | Note |
---|---|
P4EST_CONN_ENCODE_LAST | Invalid entry to close the list. |
P4est.LibP4est.p4est_connectivity_t
— TypeThis structure holds the 2D inter-tree connectivity information. Identification of arbitrary faces and corners is possible.
The arrays tree_to_* are stored in z ordering. For corners the order wrt. yx is 00 01 10 11. For faces the order is -x +x -y +y. They are allocated [0][0]..[0][3]..[num_trees-1][0]..[num_trees-1][3].
The values for tree_to_face are 0..7 where ttf % 4 gives the face number and ttf / 4 the face orientation code. The orientation is 0 for edges that are aligned in z-order, and 1 for edges that are running opposite in z-order.
It is valid to specify num_vertices as 0. In this case vertices and tree_to_vertex are set to NULL. Otherwise the vertex coordinates are stored in the array vertices as [0][0]..[0][2]..[num_vertices-1][0]..[num_vertices-1][2].
The corners are only stored when they connect trees. In this case tree_to_corner indexes into ctt_offset. Otherwise the tree_to_corner entry must be -1 and this corner is ignored. If num_corners == 0, tree_to_corner and corner_to_* arrays are set to NULL.
The arrays corner_to_* store a variable number of entries per corner. For corner c these are at position [ctt_offset[c]]..[ctt_offset[c+1]-1]. Their number for corner c is ctt_offset[c+1] - ctt_offset[c]. The entries encode all trees adjacent to corner c. The size of the corner_to_* arrays is num_ctt = ctt_offset[num_corners].
The *_to_attr arrays may have arbitrary contents defined by the user.
P4est.LibP4est.p4est_ghost_exchange
— Typep4est_ghost_exchange
Transient storage for asynchronous ghost exchange.
Field | Note |
---|---|
is_custom | False for p4est_ghost_exchange_data |
is_levels | Are we restricted to levels or not |
minlevel | Meaningful with is_levels |
maxlevel |
P4est.LibP4est.p4est_ghost_exchange_t
— TypeTransient storage for asynchronous ghost exchange.
P4est.LibP4est.p4est_ghost_t
— Typep4est_ghost_t
quadrants that neighbor the local domain
Field | Note |
---|---|
btype | which neighbors are in the ghost layer |
ghosts | array of p4est_quadrant_t type |
tree_offsets | num_trees + 1 ghost indices |
proc_offsets | mpisize + 1 ghost indices |
mirrors | array of p4est_quadrant_t type |
mirror_tree_offsets | num_trees + 1 mirror indices |
mirror_proc_mirrors | indices into mirrors grouped by outside processor rank and ascending within each rank |
mirror_proc_offsets | mpisize + 1 indices into mirror_proc_mirrors |
mirror_proc_fronts | like mirror_proc_mirrors, but limited to the outermost octants. This is NULL until p4est_ghost_expand is called |
mirror_proc_front_offsets | NULL until p4est_ghost_expand is called |
P4est.LibP4est.p4est_gloidx_t
— TypeTypedef for globally unique indexing of quadrants.
P4est.LibP4est.p4est_init_t
— TypeCallback function prototype to initialize the quadrant's user data.
Parameters
p4est
:[in] the forestwhich_tree
:[in] the tree containing quadrantquadrant
:[in,out] the quadrant to be initialized: if data_size > 0, the data to be initialized is at quadrant->p.userdata; otherwise, the non-pointer user data (such as quadrant->p.userint) can be initialized
P4est.LibP4est.p4est_inspect
— Typep4est_inspect
Data pertaining to selecting, inspecting, and profiling algorithms. A pointer to this structure is hooked into the p4est
main structure.
The balance_ranges and balance_notify* times are collected whenever an inspect structure is present in p4est
.
Field | Note |
---|---|
use_balance_ranges | Use sc_ranges to determine the asymmetric communication pattern. If usebalanceranges is false (the default), sc_notify is used. |
use_balance_ranges_notify | If true, call both sc_ranges and sc_notify and verify consistency. Which is actually used is still determined by usebalanceranges. |
use_balance_verify | Verify sc_ranges and/or sc_notify as applicable. |
balance_max_ranges | If positive and smaller than p4est_num ranges, overrides it |
balance_ranges | time spent in sc_ranges |
balance_notify | time spent in sc_notify |
balance_notify_allgather | time spent in sc_notify_allgather |
P4est.LibP4est.p4est_inspect_t
— TypeData pertaining to selecting, inspecting, and profiling algorithms. A pointer to this structure is hooked into the p4est
main structure. Declared in p4est_extended.h. Used to profile important algorithms.
P4est.LibP4est.p4est_iter_corner_info
— Typep4est_iter_corner_info
The information that is available to the user-defined p4est_iter_corner_t
callback.
If tree_boundary is false, the corner is on the interior of a tree. When tree_boundary is false, sides[0] contains the lowest z-order quadrant that touches the corner. When tree_boundary is true, its value is P4EST_CONNECT_FACE/CORNER depending on the location of the corner relative to the tree.
Field | Note |
---|---|
tree_boundary | boolean: interior face (0), tree boundary face (true) |
sides | array of type p4est_iter_corner_side_t type |
P4est.LibP4est.p4est_iter_corner_info_t
— TypeThe information that is available to the user-defined p4est_iter_corner_t
callback.
If tree_boundary is false, the corner is on the interior of a tree. When tree_boundary is false, sides[0] contains the lowest z-order quadrant that touches the corner. When tree_boundary is true, its value is P4EST_CONNECT_FACE/CORNER depending on the location of the corner relative to the tree.
P4est.LibP4est.p4est_iter_corner_side
— Typep4est_iter_corner_side
Information about one side of a corner in the forest. If a quad is local (is_ghost is false), then its quadid indexes the tree's quadrant array; otherwise, it indexes the ghosts array. If a quadrant should be present, but it is not included in the ghost layer, then quad = NULL, is_ghost is true, and quadid = -1.
the faces field provides some additional information about the local topology: if side[i]->faces[j] == side[k]->faces[l], this indicates that there is a common face between these two sides of the corner.
Field | Note |
---|---|
treeid | the tree that contains quad |
corner | which of the quadrant's corners touches this corner |
is_ghost | boolean: local (0) or ghost (1) |
quadid | the index in the tree or ghost array |
faces | internal work data |
P4est.LibP4est.p4est_iter_corner_side_t
— TypeInformation about one side of a corner in the forest. If a quad is local (is_ghost is false), then its quadid indexes the tree's quadrant array; otherwise, it indexes the ghosts array. If a quadrant should be present, but it is not included in the ghost layer, then quad = NULL, is_ghost is true, and quadid = -1.
the faces field provides some additional information about the local topology: if side[i]->faces[j] == side[k]->faces[l], this indicates that there is a common face between these two sides of the corner.
P4est.LibP4est.p4est_iter_corner_t
— TypeThe prototype for a function that p4est_iterate
will execute wherever quadrants meet at a conformal corner
i.e. the callback will not execute on a hanging corner.
the forest does not need to be corner balanced for p4est_iterate
() to correctly execute a callback function at corners, only face balanced (see p4est_balance
()).
Parameters
info
:[in] information about a quadrant provided to the useruser_data
:[in,out] the user context passed top4est_iterate
()
P4est.LibP4est.p4est_iter_face_info
— Typep4est_iter_face_info
The information that is available to the user-defined p4est_iter_face_t
callback.
The orientation is 0 if the face is within one tree; otherwise, it is the same as the orientation value between the two trees given in the connectivity. If the face is on the outside boundary of the forest, then there is only one side. If tree_boundary is false, the face is on the interior of a tree. When tree_boundary is false, sides[0] contains the lowest z-order quadrant that touches the face. When tree_boundary is true, its value is P4EST_CONNECT_FACE.
Field | Note |
---|---|
orientation | the orientation of the sides to each other, as in the definition of p4est_connectivity_t |
tree_boundary | boolean: interior face (0), tree boundary face (true) |
P4est.LibP4est.p4est_iter_face_info_t
— TypeThe information that is available to the user-defined p4est_iter_face_t
callback.
The orientation is 0 if the face is within one tree; otherwise, it is the same as the orientation value between the two trees given in the connectivity. If the face is on the outside boundary of the forest, then there is only one side. If tree_boundary is false, the face is on the interior of a tree. When tree_boundary is false, sides[0] contains the lowest z-order quadrant that touches the face. When tree_boundary is true, its value is P4EST_CONNECT_FACE.
P4est.LibP4est.p4est_iter_face_side
— Typep4est_iter_face_side
Information about one side of a face in the forest.
If a quad is local (is_ghost is false), then its quadid indexes the tree's quadrant array; otherwise, it indexes the ghosts array. If the face is hanging, then the quadrants are listed in z-order. If a quadrant should be present, but it is not included in the ghost layer, then quad = NULL, is_ghost is true, and quadid = -1.
Field | Note |
---|---|
treeid | the tree on this side |
face | which quadrant side the face touches |
is_hanging | boolean: one full quad (0) or two smaller quads (1) |
P4est.LibP4est.p4est_iter_face_side_t
— TypeInformation about one side of a face in the forest.
If a quad is local (is_ghost is false), then its quadid indexes the tree's quadrant array; otherwise, it indexes the ghosts array. If the face is hanging, then the quadrants are listed in z-order. If a quadrant should be present, but it is not included in the ghost layer, then quad = NULL, is_ghost is true, and quadid = -1.
P4est.LibP4est.p4est_iter_face_t
— TypeThe prototype for a function that p4est_iterate
will execute wherever two quadrants share a face: the face can be a 2:1 hanging face, it does not have to be conformal.
the forest must be face balanced for p4est_iterate
() to execute a callback function on faces (see p4est_balance
()).
Parameters
info
:[in] information about a quadrant provided to the useruser_data
:[in,out] the user context passed top4est_iterate
()
P4est.LibP4est.p4est_iter_volume_info
— Typep4est_iter_volume_info
The information that is available to the user-defined p4est_iter_volume_t
callback function.
treeid gives the index in p4est
->trees of the tree to which quad belongs. quadid gives the index of quad within tree's quadrants array.
Field | Note |
---|---|
quad | the quadrant of the callback |
quadid | id in quad's tree array (see p4est_tree_t ) |
treeid | the tree containing quad |
P4est.LibP4est.p4est_iter_volume_info_t
— TypeThe information that is available to the user-defined p4est_iter_volume_t
callback function.
treeid gives the index in p4est
->trees of the tree to which quad belongs. quadid gives the index of quad within tree's quadrants array.
P4est.LibP4est.p4est_iter_volume_t
— TypeThe prototype for a function that p4est_iterate
will execute at every quadrant local to the current process.
Parameters
info
:[in] information about a quadrant provided to the useruser_data
:[in,out] the user context passed top4est_iterate
()
P4est.LibP4est.p4est_lid_t
— TypeA datatype to handle the linear id in 2D.
P4est.LibP4est.p4est_lnodes_buffer
— Typep4est_lnodes_buffer
p4est_lnodes_buffer_t
handles the communication of data associated with nodes.
send_buffers is an array of arrays: one buffer for each process to which the current process sends node-data. It should not be altered between a shared__begin and a shared__end call.
recv_buffers is an array of arrays that is used in lnodes_share_all_. *recv_buffers[j] corresponds with lnodes->sharers[j]: it is the same length as lnodes->sharers[j]->sharednodes. At the completion of lnodes\share_all or lnodes_share_all_end, recv_buffers[j] contains the node-data from the process lnodes->sharers[j]->rank (unless j is the current rank, in which case recv_buffers[j] is empty).
P4est.LibP4est.p4est_lnodes_buffer_t
— Typep4est_lnodes_buffer_t
handles the communication of data associated with nodes.
send_buffers is an array of arrays: one buffer for each process to which the current process sends node-data. It should not be altered between a shared__begin and a shared__end call.
recv_buffers is an array of arrays that is used in lnodes_share_all_. *recv_buffers[j] corresponds with lnodes->sharers[j]: it is the same length as lnodes->sharers[j]->sharednodes. At the completion of lnodes\share_all or lnodes_share_all_end, recv_buffers[j] contains the node-data from the process lnodes->sharers[j]->rank (unless j is the current rank, in which case recv_buffers[j] is empty).
P4est.LibP4est.p4est_lnodes_rank
— Typep4est_lnodes_rank
The structure stored in the sharers array.
shared_nodes is a sorted array of p4est_locidx_t
that indexes into local nodes. The shared_nodes array has a contiguous (or empty) section of nodes owned by the current rank. shared_mine_offset and shared_mine_count identify this section by indexing the shared_nodes array, not the local nodes array. owned_offset and owned_count define the section of local nodes that is owned by the listed rank (the section may be empty). For the current process these coincide with those in p4est_lnodes_t
.
P4est.LibP4est.p4est_lnodes_rank_t
— TypeThe structure stored in the sharers array.
shared_nodes is a sorted array of p4est_locidx_t
that indexes into local nodes. The shared_nodes array has a contiguous (or empty) section of nodes owned by the current rank. shared_mine_offset and shared_mine_count identify this section by indexing the shared_nodes array, not the local nodes array. owned_offset and owned_count define the section of local nodes that is owned by the listed rank (the section may be empty). For the current process these coincide with those in p4est_lnodes_t
.
P4est.LibP4est.p4est_lnodes_t
— TypeStore a parallel numbering of Lobatto points of a given degree > 0.
Each element has degree+1 nodes per face and vnodes = (degree+1)^2 nodes per volume. num_local_elements is the number of local quadrants in the p4est
. element_nodes is of dimension vnodes * num_local_elements and lists the nodes of each element in lexicographic yx-order (x varies fastest); so for degree == 2, this is the layout of nodes:
f_3 c_2 c_3 6–-7–-8 | | f_0 3 4 5 f_1 | | 0–-1–-2 c_0 c_1 f_2
element_nodes indexes into the set of local nodes, layed out as follows: local nodes = [<––-owned_count––->|<––-nonlocal_nodes––->] = [<––––––––num_local_nodes––––––––->] nonlocal_nodes contains the globally unique numbers for independent nodes that are owned by other processes; for local nodes, the globally unique numbers are given by i + global_offset, where i is the local number. Hanging nodes are always local and don't have a global number. They index the geometrically corresponding independent nodes of a neighbor.
Whether nodes are hanging or not is decided based on the element faces. This information is encoded in face_code with one int8_t per element. If no faces are hanging, the value is zero, otherwise the face_code is interpreted by p4est_lnodes_decode.
Independent nodes can be shared by multiple MPI ranks. The owner rank of a node is the one from the lowest numbered element on the lowest numbered octree touching the node.
What is meant by touching? A quadrant is said to touch all faces/corners that are incident on it, and by extension all nodes that are contained in those faces/corners.
X +–––––-+ o | | o | | +––-+ o | p | | q | o | | | | o | | +––-+ O +–––––-+
In this example degree = 6. There are 5 nodes that live on the face between q and p, and one at each corner of that face. The face is incident on q, so q owns the nodes on the face (provided q is from a lower tree or has a lower index than p). The lower corner is incident on q, so q owns it as well. The upper corner is not incident on q, so q cannot own it.
global_owned_count contains the number of independent nodes owned by each process.
The sharers array contains items of type p4est_lnodes_rank_t
that hold the ranks that own or share independent local nodes. If there are no shared nodes on this processor, it is empty. Otherwise, it is sorted by rank and the current process is included.
degree < 0 indicates that the lnodes data structure is being used to number the quadrant boundary object (faces and corners) rather than the $C^0$ Lobatto nodes:
if degree == -1, then one node is assigned per face, and no nodes are assigned per volume or per corner: this numbering can be used for low-order Raviart-Thomas elements. In this case, vnodes == 4, and the nodes are listed in face-order:
f_3 c_2 c_3 +–-3–-+ | | f_0 0 1 f_1 | | +–-2–-+ c_0 c_1 f_2
if degree == -2, then one node is assigned per face and per corner and no nodes are assigned per volume. In this case, vnodes == 8, and the nodes are listed in face-order, followed by corner-order:
f_3 c_2 c_3 6–-3–-7 | | f_0 0 1 f_1 | | 4–-2–-5 c_0 c_1 f_2
P4est.LibP4est.p4est_locidx_t
— TypeTypedef for processor-local indexing of quadrants and nodes.
P4est.LibP4est.p4est_mesh_face_neighbor_t
— Typep4est_mesh_face_neighbor_t
This structure can be used as the status of a face neighbor iterator. It always contains the face and subface of the neighbor to be processed.
P4est.LibP4est.p4est_mesh_t
— Typep4est_mesh_t
This structure contains complete mesh information on a 2:1 balanced forest. It stores the locally relevant neighborhood, that is, all locally owned quadrants and one layer of adjacent ghost quadrants and their owners.
For each local quadrant, its tree number is stored in quad_to_tree. The quad_to_tree array is NULL by default and can be enabled using p4estmeshnewext. For each ghost quadrant, its owner rank is stored in ghost\to_proc. For each level, an array of local quadrant numbers is stored in quad_level. The quad_level array is NULL by default and can be enabled using p4estmeshnew_ext.
The quad_to_quad list stores one value for each local quadrant's face. This value is in 0..local_num_quadrants-1 for local quadrants, or in local_num_quadrants + (0..ghost_num_quadrants-1) for ghost quadrants.
The quad_to_face list has equally many entries that are either: 1. A value of v = 0..7 indicates one same-size neighbor. This value is decoded as v = r * 4 + nf, where nf = 0..3 is the neighbor's connecting face number and r = 0..1 is the relative orientation of the neighbor's face; see p4est_connectivity
.h. 2. A value of v = 8..23 indicates a double-size neighbor. This value is decoded as v = 8 + h * 8 + r * 4 + nf, where r and nf are as above and h = 0..1 is the number of the subface. h designates the subface of the large neighbor that the quadrant touches (this is the same as the large neighbor's face corner). 3. A value of v = -8..-1 indicates two half-size neighbors. In this case the corresponding quad_to_quad index points into the quad_to_half array that stores two quadrant numbers per index, and the orientation of the smaller faces follows from 8 + v. The entries of quad_to_half encode between local and ghost quadrant in the same way as the quad_to_quad values described above. The small neighbors in quad_to_half are stored in the sequence of the face corners of this, i.e., the large quadrant.
A quadrant on the boundary of the forest sees itself and its face number.
The quad_to_corner list stores corner neighbors that are not face neighbors. On the inside of a tree, there is precisely one such neighbor per corner. In this case, its index is encoded as described above for quad_to_quad. The neighbor's matching corner number is always diagonally opposite, that is, corner number ^ 3.
On the inside of an inter-tree face, we have precisely one corner neighbor. If a corner is an inter-tree corner, then the number of corner neighbors may be any non-negative number. In both cases, the quad_to_corner value is in local_num_quadrants + local_num_ghosts + [0 .. local_num_corners - 1]. After subtracting the number of local and ghost quadrants, it indexes into corner_offset, which encodes a group of corner neighbors. Each group contains the quadrant numbers encoded as usual for quad_to_quad in corner_quad, and the corner number from the neighbor as corner_corner.
Corners with no diagonal neighbor at all are assigned the value -3. This only happens on the domain boundary, which is necessarily a tree boundary. Corner-neighbors for hanging nodes are assigned the value -1.
TODO: In case of an inter-tree corner neighbor relation in a brick-like situation (exactly one neighbor, diagonally opposite corner number), use the same encoding as for corners within a tree.
Field | Note |
---|---|
quad_to_tree | tree index for each local quad. Is NULL by default, but may be enabled by p4estmeshnew_ext. |
ghost_to_proc | processor for each ghost quad |
quad_to_quad | one index for each of the 4 faces |
quad_to_face | encodes orientation/2:1 status |
quad_to_half | stores half-size neighbors |
quad_level | Stores lists of per-level quads. The array has entries indexed by 0..P4EST_QMAXLEVEL inclusive that are arrays of local quadrant ids. Is NULL by default, but may be enabled by p4estmeshnew_ext. |
P4est.LibP4est.p4est_qcoord_t
— TypeTypedef for quadrant coordinates.
P4est.LibP4est.p4est_quadrant
— Typep4est_quadrant
The 2D quadrant datatype
Field | Note |
---|---|
x | coordinates |
y | |
level | level of refinement |
pad8 | padding |
pad16 | |
p | a union of additional data attached to a quadrant |
P4est.LibP4est.p4est_quadrant_t
— TypeThe 2D quadrant datatype
P4est.LibP4est.p4est_refine_t
— TypeCallback function prototype to decide for refinement.
Parameters
p4est
:[in] the forestwhich_tree
:[in] the tree containing quadrantquadrant
:[in] the quadrant that may be refined
Returns
nonzero if the quadrant shall be refined.
P4est.LibP4est.p4est_replace_t
— TypeCallback 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.
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.
Parameters
num_outgoing
:[in] The number of outgoing quadrants.outgoing
:[in] The outgoing quadrants: after the callback, the user_data, ifp4est
->data_size is nonzero, will be destroyed.num_incoming
:[in] The number of incoming quadrants.incoming
:[in,out] The incoming quadrants: prior to the callback, the user_data, ifp4est
->datasize is nonzero, is allocated, and the [`p4estinit_t`](@ref) callback, if it has been provided, will be called.
P4est.LibP4est.p4est_search_all_t
— TypeCallback function for the top-down search through the whole forest.
Parameters
p4est
:[in] The forest to search. We recurse through the trees one after another.which_tree
:[in] The current tree number.quadrant
:[in] The current quadrant in the recursion. This quadrant is either a non-leaf tree branch or a leaf. If the quadrant is contained in the local partition, we know which, otherwise we don't. Let us first consider the situation when quadrant is local, which is indicated by both pfirst and plast being equal top4est
->mpirank. Then the parameter local_num is negative for non-leaves and the number of the quadrant as a leaf in local storage otherwise. Only if the quadrant is a local leaf, it points to the actual local storage and can be used to access user data etc., and the recursion terminates. The other possibility is that pfirst < plast, in which case we proceed with the recursion, or both are equal to the same remote rank, in which case the recursion terminates. Either way, the quadrant is not from local forest storage.pfirst
:[in] The lowest processor that owns part of quadrant. Guaranteed to be non-empty.plast
:[in] The highest processor that owns part of quadrant. Guaranteed to be non-empty.local_num
:[in] If quadrant is a local leaf, this number is the index of the leaf in local quadrant storage. Else, this is a negative value.point
:[in,out] User-defined representation of a point. This parameter distinguishes two uses of the callback. For each quadrant, the callback is first called with a NULL point, and if this callback returns true, once for each point tracked in this branch. The return value for a point determines whether it shall be tracked further down the branch or not, and has no effect on a local leaf. The call with a NULL point is intended to prepare quadrant-related search meta data that is common to all points, and/or to efficiently terminate the recursion for all points in the branch in one call.
Returns
If false, the recursion at quadrant terminates. If true, it continues if pfirst < plast or if they are both equal to p4est
->mpirank and the recursion has not reached a leaf yet.
P4est.LibP4est.p4est_search_local_t
— TypeCallback function to query the match of a "point" with a quadrant.
This function can be called in two roles: Per-quadrant, in which case the parameter point is NULL, or per-point, possibly many times per quadrant.
Parameters
p4est
:[in] The forest to be queried.which_tree
:[in] The tree id under consideration.quadrant
:[in] The quadrant under consideration. This quadrant may be coarser than the quadrants that are contained in the forest (an ancestor), in which case it is a temporary variable and not part of the forest storage. Otherwise, it is a leaf and points directly into the forest storage.local_num
:[in] If the quadrant is not a leaf, this is < 0. Otherwise it is the (non-negative) index of the quadrant relative to the processor-local storage.point
:[in] Representation of a "point"; user-defined. If point is NULL, the callback may be used to prepare quadrant-related search meta data.
Returns
If point is NULL, true if the search confined to quadrant should be executed, false to skip it. Else, true if point may be contained in the quadrant and false otherwise; the return value has no effect on a leaf.
P4est.LibP4est.p4est_search_partition_t
— TypeCallback function for the partition recursion.
Parameters
p4est
:[in] The forest to traverse. Its local quadrants are never accessed.which_tree
:[in] The tree number under consideration.quadrant
:[in] This quadrant is not from local forest storage, and its user data is undefined. It represents the branch of the forest in the top-down recursion.pfirst
:[in] The lowest processor that owns part of quadrant. Guaranteed to be non-empty.plast
:[in] The highest processor that owns part of quadrant. Guaranteed to be non-empty. If this is equal to pfirst, then the recursion will stop for quadrant's branch after this function returns.point
:[in,out] Pointer to a user-defined point object. If called per-quadrant, this is NULL.
Returns
If false, the recursion at quadrant is terminated. If true, it continues if pfirst < plast.
P4est.LibP4est.p4est_search_query_t
— TypeThis typedef is provided for backwards compatibility.
P4est.LibP4est.p4est_t
— TypeThe p4est
forest datatype
P4est.LibP4est.p4est_topidx_t
— TypeTypedef for counting topological entities (trees, tree vertices).
P4est.LibP4est.p4est_tree
— Typep4est_tree
The p4est
tree datatype
Field | Note |
---|---|
quadrants | locally stored quadrants |
first_desc | first local descendant |
last_desc | last local descendant |
quadrants_offset | cumulative sum over earlier trees on this processor (locals only) |
maxlevel | highest local quadrant level |
P4est.LibP4est.p4est_tree_t
— TypeThe p4est
tree datatype
P4est.LibP4est.p4est_weight_t
— TypeCallback function prototype to calculate weights for partitioning.
Global sum of weights must fit into a 64bit integer.
Parameters
p4est
:[in] the forestwhich_tree
:[in] the tree containing quadrant
Returns
a 32bit integer >= 0 as the quadrant weight.
P4est.LibP4est.p6est_coarsen_column_t
— TypeCallback function prototype to decide for horizontal coarsening.
Parameters
columns
:[in] Pointers to 4 sibling columns.
Returns
nonzero if the columns shall be replaced with their parent.
P4est.LibP4est.p6est_coarsen_layer_t
— TypeCallback function prototype to decide for vertical coarsening.
Parameters
layers
:[in] Pointers to 2 vertical sibling layers.
Returns
nonzero if the layers shall be replaced with their parent.
P4est.LibP4est.p6est_connectivity
— Typep6est_connectivity
This structure holds the 2D+1D inter-tree connectivity information. It is essentially a wrapper of the 2D p4est_connecitivity_t datatype, with some additional information about how the third dimension is embedded.
Field | Note |
---|---|
conn4 | the 2D connecitvity; owned; vertices interpreted as the vertices of the bottom of the sheet |
top_vertices | if NULL, uniform vertical profile, otherwise the vertices of the top of the sheet: should be the same size as conn4->treetovertex; owned. |
height | if top_vertices == NULL, this gives the offset from the bottom of the sheet to the top |
P4est.LibP4est.p6est_connectivity_t
— TypeThis structure holds the 2D+1D inter-tree connectivity information. It is essentially a wrapper of the 2D p4est_connecitivity_t datatype, with some additional information about how the third dimension is embedded.
P4est.LibP4est.p6est_init_t
— TypeCallback function prototype to initialize the layers's user data.
Parameters
p6est
:[in] the forestwhich_tree
:[in] the tree in the forestcolumn
:[in] the column in the tree in the forestlayer
:[in] the layer in the column in the tree in the forest, whose user_data is to be initialized
P4est.LibP4est.p6est_refine_column_t
— TypeCallback function prototype to decide whether to horizontally refine a column, i.e., horizontally refine all of the layers in the column.
Returns
nonzero if the layer shall be refined.
P4est.LibP4est.p6est_refine_layer_t
— TypeCallback function prototype to decide whether to vertically refine a layer.
Returns
nonzero if the layer shall be refined.
P4est.LibP4est.p6est_replace_t
— TypeCallback function prototype to transfer information from outgoing layers to incoming layers.
This is used by extended routines when the layers of an existing, valid p6est
are changed. The callback allows the user to make changes to newly initialized layers before the layers that they replace are destroyed.
Parameters
num_outcolumns
:[in] The number of columns that contain the outgoing layers: will be either 1 or 4.num_outlayers
:[in] The number of outgoing layers: will be either 1 (a single layer is being refined), 2 (two layers are being vertically coarsened), or 4 (four layers are being horizontally coarsened).outcolumns
:[in] The columns of the outgoing layersoutlayers
:[in] The outgoing layers: after the callback, the user_data, ifp6est
->data_size is nonzero, will be destroyed.num_incolumns
:[in] The number of columns that contain the outgoing layers: will be either 1 or 4.num_inlayers
:[in] The number of incoming layers: will be either 1 (coarsening), 2 (vertical refinement), or 4 (horizontal refinement)incolumns
:[in] The columns of the incoming layersinlayers
:[in,out] The incoming layers: prior to the callback, the user_data, ifp6est
->datasize is nonzero, is allocated, and the [`p6estinit_t`](@ref) callback, if it has been provided, will be called.
P4est.LibP4est.p6est_t
— TypeThe p6est
forest datatype
P4est.LibP4est.p6est_weight_t
— TypeCallback function prototype to calculate weights for partitioning.
Global sum of weights must fit into a 64bit integer.
Returns
a 32bit integer >= 0 as the quadrant weight.
P4est.LibP4est.p8est_coarsen_t
— TypeCallback function prototype to decide for coarsening.
Parameters
p8est
:[in] the forestwhich_tree
:[in] the tree containing quadrantquadrants
:[in] Pointers to 8 siblings in Morton ordering.
Returns
nonzero if the quadrants shall be replaced with their parent.
P4est.LibP4est.p8est_connect_type_t
— Typep8est_connect_type_t
Characterize a type of adjacency.
Several functions involve relationships between neighboring trees and/or quadrants, and their behavior depends on how one defines adjacency: 1) entities are adjacent if they share a face, or 2) entities are adjacent if they share a face or corner, or 3) entities are adjacent if they share a face, corner or edge. p8est_connect_type_t
is used to choose the desired behavior. This enum must fit into an int8_t.
P4est.LibP4est.p8est_connectivity
— Typep8est_connectivity
This structure holds the 3D inter-tree connectivity information. Identification of arbitrary faces, edges and corners is possible.
The arrays tree_to_* are stored in z ordering. For corners the order wrt. zyx is 000 001 010 011 100 101 110 111. For faces the order is -x +x -y +y -z +z. They are allocated [0][0]..[0][N-1]..[num_trees-1][0]..[num_trees-1][N-1]. where N is 6 for tree and face, 8 for corner, 12 for edge.
The values for tree_to_face are in 0..23 where ttf % 6 gives the face number and ttf / 6 the face orientation code. The orientation is determined as follows. Let my_face and other_face be the two face numbers of the connecting trees in 0..5. Then the first face corner of the lower of my_face and other_face connects to a face corner numbered 0..3 in the higher of my_face and other_face. The face orientation is defined as this number. If my_face == other_face, treating either of both faces as the lower one leads to the same result.
It is valid to specify num_vertices as 0. In this case vertices and tree_to_vertex are set to NULL. Otherwise the vertex coordinates are stored in the array vertices as [0][0]..[0][2]..[num_vertices-1][0]..[num_vertices-1][2].
The edges are only stored when they connect trees. In this case tree_to_edge indexes into ett_offset. Otherwise the tree_to_edge entry must be -1 and this edge is ignored. If num_edges == 0, tree_to_edge and edge_to_* arrays are set to NULL.
The arrays edge_to_* store a variable number of entries per edge. For edge e these are at position [ett_offset[e]]..[ett_offset[e+1]-1]. Their number for edge e is ett_offset[e+1] - ett_offset[e]. The entries encode all trees adjacent to edge e. The size of the edge_to_* arrays is num_ett = ett_offset[num_edges]. The edge_to_edge array holds values in 0..23, where the lower 12 indicate one edge orientation and the higher 12 the opposite edge orientation.
The corners are only stored when they connect trees. In this case tree_to_corner indexes into ctt_offset. Otherwise the tree_to_corner entry must be -1 and this corner is ignored. If num_corners == 0, tree_to_corner and corner_to_* arrays are set to NULL.
The arrays corner_to_* store a variable number of entries per corner. For corner c these are at position [ctt_offset[c]]..[ctt_offset[c+1]-1]. Their number for corner c is ctt_offset[c+1] - ctt_offset[c]. The entries encode all trees adjacent to corner c. The size of the corner_to_* arrays is num_ctt = ctt_offset[num_corners].
The *_to_attr arrays may have arbitrary contents defined by the user.
Field | Note |
---|---|
num_vertices | the number of vertices that define the embedding of the forest (not the topology) |
num_trees | the number of trees |
num_edges | the number of edges that help define the topology |
num_corners | the number of corners that help define the topology |
vertices | an array of size (3 * num_vertices) |
tree_to_vertex | embed each tree into c++ R^3 for e.g. visualization (see p8est_vtk.h) |
tree_attr_bytes | bytes per tree in tree_to_attr |
tree_to_attr | not touched by p4est |
tree_to_tree | (6 * num_trees) neighbors across faces |
tree_to_face | (6 * num_trees) face to face+orientation (see description) |
tree_to_edge | (12 * num_trees) or NULL (see description) |
ett_offset | edge to offset in edgetotree and edgetoedge |
edge_to_tree | list of trees that meet at an edge |
edge_to_edge | list of tree-edges+orientations that meet at an edge (see description) |
tree_to_corner | (8 * num_trees) or NULL (see description) |
ctt_offset | corner to offset in cornertotree and cornertocorner |
corner_to_tree | list of trees that meet at a corner |
corner_to_corner | list of tree-corners that meet at a corner |
P4est.LibP4est.p8est_connectivity_encode_t
— Typep8est_connectivity_encode_t
Typedef for serialization method.
Enumerator | Note |
---|---|
P8EST_CONN_ENCODE_LAST | Invalid entry to close the list. |
P4est.LibP4est.p8est_connectivity_t
— TypeThis structure holds the 3D inter-tree connectivity information. Identification of arbitrary faces, edges and corners is possible.
The arrays tree_to_* are stored in z ordering. For corners the order wrt. zyx is 000 001 010 011 100 101 110 111. For faces the order is -x +x -y +y -z +z. They are allocated [0][0]..[0][N-1]..[num_trees-1][0]..[num_trees-1][N-1]. where N is 6 for tree and face, 8 for corner, 12 for edge.
The values for tree_to_face are in 0..23 where ttf % 6 gives the face number and ttf / 6 the face orientation code. The orientation is determined as follows. Let my_face and other_face be the two face numbers of the connecting trees in 0..5. Then the first face corner of the lower of my_face and other_face connects to a face corner numbered 0..3 in the higher of my_face and other_face. The face orientation is defined as this number. If my_face == other_face, treating either of both faces as the lower one leads to the same result.
It is valid to specify num_vertices as 0. In this case vertices and tree_to_vertex are set to NULL. Otherwise the vertex coordinates are stored in the array vertices as [0][0]..[0][2]..[num_vertices-1][0]..[num_vertices-1][2].
The edges are only stored when they connect trees. In this case tree_to_edge indexes into ett_offset. Otherwise the tree_to_edge entry must be -1 and this edge is ignored. If num_edges == 0, tree_to_edge and edge_to_* arrays are set to NULL.
The arrays edge_to_* store a variable number of entries per edge. For edge e these are at position [ett_offset[e]]..[ett_offset[e+1]-1]. Their number for edge e is ett_offset[e+1] - ett_offset[e]. The entries encode all trees adjacent to edge e. The size of the edge_to_* arrays is num_ett = ett_offset[num_edges]. The edge_to_edge array holds values in 0..23, where the lower 12 indicate one edge orientation and the higher 12 the opposite edge orientation.
The corners are only stored when they connect trees. In this case tree_to_corner indexes into ctt_offset. Otherwise the tree_to_corner entry must be -1 and this corner is ignored. If num_corners == 0, tree_to_corner and corner_to_* arrays are set to NULL.
The arrays corner_to_* store a variable number of entries per corner. For corner c these are at position [ctt_offset[c]]..[ctt_offset[c+1]-1]. Their number for corner c is ctt_offset[c+1] - ctt_offset[c]. The entries encode all trees adjacent to corner c. The size of the corner_to_* arrays is num_ctt = ctt_offset[num_corners].
The *_to_attr arrays may have arbitrary contents defined by the user.
P4est.LibP4est.p8est_ghost_exchange
— Typep8est_ghost_exchange
Transient storage for asynchronous ghost exchange.
Field | Note |
---|---|
is_custom | False for p8est_ghost_exchange_data |
is_levels | Are we restricted to levels or not |
minlevel | Meaningful with is_levels |
maxlevel |
P4est.LibP4est.p8est_ghost_exchange_t
— TypeTransient storage for asynchronous ghost exchange.
P4est.LibP4est.p8est_ghost_t
— Typep8est_ghost_t
quadrants that neighbor the local domain
Field | Note |
---|---|
btype | which neighbors are in the ghost layer |
ghosts | array of p8est_quadrant_t type |
tree_offsets | num_trees + 1 ghost indices |
proc_offsets | mpisize + 1 ghost indices |
mirrors | array of p8est_quadrant_t type |
mirror_tree_offsets | num_trees + 1 mirror indices |
mirror_proc_mirrors | indices into mirrors grouped by outside processor rank and ascending within each rank |
mirror_proc_offsets | mpisize + 1 indices into mirror_proc_mirrors |
mirror_proc_fronts | like mirror_proc_mirrors, but limited to the outermost octants. This is NULL until p8est_ghost_expand is called |
mirror_proc_front_offsets | NULL until p8est_ghost_expand is called |
P4est.LibP4est.p8est_init_t
— TypeCallback function prototype to initialize the quadrant's user data.
Parameters
p8est
:[in] the forestwhich_tree
:[in] the tree containing quadrantquadrant
:[in,out] the quadrant to be initialized: if data_size > 0, the data to be initialized is at quadrant->p.userdata; otherwise, the non-pointer user data (such as quadrant->p.userint) can be initialized
P4est.LibP4est.p8est_inspect
— Typep8est_inspect
Field | Note |
---|---|
use_balance_ranges | Use sc_ranges to determine the asymmetric communication pattern. If usebalanceranges is false (the default), sc_notify is used. |
use_balance_ranges_notify | If true, call both sc_ranges and sc_notify and verify consistency. Which is actually used is still determined by usebalanceranges. |
use_balance_verify | Verify sc_ranges and/or sc_notify as applicable. |
balance_max_ranges | If positive and smaller than p8est_num ranges, overrides it |
balance_ranges | time spent in sc_ranges |
balance_notify | time spent in sc_notify |
balance_notify_allgather | time spent in sc_notify_allgather |
P4est.LibP4est.p8est_inspect_t
— TypeData pertaining to selecting, inspecting, and profiling algorithms. A pointer to this structure is hooked into the p8est
main structure. Declared in p8est_extended.h. Used to profile important algorithms.
P4est.LibP4est.p8est_iter_corner_info
— Typep8est_iter_corner_info
The information that is availalbe to the user-defined p8est_iter_corner_t
callback.
If tree_boundary is false, the corner is on the interior of a tree. When tree_boundary is false, sides[0] contains the lowest z-order quadrant that touches the corner. When tree_boundary is true, its value is P8EST_CONNECT_FACE/EDGE/CORNER depending on the location of the corner relative to the tree.
Field | Note |
---|---|
tree_boundary | boolean: interior face (0), tree boundary face (true) |
sides | array of p8est_iter_corner_side_t type |
P4est.LibP4est.p8est_iter_corner_info_t
— TypeThe information that is availalbe to the user-defined p8est_iter_corner_t
callback.
If tree_boundary is false, the corner is on the interior of a tree. When tree_boundary is false, sides[0] contains the lowest z-order quadrant that touches the corner. When tree_boundary is true, its value is P8EST_CONNECT_FACE/EDGE/CORNER depending on the location of the corner relative to the tree.
P4est.LibP4est.p8est_iter_corner_side
— Typep8est_iter_corner_side
Field | Note |
---|---|
treeid | the tree that contains quad |
corner | which of the quadrant's corners touches this corner |
is_ghost | boolean: local (0) or ghost (1) |
quadid | the index in the tree or ghost array |
faces | internal work data |
edges |
P4est.LibP4est.p8est_iter_corner_t
— TypeThe prototype for a function that p8est_iterate
will execute wherever the corner is a corner for all quadrants that touch it
i.e. the callback will not execute on a corner that sits on a hanging face or edge.
the forest does not need to be corner balanced for p8est_iterate
() to execute a callback function at corners, only face and edge balanced.
Parameters
info
:[in] information about a quadrant provided to the useruser_data
:[in,out] the user context passed top8est_iterate
()
P4est.LibP4est.p8est_iter_edge_info
— Typep8est_iter_edge_info
The information about all sides of an edge in the forest. If tree_boundary is false, the edge is on the interior of a tree. When tree_boundary is false, sides[0] contains the lowest z-order quadrant that touches the edge. When tree_boundary is true, its value is P8EST_CONNECT_FACE/EDGE depending on the location of the edge relative to the tree.
Field | Note |
---|---|
tree_boundary | boolean: interior face (0), tree boundary face (true) |
sides | array of p8est_iter_edge_side_t type |
P4est.LibP4est.p8est_iter_edge_info_t
— TypeThe information about all sides of an edge in the forest. If tree_boundary is false, the edge is on the interior of a tree. When tree_boundary is false, sides[0] contains the lowest z-order quadrant that touches the edge. When tree_boundary is true, its value is P8EST_CONNECT_FACE/EDGE depending on the location of the edge relative to the tree.
P4est.LibP4est.p8est_iter_edge_side
— Typep8est_iter_edge_side
Field | Note |
---|---|
treeid | the tree on this side |
edge | which quadrant side the edge touches |
orientation | the orientation of each quadrant relative to this edge, as in the definition of p8est_connectivity_t |
is_hanging | boolean: one full quad (0) or two smaller quads (1) |
P4est.LibP4est.p8est_iter_edge_t
— TypeThe prototype for a function that p8est_iterate
will execute wherever the edge is an edge of all quadrants that touch it i.e. the callback will not execute on an edge the sits on a hanging face.
the forest must be edge balanced for p8est_iterate
() to execute a callback function on edges.
Parameters
info
:[in] information about a quadrant provided to the useruser_data
:[in,out] the user context passed top8est_iterate
()
P4est.LibP4est.p8est_iter_face_info
— Typep8est_iter_face_info
The information that is available to the user-defined p8est_iter_face_t
callback.
The orientation is 0 if the face is within one tree; otherwise, it is the same as the orientation value between the two trees given in the connectivity. If the face is on the outside of the forest, then there is only one side. If tree_boundary is false, the face is on the interior of a tree. When tree_boundary false, sides[0] contains the lowest z-order quadrant that touches the face. When tree_boundary is true, its value is P8EST_CONNECT_FACE.
Field | Note |
---|---|
orientation | the orientation of the sides to each other, as in the definition of p8est_connectivity_t |
tree_boundary | boolean: interior face (0), tree boundary face (true) |
P4est.LibP4est.p8est_iter_face_info_t
— TypeThe information that is available to the user-defined p8est_iter_face_t
callback.
The orientation is 0 if the face is within one tree; otherwise, it is the same as the orientation value between the two trees given in the connectivity. If the face is on the outside of the forest, then there is only one side. If tree_boundary is false, the face is on the interior of a tree. When tree_boundary false, sides[0] contains the lowest z-order quadrant that touches the face. When tree_boundary is true, its value is P8EST_CONNECT_FACE.
P4est.LibP4est.p8est_iter_face_side
— Typep8est_iter_face_side
Information about one side of a face in the forest. If a quad is local (is_ghost is false), then its quadid indexes the tree's quadrant array; otherwise, it indexes the ghosts array. If the face is hanging, then the quadrants are listed in z-order. If a quadrant should be present, but it is not included in the ghost layer, then quad = NULL, is_ghost is true, and quadid = -1.
Field | Note |
---|---|
treeid | the tree on this side |
face | which quadrant side the face touches |
is_hanging | boolean: one full quad (0) or four smaller quads (1) |
P4est.LibP4est.p8est_iter_face_side_t
— TypeInformation about one side of a face in the forest. If a quad is local (is_ghost is false), then its quadid indexes the tree's quadrant array; otherwise, it indexes the ghosts array. If the face is hanging, then the quadrants are listed in z-order. If a quadrant should be present, but it is not included in the ghost layer, then quad = NULL, is_ghost is true, and quadid = -1.
P4est.LibP4est.p8est_iter_face_t
— TypeThe prototype for a function that p8est_iterate
() will execute wherever two quadrants share a face: the face can be a 2:1 hanging face, it does not have to be conformal.
the forest must be face balanced for p8est_iterate
() to execute a callback function on faces (see p8est_balance
()).
Parameters
info
:[in] information about a quadrant provided to the useruser_data
:[in,out] the user context passed top8est_iterate
()
P4est.LibP4est.p8est_iter_volume_info
— Typep8est_iter_volume_info
The information that is available to the user-defined p8est_iter_volume_t
callback function.
treeid gives the index in p4est
->trees of the tree to which quad belongs. quadid gives the index of quad within tree's quadrants array.
Field | Note |
---|---|
quad | the quadrant of the callback |
quadid | id in quad's tree array (see p8est_tree_t ) |
treeid | the tree containing quad |
P4est.LibP4est.p8est_iter_volume_info_t
— TypeThe information that is available to the user-defined p8est_iter_volume_t
callback function.
treeid gives the index in p4est
->trees of the tree to which quad belongs. quadid gives the index of quad within tree's quadrants array.
P4est.LibP4est.p8est_iter_volume_t
— TypeThe prototype for a function that p8est_iterate
() will execute at every quadrant local to the current process.
Parameters
info
:[in] information about a quadrant provided to the useruser_data
:[in,out] the user context passed top8est_iterate
()
P4est.LibP4est.p8est_lid_t
— TypeA datatype to handle the linear id in 3D. We use the implementation of unsigned 128 bit integer in libsc, i.e., a struct with the members high_bits and low_bits (both uint64_t).
P4est.LibP4est.p8est_lnodes_buffer
— Typep8est_lnodes_buffer
p8est_lnodes_buffer_t
handles the communication of data associated with nodes.
send_buffers is an array of arrays: one buffer for each process to which the current process sends node-data. It should not be altered between a shared__begin and a shared__end call.
recv_buffers is an array of arrays that is used in lnodes_share_all_. *recv_buffers[j] corresponds with lnodes->sharers[j]: it is the same length as lnodes->sharers[j]->sharednodes. At the completion of lnodes\share_all or lnodes_share_all_end, recv_buffers[j] contains the node-data from the process lnodes->sharers[j]->rank (unless j is the current rank, in which case recv_buffers[j] is empty).
P4est.LibP4est.p8est_lnodes_buffer_t
— Typep8est_lnodes_buffer_t
handles the communication of data associated with nodes.
send_buffers is an array of arrays: one buffer for each process to which the current process sends node-data. It should not be altered between a shared__begin and a shared__end call.
recv_buffers is an array of arrays that is used in lnodes_share_all_. *recv_buffers[j] corresponds with lnodes->sharers[j]: it is the same length as lnodes->sharers[j]->sharednodes. At the completion of lnodes\share_all or lnodes_share_all_end, recv_buffers[j] contains the node-data from the process lnodes->sharers[j]->rank (unless j is the current rank, in which case recv_buffers[j] is empty).
P4est.LibP4est.p8est_lnodes_rank
— Typep8est_lnodes_rank
The structure stored in the sharers array.
shared_nodes is a sorted array of p4est_locidx_t
that indexes into local nodes. The shared_nodes array has a contiguous (or empty) section of nodes owned by the current rank. shared_mine_offset and shared_mine_count identify this section by indexing the shared_nodes array, not the local nodes array. owned_offset and owned_count define the section of local nodes that is owned by the listed rank (the section may be empty). For the current process these coincide with those in p8est_lnodes_t
.
P4est.LibP4est.p8est_lnodes_rank_t
— TypeThe structure stored in the sharers array.
shared_nodes is a sorted array of p4est_locidx_t
that indexes into local nodes. The shared_nodes array has a contiguous (or empty) section of nodes owned by the current rank. shared_mine_offset and shared_mine_count identify this section by indexing the shared_nodes array, not the local nodes array. owned_offset and owned_count define the section of local nodes that is owned by the listed rank (the section may be empty). For the current process these coincide with those in p8est_lnodes_t
.
P4est.LibP4est.p8est_lnodes_t
— TypeStore a parallel numbering of Lobatto points of a given degree > 0.
Each element has degree+1 nodes per edge and vnodes = (degree+1)^3 nodes per volume. element_nodes is of dimension vnodes * num_local_elements and lists the nodes of each element in lexicographic yx-order (x varies fastest); element_nodes indexes into the set of local nodes, layed out as follows: local nodes = [<––-owned_count––->|<––-nonlocal_nodes––->] = [<––––––––num_local_nodes––––––––->] nonlocal_nodes contains the globally unique numbers for independent nodes that are owned by other processes; for local nodes, the globally unique numbers are given by i + global_offset, where i is the local number. Hanging nodes are always local and don't have a global number. They index the geometrically corresponding independent nodes of a neighbor.
Whether nodes are hanging or not is decided based on the element faces and edges. This information is encoded in face_code with one int16_t per element. If no faces or edges are hanging, the value is zero, otherwise the face_code is interpreted by p8est_lnodes_decode.
Independent nodes can be shared by multiple MPI ranks. The owner rank of a node is the one from the lowest numbered element on the lowest numbered octree touching the node.
What is meant by touching? A quadrant is said to touch all faces/edges/corners that are incident on it, and by extension all nodes that are contained in those faces/edges/corners.
X +–––––-+ x |\ \ x | \ \ . x | \ \ x X | +–––––-+ +––-+ . . | | | |\ \ X o + | | | +––-+ o . \ | p | + | q | o \ | | \| | o \| | +––-+ O +–––––-+
In this example degree = 3. There are 4 nodes that live on the face between q and p, two on each edge and one at each corner of that face. The face is incident on q, so q owns the nodes marked '.' on the face (provided q is from a lower tree or has a lower index than p). The bottom and front edges are incident on q, so q owns its nodes marked 'o' as well. The front lower corner is incident on q, so q owns its node 'O' as well. The other edges and corners are not incident on q, so q cannot own their nodes, marked 'x' and 'X'.
global_owned_count contains the number of independent nodes owned by each process.
The sharers array contains items of type p8est_lnodes_rank_t
that hold the ranks that own or share independent local nodes. If there are no shared nodes on this processor, it is empty. Otherwise, it is sorted by rank and the current process is included.
degree < 0 indicates that the lnodes data structure is being used to number the quadrant boundary object (faces, edge and corners) rather than the $C^0$ Lobatto nodes:
if degree == -1, then one node is assigned per face, and no nodes are assigned per volume, per edge, or per corner: this numbering can be used for low-order Raviart-Thomas elements. In this case, vnodes == 6, and the nodes are listed in face-order.
if degree == -2, then one node is assigned per face and per edge and no nodes are assigned per volume or per corner. In this case, vnodes == 18, and the nodes are listed in face-order, followed by edge-order.
if degree == -3, then one node is assigned per face, per edge and per corner and no nodes are assigned per volume. In this case, vnodes == 26, and the nodes are listed in face-order, followed by edge-order, followed by corner-order.
P4est.LibP4est.p8est_mesh_face_neighbor_t
— Typep8est_mesh_face_neighbor_t
This structure can be used as the status of a face neighbor iterator. It always contains the face and subface of the neighbor to be processed.
P4est.LibP4est.p8est_mesh_t
— Typep8est_mesh_t
This structure contains complete mesh information on a 2:1 balanced forest. It stores the locally relevant neighborhood, that is, all locally owned quadrants and one layer of adjacent ghost quadrants and their owners.
For each local quadrant, its tree number is stored in quad_to_tree. The quad_to_tree array is NULL by default and can be enabled using p8estmeshnewext. For each ghost quadrant, its owner rank is stored in ghost\to_proc. For each level, an array of local quadrant numbers is stored in quad_level. The quad_level array is NULL by default and can be enabled using p8estmeshnew_ext.
The quad_to_quad list stores one value for each local quadrant's face. This value is in 0..local_num_quadrants-1 for local quadrants, or in local_num_quadrants + (0..ghost_num_quadrants-1) for ghost quadrants.
The quad_to_face list has equally many entries that are either: 1. A value of v = 0..23 indicates one same-size neighbor. This value is decoded as v = r * 6 + nf, where nf = 0..5 is the neighbor's connecting face number and r = 0..3 is the relative orientation of the neighbor's face; see p8est_connectivity
.h. 2. A value of v = 24..119 indicates a double-size neighbor. This value is decoded as v = 24 + h * 24 + r * 6 + nf, where r and nf are as above and h = 0..3 is the number of the subface. h designates the subface of the large neighbor that the quadrant touches (this is the same as the large neighbor's face corner). 3. A value of v = -24..-1 indicates four half-size neighbors. In this case the corresponding quad_to_quad index points into the quad_to_half array that stores four quadrant numbers per index, and the orientation of the smaller faces follows from 24 + v. The entries of quad_to_half encode between local and ghost quadrant in the same way as the quad_to_quad values described above. The small neighbors in quad_to_half are stored in the sequence of the face corners of this, i.e., the large quadrant.
A quadrant on the boundary of the forest sees itself and its face number.
The quad_to_edge list stores edge neighbors that are not face neighbors. On the inside of a tree, there are one or two of those depending on size. Between trees, there can be any number of same- or different-sized neighbors. For same-tree same-size neighbors, we record their number in quad_to_edge by the same convention as described for quad_to_quad above. In this case, the neighbor's matching edge number is always diagonally opposite, that is, edge number ^ 3.
For half- and double-size and all inter-tree edge neighbors, the quad_to_edge value is in local_num_quadrants + local_num_ghosts + [0 .. local_num_edges - 1]. After subtracting the number of local and ghost quadrants, it indexes into edge_offset, which encodes a group of edge neighbors. Each member of a group may be one same/double-size quadrant or two half-size quadrants; this is determined by the value of the edge_edge field as follows. 1. A value of e = 0..23 indicates one same-size neighbor. This value is encoded as e = r * 12 + ne, where ne = 0..11 is the neighbor's connecting edge number and r = 0..1 indicates an edge flip. 2. A value of e = 24..71 indicates a double-size neighbor. This value is decoded as e = 24 + h * 24 + r * 12 + ne, where r and ne are as above and h = 0..1 is the number of the subedge. h designates the subedge of the large neighbor that the quadrant touches (this is the same as the large neighbor's edge corner). 3. A value of e = -24..-1 indicates two half-size neighbors. They are represented by two consecutive entries of the edge_quad and edge_edge arrays with identical values for edge_edge. The orientation of the smaller edges follows from 24 + e. The small neighbors in edge_quad are stored in the sequence of the edge corners of this, i.e., the large quadrant.
Edges with no diagonal neighbor at all are assigned the value -3. This only happens on the domain boundary, which is necessarily a tree boundary. Edge neighbors for face-hanging nodes are assigned the value -1.
The quad_to_corner list stores corner neighbors that are not face or edge neighbors. On the inside of a tree, there is precisely one such neighbor per corner. In this case, its index is encoded as described above for quad_to_quad. The neighbor's matching corner number is always diagonally opposite, that is, corner number ^ 7.
On the inside of an inter-tree face, we have precisely one corner neighbor. If a corner is across an inter-tree edge or corner, then the number of corner neighbors may be any non-negative number. In all three cases, the quad_to_corner value is in local_num_quadrants + local_num_ghosts + [0 .. local_num_corners - 1]. After subtracting the number of local and ghost quadrants, it indexes into corner_offset, which encodes a group of corner neighbors. Each group contains the quadrant numbers encoded as usual for quad_to_quad in corner_quad, and the corner number from the neighbor as corner_corner.
Corners with no diagonal neighbor at all are assigned the value -3. This only happens on the domain boundary, which is necessarily a tree boundary. Corner-neighbors for face- and edge-hanging nodes are assigned the value -1.
TODO: In case of an inter-tree neighbor relation in a brick-like situation (one same-size neighbor, diagonally opposite edge/corner), use the same encoding as for edges/corners within a tree.
Field | Note |
---|---|
quad_to_tree | tree index for each local quad. Is NULL by default, but may be enabled by p8estmeshnew_ext. |
ghost_to_proc | processor for each ghost quad |
quad_to_quad | one index for each of the 6 faces |
quad_to_face | encodes orientation/2:1 status |
quad_to_half | stores half-size neighbors |
quad_level | Stores lists of per-level quads. The array has entries indexed by 0..P4EST_QMAXLEVEL inclusive that are arrays of local quadrant ids. Is NULL by default, but may be enabled by p8estmeshnew_ext. |
local_num_edges | unsame-size and tree-boundary edges |
quad_to_edge | 12 indices for each local quad |
edge_offset | local_num_edges + 1 entries |
edge_quad | edge_offset indexes into this |
edge_edge | and this one too (type int8_t) |
P4est.LibP4est.p8est_quadrant
— Typep8est_quadrant
The 3D quadrant (i.e., octant) datatype
Field | Note |
---|---|
x | coordinates |
y | |
z | |
level | level of refinement |
pad8 | padding |
pad16 | |
p | a union of additional data attached to a quadrant |
P4est.LibP4est.p8est_quadrant_t
— TypeThe 3D quadrant (i.e., octant) datatype
P4est.LibP4est.p8est_refine_t
— TypeCallback function prototype to decide for refinement.
Parameters
p8est
:[in] the forestwhich_tree
:[in] the tree containing quadrantquadrant
:[in] the quadrant that may be refined
Returns
nonzero if the quadrant shall be refined.
P4est.LibP4est.p8est_replace_t
— TypeCallback function prototype to replace one set of quadrants with another.
This is used by extended routines when the quadrants of an existing, valid p8est
are changed. The callback allows the user to make changes to newly initialized quadrants before the quadrants that they replace are destroyed.
If the mesh is being refined, num_outgoing will be 1 and num_incoming will be 8, and vice versa if the mesh is being coarsened.
Parameters
num_outgoing
:[in] The number of outgoing quadrants.outgoing
:[in] The outgoing quadrants: after the callback, the user_data, ifp8est
->data_size is nonzero, will be destroyed.num_incoming
:[in] The number of incoming quadrants.incoming
:[in,out] The incoming quadrants: prior to the callback, the user_data, ifp8est
->datasize is nonzero, is allocated, and the [`p8estinit_t`](@ref) callback, if it has been provided, will be called.
P4est.LibP4est.p8est_search_all_t
— TypeCallback function for the top-down search through the whole forest.
Parameters
p4est
:[in] The forest to search. We recurse through the trees one after another.which_tree
:[in] The current tree number.quadrant
:[in] The current quadrant in the recursion. This quadrant is either a non-leaf tree branch or a leaf. If the quadrant is contained in the local partition, we know which, otherwise we don't. Let us first consider the situation when quadrant is local, which is indicated by both pfirst and plast being equal top4est
->mpirank. Then the parameter local_num is negative for non-leaves and the number of the quadrant as a leaf in local storage otherwise. Only if the quadrant is a local leaf, it points to the actual local storage and can be used to access user data etc., and the recursion terminates. The other possibility is that pfirst < plast, in which case we proceed with the recursion, or both are equal to the same remote rank, in which case the recursion terminates. Either way, the quadrant is not from local forest storage.pfirst
:[in] The lowest processor that owns part of quadrant. Guaranteed to be non-empty.plast
:[in] The highest processor that owns part of quadrant. Guaranteed to be non-empty.local_num
:[in] If quadrant is a local leaf, this number is the index of the leaf in local quadrant storage. Else, this is a negative value.point
:[in,out] User-defined representation of a point. This parameter distinguishes two uses of the callback. For each quadrant, the callback is first called with a NULL point, and if this callback returns true, once for each point tracked in this branch. The return value for a point determines whether it shall be tracked further down the branch or not, and has no effect on a local leaf. The call with a NULL point is intended to prepare quadrant-related search meta data that is common to all points, and/or to efficiently terminate the recursion for all points in the branch in one call.
Returns
If false, the recursion at quadrant terminates. If true, it continues if pfirst < plast or if they are both equal to p4est
->mpirank and the recursion has not reached a leaf yet.
P4est.LibP4est.p8est_search_local_t
— TypeCallback function to query the match of a "point" with a quadrant.
This function can be called in two roles: Per-quadrant, in which case the parameter point is NULL, or per-point, possibly many times per quadrant.
Parameters
p4est
:[in] The forest to be queried.which_tree
:[in] The tree id under consideration.quadrant
:[in] The quadrant under consideration. This quadrant may be coarser than the quadrants that are contained in the forest (an ancestor), in which case it is a temporary variable and not part of the forest storage. Otherwise, it is a leaf and points directly into the forest storage.local_num
:[in] If the quadrant is not a leaf, this is < 0. Otherwise it is the (non-negative) index of the quadrant relative to the processor-local storage.point
:[in] Representation of a "point"; user-defined. If point is NULL, the callback may be used to prepare quadrant-related search meta data.
Returns
If point is NULL, true if the search confined to quadrant should be executed, false to skip it. Else, true if point may be contained in the quadrant and false otherwise; the return value has no effect on a leaf.
P4est.LibP4est.p8est_search_partition_t
— TypeCallback function for the partition recursion.
Parameters
p4est
:[in] The forest to traverse. Its local quadrants are never accessed.which_tree
:[in] The tree number under consideration.quadrant
:[in] This quadrant is not from local forest storage, and its user data is undefined. It represents the branch of the forest in the top-down recursion.pfirst
:[in] The lowest processor that owns part of quadrant. Guaranteed to be non-empty.plast
:[in] The highest processor that owns part of quadrant. Guaranteed to be non-empty. If this is equal to pfirst, then the recursion will stop for quadrant's branch after this function returns.point
:[in,out] Pointer to a user-defined point object. If called per-quadrant, this is NULL.
Returns
If false, the recursion at quadrant is terminated. If true, it continues if pfirst < plast.
P4est.LibP4est.p8est_search_query_t
— TypeThis typedef is provided for backwards compatibility.
P4est.LibP4est.p8est_t
— TypeThe p8est
forest datatype
P4est.LibP4est.p8est_tree
— Typep8est_tree
The p8est
tree datatype
Field | Note |
---|---|
quadrants | locally stored quadrants |
first_desc | first local descendant |
last_desc | last local descendant |
quadrants_offset | cumulative sum over earlier trees on this processor (locals only) |
maxlevel | highest local quadrant level |
P4est.LibP4est.p8est_tree_t
— TypeThe p8est
tree datatype
P4est.LibP4est.p8est_weight_t
— TypeCallback function prototype to calculate weights for partitioning.
Global sum of weights must fit into a 64bit integer.
Parameters
p8est
:[in] the forestwhich_tree
:[in] the tree containing quadrant
Returns
a 32bit integer >= 0 as the quadrant weight.
P4est.LibP4est.sc_array
— Typesc_array
The sc_array
object provides a dynamic array of equal-size elements. Elements are accessed by their 0-based index. Their address may change. The number of elements (== elem_count) of the array can be changed by scarrayresize and scarrayrewind. Elements can be sorted with scarraysort. If the array is sorted, it can be searched with scarraybsearch. A priority queue is implemented with pqueue_add and pqueue_pop (untested).
Field | Note |
---|---|
elem_size | size of a single element |
elem_count | number of valid elements |
byte_alloc | number of allocated bytes or -(number of viewed bytes + 1) if this is a view: the "+ 1" distinguishes an array of size 0 from a view of size 0 |
array | linear array to store elements |
P4est.LibP4est.sc_array_t
— TypeThe sc_array
object provides a dynamic array of equal-size elements. Elements are accessed by their 0-based index. Their address may change. The number of elements (== elem_count) of the array can be changed by scarrayresize and scarrayrewind. Elements can be sorted with scarraysort. If the array is sorted, it can be searched with scarraybsearch. A priority queue is implemented with pqueue_add and pqueue_pop (untested).
P4est.LibP4est.sc_array_type_t
— TypeFunction to determine the enumerable type of an object in an array.
Parameters
array
:[in] Array containing the object.index
:[in] The location of the object.data
:[in] Arbitrary user data.
P4est.LibP4est.sc_equal_function_t
— TypeFunction to check equality of two objects.
Parameters
u
:[in] Arbitrary user data.
Returns
Returns false if *v1 is unequal *v2 and true otherwise.
P4est.LibP4est.sc_hash
— Typesc_hash
The sc_hash
implements a hash table. It uses an array which has linked lists as elements.
Field | Note |
---|---|
elem_count | total number of objects contained |
slots | the slot count is slots->elem_count |
user_data | user data passed to hash function |
allocator | must allocate sc_link_t |
P4est.LibP4est.sc_hash_array
— Typesc_hash_array
The sc_hash_array
implements an array backed up by a hash table. This enables O(1) access for array elements.
P4est.LibP4est.sc_hash_array_t
— TypeThe sc_hash_array
implements an array backed up by a hash table. This enables O(1) access for array elements.
P4est.LibP4est.sc_hash_foreach_t
— TypeFunction to call on every data item of a hash table.
Parameters
v
:[in] The address of the pointer to the current object.u
:[in] Arbitrary user data.
Returns
Return true if the traversal should continue, false to stop.
P4est.LibP4est.sc_hash_function_t
— TypeFunction to compute a hash value of an object.
Parameters
v
:[in] The object to hash.u
:[in] Arbitrary user data.
Returns
Returns an unsigned integer.
P4est.LibP4est.sc_hash_t
— TypeThe sc_hash
implements a hash table. It uses an array which has linked lists as elements.
P4est.LibP4est.sc_io_encode_t
— Typesc_io_encode_t
Enumerator | Note |
---|---|
SC_IO_ENCODE_LAST | Invalid entry to close list |
P4est.LibP4est.sc_io_error_t
— Typesc_io_error_t
Error values for io.
Enumerator | Note |
---|---|
SC_IO_ERROR_NONE | The value of zero means no error. |
SC_IO_ERROR_FATAL | The io object is now disfunctional. |
SC_IO_ERROR_AGAIN | Another io operation may resolve it. The function just returned was a noop. |
P4est.LibP4est.sc_io_mode_t
— Typesc_io_mode_t
Enumerator | Note |
---|---|
SC_IO_MODE_WRITE | Semantics as "w" in fopen. |
SC_IO_MODE_APPEND | Semantics as "a" in fopen. |
SC_IO_MODE_LAST | Invalid entry to close list |
P4est.LibP4est.sc_io_sink
— Typesc_io_sink
Field | Note |
---|---|
buffer_bytes | distinguish from array elems |
P4est.LibP4est.sc_io_source
— Typesc_io_source
Field | Note |
---|---|
buffer_bytes | distinguish from array elems |
P4est.LibP4est.sc_io_type_t
— Typesc_io_type_t
Enumerator | Note |
---|---|
SC_IO_TYPE_LAST | Invalid entry to close list |
P4est.LibP4est.sc_link
— Typesc_link
The sc_link
structure is one link of a linked list.
P4est.LibP4est.sc_link_t
— TypeThe sc_link
structure is one link of a linked list.
P4est.LibP4est.sc_list
— Typesc_list
The sc_list
object provides a linked list.
P4est.LibP4est.sc_list_t
— TypeThe sc_list
object provides a linked list.
P4est.LibP4est.sc_mempool
— Typesc_mempool
The sc_mempool
object provides a large pool of equal-size elements. The pool grows dynamically for element allocation. Elements are referenced by their address which never changes. Elements can be freed (that is, returned to the pool) and are transparently reused. If the zero_and_persist option is selected, new elements are initialized to all zeros on creation, and the contents of an element are not touched between freeing and re-returning it.
Field | Note |
---|---|
elem_size | size of a single element |
elem_count | number of valid elements |
zero_and_persist | Boolean; is set in constructor. |
mstamp | fixed-size chunk allocator |
freed | buffers the freed elements |
P4est.LibP4est.sc_mempool_t
— TypeThe sc_mempool
object provides a large pool of equal-size elements. The pool grows dynamically for element allocation. Elements are referenced by their address which never changes. Elements can be freed (that is, returned to the pool) and are transparently reused. If the zero_and_persist option is selected, new elements are initialized to all zeros on creation, and the contents of an element are not touched between freeing and re-returning it.
P4est.LibP4est.sc_mstamp
— Typesc_mstamp
A data container to create memory items of the same size. Allocations are bundled so it's fast for small memory sizes. The items created will remain valid until the container is destroyed. There is no option to return an item to the container. See scmempoolt for that purpose.
Field | Note |
---|---|
elem_size | Input parameter: size per item |
per_stamp | Number of items per stamp |
stamp_size | Bytes allocated in a stamp |
cur_snext | Next number within a stamp |
current | Memory of current stamp |
remember | Collects all stamps |
P4est.LibP4est.sc_mstamp_t
— TypeA data container to create memory items of the same size. Allocations are bundled so it's fast for small memory sizes. The items created will remain valid until the container is destroyed. There is no option to return an item to the container. See scmempoolt for that purpose.
P4est.LibP4est.sc_recycle_array
— Typesc_recycle_array
The sc_recycle_array
object provides an array of slots that can be reused.
It keeps a list of free slots in the array which will be used for insertion while available. Otherwise, the array is grown.
P4est.LibP4est.sc_recycle_array_t
— TypeThe sc_recycle_array
object provides an array of slots that can be reused.
It keeps a list of free slots in the array which will be used for insertion while available. Otherwise, the array is grown.
P4est.LibP4est.sc_uint128
— Typesc_uint128
An unsigned 128 bit integer represented as two uint64_t.
Field | Note |
---|---|
high_bits | The more significant 64 bits. |
low_bits | The less significant 64 bits. |
P4est.LibP4est.sc_uint128_t
— TypeAn unsigned 128 bit integer represented as two uint64_t.
P4est.LibP4est.p4est_balance
— Methodp4est_balance(p4est_, btype, init_fn)
2:1 balance the size differences of neighboring elements in a forest.
Parameters
p4est
:[in,out] Thep4est
to be worked on.btype
:[in] Balance type (face or corner/full). Corner balance is almost never required when discretizing a PDE; just causes smoother mesh grading.init_fn
:[in] Callback function to initialize the user_data which is already allocated automatically.
Prototype
void p4est_balance (p4est_t * p4est, p4est_connect_type_t btype, p4est_init_t init_fn);
P4est.LibP4est.p4est_balance_ext
— Methodp4est_balance_ext(p4est_, btype, init_fn, replace_fn)
2:1 balance the size differences of neighboring elements in a forest.
Parameters
p4est
:[in,out] Thep4est
to be worked on.btype
:[in] Balance type (face or corner/full). Corner balance is almost never required when discretizing a PDE; just causes smoother mesh grading.init_fn
:[in] Callback function to initialize the user_data which is already allocated automatically.replace_fn
:[in] Callback function that allows the user to change incoming quadrants based on the quadrants they replace.
Prototype
void p4est_balance_ext (p4est_t * p4est, p4est_connect_type_t btype, p4est_init_t init_fn, p4est_replace_t replace_fn);
P4est.LibP4est.p4est_balance_subtree_ext
— Methodp4est_balance_subtree_ext(p4est_, btype, which_tree, init_fn, replace_fn)
Prototype
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.LibP4est.p4est_checksum
— Methodp4est_checksum(p4est_)
Compute the checksum for a forest. Based on quadrant arrays only. It is independent of partition and mpisize.
Returns
Returns the checksum on processor 0 only. 0 on other processors.
Prototype
unsigned p4est_checksum (p4est_t * p4est);
P4est.LibP4est.p4est_checksum_partition
— Methodp4est_checksum_partition(p4est_)
Compute a partition-dependent checksum for a forest.
Returns
Returns the checksum on processor 0 only. 0 on other processors.
Prototype
unsigned p4est_checksum_partition (p4est_t * p4est);
P4est.LibP4est.p4est_coarsen
— Methodp4est_coarsen(p4est_, coarsen_recursive, coarsen_fn, init_fn)
Coarsen a forest.
Parameters
p4est
:[in,out] The forest is changed in place.coarsen_recursive
:[in] Boolean to decide on recursive coarsening.coarsen_fn
:[in] Callback function that returns true if a family of quadrants shall be coarsenedinit_fn
:[in] Callback function to initialize the user_data which is already allocated automatically.
Prototype
void p4est_coarsen (p4est_t * p4est, int coarsen_recursive, p4est_coarsen_t coarsen_fn, p4est_init_t init_fn);
P4est.LibP4est.p4est_coarsen_ext
— Methodp4est_coarsen_ext(p4est_, coarsen_recursive, callback_orphans, coarsen_fn, init_fn, replace_fn)
Coarsen a forest.
Parameters
p4est
:[in,out] The forest is changed in place.coarsen_recursive
:[in] Boolean to decide on recursive coarsening.callback_orphans
:[in] 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. With coarsen_recursive false and callback_orphans true, it is guaranteed that every quadrant is passed exactly once into the coarsen_fn callback.coarsen_fn
:[in] Callback function that returns true if a family of quadrants shall be coarsened.init_fn
:[in] Callback function to initialize the user_data which is already allocated automatically.replace_fn
:[in] Callback function that allows the user to change incoming quadrants based on the quadrants they replace.
Prototype
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);
P4est.LibP4est.p4est_connect_type_int
— Methodp4est_connect_type_int(btype)
Convert the p4est_connect_type_t
into a number.
Parameters
btype
:[in] The balance type to convert.
Returns
Returns 1 or 2.
Prototype
int p4est_connect_type_int (p4est_connect_type_t btype);
P4est.LibP4est.p4est_connect_type_string
— Methodp4est_connect_type_string(btype)
Convert the p4est_connect_type_t
into a const string.
Parameters
btype
:[in] The balance type to convert.
Returns
Returns a pointer to a constant string.
Prototype
const char *p4est_connect_type_string (p4est_connect_type_t btype);
P4est.LibP4est.p4est_connectivity_bcast
— Methodp4est_connectivity_bcast(conn_in, root, comm)
Prototype
p4est_connectivity_t *p4est_connectivity_bcast (p4est_connectivity_t * conn_in, int root, sc_MPI_Comm comm);
P4est.LibP4est.p4est_connectivity_complete
— Methodp4est_connectivity_complete(conn)
Internally connect a connectivity based on tree_to_vertex information. Periodicity that is not inherent in the list of vertices will be lost.
Parameters
conn
:[in,out] The connectivity needs to have proper vertices and tree_to_vertex fields. The tree_to_tree and tree_to_face fields must be allocated and satisfyp4est_connectivity_is_valid
(conn) but will be overwritten. The corner fields will be freed and allocated anew.
Prototype
void p4est_connectivity_complete (p4est_connectivity_t * conn);
P4est.LibP4est.p4est_connectivity_deflate
— Methodp4est_connectivity_deflate(conn, code)
Allocate memory and store the connectivity information there.
Parameters
conn
:[in] The connectivity structure to be exported to memory.code
:[in] Encoding and compression method for serialization.
Returns
Newly created array that contains the information.
Prototype
sc_array_t *p4est_connectivity_deflate (p4est_connectivity_t * conn, p4est_connectivity_encode_t code);
P4est.LibP4est.p4est_connectivity_destroy
— Methodp4est_connectivity_destroy(connectivity)
Destroy a connectivity structure. Also destroy all attributes.
Prototype
void p4est_connectivity_destroy (p4est_connectivity_t * connectivity);
P4est.LibP4est.p4est_connectivity_face_neighbor_corner
— Methodp4est_connectivity_face_neighbor_corner(c, f, nf, o)
Transform a corner across one of the adjacent faces into a neighbor tree. This version expects the neighbor face and orientation separately.
.
Parameters
c
:[in] A corner number in 0..3.f
:[in] A face number that touches the corner c.nf
:[in] A neighbor face that is on the other side of .o
:[in] The orientation between tree boundary faces f and
Returns
The number of the corner seen from the neighbor tree.
Prototype
int p4est_connectivity_face_neighbor_corner (int c, int f, int nf, int o);
P4est.LibP4est.p4est_connectivity_face_neighbor_face_corner
— Methodp4est_connectivity_face_neighbor_face_corner(fc, f, nf, o)
Transform a face corner across one of the adjacent faces into a neighbor tree. This version expects the neighbor face and orientation separately.
.
Parameters
fc
:[in] A face corner number in 0..1.f
:[in] A face that the face corner number fc is relative to.nf
:[in] A neighbor face that is on the other side of .o
:[in] The orientation between tree boundary faces f and
Returns
The face corner number relative to the neighbor's face.
Prototype
int p4est_connectivity_face_neighbor_face_corner (int fc, int f, int nf, int o);
P4est.LibP4est.p4est_connectivity_inflate
— Methodp4est_connectivity_inflate(buffer)
Create new connectivity from a memory buffer.
Parameters
buffer
:[in] The connectivity is created from this memory buffer.
Returns
The newly created connectivity, or NULL on error.
Prototype
p4est_connectivity_t *p4est_connectivity_inflate (sc_array_t * buffer);
P4est.LibP4est.p4est_connectivity_is_equal
— Methodp4est_connectivity_is_equal(conn1, conn2)
Check two connectivity structures for equality.
Returns
Returns true if structures are equal, false otherwise.
Prototype
int p4est_connectivity_is_equal (p4est_connectivity_t * conn1, p4est_connectivity_t * conn2);
P4est.LibP4est.p4est_connectivity_is_equivalent
— Methodp4est_connectivity_is_equivalent(conn1, conn2)
p4est_connectivity_is_equivalent
This function compares two connectivities for equivalence: it returns true if they are the same connectivity, or if they have the same topology. The definition of topological sameness is strict: there is no attempt made to determine whether permutation and/or rotation of the trees makes the connectivities equivalent.
Parameters
conn1
:[in] a valid connectivityconn2
:[out] a valid connectivity
Prototype
int p4est_connectivity_is_equivalent (p4est_connectivity_t * conn1, p4est_connectivity_t * conn2);
P4est.LibP4est.p4est_connectivity_is_valid
— Methodp4est_connectivity_is_valid(connectivity)
Examine a connectivity structure.
Returns
Returns true if structure is valid, false otherwise.
Prototype
int p4est_connectivity_is_valid (p4est_connectivity_t * connectivity);
P4est.LibP4est.p4est_connectivity_join_faces
— Methodp4est_connectivity_join_faces(conn, tree_left, tree_right, face_left, face_right, orientation)
p4est_connectivity_join_faces
This function takes an existing valid connectivity conn and modifies it by joining two tree faces that are currently boundary faces.
Parameters
conn
:[in,out] connectivity that will be altered.tree_left
:[in] tree that will be on the left side of the joined faces.tree_right
:[in] tree that will be on the right side of the joined faces.face_left
:[in] face of tree_left that will be joined.face_right
:[in] face of tree_right that will be joined.orientation
:[in] the orientation of face_left and face_right once joined (see the description ofp4est_connectivity_t
to understand orientation).
Prototype
void p4est_connectivity_join_faces (p4est_connectivity_t * conn, p4est_topidx_t tree_left, p4est_topidx_t tree_right, int face_left, int face_right, int orientation);
P4est.LibP4est.p4est_connectivity_load
— Methodp4est_connectivity_load(filename, bytes)
Load a connectivity structure from disk.
Parameters
filename
:[in] Name of the file to read.bytes
:[in,out] Size in bytes of connectivity on disk or NULL.
Returns
Returns valid connectivity, or NULL on file error.
Prototype
p4est_connectivity_t *p4est_connectivity_load (const char *filename, size_t *bytes);
P4est.LibP4est.p4est_connectivity_memory_used
— Methodp4est_connectivity_memory_used(conn)
Calculate memory usage of a connectivity structure.
Parameters
conn
:[in] Connectivity structure.
Returns
Memory used in bytes.
Prototype
size_t p4est_connectivity_memory_used (p4est_connectivity_t * conn);
P4est.LibP4est.p4est_connectivity_new
— Methodp4est_connectivity_new(num_vertices, num_trees, num_corners, num_ctt)
Allocate a connectivity structure. The attribute fields are initialized to NULL.
Parameters
num_vertices
:[in] Number of total vertices (i.e. geometric points).num_trees
:[in] Number of trees in the forest.num_corners
:[in] Number of tree-connecting corners.num_ctt
:[in] Number of total trees in corner_to_tree array.
Returns
A connectivity structure with allocated arrays.
Prototype
p4est_connectivity_t *p4est_connectivity_new (p4est_topidx_t num_vertices, p4est_topidx_t num_trees, p4est_topidx_t num_corners, p4est_topidx_t num_ctt);
P4est.LibP4est.p4est_connectivity_new_brick
— Methodp4est_connectivity_new_brick(mi, ni, periodic_a, periodic_b)
A rectangular m by n array of trees with configurable periodicity. The brick is periodic in x and y if periodic_a and periodic_b are true, respectively.
Prototype
p4est_connectivity_t *p4est_connectivity_new_brick (int mi, int ni, int periodic_a, int periodic_b);
P4est.LibP4est.p4est_connectivity_new_byname
— Methodp4est_connectivity_new_byname(name)
Create connectivity structure from predefined catalogue.
Parameters
name
:[in] Invokes connectivity_new_* function. brick23 brick (2, 3, 0, 0) corner corner cubed cubed disk disk moebius moebius periodic periodic pillow pillow rotwrap rotwrap star star unit unitsquare
Returns
An initialized connectivity if name is defined, NULL else.
Prototype
p4est_connectivity_t *p4est_connectivity_new_byname (const char *name);
P4est.LibP4est.p4est_connectivity_new_copy
— Methodp4est_connectivity_new_copy(num_vertices, num_trees, num_corners, vertices, ttv, ttt, ttf, ttc, coff, ctt, ctc)
Allocate a connectivity structure and populate from constants. The attribute fields are initialized to NULL.
Parameters
num_vertices
:[in] Number of total vertices (i.e. geometric points).num_trees
:[in] Number of trees in the forest.num_corners
:[in] Number of tree-connecting corners.coff
:[in] Corner-to-tree offsets (num_corners + 1 values). This must always be non-NULL; in trivial cases it is just a pointer to a p4est_topix value of 0.
Returns
The connectivity is checked for validity.
Prototype
p4est_connectivity_t *p4est_connectivity_new_copy (p4est_topidx_t num_vertices, p4est_topidx_t num_trees, p4est_topidx_t num_corners, const double *vertices, const p4est_topidx_t * ttv, const p4est_topidx_t * ttt, const int8_t * ttf, const p4est_topidx_t * ttc, const p4est_topidx_t * coff, const p4est_topidx_t * ctt, const int8_t * ctc);
P4est.LibP4est.p4est_connectivity_new_corner
— Methodp4est_connectivity_new_corner()
Create a connectivity structure for a three-tree mesh around a corner.
Prototype
p4est_connectivity_t *p4est_connectivity_new_corner (void);
P4est.LibP4est.p4est_connectivity_new_cubed
— Methodp4est_connectivity_new_cubed()
Create a connectivity structure for the six sides of a unit cube. The ordering of the trees is as follows: 0 1 2 3 <– 3: axis-aligned top side 4 5. This choice has been made for maximum symmetry (see tree_to_* in .c file).
Prototype
p4est_connectivity_t *p4est_connectivity_new_cubed (void);
P4est.LibP4est.p4est_connectivity_new_disk
— Methodp4est_connectivity_new_disk(periodic_a, periodic_b)
Create a connectivity structure for a five-tree flat spherical disk. This disk can just as well be used as a square to test non-Cartesian maps. Without any mapping this connectivity covers the square [-3, 3]**2.
The API of this function has changed to accept two arguments. You can query the #define P4EST_CONN_DISK_PERIODIC
to check whether the new version with the argument is in effect.
The ordering of the trees is as follows: 4 1 2 3 0.
The outside x faces may be identified topologically. The outside y faces may be identified topologically. Both identifications may be specified simultaneously. The general shape and periodicity are the same as those obtained with p4estconnectivitynewbrick (1, 1, periodic\a, periodic_b).
When setting periodic_a and periodic_b to false, the result is the same as that of p4estconnectivitynewdisknonperiodic.
Parameters
periodic_a
:[in] Bool to make disk periodic in x direction.periodic_b
:[in] Bool to make disk periodic in y direction.
Returns
Initialized and usable connectivity.
Prototype
p4est_connectivity_t *p4est_connectivity_new_disk (int periodic_a, int periodic_b);
P4est.LibP4est.p4est_connectivity_new_disk2d
— Methodp4est_connectivity_new_disk2d()
Create a connectivity structure that maps a 2d disk.
This is a 5 trees connectivity meant to be used together with p4estgeometrynew_disk2d to map the disk.
Prototype
p4est_connectivity_t *p4est_connectivity_new_disk2d (void);
P4est.LibP4est.p4est_connectivity_new_disk_nonperiodic
— Methodp4est_connectivity_new_disk_nonperiodic()
Create a connectivity structure for a five-tree flat spherical disk. This disk can just as well be used as a square to test non-Cartesian maps. Without any mapping this connectivity covers the square [-3, 3]**2.
Returns
Initialized and usable connectivity.
Prototype
p4est_connectivity_t *p4est_connectivity_new_disk_nonperiodic (void);
P4est.LibP4est.p4est_connectivity_new_icosahedron
— Methodp4est_connectivity_new_icosahedron()
Create a connectivity for mapping the sphere using an icosahedron.
The regular icosadron is a polyhedron with 20 faces, each of which is an equilateral triangle. To build the p4est
connectivity, we group faces 2 by 2 to from 10 quadrangles, and thus 10 trees.
This connectivity is meant to be used together with p4estgeometrynew_icosahedron to map the sphere.
The flat connectivity looks like that: Vextex numbering:
A00 A01 A02 A03 A04 / \ / \ / \ / \ / \ A05–-A06–-A07–-A08–-A09–-A10 \ / \ / \ / \ / \ / \ A11–-A12–-A13–-A14–-A15–-A16 \ / \ / \ / \ / \ / A17 A18 A19 A20 A21
Origin in A05.
Tree numbering:
0 2 4 6 8 1 3 5 7 9
Prototype
p4est_connectivity_t *p4est_connectivity_new_icosahedron ();
P4est.LibP4est.p4est_connectivity_new_moebius
— Methodp4est_connectivity_new_moebius()
Create a connectivity structure for a five-tree moebius band.
Prototype
p4est_connectivity_t *p4est_connectivity_new_moebius (void);
P4est.LibP4est.p4est_connectivity_new_periodic
— Methodp4est_connectivity_new_periodic()
Create a connectivity structure for an all-periodic unit square.
Prototype
p4est_connectivity_t *p4est_connectivity_new_periodic (void);
P4est.LibP4est.p4est_connectivity_new_pillow
— Methodp4est_connectivity_new_pillow()
Create a connectivity structure for two trees on top of each other.
Prototype
p4est_connectivity_t *p4est_connectivity_new_pillow (void);
P4est.LibP4est.p4est_connectivity_new_rotwrap
— Methodp4est_connectivity_new_rotwrap()
Create a connectivity structure for a periodic unit square. The left and right faces are identified, and bottom and top opposite.
Prototype
p4est_connectivity_t *p4est_connectivity_new_rotwrap (void);
P4est.LibP4est.p4est_connectivity_new_shell2d
— Methodp4est_connectivity_new_shell2d()
Create a connectivity structure that builds a 2d spherical shell. p8estconnectivitynew_shell
Prototype
p4est_connectivity_t *p4est_connectivity_new_shell2d (void);
P4est.LibP4est.p4est_connectivity_new_star
— Methodp4est_connectivity_new_star()
Create a connectivity structure for a six-tree star.
Prototype
p4est_connectivity_t *p4est_connectivity_new_star (void);
P4est.LibP4est.p4est_connectivity_new_twotrees
— Methodp4est_connectivity_new_twotrees(l_face, r_face, orientation)
Create a connectivity structure for two trees being rotated w.r.t. each other in a user-defined way
Parameters
l_face
:[in] index of left facer_face
:[in] index of right faceorientation
:[in] orientation of trees w.r.t. each other
Prototype
p4est_connectivity_t *p4est_connectivity_new_twotrees (int l_face, int r_face, int orientation);
P4est.LibP4est.p4est_connectivity_new_unitsquare
— Methodp4est_connectivity_new_unitsquare()
Create a connectivity structure for the unit square.
Prototype
p4est_connectivity_t *p4est_connectivity_new_unitsquare (void);
P4est.LibP4est.p4est_connectivity_permute
— Methodp4est_connectivity_permute(conn, perm, is_current_to_new)
p4est_connectivity_permute
Given a permutation perm of the trees in a connectivity conn, permute the trees of conn in place and update conn to match.
Parameters
conn
:[in,out] The connectivity whose trees are permuted.perm
:[in] A permutation array, whose elements are size_t's.is_current_to_new
:[in] if true, the jth entry of perm is the new index for the entry whose current index is j, otherwise the jth entry of perm is the current index of the tree whose index will be j after the permutation.
Prototype
void p4est_connectivity_permute (p4est_connectivity_t * conn, sc_array_t * perm, int is_current_to_new);
P4est.LibP4est.p4est_connectivity_read_inp
— Methodp4est_connectivity_read_inp(filename)
Create a p4est
connectivity from an ABAQUS input file.
This utility function reads a basic ABAQUS file supporting element type with the prefix C2D4, CPS4, and S4 in 2D and of type C3D8 reading them as bilinear quadrilateral and trilinear hexahedral trees respectively.
A basic 2D mesh is given below. The *Node
section gives the vertex number and x, y, and z components for each vertex. The *Element
section gives the 4 vertices in 2D (8 vertices in 3D) of each element in counter clockwise order. So in 2D the nodes are given as:
4 3 +–––––––––-+ | | | | | | | | | | | | +–––––––––-+ 1 2
and in 3D they are given as:
8 7 +––––––––––-+ |\ |\ | \ | \ | \ | \ | \ | \ | 5+––––––––––-+6 | | | | +––|––––––––+ | 4\ | 3 \ | \ | \ | \ | \ | \| \| +––––––––––-+ 1 2
*Heading
box.inp
*Node
1, -5, -5, 0
2, 5, -5, 0
3, 5, 5, 0
4, -5, 5, 0
5, 0, -5, 0
6, 5, 0, 0
7, 0, 5, 0
8, -5, 0, 0
9, 1, -1, 0
10, 0, 0, 0
11, -2, 1, 0
*Element, type=CPS4, ELSET=Surface1
1, 1, 10, 11, 8
2, 3, 10, 9, 6
3, 9, 10, 1, 5
4, 7, 4, 8, 11
5, 11, 10, 3, 7
6, 2, 6, 9, 5
This function reads a mesh from filename and returns an associated p4est
connectivity.
Parameters
filename
:[in] file to read the connectivity from
Returns
an allocated connectivity associated with the mesh in filename or NULL if an error occurred.
Prototype
p4est_connectivity_t *p4est_connectivity_read_inp (const char *filename);
P4est.LibP4est.p4est_connectivity_read_inp_stream
— Methodp4est_connectivity_read_inp_stream(stream, num_vertices, num_trees, vertices, tree_to_vertex)
Read an ABAQUS input file from a file stream.
This utility function reads a basic ABAQUS file supporting element type with the prefix C2D4, CPS4, and S4 in 2D and of type C3D8 reading them as bilinear quadrilateral and trilinear hexahedral trees respectively.
A basic 2D mesh is given below. The *Node
section gives the vertex number and x, y, and z components for each vertex. The *Element
section gives the 4 vertices in 2D (8 vertices in 3D) of each element in counter clockwise order. So in 2D the nodes are given as:
4 3 +–––––––––-+ | | | | | | | | | | | | +–––––––––-+ 1 2
and in 3D they are given as:
8 7 +––––––––––-+ |\ |\ | \ | \ | \ | \ | \ | \ | 5+––––––––––-+6 | | | | +––|––––––––+ | 4\ | 3 \ | \ | \ | \ | \ | \| \| +––––––––––-+ 1 2
*Heading
box.inp
*Node
1, -5, -5, 0
2, 5, -5, 0
3, 5, 5, 0
4, -5, 5, 0
5, 0, -5, 0
6, 5, 0, 0
7, 0, 5, 0
8, -5, 0, 0
9, 1, -1, 0
10, 0, 0, 0
11, -2, 1, 0
*Element, type=CPS4, ELSET=Surface1
1, 1, 10, 11, 8
2, 3, 10, 9, 6
3, 9, 10, 1, 5
4, 7, 4, 8, 11
5, 11, 10, 3, 7
6, 2, 6, 9, 5
This code can be called two ways. The first, when vertex
==NULL and tree_to_vertex
==NULL, is used to count the number of trees and vertices in the connectivity to be generated by the .inp
mesh in the stream. The second, when vertices
!=NULL and tree_to_vertex
!=NULL, fill vertices
and tree_to_vertex
. In this case num_vertices
and num_trees
need to be set to the maximum number of entries allocated in vertices
and tree_to_vertex
.
Parameters
stream
:[in,out] file stream to read the connectivity fromnum_vertices
:[in,out] the number of vertices in the connectivitynum_trees
:[in,out] the number of trees in the connectivityvertices
:[out] the list ofvertices
of the connectivitytree_to_vertex
:[out] thetree_to_vertex
map of the connectivity
Returns
0 if successful and nonzero if not
Prototype
int p4est_connectivity_read_inp_stream (FILE * stream, p4est_topidx_t * num_vertices, p4est_topidx_t * num_trees, double *vertices, p4est_topidx_t * tree_to_vertex);
P4est.LibP4est.p4est_connectivity_reduce
— Methodp4est_connectivity_reduce(conn)
Removes corner information of a connectivity such that enough information is left to run p4est_connectivity_complete
successfully. The reduced connectivity still passes p4est_connectivity_is_valid
.
Parameters
conn
:[in,out] The connectivity to be reduced.
Prototype
void p4est_connectivity_reduce (p4est_connectivity_t * conn);
P4est.LibP4est.p4est_connectivity_refine
— Methodp4est_connectivity_refine(conn, num_per_edge)
Uniformly refine a connectivity. This is useful if you would like to uniformly refine by something other than a power of 2.
Parameters
conn
:[in] A valid connectivitynum_per_edge
:[in] The number of new trees in each direction. Must use no more than P4ESTOLDQMAXLEVEL bits.
Returns
a refined connectivity.
Prototype
p4est_connectivity_t *p4est_connectivity_refine (p4est_connectivity_t * conn, int num_per_edge);
P4est.LibP4est.p4est_connectivity_save
— Methodp4est_connectivity_save(filename, connectivity)
Save a connectivity structure to disk.
Parameters
filename
:[in] Name of the file to write.connectivity
:[in] Valid connectivity structure.
Returns
Returns 0 on success, nonzero on file error.
Prototype
int p4est_connectivity_save (const char *filename, p4est_connectivity_t * connectivity);
P4est.LibP4est.p4est_connectivity_set_attr
— Methodp4est_connectivity_set_attr(conn, bytes_per_tree)
Allocate or free the attribute fields in a connectivity.
Parameters
conn
:[in,out] The conn->*_to_attr fields must either be NULL or previously be allocated by this function.bytes_per_tree
:[in] If 0, tree_to_attr is freed (being NULL is ok). If positive, requested space is allocated.
Prototype
void p4est_connectivity_set_attr (p4est_connectivity_t * conn, size_t bytes_per_tree);
P4est.LibP4est.p4est_connectivity_sink
— Methodp4est_connectivity_sink(conn, sink)
Write connectivity to a sink object.
Parameters
conn
:[in] The connectivity to be written.sink
:[in,out] The connectivity is written into this sink.
Returns
0 on success, nonzero on error.
Prototype
int p4est_connectivity_sink (p4est_connectivity_t * conn, sc_io_sink_t * sink);
P4est.LibP4est.p4est_connectivity_source
— Methodp4est_connectivity_source(source)
Read connectivity from a source object.
Parameters
source
:[in,out] The connectivity is read from this source.
Returns
The newly created connectivity, or NULL on error.
Prototype
p4est_connectivity_t *p4est_connectivity_source (sc_io_source_t * source);
P4est.LibP4est.p4est_copy
— Methodp4est_copy(input, copy_data)
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
copy_data
:[in] If true, data are copied. If false, data_size is set to 0.
Returns
Returns a valid p4est
that does not depend on the input, except for borrowing the same connectivity. Its revision counter is 0.
Prototype
p4est_t *p4est_copy (p4est_t * input, int copy_data);
P4est.LibP4est.p4est_copy_ext
— Methodp4est_copy_ext(input, copy_data, 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
copy_data
:[in] If true, data are copied. If false, data_size is set to 0.duplicate_mpicomm
:[in] If 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.
Prototype
p4est_t *p4est_copy_ext (p4est_t * input, int copy_data, int duplicate_mpicomm);
P4est.LibP4est.p4est_destroy
— Methodp4est_destroy(p4est_)
Destroy a p4est
.
The connectivity structure is not destroyed with the p4est
.
Prototype
void p4est_destroy (p4est_t * p4est);
P4est.LibP4est.p4est_expand_face_transform
— Methodp4est_expand_face_transform(iface, nface, ftransform)
Fill an array with the axis combination of a face neighbor transform.
Parameters
iface
:[in] The number of the originating face.nface
:[in] Encoded as nface = r * 4 + nf, where nf = 0..3 is the neigbbor's connecting face number and r = 0..1 is the relative orientation to the neighbor's face. This encoding matchesp4est_connectivity_t
.ftransform
:[out] This array holds 9 integers. [0,2] The coordinate axis sequence of the origin face, the first referring to the tangential and the second to the normal. A permutation of (0, 1). [3,5] The coordinate axis sequence of the target face. [6,8] Edge reversal flag for tangential axis (boolean); face code in [0, 3] for the normal coordinate q: 0: q' = -q 1: q' = q + 1 2: q' = q - 1 3: q' = 2 - q [1,4,7] 0 (unused for compatibility with 3D).
Prototype
void p4est_expand_face_transform (int iface, int nface, int ftransform[]);
P4est.LibP4est.p4est_face_quadrant_exists
— Methodp4est_face_quadrant_exists(p4est_, ghost, treeid, q, face, hang, owner_rank)
Checks if quadrant exists in the local forest or the ghost layer.
For quadrants across tree boundaries it checks if the quadrant exists across any face, but not across corners.
Parameters
p4est
:[in] The forest in which to search for q.ghost
:[in] The ghost layer in which to search for q.treeid
:[in] The tree to which q belongs.q
:[in] The quadrant that is being searched for.face
:[in,out] On input, face id across which q was created. On output, the neighbor's face number augmented by orientation, so face is in 0..7.hang
:[in,out] If not NULL, signals that q is bigger than the quadrant it came from. The child id of that originating quadrant is passed into hang. On output, hang holds the hanging face number of q that is in contact with its originator.owner_rank
:[out] Filled with the rank of the owner if it is found and undefined otherwise.
Returns
Returns the local number of q if the quadrant exists in the local forest or in the ghost_layer. Otherwise, returns -2 for a domain boundary and -1 if not found.
Prototype
p4est_locidx_t p4est_face_quadrant_exists (p4est_t * p4est, p4est_ghost_t * ghost, p4est_topidx_t treeid, const p4est_quadrant_t * q, int *face, int *hang, int *owner_rank);
P4est.LibP4est.p4est_find_corner_transform
— Methodp4est_find_corner_transform(connectivity, itree, icorner, ci)
Fills an array with information about corner neighbors.
Parameters
itree
:[in] The number of the originating tree.icorner
:[in] The number of the originating corner.ci
:[in,out] Ap4est_corner_info_t
structure with initialized array.
Prototype
void p4est_find_corner_transform (p4est_connectivity_t * connectivity, p4est_topidx_t itree, int icorner, p4est_corner_info_t * ci);
P4est.LibP4est.p4est_find_face_transform
— Methodp4est_find_face_transform(connectivity, itree, iface, ftransform)
Fill an array with the axis combinations of a tree neighbor transform.
Parameters
itree
:[in] The number of the originating tree.iface
:[in] The number of the originating tree's face.ftransform
:[out] This array holds 9 integers. [0,2] The coordinate axis sequence of the origin face. [3,5] The coordinate axis sequence of the target face. [6,8] Edge reverse flag for axis t; face code for axis n. [1,4,7] 0 (unused for compatibility with 3D).
Returns
The face neighbor tree if it exists, -1 otherwise.
Prototype
p4est_topidx_t p4est_find_face_transform (p4est_connectivity_t * connectivity, p4est_topidx_t itree, int iface, int ftransform[]);
P4est.LibP4est.p4est_find_higher_bound
— Methodp4est_find_higher_bound(array, q, guess)
Find the highest position tq in a quadrant array such that tq <= q.
Returns
Returns the id of the matching quadrant or -1 if array > q or the array is empty.
Prototype
ssize_t p4est_find_higher_bound (sc_array_t * array, const p4est_quadrant_t * q, size_t guess);
P4est.LibP4est.p4est_find_lower_bound
— Methodp4est_find_lower_bound(array, q, guess)
Find the lowest position tq in a quadrant array such that tq >= q.
Returns
Returns the id of the matching quadrant or -1 if array < q or the array is empty.
Prototype
ssize_t p4est_find_lower_bound (sc_array_t * array, const p4est_quadrant_t * q, size_t guess);
P4est.LibP4est.p4est_find_partition
— Methodp4est_find_partition(num_procs, search_in, my_begin, my_end, _begin, _end)
Binary search in partition array. Given two targets my_begin and my_end, find offsets such that search\_in[begin] >= my\_begin
, my\_end <= search\_in[end]
. If more than one index satisfies the conditions, then the minimal index is the result. If there is no index that satisfies the conditions, then begin and end are tried to set equal such that search\_in[begin] >= my\_end
. If my_begin is less or equal than the smallest value of search_in begin is set to 0 and if my_end is bigger or equal than the largest value of search_in end is set to num_procs - 1. If none of the above conditions is satisfied, the output is not well defined. We require `my_begin <= my_begin'.
Parameters
num_procs
:[in] Number of processes to get the length of search_in.search_in
:[in] The sorted array (ascending) in that the function will search. Ifk
indexes search_in, then0 <= k < num\_procs
.my_begin
:[in] The first target that defines the start of the search window.my_end
:[in] The second target that defines the end of the search window.begin
:[in,out] The first offset such thatsearch\_in[begin] >= my\_begin
.end
:[in,out] The second offset such thatmy\_end <= search\_in[end]
.
Prototype
void p4est_find_partition (const int num_procs, p4est_gloidx_t * search_in, p4est_gloidx_t my_begin, p4est_gloidx_t my_end, p4est_gloidx_t * begin, p4est_gloidx_t * end);
P4est.LibP4est.p4est_find_quadrant_cumulative
— Methodp4est_find_quadrant_cumulative(p4est_, cumulative_id, which_tree, quadrant_id)
Search a local quadrant by its cumulative number in the forest.
We perform a binary search over the processor-local trees, which means that it is advisable NOT to use this function if possible, and to try to maintain O(1) tree context information in the calling code.
Parameters
p4est
:[in] Forest to be worked with.cumulative_id
:[in] Cumulative index over all trees of quadrant.which_tree
:[in,out] If not NULL, the input value can be -1 or an initial guess for the quadrant's tree. An initial guess must be the index of a nonempty local tree. Output is the tree of returned quadrant.quadrant_id
:[out] If not NULL, the number of quadrant in tree.
Returns
The identified quadrant.
Prototype
p4est_quadrant_t *p4est_find_quadrant_cumulative (p4est_t * p4est, p4est_locidx_t cumulative_id, p4est_topidx_t * which_tree, p4est_locidx_t * quadrant_id);
P4est.LibP4est.p4est_find_range_boundaries
— Methodp4est_find_range_boundaries(lq, uq, level, faces, corners)
Find the boundary points touched by a range of quadrants.
Given two smallest quadrants, lq and uq, that mark the first and the last quadrant in a range of quadrants, determine which portions of the tree boundary the range touches.
Parameters
lq
:[in] The smallest quadrant at the start of the range: if NULL, the tree's first quadrant is taken to be the start of the range.uq
:[in] The smallest quadrant at the end of the range: if NULL, the tree's last quadrant is taken to be the end of the range.level
:[in] The level of the containing quadrant whose boundaries are tested: 0 if we want to test the boundaries of the whole tree.faces
:[in,out] An array of size 4 that is filled: faces[i] is true if the range touches that face.corners
:[in,out] An array of size 4 that is filled: corners[i] is true if the range touches that corner. faces or corners may be NULL.
Returns
Returns an int32_t encoded with the same information in faces and corners: the first (least) four bits represent the four faces, the next four bits represent the four corners.
Prototype
int32_t p4est_find_range_boundaries (p4est_quadrant_t * lq, p4est_quadrant_t * uq, int level, int faces[], int corners[]);
P4est.LibP4est.p4est_get_plex_data_ext
— Methodp4est_get_plex_data_ext(p4est_, ghost, lnodes, ctype, overlap, first_local_quad, out_points_per_dim, out_cone_sizes, out_cones, out_cone_orientations, out_vertex_coords, out_children, out_parents, out_childids, out_leaves, out_remotes, 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
p4est
:[in] the forestghost
:[out] the ghost layerlnodes
:[out] the lnodesctype
:[in] the type of adjacency for the overlapoverlap
:[in] the number of layers of overlap (zero is acceptable)first_local_quad
:[out] the local quadrants are assigned contiguous plex indices, starting with this indexout_points_per_dim
:[in,out] filled with argument for DMPlexCreateFromDAG()out_cone_sizes
:[in,out] filled with argument for DMPlexCreateFromDAG()out_cones
:[in,out] filled with argument for DMPlexCreateFromDAG()out_cone_orientations
:[in,out] filled with argument for DMPlexCreateFromDAG()out_vertex_coords
:[in,out] filled with argument for DMPlexCreateFromDAG()out_children
:[in,out] filled with argument for DMPlexSetTree()out_parents
:[in,out] filled with argument for DMPlexSetTree()out_childids
:[in,out] filled with argument for DMPlexSetTree()out_leaves
:[in,out] filled with argument for PetscSFSetGraph()out_remotes
:[in,out] filled with argument for PetscSFSetGraph()custom_numbering
:[in] Whether or use the default numbering (0) of DMPlex child ids or the custom (1).
Prototype
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);
P4est.LibP4est.p4est_ghost_bsearch
— Methodp4est_ghost_bsearch(ghost, which_proc, which_tree, q)
Conduct binary search for exact match on a range of the ghost layer.
Parameters
ghost
:[in] The ghost layer.which_proc
:[in] The owner of the searched quadrant. Can be -1.which_tree
:[in] The tree of the searched quadrant. Can be -1.q
:[in] Valid quadrant is searched in the ghost layer.
Returns
Offset in the ghost layer, or -1 if not found.
Prototype
ssize_t p4est_ghost_bsearch (p4est_ghost_t * ghost, int which_proc, p4est_topidx_t which_tree, const p4est_quadrant_t * q);
P4est.LibP4est.p4est_ghost_checksum
— Methodp4est_ghost_checksum(p4est_, ghost)
Compute the parallel checksum of a ghost layer.
Parameters
p4est
:[in] The MPI information of thisp4est
will be used.ghost
:[in] A ghost layer obtained from thep4est
.
Returns
Parallel checksum on rank 0, 0 otherwise.
Prototype
unsigned p4est_ghost_checksum (p4est_t * p4est, p4est_ghost_t * ghost);
P4est.LibP4est.p4est_ghost_contains
— Methodp4est_ghost_contains(ghost, which_proc, which_tree, q)
Conduct binary search for ancestor on range of the ghost layer.
Parameters
ghost
:[in] The ghost layer.which_proc
:[in] The owner of the searched quadrant. Can be -1.which_tree
:[in] The tree of the searched quadrant. Can be -1.q
:[in] Valid quadrant's ancestor is searched.
Returns
Offset in the ghost layer, or -1 if not found.
Prototype
ssize_t p4est_ghost_contains (p4est_ghost_t * ghost, int which_proc, p4est_topidx_t which_tree, const p4est_quadrant_t * q);
P4est.LibP4est.p4est_ghost_destroy
— Methodp4est_ghost_destroy(ghost)
Frees all memory used for the ghost layer.
Prototype
void p4est_ghost_destroy (p4est_ghost_t * ghost);
P4est.LibP4est.p4est_ghost_exchange_custom
— Methodp4est_ghost_exchange_custom(p4est_, ghost, data_size, mirror_data, ghost_data)
Transfer data for local quadrants that are ghosts to other processors. The data size is the same for all quadrants and can be chosen arbitrarily.
Parameters
p4est
:[in] The forest used for reference.ghost
:[in] The ghost layer used for reference.data_size
:[in] The data size to transfer per quadrant.mirror_data
:[in] One data pointer per mirror quadrant as input.ghost_data
:[in,out] Pre-allocated contiguous data for all ghosts in sequence, which must hold at leastdata_size
for each ghost.
Prototype
void p4est_ghost_exchange_custom (p4est_t * p4est, p4est_ghost_t * ghost, size_t data_size, void **mirror_data, void *ghost_data);
P4est.LibP4est.p4est_ghost_exchange_custom_begin
— Methodp4est_ghost_exchange_custom_begin(p4est_, ghost, data_size, mirror_data, ghost_data)
Begin an asynchronous ghost data exchange by posting messages. The arguments are identical to p4est_ghost_exchange_custom
. The return type is always non-NULL and must be passed to p4est_ghost_exchange_custom_end
to complete the exchange. The ghost data must not be accessed before completion. The mirror data can be safely discarded right after this function returns since it is copied into internal send buffers.
Parameters
mirror_data
:[in] Not required to stay alive any longer.ghost_data
:[in,out] Must stay alive into the completion call.
Returns
Transient storage for messages in progress.
Prototype
p4est_ghost_exchange_t *p4est_ghost_exchange_custom_begin (p4est_t * p4est, p4est_ghost_t * ghost, size_t data_size, void **mirror_data, void *ghost_data);
P4est.LibP4est.p4est_ghost_exchange_custom_end
— Methodp4est_ghost_exchange_custom_end(exc)
Complete an asynchronous ghost data exchange. This function waits for all pending MPI communications.
Parameters
Data
:[in,out] created ONLY byp4est_ghost_exchange_custom_begin
. It is deallocated before this function returns.
Prototype
void p4est_ghost_exchange_custom_end (p4est_ghost_exchange_t * exc);
P4est.LibP4est.p4est_ghost_exchange_custom_levels
— Methodp4est_ghost_exchange_custom_levels(p4est_, ghost, minlevel, maxlevel, data_size, mirror_data, ghost_data)
Transfer data for local quadrants that are ghosts to other processors. The data size is the same for all quadrants and can be chosen arbitrarily. This function restricts the transfer to a range of refinement levels. The memory for quadrants outside the level range is not dereferenced.
Parameters
p4est
:[in] The forest used for reference.ghost
:[in] The ghost layer used for reference.minlevel
:[in] Level of the largest quads to be exchanged. Use <= 0 for no restriction.maxlevel
:[in] Level of the smallest quads to be exchanged. Use >=P4EST_QMAXLEVEL
for no restriction.data_size
:[in] The data size to transfer per quadrant.mirror_data
:[in] One data pointer per mirror quadrant as input.ghost_data
:[in,out] Pre-allocated contiguous data for all ghosts in sequence, which must hold at leastdata_size
for each ghost.
Prototype
void p4est_ghost_exchange_custom_levels (p4est_t * p4est, p4est_ghost_t * ghost, int minlevel, int maxlevel, size_t data_size, void **mirror_data, void *ghost_data);
P4est.LibP4est.p4est_ghost_exchange_custom_levels_begin
— Methodp4est_ghost_exchange_custom_levels_begin(p4est_, ghost, minlevel, maxlevel, data_size, mirror_data, ghost_data)
Begin an asynchronous ghost data exchange by posting messages. The arguments are identical to p4est_ghost_exchange_custom_levels
. The return type is always non-NULL and must be passed to p4est_ghost_exchange_custom_levels_end
to complete the exchange. The ghost data must not be accessed before completion. The mirror data can be safely discarded right after this function returns since it is copied into internal send buffers.
Parameters
mirror_data
:[in] Not required to stay alive any longer.ghost_data
:[in,out] Must stay alive into the completion call.
Returns
Transient storage for messages in progress.
Prototype
p4est_ghost_exchange_t *p4est_ghost_exchange_custom_levels_begin (p4est_t * p4est, p4est_ghost_t * ghost, int minlevel, int maxlevel, size_t data_size, void **mirror_data, void *ghost_data);
P4est.LibP4est.p4est_ghost_exchange_custom_levels_end
— Methodp4est_ghost_exchange_custom_levels_end(exc)
Complete an asynchronous ghost data exchange. This function waits for all pending MPI communications.
Parameters
Data
:[in,out] created ONLY byp4est_ghost_exchange_custom_levels_begin
. It is deallocated before this function returns.
Prototype
void p4est_ghost_exchange_custom_levels_end (p4est_ghost_exchange_t * exc);
P4est.LibP4est.p4est_ghost_exchange_data
— Methodp4est_ghost_exchange_data(p4est_, ghost, ghost_data)
Transfer data for local quadrants that are ghosts to other processors. Send the data stored in the quadrant's user_data. This is either the pointer variable itself if p4est
->datasize is 0, or the content of the referenced memory field if p4est
->data\size is positive.
Parameters
p4est
:[in] The forest used for reference.ghost
:[in] The ghost layer used for reference.ghost_data
:[in,out] Pre-allocated contiguous data for all ghost quadrants in sequence. Ifp4est
->data_size is 0, must at least hold sizeof (void *) bytes for each, otherwisep4est
->data_size each.
Prototype
void p4est_ghost_exchange_data (p4est_t * p4est, p4est_ghost_t * ghost, void *ghost_data);
P4est.LibP4est.p4est_ghost_exchange_data_begin
— Methodp4est_ghost_exchange_data_begin(p4est_, ghost, ghost_data)
Begin an asynchronous ghost data exchange by posting messages. The arguments are identical to p4est_ghost_exchange_data
. The return type is always non-NULL and must be passed to p4est_ghost_exchange_data_end
to complete the exchange. The ghost data must not be accessed before completion.
Parameters
ghost_data
:[in,out] Must stay alive into the completion call.
Returns
Transient storage for messages in progress.
Prototype
p4est_ghost_exchange_t *p4est_ghost_exchange_data_begin (p4est_t * p4est, p4est_ghost_t * ghost, void *ghost_data);
P4est.LibP4est.p4est_ghost_exchange_data_end
— Methodp4est_ghost_exchange_data_end(exc)
Complete an asynchronous ghost data exchange. This function waits for all pending MPI communications.
Parameters
Data
:[in,out] created ONLY byp4est_ghost_exchange_data_begin
. It is deallocated before this function returns.
Prototype
void p4est_ghost_exchange_data_end (p4est_ghost_exchange_t * exc);
P4est.LibP4est.p4est_ghost_expand
— Methodp4est_ghost_expand(p4est_, ghost)
Expand the size of the ghost layer and mirrors by one additional layer of adjacency.
Parameters
p4est
:[in] The forest from which the ghost layer was generated.ghost
:[in,out] The ghost layer to be expanded.
Prototype
void p4est_ghost_expand (p4est_t * p4est, p4est_ghost_t * ghost);
P4est.LibP4est.p4est_ghost_expand_by_lnodes
— Methodp4est_ghost_expand_by_lnodes(p4est_, lnodes, ghost)
Expand the ghost layer as in p4est_ghost_expand
(), but use node support to define adjacency instead of geometric adjacency.
Parameters
p4est
:[in] The forest from which the ghost layer was generated.lnodes
:[in] The nodes to support.ghost
:[in,out] The ghost layer to be expanded.
Prototype
void p4est_ghost_expand_by_lnodes (p4est_t * p4est, p4est_lnodes_t * lnodes, p4est_ghost_t * ghost);
P4est.LibP4est.p4est_ghost_is_valid
— Methodp4est_ghost_is_valid(p4est_, ghost)
Examine if a ghost structure is valid. Test if within a ghost-structure the array ghosts is in p4est_quadrant_compare_piggy order. Test if local_num in piggy3 data member of the quadrants in ghosts and mirrors are in ascending order (ascending within each rank for ghost).
Test if the p4est_locidx_t
arrays are in ascending order (for mirror_proc_mirrors ascending within each rank)
Parameters
p4est
:[in] the forest.ghost
:[in] Ghost layer structure.
Returns
true if ghost is valid
Prototype
int p4est_ghost_is_valid (p4est_t * p4est, p4est_ghost_t * ghost);
P4est.LibP4est.p4est_ghost_memory_used
— Methodp4est_ghost_memory_used(ghost)
Calculate the memory usage of the ghost layer.
Parameters
ghost
:[in] Ghost layer structure.
Returns
Memory used in bytes.
Prototype
size_t p4est_ghost_memory_used (p4est_ghost_t * ghost);
P4est.LibP4est.p4est_ghost_new
— Methodp4est_ghost_new(p4est_, btype)
Builds the ghost layer.
This will gather the quadrants from each neighboring proc to build one layer of face and corner based ghost elements around the ones they own.
Parameters
p4est
:[in] The forest for which the ghost layer will be generated.btype
:[in] Which ghosts to include (across face, corner or full).
Returns
A fully initialized ghost layer.
Prototype
p4est_ghost_t *p4est_ghost_new (p4est_t * p4est, p4est_connect_type_t btype);
P4est.LibP4est.p4est_ghost_support_lnodes
— Methodp4est_ghost_support_lnodes(p4est_, lnodes, ghost)
Expand the ghost layer to include the support of all nodes supported on the local partition.
Parameters
p4est
:[in] The forest from which the ghost layer was generated.lnodes
:[in] The nodes to support.ghost
:[in,out] The ghost layer to be expanded.
Prototype
void p4est_ghost_support_lnodes (p4est_t * p4est, p4est_lnodes_t * lnodes, p4est_ghost_t * ghost);
P4est.LibP4est.p4est_init
— Methodp4est_init(log_handler, log_threshold)
Registers p4est
with the SC Library and sets the logging behavior. This function is optional. This function must only be called before additional threads are created. If this function is not called or called with log_handler == NULL, the default SC log handler will be used. If this function is not called or called with log_threshold == SC_LP_DEFAULT
, the default SC log threshold will be used. The default SC log settings can be changed with sc_set_log_defaults
().
Prototype
void p4est_init (sc_log_handler_t log_handler, int log_threshold);
P4est.LibP4est.p4est_is_balanced
— Methodp4est_is_balanced(p4est_, btype)
Check a forest to see if it is balanced.
This function builds the ghost layer and discards it when done.
Parameters
p4est
:[in] Thep4est
to be tested.btype
:[in] Balance type (face, corner or default, full).
Returns
Returns true if balanced, false otherwise.
Prototype
int p4est_is_balanced (p4est_t * p4est, p4est_connect_type_t btype);
P4est.LibP4est.p4est_iterate
— Methodp4est_iterate(p4est_, ghost_layer, user_data, iter_volume, iter_face, iter_corner)
Execute user supplied callbacks at every volume, face, and corner in the local forest.
p4est_iterate
executes the user-supplied callback functions at every volume, face, and corner in the local forest. The ghost_layer may be NULL. The user_data pointer is not touched by p4est_iterate
, but is passed to each of the callbacks. Any of the callbacks may be NULL. The callback functions are interspersed with each other, i.e. some face callbacks will occur between volume callbacks, and some corner callbacks will occur between face callbacks:
- volume callbacks occur in the sorted Morton-index order. 2) a face callback is not executed until after the volume callbacks have been executed for the quadrants that share it. 3) a corner callback is not executed until the face callbacks have been executed for all faces that touch the corner. 4) it is not always the case that every face callback for a given quadrant is executed before any of the corner callbacks. 5) callbacks are not executed at faces or corners that only involve ghost quadrants, i.e. that are not adjacent in the local section of the forest.
Parameters
p4est
:[in] the forestghost_layer
:[in] optional: when not given, callbacks at the boundaries of the local partition cannot provide quadrant data about ghost quadrants: missing (p4est_quadrant_t
*) pointers are set to NULL, missing indices are set to -1.user_data
:[in,out] optional context to supply to each callbackiter_volume
:[in] callback function for every quadrant's interioriter_face
:[in] callback function for every face between quadrantsiter_corner
:[in] callback function for every corner between quadrants
Prototype
void p4est_iterate (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);
P4est.LibP4est.p4est_iterate_ext
— Methodp4est_iterate_ext(p4est_, ghost_layer, user_data, iter_volume, iter_face, iter_corner, 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.
Prototype
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.LibP4est.p4est_lid_add
— Methodp4est_lid_add(a, b, result)
Adds the uint128_t b to the uint128_t a. result == a or result == b is not allowed. a == b is allowed.
Parameters
a
:[in] A pointer to ap4est_lid_t
.b
:[in] A pointer to ap4est_lid_t
.result
:[out] A pointer to ap4est_lid_t
. The sum a + b will be saved in result.
Prototype
void p4est_lid_add (const p4est_lid_t * a, const p4est_lid_t * b, p4est_lid_t * result);
P4est.LibP4est.p4est_lid_add_inplace
— Methodp4est_lid_add_inplace(a, b)
Adds the p4est_lid_t
b to the p4est_lid_t
a. The result is saved in a. a == b is allowed.
Parameters
a
:[in,out] A pointer to ap4est_lid_t
. a will be overwritten by a + b.b
:[in] A pointer to ap4est_lid_t
.
Prototype
void p4est_lid_add_inplace (p4est_lid_t * a, const p4est_lid_t * b);
P4est.LibP4est.p4est_lid_bitwise_and
— Methodp4est_lid_bitwise_and(a, b, 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
a
:[in] A pointer to ap4est_lid_t
.b
:[in] A pointer to ap4est_lid_t
.result
:[out] A pointer to ap4est_lid_t
. The bitwise and of a and b will be saved. in result.
Prototype
void p4est_lid_bitwise_and (const p4est_lid_t * a, const p4est_lid_t * b, p4est_lid_t * result);
P4est.LibP4est.p4est_lid_bitwise_and_inplace
— Methodp4est_lid_bitwise_and_inplace(a, b)
Calculates the bitwise and of the uint128_t a and the uint128_t b. a == b is allowed.
Parameters
a
:[in,out] A pointer to ap4est_lid_t
. The bitwise and will be saved in a.b
:[in] A pointer to ap4est_lid_t
.
Prototype
void p4est_lid_bitwise_and_inplace (p4est_lid_t * a, const p4est_lid_t * b);
P4est.LibP4est.p4est_lid_bitwise_neg
— Methodp4est_lid_bitwise_neg(a, result)
Calculates the bitwise negation of the uint128_t a. a == result is allowed.
Parameters
a
:[in] A pointer to ap4est_lid_t
.result
:[out] A pointer to ap4est_lid_t
. The bitwise negation of a will be saved in result.
Prototype
void p4est_lid_bitwise_neg (const p4est_lid_t * a, p4est_lid_t * result);
P4est.LibP4est.p4est_lid_bitwise_or
— Methodp4est_lid_bitwise_or(a, b, 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
a
:[in] A pointer to ap4est_lid_t
.b
:[in] A pointer to ap4est_lid_t
.result
:[out] A pointer to ap4est_lid_t
. The bitwise or of a and b will be saved in result.
Prototype
void p4est_lid_bitwise_or (const p4est_lid_t * a, const p4est_lid_t * b, p4est_lid_t * result);
P4est.LibP4est.p4est_lid_bitwise_or_inplace
— Methodp4est_lid_bitwise_or_inplace(a, b)
Calculates the bitwise or of the uint128_t a and the uint128_t b. a == b is allowed.
Parameters
a
:[in,out] A pointer to ap4est_lid_t
. The bitwise or will be saved in a.b
:[in] A pointer to ap4est_lid_t
.
Prototype
void p4est_lid_bitwise_or_inplace (p4est_lid_t * a, const p4est_lid_t * b);
P4est.LibP4est.p4est_lid_chk_bit
— Methodp4est_lid_chk_bit(input, bit_number)
Returns the bit_number-th bit of input. This function checks a bit of an existing, initialized value.
Parameters
input
:[in] A pointer to ap4est_lid_t
.bit_number
:[in] The 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.
Prototype
int p4est_lid_chk_bit (const p4est_lid_t * input, int bit_number);
P4est.LibP4est.p4est_lid_compare
— Methodp4est_lid_compare(a, b)
Compare the p4est_lid_t
a and the p4est_lid_t
b.
Parameters
a
:[in] A pointer to ap4est_lid_t
.b
:[in] A pointer to ap4est_lid_t
.
Returns
Returns -1 if a < b, 1 if a > b and 0 if a == b.
Prototype
int p4est_lid_compare (const p4est_lid_t * a, const p4est_lid_t * b);
P4est.LibP4est.p4est_lid_copy
— Methodp4est_lid_copy(input, output)
Copies an initialized p4est_lid_t
to a p4est_lid_t
.
Parameters
input
:[in] A pointer to thep4est_lid_t
that is copied.output
:[in,out] A pointer to ap4est_lid_t
. The low bits of output will be set to the low bits of input and high bits are ignored.
Prototype
void p4est_lid_copy (const p4est_lid_t * input, p4est_lid_t * output);
P4est.LibP4est.p4est_lid_init
— Methodp4est_lid_init(input, high, low)
Initializes an unsigned 64 bit integer. high is just a a placeholder to use the same interface in 3D.
Parameters
input
:[in,out] A pointer to ap4est_lid_t
that will be intialized.high
:[in] The given high bits must be zero.low
:[in] The given low bits to initialize input.
Prototype
void p4est_lid_init (p4est_lid_t * input, uint64_t high, uint64_t low);
P4est.LibP4est.p4est_lid_is_equal
— Methodp4est_lid_is_equal(a, b)
Checks if the p4est_lid_t
a and the p4est_lid_t
b are equal.
Parameters
a
:[in] A pointer to ap4est_lid_t
.b
:[in] A pointer to ap4est_lid_t
.
Returns
Returns a true value if a and b are equal, false otherwise
Prototype
int p4est_lid_is_equal (const p4est_lid_t * a, const p4est_lid_t * b);
P4est.LibP4est.p4est_lid_set_bit
— Methodp4est_lid_set_bit(input, bit_number)
Sets the exponent-th bit of a to one. This function modifies an existing, initialized value.
Parameters
input
:[in,out] A pointer to ap4est_lid_t
.bit_number
:[in] The bit (counted from the right hand side) that is set to one by logical or. Require 0 <= bit_number < 64.
Prototype
void p4est_lid_set_bit (p4est_lid_t * input, int bit_number);
P4est.LibP4est.p4est_lid_set_one
— Methodp4est_lid_set_one(input)
Initializes a linear index to one.
Parameters
input
:[out] A pointer to ap4est_lid_t
that will be intialized.
Prototype
void p4est_lid_set_one (p4est_lid_t * input);
P4est.LibP4est.p4est_lid_set_uint64
— Methodp4est_lid_set_uint64(input, u)
Initializes a linear index to an unsigned 64 bit integer.
Parameters
input
:[out] A pointer to ap4est_lid_t
that will be intialized.
Prototype
void p4est_lid_set_uint64 (p4est_lid_t * input, uint64_t u);
P4est.LibP4est.p4est_lid_set_zero
— Methodp4est_lid_set_zero(input)
Initializes a linear index to zero.
Parameters
input
:[out] A pointer to ap4est_lid_t
that will be intialized.
Prototype
void p4est_lid_set_zero (p4est_lid_t * input);
P4est.LibP4est.p4est_lid_shift_left
— Methodp4est_lid_shift_left(input, shift_count, 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
input
:[in] A pointer to ap4est_lid_t
.shift_count
:[in] Bits to shift. shift_count >= 0.result
:[in,out] A pointer to ap4est_lid_t
. The left shifted number will be saved in result.
Prototype
void p4est_lid_shift_left (const p4est_lid_t * input, unsigned shift_count, p4est_lid_t * result);
P4est.LibP4est.p4est_lid_shift_right
— Methodp4est_lid_shift_right(input, shift_count, 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
input
:[in] A pointer to ap4est_lid_t
.shift_count
:[in] Bits to shift. shift_count >= 0.result
:[in,out] A pointer to ap4est_lid_t
. The right shifted number will be saved in result.
Prototype
void p4est_lid_shift_right (const p4est_lid_t * input, unsigned shift_count, p4est_lid_t * result);
P4est.LibP4est.p4est_lid_sub
— Methodp4est_lid_sub(a, b, result)
Substracts 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
a
:[in] A pointer to ap4est_lid_t
.b
:[in] A pointer to ap4est_lid_t
.result
:[out] A pointer to ap4est_lid_t
. The difference a - b will be saved in result.
Prototype
void p4est_lid_sub (const p4est_lid_t * a, const p4est_lid_t * b, p4est_lid_t * result);
P4est.LibP4est.p4est_lid_sub_inplace
— Methodp4est_lid_sub_inplace(a, b)
Substracts 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
a
:[in,out] A pointer to ap4est_lid_t
. a will be overwritten by a - b.b
:[in] A pointer to ap4est_lid_t
.
Prototype
void p4est_lid_sub_inplace (p4est_lid_t * a, const p4est_lid_t * b);
P4est.LibP4est.p4est_lnodes_buffer_destroy
— Methodp4est_lnodes_buffer_destroy(buffer)
Prototype
void p4est_lnodes_buffer_destroy (p4est_lnodes_buffer_t * buffer);
P4est.LibP4est.p4est_lnodes_destroy
— Methodp4est_lnodes_destroy(lnodes)
Prototype
void p4est_lnodes_destroy (p4est_lnodes_t * lnodes);
P4est.LibP4est.p4est_lnodes_new
— Methodp4est_lnodes_new(p4est_, ghost_layer, degree)
Prototype
p4est_lnodes_t *p4est_lnodes_new (p4est_t * p4est, p4est_ghost_t * ghost_layer, int degree);
P4est.LibP4est.p4est_lnodes_share_all
— Methodp4est_lnodes_share_all(node_data, lnodes)
Equivalent to calling p4est_lnodes_share_all_end
directly after p4est_lnodes_share_all_begin
. Use if there is no local work that can be done to mask the communication cost.
Returns
A fully initialized buffer that contains the received data. After processing this data, the buffer must be freed with p4est_lnodes_buffer_destroy
.
Prototype
p4est_lnodes_buffer_t *p4est_lnodes_share_all (sc_array_t * node_data, p4est_lnodes_t * lnodes);
P4est.LibP4est.p4est_lnodes_share_all_begin
— Methodp4est_lnodes_share_all_begin(node_data, lnodes)
node_data is a user_defined array of arbitrary type, where each entry is associated with the lnodes local nodes entry of matching index. For every process that shares an entry with the current one, the value in the node_data array of that process is written into a buffer->recvbuffers entry as described above. The user can then perform some arbitrary work that requires the data from all processes that share a node (such as reduce, max, min, etc.). When the work concludes, the buffer should be destroyed with [`p4estlnodesbufferdestroy`](@ref).
Values of node_data are not guaranteed to be sent, and buffer->recvbuffer entries are not guaranteed to be received until the buffer created by [`p4estlnodesshareallbegin](@ref) is passed to [
p4estlnodesshareall_end`](@ref).
Prototype
p4est_lnodes_buffer_t *p4est_lnodes_share_all_begin (sc_array_t * node_data, p4est_lnodes_t * lnodes);
P4est.LibP4est.p4est_lnodes_share_all_end
— Methodp4est_lnodes_share_all_end(buffer)
Prototype
void p4est_lnodes_share_all_end (p4est_lnodes_buffer_t * buffer);
P4est.LibP4est.p4est_lnodes_share_owned
— Methodp4est_lnodes_share_owned(node_data, lnodes)
Equivalent to calling p4est_lnodes_share_owned_end
directly after p4est_lnodes_share_owned_begin
. Use if there is no local work that can be done to mask the communication cost.
Prototype
void p4est_lnodes_share_owned (sc_array_t * node_data, p4est_lnodes_t * lnodes);
P4est.LibP4est.p4est_lnodes_share_owned_begin
— Methodp4est_lnodes_share_owned_begin(node_data, lnodes)
p4est_lnodes_share_owned_begin
node_data is a user-defined array of arbitrary type, where each entry is associated with the lnodes local nodes entry of matching index. For every local nodes entry that is owned by a process other than the current one, the value in the node_data array of the owning process is written directly into the node_data array of the current process. Values of node_data are not guaranteed to be sent or received until the buffer created by p4est_lnodes_share_owned_begin
is passed to p4est_lnodes_share_owned_end
.
To be memory neutral, the buffer created by p4est_lnodes_share_owned_begin
must be destroying with p4est_lnodes_buffer_destroy
(it is not destroyed by p4est_lnodes_share_owned_end
).
Prototype
p4est_lnodes_buffer_t *p4est_lnodes_share_owned_begin (sc_array_t * node_data, p4est_lnodes_t * lnodes);
P4est.LibP4est.p4est_lnodes_share_owned_end
— Methodp4est_lnodes_share_owned_end(buffer)
Prototype
void p4est_lnodes_share_owned_end (p4est_lnodes_buffer_t * buffer);
P4est.LibP4est.p4est_load
— Methodp4est_load(filename, mpicomm, data_size, load_data, user_pointer, connectivity)
Prototype
p4est_t *p4est_load (const char *filename, sc_MPI_Comm mpicomm, size_t data_size, int load_data, void *user_pointer, p4est_connectivity_t ** connectivity);
P4est.LibP4est.p4est_load_ext
— Methodp4est_load_ext(filename, mpicomm, data_size, load_data, autopartition, broadcasthead, user_pointer, connectivity)
Prototype
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);
P4est.LibP4est.p4est_memory_used
— Methodp4est_memory_used(p4est_)
Calculate local memory usage of a forest structure. Not collective. The memory used on the current rank is returned. The connectivity structure is not counted since it is not owned; use p4est_connectivity_memory_usage (p4est
->connectivity).
Parameters
p4est
:[in] Valid forest structure.
Returns
Memory used in bytes.
Prototype
size_t p4est_memory_used (p4est_t * p4est);
P4est.LibP4est.p4est_mesh_destroy
— Methodp4est_mesh_destroy(mesh)
Destroy a p4est_mesh structure.
Parameters
mesh
:[in] Mesh structure previously created byp4est_mesh_new
.
Prototype
void p4est_mesh_destroy (p4est_mesh_t * mesh);
P4est.LibP4est.p4est_mesh_face_neighbor_data
— Methodp4est_mesh_face_neighbor_data(mfn, ghost_data)
Get the user data for the current face neighbor.
Parameters
mfn
:[in] Internal status of the iterator.ghost_data
:[in] Data for the ghost quadrants that has been synchronized withp4est_ghost_exchange_data
.
Returns
A pointer to the user data for the current neighbor.
Prototype
void *p4est_mesh_face_neighbor_data (p4est_mesh_face_neighbor_t * mfn, void *ghost_data);
P4est.LibP4est.p4est_mesh_face_neighbor_init
— Methodp4est_mesh_face_neighbor_init(mfn, p4est_, ghost, mesh, which_tree, quadrant)
Initialize a mesh neighbor iterator by quadrant pointer.
Parameters
mfn
:[out] Ap4est_mesh_face_neighbor_t
to be initialized.which_tree
:[in] Tree of quadrant whose neighbors are looped over.quadrant
:[in] Pointer to quadrant contained in which_tree.
Prototype
void p4est_mesh_face_neighbor_init (p4est_mesh_face_neighbor_t * mfn, p4est_t * p4est, p4est_ghost_t * ghost, p4est_mesh_t * mesh, p4est_topidx_t which_tree, p4est_quadrant_t * quadrant);
P4est.LibP4est.p4est_mesh_face_neighbor_init2
— Methodp4est_mesh_face_neighbor_init2(mfn, p4est_, ghost, mesh, which_tree, quadrant_id)
Initialize a mesh neighbor iterator by quadrant index.
Parameters
mfn
:[out] Ap4est_mesh_face_neighbor_t
to be initialized.which_tree
:[in] Tree of quadrant whose neighbors are looped over.quadrant_id
:[in] Index relative to which_tree of quadrant.
Prototype
void p4est_mesh_face_neighbor_init2 (p4est_mesh_face_neighbor_t * mfn, p4est_t * p4est, p4est_ghost_t * ghost, p4est_mesh_t * mesh, p4est_topidx_t which_tree, p4est_locidx_t quadrant_id);
P4est.LibP4est.p4est_mesh_face_neighbor_next
— Methodp4est_mesh_face_neighbor_next(mfn, ntree, nquad, nface, nrank)
Move the iterator forward to loop around neighbors of the quadrant.
Parameters
mfn
:[in,out] Internal status of the iterator.ntree
:[out] If not NULL, the tree number of the neighbor.nquad
:[out] If not NULL, the quadrant number within tree. For ghosts instead the number in ghost layer.nface
:[out] If not NULL, neighbor's face as inp4est_mesh_t
.nrank
:[out] If not NULL, the owner process of the neighbor.
Returns
Either a real quadrant or one from the ghost layer. Returns NULL when the iterator is done.
Prototype
p4est_quadrant_t *p4est_mesh_face_neighbor_next (p4est_mesh_face_neighbor_t * mfn, p4est_topidx_t * ntree, p4est_locidx_t * nquad, int *nface, int *nrank);
P4est.LibP4est.p4est_mesh_get_neighbors
— Methodp4est_mesh_get_neighbors(p4est_, ghost, mesh, curr_quad_id, direction, neighboring_quads, neighboring_encs, neighboring_qids)
Lookup neighboring quads of quadrant in a specific direction.
Parameters
p4est
:[in] Forest to be worked with.ghost
:[in] Ghost layer.mesh
:[in] Mesh structure.curr_quad_id
:[in] Process-local id of current quad.direction
:[in] Direction i in which to look for adjacent quadrants is encoded as follows: 0 .. 3 neighbor(-s) across face i, 4 .. 7 neighbor(-s) across corner i-4. TODO: Allow any combination of empty output arrays.neighboring_quads
:[out] Array containing neighboring quad(-s). Needs to be empty on input, size ofp4est_quadrant_t
*. May be NULL, then neighboring_qids must not be NULL.neighboring_qids
:[out] Array containing quadrant ids for neighboring quadrants. May be NULL, then no neighboring qids are collected. If non-NULL the array needs to be empty and will contain int. CAUTION: Note, that the encodings differ from the encodings saved in the mesh. TODO: Encodings are the same as in p4est_mesh for all quadrants. TODO: Ghosts can be encoded by returning the quad_to_quad convention in qid. For ghost quadrants, we add -300 to the values in p4est_mesh. This means that values below -100 belong to ghosts, values above to locals. Positive values are for local quadrants, negative values indicate ghost quadrants. Faces: 1 .. 8 => same size neighbor (r * 4 + nf) + 1; nf = 0 .. 3 face index; r = 0 .. 1 relative orientation 9 .. 24 => double size neighbor 9 + h * 8 + r * 4 + nf; h = 0 .. 1 number of the subface; r, nf as above 25 .. 32 => half-size neighbors 25 + r * 4 + nf; r, nf as above Corners: 1 .. 4 => size not encoded for corners nc + 1; nc = 0 .. 3 corner indexneighboring_encs
:[out] Array containing encodings for neighboring quads. Needs to be empty, contains int.
Prototype
p4est_locidx_t p4est_mesh_get_neighbors (p4est_t * p4est, p4est_ghost_t * ghost, p4est_mesh_t * mesh, p4est_locidx_t curr_quad_id, p4est_locidx_t direction, sc_array_t * neighboring_quads, sc_array_t * neighboring_encs, sc_array_t * neighboring_qids);
P4est.LibP4est.p4est_mesh_get_quadrant
— Methodp4est_mesh_get_quadrant(p4est_, mesh, qid)
Access a process-local quadrant inside a forest. Needs a mesh with populated quad_to_tree array. This is a special case of p4estmeshquadrant_cumulative.
Parameters
p4est
:[in] The forest.mesh
:[in] The mesh.qid
:[in] Process-local id of the quadrant (cumulative over trees).
Returns
A pointer to the requested quadrant.
Prototype
p4est_quadrant_t *p4est_mesh_get_quadrant (p4est_t * p4est, p4est_mesh_t * mesh, p4est_locidx_t qid);
P4est.LibP4est.p4est_mesh_memory_used
— Methodp4est_mesh_memory_used(mesh)
Calculate the memory usage of the mesh structure.
Parameters
mesh
:[in] Mesh structure.
Returns
Memory used in bytes.
Prototype
size_t p4est_mesh_memory_used (p4est_mesh_t * mesh);
P4est.LibP4est.p4est_mesh_new
— Methodp4est_mesh_new(p4est_, ghost, btype)
Create a p4est_mesh structure. This function does not populate the quad_to_tree and quad_level fields. To populate them, use p4estmeshnew_ext.
Parameters
p4est
:[in] A forest that is fully 2:1 balanced.ghost
:[in] The ghost layer created from the providedp4est
.btype
:[in] Determines the highest codimension of neighbors.
Returns
A fully allocated mesh structure.
Prototype
p4est_mesh_t *p4est_mesh_new (p4est_t * p4est, p4est_ghost_t * ghost, p4est_connect_type_t btype);
P4est.LibP4est.p4est_mesh_new_ext
— Methodp4est_mesh_new_ext(p4est_, ghost, compute_tree_index, compute_level_lists, btype)
Create a new mesh.
Parameters
p4est
:[in] A forest that is fully 2:1 balanced.ghost
:[in] The ghost layer created from the providedp4est
.compute_tree_index
:[in] Boolean to decide whether to allocate and compute the quad_to_tree list.compute_level_lists
:[in] Boolean to decide whether to compute the level lists in quad_level.btype
:[in] Currently ignored, only face neighbors are stored.
Returns
A fully allocated mesh structure.
Prototype
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);
P4est.LibP4est.p4est_mesh_quadrant_cumulative
— Methodp4est_mesh_quadrant_cumulative(p4est_, mesh, cumulative_id, which_tree, quadrant_id)
Find a quadrant based on its cumulative number in the local forest. If the quad_to_tree field of the mesh structure exists, this is O(1). Otherwise, we perform a binary search over the processor-local trees.
Parameters
p4est
:[in] Forest to be worked with.mesh
:[in] A mesh derived from the forest.cumulative_id
:[in] Cumulative index over all trees of quadrant. Must refer to a local (non-ghost) quadrant.which_tree
:[in,out] If not NULL, the input value can be -1 or an initial guess for the quadrant's tree and output is the tree of returned quadrant.quadrant_id
:[out] If not NULL, the number of quadrant in tree.
Returns
The identified quadrant.
Prototype
p4est_quadrant_t *p4est_mesh_quadrant_cumulative (p4est_t * p4est, p4est_mesh_t * mesh, p4est_locidx_t cumulative_id, p4est_topidx_t * which_tree, p4est_locidx_t * quadrant_id);
P4est.LibP4est.p4est_new
— Methodp4est_new(mpicomm, connectivity, data_size, init_fn, user_pointer)
Prototype
p4est_t *p4est_new (sc_MPI_Comm mpicomm, p4est_connectivity_t * connectivity, size_t data_size, p4est_init_t init_fn, void *user_pointer);
P4est.LibP4est.p4est_new_ext
— Methodp4est_new_ext(mpicomm, connectivity, min_quadrants, min_level, fill_uniform, data_size, init_fn, user_pointer)
Prototype
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);
P4est.LibP4est.p4est_partition
— Methodp4est_partition(p4est_, allow_for_coarsening, 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).
On one process, the function noops and does not call the weight callback. Otherwise, the weight callback is called once per quadrant in order.
Parameters
p4est
:[in,out] The forest that will be partitioned.allow_for_coarsening
:[in] Slightly modify partition such that quadrant families are not split between ranks.weight_fn
:[in] A weighting function or NULL for uniform partitioning. When running with mpisize == 1, never called. Otherwise, called in order for all quadrants if not NULL. 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.
Prototype
void p4est_partition (p4est_t * p4est, int allow_for_coarsening, p4est_weight_t weight_fn);
P4est.LibP4est.p4est_partition_ext
— Methodp4est_partition_ext(p4est_, partition_for_coarsening, 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
p4est
:[in,out] The forest that will be partitioned.partition_for_coarsening
:[in] If true, the partition is modified to allow one level of coarsening.weight_fn
:[in] A 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
Prototype
p4est_gloidx_t p4est_partition_ext (p4est_t * p4est, int partition_for_coarsening, p4est_weight_t weight_fn);
P4est.LibP4est.p4est_partition_for_coarsening
— Methodp4est_partition_for_coarsening(p4est_, num_quadrants_in_proc)
Correct partition to allow one level of coarsening.
Parameters
p4est
:[in] forest whose partition is correctednum_quadrants_in_proc
:[in,out] partition that will be corrected
Returns
absolute number of moved quadrants
Prototype
p4est_gloidx_t p4est_partition_for_coarsening (p4est_t * p4est, p4est_locidx_t * num_quadrants_in_proc);
P4est.LibP4est.p4est_partition_lnodes
— Methodp4est_partition_lnodes(p4est_, ghost, degree, partition_for_coarsening)
Partition using weights based on the number of nodes assigned to each element in lnodes
Parameters
p4est
:[in,out] the forest to be repartitionedghost
:[in] the ghost layerdegree
:[in] the degree that would be passed top4est_lnodes_new
()partition_for_coarsening
:[in] whether the partition should allow coarsening (i.e. group siblings who might merge)
Prototype
void p4est_partition_lnodes (p4est_t * p4est, p4est_ghost_t * ghost, int degree, int partition_for_coarsening);
P4est.LibP4est.p4est_partition_lnodes_detailed
— Methodp4est_partition_lnodes_detailed(p4est_, ghost, nodes_per_volume, nodes_per_face, nodes_per_corner, partition_for_coarsening)
Partition using weights that are broken down by where they reside: in volumes, on faces, or on corners.
Prototype
void p4est_partition_lnodes_detailed (p4est_t * p4est, p4est_ghost_t * ghost, int nodes_per_volume, int nodes_per_face, int nodes_per_corner, int partition_for_coarsening);
P4est.LibP4est.p4est_partition_to_p6est_partition
— Methodp4est_partition_to_p6est_partition(p6est_, num_columns_in_proc, num_layers_in_proc)
Prototype
void p4est_partition_to_p6est_partition (p6est_t * p6est, p4est_locidx_t * num_columns_in_proc, p4est_locidx_t * num_layers_in_proc);
P4est.LibP4est.p4est_qcoord_to_vertex
— Methodp4est_qcoord_to_vertex(connectivity, treeid, x, y, vxyz)
Transform a quadrant coordinate into the space spanned by tree vertices.
Parameters
connectivity
:[in] Connectivity must provide the vertices.treeid
:[in] Identify the tree that contains x, y.x,
:[in] y Quadrant coordinates relative to treeid.vxyz
:[out] Transformed coordinates in vertex space.
Prototype
void p4est_qcoord_to_vertex (p4est_connectivity_t * connectivity, p4est_topidx_t treeid, p4est_qcoord_t x, p4est_qcoord_t y, double vxyz[3]);
P4est.LibP4est.p4est_quadrant_exists
— Methodp4est_quadrant_exists(p4est_, ghost, treeid, q, exists_arr, rproc_arr, rquad_arr)
Checks if quadrant exists in the local forest or the ghost layer.
For quadrants across tree corners it checks if the quadrant exists in any of the corner neighbors, thus it can execute multiple queries.
Parameters
p4est
:[in] The forest in which to search for qghost
:[in] The ghost layer in which to search for qtreeid
:[in] The tree to which q belongs (can be extended).q
:[in] The quadrant that is being searched for.exists_arr
:[in,out] Must exist and be of of elem_size = sizeof (int) for inter-tree corner cases. Is resized by this function to one entry for each corner search and set to true/false depending on its existence in the local forest or ghost_layer.rproc_arr
:[in,out] If not NULL is filled with one rank per query.rquad_arr
:[in,out] If not NULL is filled with one quadrant per query. Its piggy3 member is defined as well.
Returns
true if the quadrant exists in the local forest or in the ghost_layer, and false if doesn't exist in either.
Prototype
int p4est_quadrant_exists (p4est_t * p4est, p4est_ghost_t * ghost, p4est_topidx_t treeid, const p4est_quadrant_t * q, sc_array_t * exists_arr, sc_array_t * rproc_arr, sc_array_t * rquad_arr);
P4est.LibP4est.p4est_quadrant_find_owner
— Methodp4est_quadrant_find_owner(p4est_, treeid, face, q)
Gets the processor id of a quadrant's owner. The quadrant can lie outside of a tree across faces (and only faces).
Does not work for tree edge or corner neighbors.
Parameters
p4est
:[in] The forest in which to search for a quadrant.treeid
:[in] The tree to which the quadrant belongs.face
:[in] Supply a face direction if known, or -1 otherwise.q
:[in] The quadrant that is being searched for.
Returns
Processor id of the owner or -1 if the quadrant lies outside of the mesh.
Prototype
int p4est_quadrant_find_owner (p4est_t * p4est, p4est_topidx_t treeid, int face, const p4est_quadrant_t * q);
P4est.LibP4est.p4est_quadrant_linear_id_ext128
— Methodp4est_quadrant_linear_id_ext128(quadrant, level, 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 p4estquadrantset_morton.
The user_data of quadrant is never modified.
Parameters
quadrant
:[in] Quadrant 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.level
:[in] The level of the regular grid compared to which the linear position is to be computed.id
:[in,out] A pointer to an allocated or staticp4est_lid_t
. id will be the linear position of this quadrant on a uniform grid.
Prototype
void p4est_quadrant_linear_id_ext128 (const p4est_quadrant_t * quadrant, int level, p4est_lid_t * id);
P4est.LibP4est.p4est_quadrant_set_morton_ext128
— Methodp4est_quadrant_set_morton_ext128(quadrant, level, id)
Set quadrant Morton indices based on linear position given as p4est_lid_t
in uniform grid. This is the inverse operation of p4estquadrantlinear_id.
The user_data of quadrant is never modified.
Parameters
quadrant
:[in,out] Quadrant whose Morton indices will be set.level
:[in] Level of the grid and of the resulting quadrant.id
:[in] Linear index of the quadrant on a uniform grid.
Prototype
void p4est_quadrant_set_morton_ext128 (p4est_quadrant_t * quadrant, int level, const p4est_lid_t * id);
P4est.LibP4est.p4est_refine
— Methodp4est_refine(p4est_, refine_recursive, refine_fn, init_fn)
Refine a forest.
Parameters
p4est
:[in,out] The forest is changed in place.refine_recursive
:[in] Boolean to decide on recursive refinement.refine_fn
:[in] 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 usep4est_refine_ext
in p4est_extended.h and examine whether replace_fn gets called.init_fn
:[in] Callback function to initialize the user_data of newly created quadrants, which is already allocated. This function pointer may be NULL.
Prototype
void p4est_refine (p4est_t * p4est, int refine_recursive, p4est_refine_t refine_fn, p4est_init_t init_fn);
P4est.LibP4est.p4est_refine_ext
— Methodp4est_refine_ext(p4est_, refine_recursive, maxlevel, refine_fn, init_fn, replace_fn)
Refine a forest with a bounded refinement level and a replace option.
Parameters
p4est
:[in,out] The forest is changed in place.refine_recursive
:[in] Boolean to decide on recursive refinement.maxlevel
:[in] Maximum allowed refinement level (inclusive). If this is negative the level is restricted only by the compile-time constant QMAXLEVEL inp4est.h
.refine_fn
:[in] 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.init_fn
:[in] Callback function to initialize the user_data for newly created quadrants, which is guaranteed to be allocated. This function pointer may be NULL.replace_fn
:[in] Callback function that allows the user to change incoming quadrants based on the quadrants they replace; may be NULL.
Prototype
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);
P4est.LibP4est.p4est_reset_data
— Methodp4est_reset_data(p4est_, data_size, init_fn, 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.
Parameters
data_size
:[in] This is the size of data for each quadrant which can be zero. Then user_data_pool is set to NULL.init_fn
:[in] Callback function to initialize the user_data which is already allocated automatically. May be NULL.user_pointer
:[in] Assign to the user_pointer member of thep4est
before init_fn is called the first time.
Prototype
void p4est_reset_data (p4est_t * p4est, size_t data_size, p4est_init_t init_fn, void *user_pointer);
P4est.LibP4est.p4est_revision
— Methodp4est_revision(p4est_)
Return the revision counter of the forest. Not collective, even though the revision value is the same on all ranks. A newly created forest starts with a revision counter of zero. Every refine, coarsen, partition, and balance that actually changes the mesh increases the counter by one. Operations with no effect keep the old value.
Parameters
p8est
:[in] The forest must be valid.
Returns
Non-negative number.
Prototype
long p4est_revision (p4est_t * p4est);
P4est.LibP4est.p4est_save
— Methodp4est_save(filename, p4est_, save_data)
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.
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 p4est_save_ext
() in p4est_extended.h.
The revision counter is not saved to the file, since that would make files different that come from different revisions but store the same mesh.
Aborts on file errors.
If p4est
is not configured to use MPI-IO, some processes return from this function before the file is complete, in which case immediate read-access to the file may require a call to sc_MPI_Barrier
.
Parameters
filename
:[in] Name of the file to write.p4est
:[in] Valid forest structure.save_data
:[in] If true, the element data is saved. Otherwise, a data size of 0 is saved.
Prototype
void p4est_save (const char *filename, p4est_t * p4est, int save_data);
P4est.LibP4est.p4est_save_ext
— Methodp4est_save_ext(filename, p4est_, save_data, 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.
Aborts on file errors.
Parameters
filename
:[in] Name of the file to write.p4est
:[in] Valid forest structure.save_data
:[in] If true, the element data is saved. Otherwise, a data size of 0 is saved.save_partition
:[in] 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.
Prototype
void p4est_save_ext (const char *filename, p4est_t * p4est, int save_data, int save_partition);
P4est.LibP4est.p4est_search
— Methodp4est_search(p4est_, quadrant_fn, point_fn, points)
This function is provided for backwards compatibility. We call p4estsearchlocal with call_post = 0.
Prototype
void p4est_search (p4est_t * p4est, p4est_search_query_t quadrant_fn, p4est_search_query_t point_fn, sc_array_t * points);
P4est.LibP4est.p4est_search_all
— Methodp4est_search_all(p4est_, call_post, quadrant_fn, point_fn, points)
Perform a top-down search on the whole forest.
This function combines the functionality of p4estsearchlocal and p4estsearchpartition; their documentation applies for the most part.
The recursion proceeds from the root quadrant of each tree until (a) we encounter a remote quadrant that covers only one processor, or (b) we encounter a local leaf quadrant. In other words, we proceed with the recursion into a quadrant's children if (a) the quadrant is split between two or more processors, no matter whether one of them is the calling processor or not, or (b) if the quadrant is on the local processor but we have not reached a leaf yet.
The search can track one or more points, which are abstract placeholders. They are matched against the quadrants traversed using a callback function. The result of the callback function can be used to stop a recursion early. The user determines how a point is interpreted, we only pass it around.
Note that in the remote case (a), we may terminate the recursion even if the quadrant is not a leaf, which we have no means of knowing. Still, this case is sufficient to determine the processor ownership of a point.
This is a very powerful function that can become slow if not used carefully.
As with the two other search functions in this file, calling it once with many points is generally much faster than calling it once for each point. Using multiple points also allows for a per-quadrant termination of the recursion in addition to a more costly per-point termination.
This function works fine when used for the special cases that either the partition or the local quadrants are not of interest. However, in the case of querying only local information we expect that p4estsearchlocal will be faster since it employs specific local optimizations.
Parameters
p4est
:[in] The forest to be searched.call_post
:[in] If true, call quadrant callback both pre and post.quadrant_fn
:[in] Executed once for each quadrant that is entered. If the callback returns false, this quadrant and its descendants are excluded from the search, and the points in this branch are not queried further. Its point argument is always NULL. Callback may be NULL in which case it is ignored.point_fn
:[in] Executed once for each point that is relevant for a quadrant of the search. If it returns true, the point is tracked further down that branch, else it is discarded from the queries for the children. If points is not NULL, this callback must be not NULL. If points is NULL, it is not called.points
:[in] User-defined array of points. We do not interpret a point, just pass it into the callbacks. If NULL, only the quadrant_fn callback is executed. If that is NULL, the whole function noops. If not NULL, the point_fn is called on its members during the search.
Prototype
void p4est_search_all (p4est_t * p4est, int call_post, p4est_search_all_t quadrant_fn, p4est_search_all_t point_fn, sc_array_t * points);
P4est.LibP4est.p4est_search_local
— Methodp4est_search_local(p4est_, call_post, quadrant_fn, point_fn, points)
Search through the local part of a forest. The search is especially efficient if multiple targets, called "points" below, are searched for simultaneously.
The search runs over all local quadrants and proceeds recursively top-down. For each tree, it may start at the root of that tree, or further down at the root of the subtree that contains all of the tree's local quadrants. Likewise, some intermediate levels in the recursion may be skipped if the processor-local part is contained in a single deeper subtree. The outer loop is thus a depth-first, processor-local forest traversal. Each quadrant in that loop either is a leaf, or a (direct or indirect) strict ancestor of a leaf. On entering a new quadrant, a user-provided quadrant-callback is executed.
As a convenience, the user may provide anonymous "points" that are tracked down the forest. This way one search call may be used for multiple targets. The set of points that potentially matches a given quadrant diminishes from the root down to the leaves: For each quadrant, an inner loop over the potentially matching points executes a point-callback for each candidate that determines whether the point may be a match. If not, it is discarded in the current branch, otherwise it is passed to the next deeper level. The callback is allowed to return true for the same point and more than one quadrant; in this case more than one matching quadrant may be identified. The callback is also allowed to return false for all children of a quadrant that it returned true for earlier. If the point callback returns false for all points relevant to a quadrant, the recursion stops. The points can really be anything, p4est
does not perform any interpretation, just passes the pointer along to the callback function.
If points are present and the first quadrant callback returned true, we execute it a second time after calling the point callback for all current points. This can be used to gather and postprocess information about the points more easily. If it returns false, the recursion stops.
If the points are a NULL array, they are ignored and the recursion proceeds by querying the per-quadrant callback. If the points are not NULL but an empty array, the recursion will stop immediately!
Parameters
p4est
:[in] The forest to be searched.call_post
:[in] If true, call quadrant callback both pre and post.quadrant_fn
:[in] Executed once when a quadrant is entered, and once when it is left (the second time only if points are present and the first call returned true). This quadrant is always local, if not completely then at least one descendant of it. If the callback returns false, this quadrant and its descendants are excluded from the search recursion. Its point argument is always NULL. Callback may be NULL in which case it is ignored.point_fn
:[in] If points is not NULL, must be not NULL. Shall return true for any possible matching point. If points is NULL, this callback is ignored.points
:[in] User-defined array of "points". If NULL, only the quadrant_fn callback is executed. If that is NULL, this function noops. If not NULL, the point_fn is called on its members during the search.
Prototype
void p4est_search_local (p4est_t * p4est, int call_post, p4est_search_local_t quadrant_fn, p4est_search_local_t point_fn, sc_array_t * points);
P4est.LibP4est.p4est_search_partition
— Methodp4est_search_partition(p4est_, call_post, quadrant_fn, point_fn, points)
Traverse the global partition top-down. We proceed top-down through the partition, identically on all processors except for the results of two user-provided callbacks. The recursion will only go down branches that are split between multiple processors. The callback functions can be used to stop a branch recursion even for split branches. This function offers the option to search for arbitrary user-defined points analogously to p4estsearchlocal.
Traversing the whole processor partition will be at least O(P), so sensible use of the callback function is advised to cut it short.
Parameters
p4est
:[in] The forest to traverse. Its local quadrants are never accessed.call_post
:[in] If true, call quadrant callback both pre and post.quadrant_fn
:[in] This function controls the recursion, which only continues deeper if this callback returns true for a branch quadrant. It is allowed to set this to NULL.point_fn
:[in] This function decides per-point whether it is followed down the recursion. Must be non-NULL if points are not NULL.points
:[in] User-provided array of points that are passed to the callback point_fn. See p4estsearchlocal for details.
Prototype
void p4est_search_partition (p4est_t * p4est, int call_post, p4est_search_partition_t quadrant_fn, p4est_search_partition_t point_fn, sc_array_t * points);
P4est.LibP4est.p4est_source_ext
— Methodp4est_source_ext(src, mpicomm, data_size, load_data, autopartition, broadcasthead, user_pointer, connectivity)
Prototype
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);
P4est.LibP4est.p4est_split_array
— Methodp4est_split_array(array, level, indices)
Split an array of quadrants by the children of an ancestor.
Given a sorted array of quadrants that have a common ancestor at level level, compute the indices of the first quadrant in each of the common ancestor's children at level level + 1.
Parameters
array
:[in] The sorted array of quadrants of level > level.level
:[in] The level at which there is a common ancestor.indices
:[in,out] The indices of the first quadrant in each of the ancestors's children, plus an additional index on the end. The quadrants of array that are descendants of child i have indices between indices[i] and indices[i + 1] - 1. If indices[i] = indices[i+1], this indicates that no quadrant in the array is contained in child i.
Prototype
void p4est_split_array (sc_array_t * array, int level, size_t indices[]);
P4est.LibP4est.p4est_version
— Methodp4est_version()
Return the full version of p4est
.
Returns
Return the version of p4est
using the format VERSION\_MAJOR.VERSION\_MINOR.VERSION\_POINT
, where VERSION_POINT
can contain dots and characters, e.g. to indicate the additional number of commits and a git commit hash.
Prototype
const char *p4est_version (void);
P4est.LibP4est.p4est_version_major
— Methodp4est_version_major()
Return the major version of p4est
.
Returns
Return the major version of p4est
.
Prototype
int p4est_version_major (void);
P4est.LibP4est.p4est_version_minor
— Methodp4est_version_minor()
Return the minor version of p4est
.
Returns
Return the minor version of p4est
.
Prototype
int p4est_version_minor (void);
P4est.LibP4est.p6est_balance
— Methodp6est_balance(p6est_, btype, init_fn)
Balance a forest.
Parameters
p6est
:[in] Thep6est
to be worked on.btype
:[in] Balance type (face, corner or default, full).init_fn
:[in] Callback function to initialize the user_data which is already allocated automatically.
Prototype
void p6est_balance (p6est_t * p6est, p8est_connect_type_t btype, p6est_init_t init_fn);
P4est.LibP4est.p6est_balance_ext
— Methodp6est_balance_ext(p6est_, btype, max_diff, min_diff, init_fn, replace_fn)
2:1 balance the size differences of neighboring elements in a forest.
Parameters
p6est
:[in,out] Thep6est
to be worked on.btype
:[in] Balance type (face or corner/full). Corner balance is almost never required when discretizing a PDE; just causes smoother mesh grading.max_diff
:[in] The maximum difference between the horizontal refinement level and the vertical refinement levelmin_diff
:[in] The minimum difference between the horizontal refinement level and the vertical refinement levelinit_fn
:[in] Callback function to initialize the user_data which is already allocated automatically.replace_fn
:[in] Callback function that allows the user to change incoming quadrants based on the quadrants they replace.
Prototype
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);
P4est.LibP4est.p6est_checksum
— Methodp6est_checksum(p6est_)
Compute the checksum for a forest. Based on quadrant arrays only. It is independent of partition and mpisize.
Returns
Returns the checksum on processor 0 only. 0 on other processors.
Prototype
unsigned p6est_checksum (p6est_t * p6est);
P4est.LibP4est.p6est_coarsen_columns
— Methodp6est_coarsen_columns(p6est_, coarsen_recursive, coarsen_fn, init_fn)
Coarsen the columns of a sheet.
Parameters
p6est
:[in,out] The forest is changed in place.coarsen_recursive
:[in] Boolean to decide on recursive coarsening.coarsen_fn
:[in] Callback function that returns true if a family of columns shall be coarsenedinit_fn
:[in] Callback function to initialize the user_data which is already allocated automatically.
Prototype
void p6est_coarsen_columns (p6est_t * p6est, int coarsen_recursive, p6est_coarsen_column_t coarsen_fn, p6est_init_t init_fn);
P4est.LibP4est.p6est_coarsen_columns_ext
— Methodp6est_coarsen_columns_ext(p6est_, coarsen_recursive, callback_orphans, coarsen_fn, init_fn, replace_fn)
Horizontally coarsen a forest.
Parameters
p6est
:[in,out] The forest is changed in place.coarsen_recursive
:[in] Boolean to decide on recursive coarsening.callback_orphans
:[in] 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.coarsen_fn
:[in] Callback function that returns true if a family of quadrants shall be coarsened.init_fn
:[in] Callback function to initialize the user_data which is already allocated automatically.replace_fn
:[in] Callback function that allows the user to change incoming quadrants based on the quadrants they replace.
Prototype
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);
P4est.LibP4est.p6est_coarsen_layers
— Methodp6est_coarsen_layers(p6est_, coarsen_recursive, coarsen_fn, init_fn)
Coarsen the layers of a sheet.
Parameters
p6est
:[in,out] The forest is changed in place.coarsen_recursive
:[in] Boolean to decide on recursive coarsening.coarsen_fn
:[in] Callback function that returns true if a family of layers shall be coarsenedinit_fn
:[in] Callback function to initialize the user_data which is already allocated automatically.
Prototype
void p6est_coarsen_layers (p6est_t * p6est, int coarsen_recursive, p6est_coarsen_layer_t coarsen_fn, p6est_init_t init_fn);
P4est.LibP4est.p6est_coarsen_layers_ext
— Methodp6est_coarsen_layers_ext(p6est_, coarsen_recursive, callback_orphans, coarsen_fn, init_fn, replace_fn)
Vertically coarsen a forest.
Parameters
p6est
:[in,out] The forest is changed in place.coarsen_recursive
:[in] Boolean to decide on recursive coarsening.callback_orphans
:[in] 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.coarsen_fn
:[in] Callback function that returns true if a family of quadrants shall be coarsened.init_fn
:[in] Callback function to initialize the user_data which is already allocated automatically.replace_fn
:[in] Callback function that allows the user to change incoming quadrants based on the quadrants they replace.
Prototype
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);
P4est.LibP4est.p6est_compress_columns
— Methodp6est_compress_columns(p6est_)
Prototype
void p6est_compress_columns (p6est_t * p6est);
P4est.LibP4est.p6est_connectivity_destroy
— Methodp6est_connectivity_destroy(conn)
Destroy a p6est_connectivity
structure
Prototype
void p6est_connectivity_destroy (p6est_connectivity_t * conn);
P4est.LibP4est.p6est_connectivity_new
— Methodp6est_connectivity_new(conn4, top_vertices, height)
Create a p6est_connectivity_t
from a p4est_connectivity_t
. All fields are copied, so all inputs can be safey destroyed.
Parameters
conn4
:[in] the 2D connectivitytop_vertices
:[in] if NULL, then the sheet has a uniform vertical profile; otherwise, top_vertices gives teh vertices of the top of the sheet; should be the same size as conn4->treetovertexheight
:[in] if top_vertices == NULL, then this gives the offset fro the bottom of the sheet to the top.
Returns
the 2D+1D connectivity information.
Prototype
p6est_connectivity_t *p6est_connectivity_new (p4est_connectivity_t * conn4, double *top_vertices, double height[3]);
P4est.LibP4est.p6est_copy
— Methodp6est_copy(input, copy_data)
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.
Parameters
copy_data
:[in] If true, data are copied. If false, data_size is set to 0.
Returns
Returns a valid p6est
that does not depend on the input.
Prototype
p6est_t *p6est_copy (p6est_t * input, int copy_data);
P4est.LibP4est.p6est_copy_ext
— Methodp6est_copy_ext(input, copy_data, 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
copy_data
:[in] If true, data are copied. If false, data_size is set to 0.duplicate_mpicomm
:[in] If true, MPI communicator is copied.
Returns
Returns a valid p6est
that does not depend on the input.
Prototype
p6est_t *p6est_copy_ext (p6est_t * input, int copy_data, int duplicate_mpicomm);
P4est.LibP4est.p6est_destroy
— Methodp6est_destroy(p6est_)
Destroy a p6est
.
The connectivity structure is not destroyed with the p6est
.
Prototype
void p6est_destroy (p6est_t * p6est);
P4est.LibP4est.p6est_load
— Methodp6est_load(filename, mpicomm, data_size, load_data, user_pointer, connectivity)
Prototype
p6est_t *p6est_load (const char *filename, sc_MPI_Comm mpicomm, size_t data_size, int load_data, void *user_pointer, p6est_connectivity_t ** connectivity);
P4est.LibP4est.p6est_load_ext
— Methodp6est_load_ext(filename, mpicomm, data_size, load_data, autopartition, broadcasthead, user_pointer, connectivity)
Prototype
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);
P4est.LibP4est.p6est_new
— Methodp6est_new(mpicomm, connectivity, data_size, init_fn, user_pointer)
Prototype
p6est_t *p6est_new (sc_MPI_Comm mpicomm, p6est_connectivity_t * connectivity, size_t data_size, p6est_init_t init_fn, void *user_pointer);
P4est.LibP4est.p6est_new_ext
— Methodp6est_new_ext(mpicomm, connectivity, min_quadrants, min_level, min_zlevel, num_zroot, fill_uniform, data_size, init_fn, user_pointer)
Prototype
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);
P4est.LibP4est.p6est_new_from_p4est
— Methodp6est_new_from_p4est(p4est_, top_vertices, height, min_zlevel, data_size, init_fn, user_pointer)
Create a new forest from an already created p4est
that represents columns.
Parameters
p4est
:[in] A validp4est
. A deep copy will be created, so this can be destroyed without affectin the newp6est
object.top_vertices
:[in] the same as in p6est_conectivity_new()height
:[in] the same as in p6est_conectivity_new()min_zlevel
:[in] the same as inp6est_new
()data_size
:[in] the same as inp6est_new
()init_fn
:[in] the same as inp6est_new
()user_pointer
:[in] the same as inp6est_new
()
Returns
This returns a valid forest. The user must destroy the connectivity for the new p6est
independently.
Prototype
p6est_t *p6est_new_from_p4est (p4est_t * p4est, double *top_vertices, double height[3], int min_zlevel, size_t data_size, p6est_init_t init_fn, void *user_pointer);
P4est.LibP4est.p6est_partition
— Methodp6est_partition(p6est_, weight_fn)
Equally partition the forest.
The forest will be partitioned between processors where they each have an approximately equal number of quadrants.
Note that p6est
->layers and p6est
->globalfirstlayers may change during this call. Address pointers referencing these objects from before p6est_partition
is called become invalid.
Parameters
p6est
:[in,out] The forest that will be partitioned.weight_fn
:[in] A weighting function or NULL for uniform partitioning.
Prototype
p4est_gloidx_t p6est_partition (p6est_t * p6est, p6est_weight_t weight_fn);
P4est.LibP4est.p6est_partition_correct
— Methodp6est_partition_correct(p6est_, num_layers_in_proc)
Prototype
void p6est_partition_correct (p6est_t * p6est, p4est_locidx_t * num_layers_in_proc);
P4est.LibP4est.p6est_partition_ext
— Methodp6est_partition_ext(p6est_, partition_for_coarsening, 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
p6est
:[in,out] The forest that will be partitioned.partition_for_coarsening
:[in] If true, the partition is modified to allow one level of coarsening.weight_fn
:[in] A weighting function or NULL for uniform partitioning.
Returns
The global number of shipped quadrants
Prototype
p4est_gloidx_t p6est_partition_ext (p6est_t * p6est, int partition_for_coarsening, p6est_weight_t weight_fn);
P4est.LibP4est.p6est_partition_for_coarsening
— Methodp6est_partition_for_coarsening(p6est_, num_layers_in_proc)
Prototype
p4est_gloidx_t p6est_partition_for_coarsening (p6est_t * p6est, p4est_locidx_t * num_layers_in_proc);
P4est.LibP4est.p6est_partition_given
— Methodp6est_partition_given(p6est_, num_layers_in_proc)
Prototype
p4est_gloidx_t p6est_partition_given (p6est_t * p6est, p4est_locidx_t * num_layers_in_proc);
P4est.LibP4est.p6est_partition_to_p4est_partition
— Methodp6est_partition_to_p4est_partition(p6est_, num_layers_in_proc, num_columns_in_proc)
Prototype
void p6est_partition_to_p4est_partition (p6est_t * p6est, p4est_locidx_t * num_layers_in_proc, p4est_locidx_t * num_columns_in_proc);
P4est.LibP4est.p6est_qcoord_to_vertex
— Methodp6est_qcoord_to_vertex(connectivity, treeid, x, y, z, vxyz)
Transform a quadrant coordinate into the space spanned by tree vertices.
Parameters
connectivity
:[in] Connectivity must provide the vertices.treeid
:[in] Identify the tree that contains x, y.x,
:[in] y Quadrant coordinates relative to treeid.vxy
:[out] Transformed coordinates in vertex space.
Prototype
void p6est_qcoord_to_vertex (p6est_connectivity_t * connectivity, p4est_topidx_t treeid, p4est_qcoord_t x, p4est_qcoord_t y, p4est_qcoord_t z, double vxyz[3]);
P4est.LibP4est.p6est_refine_columns
— Methodp6est_refine_columns(p6est_, refine_recursive, refine_fn, init_fn)
Refine the columns of a sheet.
Parameters
p6est
:[in,out] The forest is changed in place.refine_recursive
:[in] Boolean to decide on recursive refinement.refine_fn
:[in] Callback function that must return true if a column shall be refined into smaller columns. If refine_recursive is true, refine_fn is called for every existing and newly created column. Otherwise, it is called for every existing column. 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 usep6est_refine_columns_ext
in p6est_extended.h and examine whether replace_fn gets called.init_fn
:[in] Callback function to initialize the user_data of newly created layers within columns, which are already allocated. This function pointer may be NULL.
Prototype
void p6est_refine_columns (p6est_t * p6est, int refine_recursive, p6est_refine_column_t refine_fn, p6est_init_t init_fn);
P4est.LibP4est.p6est_refine_columns_ext
— Methodp6est_refine_columns_ext(p6est_, refine_recursive, maxlevel, refine_fn, init_fn, replace_fn)
Horizontally refine a forest with a bounded refinement level and a replace option.
Parameters
p6est
:[in,out] The forest is changed in place.refine_recursive
:[in] Boolean to decide on recursive refinement.maxlevel
:[in] Maximum allowed refinement level (inclusive). If this is negative the level is restricted only by the compile-time constant QMAXLEVEL inp4est.h
.refine_fn
:[in] 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.init_fn
:[in] Callback function to initialize the user_data for newly created quadrants, which is guaranteed to be allocated. This function pointer may be NULL.replace_fn
:[in] Callback function that allows the user to change incoming quadrants based on the quadrants they replace; may be NULL.
Prototype
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);
P4est.LibP4est.p6est_refine_layers
— Methodp6est_refine_layers(p6est_, refine_recursive, refine_fn, init_fn)
Refine the layers within the columns of a sheet.
Parameters
p6est
:[in,out] The forest is changed in place.refine_recursive
:[in] Boolean to decide on recursive refinement.refine_fn
:[in] Callback function that must return true if a layer shall be refined into smaller layers. If refine_recursive is true, refine_fn is called for every existing and newly created layer. Otherwise, it is called for every existing layer. 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 usep6est_refine_layers_ext
in p6est_extended.h and examine whether replace_fn gets called.init_fn
:[in] Callback function to initialize the user_data of newly created layers, which are already allocated. This function pointer may be NULL.
Prototype
void p6est_refine_layers (p6est_t * p6est, int refine_recursive, p6est_refine_layer_t refine_fn, p6est_init_t init_fn);
P4est.LibP4est.p6est_refine_layers_ext
— Methodp6est_refine_layers_ext(p6est_, refine_recursive, maxlevel, refine_fn, init_fn, replace_fn)
Vertically refine a forest with a bounded refinement level and a replace option.
Parameters
p6est
:[in,out] The forest is changed in place.refine_recursive
:[in] Boolean to decide on recursive refinement.maxlevel
:[in] Maximum allowed refinement level (inclusive). If this is negative the level is restricted only by the compile-time constant QMAXLEVEL inp4est.h
.refine_fn
:[in] 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.init_fn
:[in] Callback function to initialize the user_data for newly created quadrants, which is guaranteed to be allocated. This function pointer may be NULL.replace_fn
:[in] Callback function that allows the user to change incoming quadrants based on the quadrants they replace; may be NULL.
Prototype
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);
P4est.LibP4est.p6est_reset_data
— Methodp6est_reset_data(p6est_, data_size, init_fn, 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.
Parameters
data_size
:[in] This is the size of data for each quadrant which can be zero. Then user_data_pool is set to NULL.init_fn
:[in] Callback function to initialize the user_data which is already allocated automatically.user_pointer
:[in] Assign to the user_pointer member of thep6est
before init_fn is called the first time.
Prototype
void p6est_reset_data (p6est_t * p6est, size_t data_size, p6est_init_t init_fn, void *user_pointer);
P4est.LibP4est.p6est_save
— Methodp6est_save(filename, p6est_, save_data)
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.
Aborts on file errors.
Parameters
filename
:[in] Name of the file to write.p6est
:[in] Valid forest structure.save_data
:[in] If true, the element data is saved. Otherwise, a data size of 0 is saved.
Prototype
void p6est_save (const char *filename, p6est_t * p6est, int save_data);
P4est.LibP4est.p6est_save_ext
— Methodp6est_save_ext(filename, p6est_, save_data, 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.
Aborts on file errors.
Parameters
filename
:[in] Name of the file to write.p6est
:[in] Valid forest structure.save_data
:[in] If true, the element data is saved. Otherwise, a data size of 0 is saved.save_partition
:[in] 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.
Prototype
void p6est_save_ext (const char *filename, p6est_t * p6est, int save_data, int save_partition);
P4est.LibP4est.p6est_tree_get_vertices
— Methodp6est_tree_get_vertices(conn, which_tree, vertices)
Get the vertices of the corners of a tree.
Parameters
conn
:[in] the 2D+1D connectivity structurewhich_tree
:[in] a tree in the forestvertices
:[out] the coordinates of the corners of the tree
Prototype
void p6est_tree_get_vertices (p6est_connectivity_t * conn, p4est_topidx_t which_tree, double vertices[24]);
P4est.LibP4est.p6est_update_offsets
— Methodp6est_update_offsets(p6est_)
Prototype
void p6est_update_offsets (p6est_t * p6est);
P4est.LibP4est.p8est_balance
— Methodp8est_balance(p8est_, btype, init_fn)
2:1 balance the size differences of neighboring elements in a forest.
Parameters
p8est
:[in,out] Thep8est
to be worked on.btype
:[in] Balance type (face, edge, or corner/full). Examples: Finite volume or discontinuous 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.init_fn
:[in] Callback function to initialize the user_data which is already allocated automatically.
Prototype
void p8est_balance (p8est_t * p8est, p8est_connect_type_t btype, p8est_init_t init_fn);
P4est.LibP4est.p8est_balance_ext
— Methodp8est_balance_ext(p8est_, btype, init_fn, replace_fn)
2:1 balance the size differences of neighboring elements in a forest.
Parameters
p8est
:[in,out] Thep8est
to be worked on.btype
:[in] Balance type (face, edge, or corner/full). Corner balance is almost never required when discretizing a PDE; just causes smoother mesh grading.init_fn
:[in] Callback function to initialize the user_data which is already allocated automatically.replace_fn
:[in] Callback function that allows the user to change incoming quadrants based on the quadrants they replace.
Prototype
void p8est_balance_ext (p8est_t * p8est, p8est_connect_type_t btype, p8est_init_t init_fn, p8est_replace_t replace_fn);
P4est.LibP4est.p8est_balance_subtree_ext
— Methodp8est_balance_subtree_ext(p8est_, btype, which_tree, init_fn, replace_fn)
Prototype
void p8est_balance_subtree_ext (p8est_t * p8est, p8est_connect_type_t btype, p4est_topidx_t which_tree, p8est_init_t init_fn, p8est_replace_t replace_fn);
P4est.LibP4est.p8est_checksum
— Methodp8est_checksum(p8est_)
Compute the checksum for a forest. Based on quadrant arrays only. It is independent of partition and mpisize.
Returns
Returns the checksum on processor 0 only. 0 on other processors.
Prototype
unsigned p8est_checksum (p8est_t * p8est);
P4est.LibP4est.p8est_checksum_partition
— Methodp8est_checksum_partition(p8est_)
Compute a partition-dependent checksum for a forest.
Returns
Returns the checksum on processor 0 only. 0 on other processors.
Prototype
unsigned p8est_checksum_partition (p8est_t * p8est);
P4est.LibP4est.p8est_coarsen
— Methodp8est_coarsen(p8est_, coarsen_recursive, coarsen_fn, init_fn)
Coarsen a forest.
Parameters
p8est
:[in,out] The forest is changed in place.coarsen_recursive
:[in] Boolean to decide on recursive coarsening.coarsen_fn
:[in] Callback function that returns true if a family of quadrants shall be coarsenedinit_fn
:[in] Callback function to initialize the user_data which is already allocated automatically.
Prototype
void p8est_coarsen (p8est_t * p8est, int coarsen_recursive, p8est_coarsen_t coarsen_fn, p8est_init_t init_fn);
P4est.LibP4est.p8est_coarsen_ext
— Methodp8est_coarsen_ext(p8est_, coarsen_recursive, callback_orphans, coarsen_fn, init_fn, replace_fn)
Coarsen a forest.
Parameters
p8est
:[in,out] The forest is changed in place.coarsen_recursive
:[in] Boolean to decide on recursive coarsening.callback_orphans
:[in] 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. With coarsen_recursive false and callback_orphans true, it is guaranteed that every quadrant is passed exactly once into the coarsen_fn callback.coarsen_fn
:[in] Callback function that returns true if a family of quadrants shall be coarsened.init_fn
:[in] Callback function to initialize the user_data which is already allocated automatically.replace_fn
:[in] Callback function that allows the user to change incoming quadrants based on the quadrants they replace.
Prototype
void p8est_coarsen_ext (p8est_t * p8est, int coarsen_recursive, int callback_orphans, p8est_coarsen_t coarsen_fn, p8est_init_t init_fn, p8est_replace_t replace_fn);
P4est.LibP4est.p8est_connect_type_int
— Methodp8est_connect_type_int(btype)
Convert the p8est_connect_type_t
into a number.
Parameters
btype
:[in] The balance type to convert.
Returns
Returns 1, 2 or 3.
Prototype
int p8est_connect_type_int (p8est_connect_type_t btype);
P4est.LibP4est.p8est_connect_type_string
— Methodp8est_connect_type_string(btype)
Convert the p8est_connect_type_t
into a const string.
Parameters
btype
:[in] The balance type to convert.
Returns
Returns a pointer to a constant string.
Prototype
const char *p8est_connect_type_string (p8est_connect_type_t btype);
P4est.LibP4est.p8est_connectivity_bcast
— Methodp8est_connectivity_bcast(conn_in, root, comm)
Prototype
p8est_connectivity_t *p8est_connectivity_bcast (p8est_connectivity_t * conn_in, int root, sc_MPI_Comm comm);
P4est.LibP4est.p8est_connectivity_complete
— Methodp8est_connectivity_complete(conn)
Internally connect a connectivity based on tree_to_vertex information. Periodicity that is not inherent in the list of vertices will be lost.
Parameters
conn
:[in,out] The connectivity needs to have proper vertices and tree_to_vertex fields. The tree_to_tree and tree_to_face fields must be allocated and satisfyp8est_connectivity_is_valid
(conn) but will be overwritten. The edge and corner fields will be freed and allocated anew.
Prototype
void p8est_connectivity_complete (p8est_connectivity_t * conn);
P4est.LibP4est.p8est_connectivity_deflate
— Methodp8est_connectivity_deflate(conn, code)
Allocate memory and store the connectivity information there.
Parameters
conn
:[in] The connectivity structure to be exported to memory.code
:[in] Encoding and compression method for serialization.
Returns
Newly created array that contains the information.
Prototype
sc_array_t *p8est_connectivity_deflate (p8est_connectivity_t * conn, p8est_connectivity_encode_t code);
P4est.LibP4est.p8est_connectivity_destroy
— Methodp8est_connectivity_destroy(connectivity)
Destroy a connectivity structure. Also destroy all attributes.
Prototype
void p8est_connectivity_destroy (p8est_connectivity_t * connectivity);
P4est.LibP4est.p8est_connectivity_edge_neighbor_corner
— Methodp8est_connectivity_edge_neighbor_corner(c, e, ne, o)
Transform a corner across one of the adjacent edges into a neighbor tree. This version expects the neighbor edge and orientation separately.
Parameters
c
:[in] A corner number in 0..7.e
:[in] An edge 0..11 that touches the corner c.ne
:[in] A neighbor edge that is on the other side of .o
:[in] The orientation between tree boundary edges e and .
Returns
Corner number seen from the neighbor.
Prototype
int p8est_connectivity_edge_neighbor_corner (int c, int e, int ne, int o);
P4est.LibP4est.p8est_connectivity_edge_neighbor_edge_corner
— Methodp8est_connectivity_edge_neighbor_edge_corner(ec, o)
Transform an edge corner across one of the adjacent edges into a neighbor tree.
Parameters
ec
:[in] An edge corner number in 0..1.o
:[in] The orientation of a tree boundary edge connection.
Returns
The edge corner number seen from the other tree.
Prototype
int p8est_connectivity_edge_neighbor_edge_corner (int ec, int o);
P4est.LibP4est.p8est_connectivity_face_neighbor_corner
— Methodp8est_connectivity_face_neighbor_corner(c, f, nf, o)
Transform a corner across one of the adjacent faces into a neighbor tree. This version expects the neighbor face and orientation separately.
.
Parameters
c
:[in] A corner number in 0..7.f
:[in] A face number that touches the corner c.nf
:[in] A neighbor face that is on the other side of .o
:[in] The orientation between tree boundary faces f and
Returns
The number of the corner seen from the neighbor tree.
Prototype
int p8est_connectivity_face_neighbor_corner (int c, int f, int nf, int o);
P4est.LibP4est.p8est_connectivity_face_neighbor_corner_set
— Methodp8est_connectivity_face_neighbor_corner_set(c, f, nf, set)
Transform a corner across one of the adjacent faces into a neighbor tree. It expects a face permutation index that has been precomputed.
Parameters
c
:[in] A corner number in 0..7.f
:[in] A face number that touches the corner c.nf
:[in] A neighbor face that is on the other side of .set
:[in] A value from p8estfacepermutation_sets that is obtained using f, nf, and a valid orientation: ref = p8est_face_permutation_refs[f][nf]; set = p8est_face_permutation_sets[ref][orientation];
Returns
The corner number in 0..7 seen from the other face.
Prototype
int p8est_connectivity_face_neighbor_corner_set (int c, int f, int nf, int set);
P4est.LibP4est.p8est_connectivity_face_neighbor_edge
— Methodp8est_connectivity_face_neighbor_edge(e, f, nf, o)
Transform an edge across one of the adjacent faces into a neighbor tree. This version expects the neighbor face and orientation separately.
.
Parameters
e
:[in] A edge number in 0..11.f
:[in] A face 0..5 that touches the edge e.nf
:[in] A neighbor face that is on the other side of .o
:[in] The orientation between tree boundary faces f and
Returns
The edge's number seen from the neighbor.
Prototype
int p8est_connectivity_face_neighbor_edge (int e, int f, int nf, int o);
P4est.LibP4est.p8est_connectivity_face_neighbor_face_corner
— Methodp8est_connectivity_face_neighbor_face_corner(fc, f, nf, o)
Transform a face corner across one of the adjacent faces into a neighbor tree. This version expects the neighbor face and orientation separately.
.
Parameters
fc
:[in] A face corner number in 0..3.f
:[in] A face that the face corner fc is relative to.nf
:[in] A neighbor face that is on the other side of .o
:[in] The orientation between tree boundary faces f and
Returns
The face corner number relative to the neighbor's face.
Prototype
int p8est_connectivity_face_neighbor_face_corner (int fc, int f, int nf, int o);
P4est.LibP4est.p8est_connectivity_face_neighbor_face_edge
— Methodp8est_connectivity_face_neighbor_face_edge(fe, f, nf, o)
Transform a face-edge across one of the adjacent faces into a neighbor tree. This version expects the neighbor face and orientation separately.
.
Parameters
fe
:[in] A face edge number in 0..3.f
:[in] A face number that touches the edge e.nf
:[in] A neighbor face that is on the other side of .o
:[in] The orientation between tree boundary faces f and
Returns
The face edge number seen from the neighbor tree.
Prototype
int p8est_connectivity_face_neighbor_face_edge (int fe, int f, int nf, int o);
P4est.LibP4est.p8est_connectivity_inflate
— Methodp8est_connectivity_inflate(buffer)
Create new connectivity from a memory buffer.
Parameters
buffer
:[in] The connectivity is created from this memory buffer.
Returns
The newly created connectivity, or NULL on error.
Prototype
p8est_connectivity_t *p8est_connectivity_inflate (sc_array_t * buffer);
P4est.LibP4est.p8est_connectivity_is_equal
— Methodp8est_connectivity_is_equal(conn1, conn2)
Check two connectivity structures for equality.
Returns
Returns true if structures are equal, false otherwise.
Prototype
int p8est_connectivity_is_equal (p8est_connectivity_t * conn1, p8est_connectivity_t * conn2);
P4est.LibP4est.p8est_connectivity_is_equivalent
— Methodp8est_connectivity_is_equivalent(conn1, conn2)
p8est_connectivity_is_equivalent
This function compares two connectivities for equivalence: it returns true if they are the same connectivity, or if they have the same topology. The definition of topological sameness is strict: there is no attempt made to determine whether permutation and/or rotation of the trees makes the connectivities equivalent.
Parameters
conn1
:[in] a valid connectivityconn2
:[out] a valid connectivity
Prototype
int p8est_connectivity_is_equivalent (p8est_connectivity_t * conn1, p8est_connectivity_t * conn2);
P4est.LibP4est.p8est_connectivity_is_valid
— Methodp8est_connectivity_is_valid(connectivity)
Examine a connectivity structure.
Returns
Returns true if structure is valid, false otherwise.
Prototype
int p8est_connectivity_is_valid (p8est_connectivity_t * connectivity);
P4est.LibP4est.p8est_connectivity_join_faces
— Methodp8est_connectivity_join_faces(conn, tree_left, tree_right, face_left, face_right, orientation)
p8est_connectivity_join_faces
This function takes an existing valid connectivity conn and modifies it by joining two tree faces that are currently boundary faces.
Parameters
conn
:[in,out] connectivity that will be altered.tree_left
:[in] tree that will be on the left side of the joined faces.tree_right
:[in] tree that will be on the right side of the joined faces.face_left
:[in] face of tree_left that will be joined.face_right
:[in] face of tree_right that will be joined.orientation
:[in] the orientation of face_left and face_right once joined (see the description ofp8est_connectivity_t
to understand orientation).
Prototype
void p8est_connectivity_join_faces (p8est_connectivity_t * conn, p4est_topidx_t tree_left, p4est_topidx_t tree_right, int face_left, int face_right, int orientation);
P4est.LibP4est.p8est_connectivity_load
— Methodp8est_connectivity_load(filename, bytes)
Load a connectivity structure from disk.
Parameters
filename
:[in] Name of the file to read.bytes
:[out] Size in bytes of connectivity on disk or NULL.
Returns
Returns valid connectivity, or NULL on file error.
Prototype
p8est_connectivity_t *p8est_connectivity_load (const char *filename, size_t *bytes);
P4est.LibP4est.p8est_connectivity_memory_used
— Methodp8est_connectivity_memory_used(conn)
Calculate memory usage of a connectivity structure.
Parameters
conn
:[in] Connectivity structure.
Returns
Memory used in bytes.
Prototype
size_t p8est_connectivity_memory_used (p8est_connectivity_t * conn);
P4est.LibP4est.p8est_connectivity_new
— Methodp8est_connectivity_new(num_vertices, num_trees, num_edges, num_ett, num_corners, num_ctt)
Allocate a connectivity structure. The attribute fields are initialized to NULL.
Parameters
num_vertices
:[in] Number of total vertices (i.e. geometric points).num_trees
:[in] Number of trees in the forest.num_edges
:[in] Number of tree-connecting edges.num_ett
:[in] Number of total trees in edge_to_tree array.num_corners
:[in] Number of tree-connecting corners.num_ctt
:[in] Number of total trees in corner_to_tree array.
Returns
A connectivity structure with allocated arrays.
Prototype
p8est_connectivity_t *p8est_connectivity_new (p4est_topidx_t num_vertices, p4est_topidx_t num_trees, p4est_topidx_t num_edges, p4est_topidx_t num_ett, p4est_topidx_t num_corners, p4est_topidx_t num_ctt);
P4est.LibP4est.p8est_connectivity_new_brick
— Methodp8est_connectivity_new_brick(m, n, p, periodic_a, periodic_b, periodic_c)
An m by n by p array with periodicity in x, y, and z if periodic_a, periodic_b, and periodic_c are true, respectively.
Prototype
p8est_connectivity_t *p8est_connectivity_new_brick (int m, int n, int p, int periodic_a, int periodic_b, int periodic_c);
P4est.LibP4est.p8est_connectivity_new_byname
— Methodp8est_connectivity_new_byname(name)
Create connectivity structure from predefined catalogue.
Parameters
name
:[in] Invokes connectivity_new_* function. brick235 brick (2, 3, 5, 0, 0, 0) periodic periodic rotcubes rotcubes rotwrap rotwrap shell shell sphere sphere twocubes twocubes twowrap twowrap unit unitcube
Returns
An initialized connectivity if name is defined, NULL else.
Prototype
p8est_connectivity_t *p8est_connectivity_new_byname (const char *name);
P4est.LibP4est.p8est_connectivity_new_copy
— Methodp8est_connectivity_new_copy(num_vertices, num_trees, num_edges, num_corners, vertices, ttv, ttt, ttf, tte, eoff, ett, ete, ttc, coff, ctt, ctc)
Allocate a connectivity structure and populate from constants. The attribute fields are initialized to NULL.
Parameters
num_vertices
:[in] Number of total vertices (i.e. geometric points).num_trees
:[in] Number of trees in the forest.num_edges
:[in] Number of tree-connecting edges.num_corners
:[in] Number of tree-connecting corners.eoff
:[in] Edge-to-tree offsets (num_edges + 1 values). This must always be non-NULL; in trivial cases it is just a pointer to a p4est_topix value of 0.coff
:[in] Corner-to-tree offsets (num_corners + 1 values). This must always be non-NULL; in trivial cases it is just a pointer to a p4est_topix value of 0.
Returns
The connectivity is checked for validity.
Prototype
p8est_connectivity_t *p8est_connectivity_new_copy (p4est_topidx_t num_vertices, p4est_topidx_t num_trees, p4est_topidx_t num_edges, p4est_topidx_t num_corners, const double *vertices, const p4est_topidx_t * ttv, const p4est_topidx_t * ttt, const int8_t * ttf, const p4est_topidx_t * tte, const p4est_topidx_t * eoff, const p4est_topidx_t * ett, const int8_t * ete, const p4est_topidx_t * ttc, const p4est_topidx_t * coff, const p4est_topidx_t * ctt, const int8_t * ctc);
P4est.LibP4est.p8est_connectivity_new_periodic
— Methodp8est_connectivity_new_periodic()
Create a connectivity structure for an all-periodic unit cube.
Prototype
p8est_connectivity_t *p8est_connectivity_new_periodic (void);
P4est.LibP4est.p8est_connectivity_new_rotcubes
— Methodp8est_connectivity_new_rotcubes()
Create a connectivity structure that contains a few cubes. These are rotated against each other to stress the topology routines.
Prototype
p8est_connectivity_t *p8est_connectivity_new_rotcubes (void);
P4est.LibP4est.p8est_connectivity_new_rotwrap
— Methodp8est_connectivity_new_rotwrap()
Create a connectivity structure for a mostly periodic unit cube. The left and right faces are identified, and bottom and top rotated. Front and back are not identified.
Prototype
p8est_connectivity_t *p8est_connectivity_new_rotwrap (void);
P4est.LibP4est.p8est_connectivity_new_shell
— Methodp8est_connectivity_new_shell()
Create a connectivity structure that builds a spherical shell. It is made up of six connected parts [-1,1]x[-1,1]x[1,2]. This connectivity reuses vertices and relies on a geometry transformation. It is thus not suitable for p8est_connectivity_complete
.
Prototype
p8est_connectivity_t *p8est_connectivity_new_shell (void);
P4est.LibP4est.p8est_connectivity_new_sphere
— Methodp8est_connectivity_new_sphere()
Create a connectivity structure that builds a solid sphere. It is made up of two layers and a cube in the center. This connectivity reuses vertices and relies on a geometry transformation. It is thus not suitable for p8est_connectivity_complete
.
Prototype
p8est_connectivity_t *p8est_connectivity_new_sphere (void);
P4est.LibP4est.p8est_connectivity_new_torus
— Methodp8est_connectivity_new_torus(nSegments)
Create a connectivity structure that builds a revolution torus.
This connectivity reuses vertices and relies on a geometry transformation. It is thus not suitable for p8est_connectivity_complete
.
This connectivity reuses ideas from disk2d connectivity. More precisely the torus is divided into segments arround the revolution axis, each segments is made of 5 trees (à la disk2d). The total number of trees if 5 times the number of segments.
This connectivity is meant to be used with p8estgeometrynew_torus
Parameters
nSegments
:[in] number of trees along the great circle
Prototype
p8est_connectivity_t *p8est_connectivity_new_torus (int nSegments);
P4est.LibP4est.p8est_connectivity_new_twocubes
— Methodp8est_connectivity_new_twocubes()
Create a connectivity structure that contains two cubes.
Prototype
p8est_connectivity_t *p8est_connectivity_new_twocubes (void);
P4est.LibP4est.p8est_connectivity_new_twotrees
— Methodp8est_connectivity_new_twotrees(l_face, r_face, orientation)
Create a connectivity structure for two trees being rotated w.r.t. each other in a user-defined way.
Parameters
l_face
:[in] index of left facer_face
:[in] index of right faceorientation
:[in] orientation of trees w.r.t. each other
Prototype
p8est_connectivity_t *p8est_connectivity_new_twotrees (int l_face, int r_face, int orientation);
P4est.LibP4est.p8est_connectivity_new_twowrap
— Methodp8est_connectivity_new_twowrap()
Create a connectivity structure that contains two cubes where the two far ends are identified periodically.
Prototype
p8est_connectivity_t *p8est_connectivity_new_twowrap (void);
P4est.LibP4est.p8est_connectivity_new_unitcube
— Methodp8est_connectivity_new_unitcube()
Create a connectivity structure for the unit cube.
Prototype
p8est_connectivity_t *p8est_connectivity_new_unitcube (void);
P4est.LibP4est.p8est_connectivity_permute
— Methodp8est_connectivity_permute(conn, perm, is_current_to_new)
p8est_connectivity_permute
Given a permutation perm of the trees in a connectivity conn, permute the trees of conn in place and update conn to match.
Parameters
conn
:[in,out] The connectivity whose trees are permuted.perm
:[in] A permutation array, whose elements are size_t's.is_current_to_new
:[in] if true, the jth entry of perm is the new index for the entry whose current index is j, otherwise the jth entry of perm is the current index of the tree whose index will be j after the permutation.
Prototype
void p8est_connectivity_permute (p8est_connectivity_t * conn, sc_array_t * perm, int is_current_to_new);
P4est.LibP4est.p8est_connectivity_read_inp
— Methodp8est_connectivity_read_inp(filename)
Create a p4est
connectivity from an ABAQUS input file.
This utility function reads a basic ABAQUS file supporting element type with the prefix C2D4, CPS4, and S4 in 2D and of type C3D8 reading them as bilinear quadrilateral and trilinear hexahedral trees respectively.
A basic 2D mesh is given below. The *Node
section gives the vertex number and x, y, and z components for each vertex. The *Element
section gives the 4 vertices in 2D (8 vertices in 3D) of each element in counter clockwise order. So in 2D the nodes are given as:
4 3 +–––––––––-+ | | | | | | | | | | | | +–––––––––-+ 1 2
and in 3D they are given as:
8 7 +––––––––––-+ |\ |\ | \ | \ | \ | \ | \ | \ | 5+––––––––––-+6 | | | | +––|––––––––+ | 4\ | 3 \ | \ | \ | \ | \ | \| \| +––––––––––-+ 1 2
*Heading
box.inp
*Node
1, 5, -5, 5
2, 5, 5, 5
3, 5, 0, 5
4, -5, 5, 5
5, 0, 5, 5
6, -5, -5, 5
7, -5, 0, 5
8, 0, -5, 5
9, 0, 0, 5
10, 5, 5, -5
11, 5, -5, -5
12, 5, 0, -5
13, -5, -5, -5
14, 0, -5, -5
15, -5, 5, -5
16, -5, 0, -5
17, 0, 5, -5
18, 0, 0, -5
19, -5, -5, 0
20, 5, -5, 0
21, 0, -5, 0
22, -5, 5, 0
23, -5, 0, 0
24, 5, 5, 0
25, 0, 5, 0
26, 5, 0, 0
27, 0, 0, 0
*Element, type=C3D8, ELSET=EB1
1, 6, 19, 23, 7, 8, 21, 27, 9
2, 19, 13, 16, 23, 21, 14, 18, 27
3, 7, 23, 22, 4, 9, 27, 25, 5
4, 23, 16, 15, 22, 27, 18, 17, 25
5, 8, 21, 27, 9, 1, 20, 26, 3
6, 21, 14, 18, 27, 20, 11, 12, 26
7, 9, 27, 25, 5, 3, 26, 24, 2
8, 27, 18, 17, 25, 26, 12, 10, 24
This function reads a mesh from filename and returns an associated p4est
connectivity.
Parameters
filename
:[in] file to read the connectivity from
Returns
an allocated connectivity associated with the mesh in filename
Prototype
p8est_connectivity_t *p8est_connectivity_read_inp (const char *filename);
P4est.LibP4est.p8est_connectivity_read_inp_stream
— Methodp8est_connectivity_read_inp_stream(stream, num_vertices, num_trees, vertices, tree_to_vertex)
Read an ABAQUS input file from a file stream.
This utility function reads a basic ABAQUS file supporting element type with the prefix C2D4, CPS4, and S4 in 2D and of type C3D8 reading them as bilinear quadrilateral and trilinear hexahedral trees respectively.
A basic 2D mesh is given below. The *Node
section gives the vertex number and x, y, and z components for each vertex. The *Element
section gives the 4 vertices in 2D (8 vertices in 3D) of each element in counter clockwise order. So in 2D the nodes are given as:
4 3 +–––––––––-+ | | | | | | | | | | | | +–––––––––-+ 1 2
and in 3D they are given as:
8 7 +––––––––––-+ |\ |\ | \ | \ | \ | \ | \ | \ | 5+––––––––––-+6 | | | | +––|––––––––+ | 4\ | 3 \ | \ | \ | \ | \ | \| \| +––––––––––-+ 1 2
*Heading
box.inp
*Node
1, 5, -5, 5
2, 5, 5, 5
3, 5, 0, 5
4, -5, 5, 5
5, 0, 5, 5
6, -5, -5, 5
7, -5, 0, 5
8, 0, -5, 5
9, 0, 0, 5
10, 5, 5, -5
11, 5, -5, -5
12, 5, 0, -5
13, -5, -5, -5
14, 0, -5, -5
15, -5, 5, -5
16, -5, 0, -5
17, 0, 5, -5
18, 0, 0, -5
19, -5, -5, 0
20, 5, -5, 0
21, 0, -5, 0
22, -5, 5, 0
23, -5, 0, 0
24, 5, 5, 0
25, 0, 5, 0
26, 5, 0, 0
27, 0, 0, 0
*Element, type=C3D8, ELSET=EB1
1, 6, 19, 23, 7, 8, 21, 27, 9
2, 19, 13, 16, 23, 21, 14, 18, 27
3, 7, 23, 22, 4, 9, 27, 25, 5
4, 23, 16, 15, 22, 27, 18, 17, 25
5, 8, 21, 27, 9, 1, 20, 26, 3
6, 21, 14, 18, 27, 20, 11, 12, 26
7, 9, 27, 25, 5, 3, 26, 24, 2
8, 27, 18, 17, 25, 26, 12, 10, 24
This code can be called two ways. The first, when vertex
==NULL and tree_to_vertex
==NULL, is used to count the number of trees and vertices in the connectivity to be generated by the .inp
mesh in the stream. The second, when vertices
!=NULL and tree_to_vertex
!=NULL, fill vertices
and tree_to_vertex
. In this case num_vertices
and num_trees
need to be set to the maximum number of entries allocated in vertices
and tree_to_vertex
.
Parameters
stream
:[in,out] file stream to read the connectivity fromnum_vertices
:[in,out] the number of vertices in the connectivitynum_trees
:[in,out] the number of trees in the connectivityvertices
:[out] the list ofvertices
of the connectivitytree_to_vertex
:[out] thetree_to_vertex
map of the connectivity
Returns
0 if successful and nonzero if not
Prototype
int p8est_connectivity_read_inp_stream (FILE * stream, p4est_topidx_t * num_vertices, p4est_topidx_t * num_trees, double *vertices, p4est_topidx_t * tree_to_vertex);
P4est.LibP4est.p8est_connectivity_reduce
— Methodp8est_connectivity_reduce(conn)
Removes corner and edge information of a connectivity such that enough information is left to run p8est_connectivity_complete
successfully. The reduced connectivity still passes p8est_connectivity_is_valid
.
Parameters
conn
:[in,out] The connectivity to be reduced.
Prototype
void p8est_connectivity_reduce (p8est_connectivity_t * conn);
P4est.LibP4est.p8est_connectivity_refine
— Methodp8est_connectivity_refine(conn, num_per_edge)
Uniformly refine a connectivity. This is useful if you would like to uniformly refine by something other than a power of 2.
Parameters
conn
:[in] A valid connectivitynum_per_edge
:[in] The number of new trees in each direction. Must use no more than P8ESTOLDQMAXLEVEL bits.
Returns
a refined connectivity.
Prototype
p8est_connectivity_t *p8est_connectivity_refine (p8est_connectivity_t * conn, int num_per_edge);
P4est.LibP4est.p8est_connectivity_save
— Methodp8est_connectivity_save(filename, connectivity)
Save a connectivity structure to disk.
Parameters
filename
:[in] Name of the file to write.connectivity
:[in] Valid connectivity structure.
Returns
Returns 0 on success, nonzero on file error.
Prototype
int p8est_connectivity_save (const char *filename, p8est_connectivity_t * connectivity);
P4est.LibP4est.p8est_connectivity_set_attr
— Methodp8est_connectivity_set_attr(conn, bytes_per_tree)
Allocate or free the attribute fields in a connectivity.
Parameters
conn
:[in,out] The conn->*_to_attr fields must either be NULL or previously be allocated by this function.bytes_per_tree
:[in] If 0, tree_to_attr is freed (being NULL is ok). If positive, requested space is allocated.
Prototype
void p8est_connectivity_set_attr (p8est_connectivity_t * conn, size_t bytes_per_tree);
P4est.LibP4est.p8est_connectivity_sink
— Methodp8est_connectivity_sink(conn, sink)
Write connectivity to a sink object.
Parameters
conn
:[in] The connectivity to be written.sink
:[in,out] The connectivity is written into this sink.
Returns
0 on success, nonzero on error.
Prototype
int p8est_connectivity_sink (p8est_connectivity_t * conn, sc_io_sink_t * sink);
P4est.LibP4est.p8est_connectivity_source
— Methodp8est_connectivity_source(source)
Read connectivity from a source object.
Parameters
source
:[in,out] The connectivity is read from this source.
Returns
The newly created connectivity, or NULL on error.
Prototype
p8est_connectivity_t *p8est_connectivity_source (sc_io_source_t * source);
P4est.LibP4est.p8est_copy
— Methodp8est_copy(input, 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. The revision counter of the copy is set to zero.
Parameters
copy_data
:[in] If true, data are copied. If false, data_size is set to 0.
Returns
Returns a valid p8est
that does not depend on the input, except for borrowing the same connectivity. Its revision counter is 0.
Prototype
p8est_t *p8est_copy (p8est_t * input, int copy_data);
P4est.LibP4est.p8est_copy_ext
— Methodp8est_copy_ext(input, copy_data, duplicate_mpicomm)
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. The revision counter of the copy is set to zero.
Parameters
copy_data
:[in] If true, data are copied. If false, data_size is set to 0.duplicate_mpicomm
:[in] If true, MPI communicator is copied.
Returns
Returns a valid p8est
that does not depend on the input, except for borrowing the same connectivity. Its revision counter is 0.
Prototype
p8est_t *p8est_copy_ext (p8est_t * input, int copy_data, int duplicate_mpicomm);
P4est.LibP4est.p8est_destroy
— Methodp8est_destroy(p8est_)
Destroy a p8est
.
The connectivity structure is not destroyed with the p8est
.
Prototype
void p8est_destroy (p8est_t * p8est);
P4est.LibP4est.p8est_expand_face_transform
— Methodp8est_expand_face_transform(iface, nface, ftransform)
Fill an array with the axis combination of a face neighbor transform.
Parameters
iface
:[in] The number of the originating face.nface
:[in] Encoded as nface = r * 6 + nf, where nf = 0..5 is the neigbbor's connecting face number and r = 0..3 is the relative orientation to the neighbor's face. This encoding matchesp8est_connectivity_t
.ftransform
:[out] This array holds 9 integers. [0]..[2] The coordinate axis sequence of the origin face, the first two referring to the tangentials and the third to the normal. A permutation of (0, 1, 2). [3]..[5] The coordinate axis sequence of the target face. [6]..[8] Edge reversal flags for tangential axes (boolean); face code in [0, 3] for the normal coordinate q: 0: q' = -q 1: q' = q + 1 2: q' = q - 1 3: q' = 2 - q
Prototype
void p8est_expand_face_transform (int iface, int nface, int ftransform[]);
P4est.LibP4est.p8est_face_quadrant_exists
— Methodp8est_face_quadrant_exists(p8est_, ghost, treeid, q, face, hang, owner_rank)
Checks if quadrant exists in the local forest or the ghost layer.
For quadrants across tree boundaries it checks if the quadrant exists across any face, but not across edges or corners.
Parameters
p8est
:[in] The forest in which to search for q.ghost
:[in] The ghost layer in which to search for q.treeid
:[in] The tree to which q belongs.q
:[in] The quadrant that is being searched for.face
:[in,out] On input, face id across which q was created. On output, the neighbor's face number augmented by orientation, so face is in 0..23.hang
:[in,out] If not NULL, signals that q is bigger than the quadrant it came from. The child id of that originating quadrant is passed into hang. On output, hang holds the hanging face number of q that is in contact with its originator.owner_rank
:[out] Filled with the rank of the owner if it is found and undefined otherwise.
Returns
Returns the local number of q if the quadrant exists in the local forest or in the ghost_layer. Otherwise, returns -2 for a domain boundary and -1 if not found.
Prototype
p4est_locidx_t p8est_face_quadrant_exists (p8est_t * p8est, p8est_ghost_t * ghost, p4est_topidx_t treeid, const p8est_quadrant_t * q, int *face, int *hang, int *owner_rank);
P4est.LibP4est.p8est_find_corner_transform
— Methodp8est_find_corner_transform(connectivity, itree, icorner, ci)
Fills an array with information about corner neighbors.
Parameters
itree
:[in] The number of the originating tree.icorner
:[in] The number of the originating corner.ci
:[in,out] Ap8est_corner_info_t
structure with initialized array.
Prototype
void p8est_find_corner_transform (p8est_connectivity_t * connectivity, p4est_topidx_t itree, int icorner, p8est_corner_info_t * ci);
P4est.LibP4est.p8est_find_edge_transform
— Methodp8est_find_edge_transform(connectivity, itree, iedge, ei)
Fills an array with information about edge neighbors.
Parameters
itree
:[in] The number of the originating tree.iedge
:[in] The number of the originating edge.ei
:[in,out] Ap8est_edge_info_t
structure with initialized array.
Prototype
void p8est_find_edge_transform (p8est_connectivity_t * connectivity, p4est_topidx_t itree, int iedge, p8est_edge_info_t * ei);
P4est.LibP4est.p8est_find_face_transform
— Methodp8est_find_face_transform(connectivity, itree, iface, ftransform)
Fill an array with the axis combination of a face neighbor transform.
Parameters
itree
:[in] The number of the originating tree.iface
:[in] The number of the originating tree's face.ftransform
:[out] This array holds 9 integers. [0]..[2] The coordinate axis sequence of the origin face. [3]..[5] The coordinate axis sequence of the target face. [6]..[8] Edge reverse flag for axes t1, t2; face code for n.
Returns
The face neighbor tree if it exists, -1 otherwise.
Prototype
p4est_topidx_t p8est_find_face_transform (p8est_connectivity_t * connectivity, p4est_topidx_t itree, int iface, int ftransform[]);
P4est.LibP4est.p8est_find_higher_bound
— Methodp8est_find_higher_bound(array, q, guess)
Find the highest position tq in a quadrant array such that tq <= q.
Returns
Returns the id of the matching quadrant or -1 if array > q or the array is empty.
Prototype
ssize_t p8est_find_higher_bound (sc_array_t * array, const p8est_quadrant_t * q, size_t guess);
P4est.LibP4est.p8est_find_lower_bound
— Methodp8est_find_lower_bound(array, q, guess)
Find the lowest position tq in a quadrant array such that tq >= q.
Returns
Returns the id of the matching quadrant or -1 if array < q or the array is empty.
Prototype
ssize_t p8est_find_lower_bound (sc_array_t * array, const p8est_quadrant_t * q, size_t guess);
P4est.LibP4est.p8est_find_partition
— Methodp8est_find_partition(num_procs, search_in, my_begin, my_end, _begin, _end)
Binary search in partition array. Given two targets my_begin and my_end, find offsets such that search\_in[begin] >= my\_begin
, my\_end <= search\_in[end]
. If more than one index satisfies the conditions, then the minimal index is the result. If there is no index that satisfies the conditions, then begin and end are tried to set equal such that search\_in[begin] >= my\_end
. If my_begin is less or equal than the smallest value of search_in begin is set to 0 and if my_end is bigger or equal than the largest value of search_in end is set to num_procs - 1. If none of the above conditions is satisfied, the output is not well defined. We require `my_begin <= my_begin'.
Parameters
num_procs
:[in] Number of processes to get the length of search_in.search_in
:[in] The sorted array (ascending) in that the function will search. Ifk
indexes search_in, then0 <= k < num\_procs
.my_begin
:[in] The first target that defines the start of the search window.my_end
:[in] The second target that defines the end of the search window.begin
:[in,out] The first offset such thatsearch\_in[begin] >= my\_begin
.end
:[in,out] The second offset such thatmy\_end <= search\_in[end]
.
Prototype
void p8est_find_partition (const int num_procs, p4est_gloidx_t * search_in, p4est_gloidx_t my_begin, p4est_gloidx_t my_end, p4est_gloidx_t * begin, p4est_gloidx_t * end);
P4est.LibP4est.p8est_find_quadrant_cumulative
— Methodp8est_find_quadrant_cumulative(p8est_, cumulative_id, which_tree, quadrant_id)
Search a local quadrant by its cumulative number in the forest.
We perform a binary search over the processor-local trees, which means that it is advisable NOT to use this function if possible, and to try to maintain O(1) tree context information in the calling code.
Parameters
p8est
:[in] Forest to be worked with.cumulative_id
:[in] Cumulative index over all trees of quadrant.which_tree
:[in,out] If not NULL, the input value can be -1 or an initial guess for the quadrant's tree. An initial guess must be the index of a nonempty local tree. Output is the tree of returned quadrant.quadrant_id
:[out] If not NULL, the number of quadrant in tree.
Returns
The identified quadrant.
Prototype
p8est_quadrant_t *p8est_find_quadrant_cumulative (p8est_t * p8est, p4est_locidx_t cumulative_id, p4est_topidx_t * which_tree, p4est_locidx_t * quadrant_id);
P4est.LibP4est.p8est_find_range_boundaries
— Methodp8est_find_range_boundaries(lq, uq, level, faces, edges, corners)
Find the boundary points touched by a range of quadrants.
Given two smallest quadrants, lq and uq, that mark the first and the last quadrant in a range of quadrants, determine which portions of the tree boundary the range touches.
Parameters
lq
:[in] The smallest quadrant at the start of the range: if NULL, the tree's first quadrant is taken to be the start of the range.uq
:[in] The smallest quadrant at the end of the range: if NULL, the tree's last quadrant is taken to be the end of the range.level
:[in] The level of the containing quadrant whose boundaries are tested: 0 if we want to test the boundaries of the whole tree.faces
:[in,out] An array of size 6 that is filled: faces[i] is true if the range touches that face.edges
:[in,out] An array of size 12 that is filled: edges[i] is true if the range touches that edge.corners
:[in,out] An array of size 8 that is filled: corners[i] is true if the range touches that corner. faces, edges or corners may be NULL.
Returns
Returns an int32_t encoded with the same information in faces, edges and corners: the first (least) six bits represent the six faces, the next twelve bits represent the twelve edges, the next eight bits represent the eight corners.
Prototype
int32_t p8est_find_range_boundaries (p8est_quadrant_t * lq, p8est_quadrant_t * uq, int level, int faces[], int edges[], int corners[]);
P4est.LibP4est.p8est_get_plex_data_ext
— Methodp8est_get_plex_data_ext(p8est_, ghost, lnodes, ctype, overlap, first_local_quad, out_points_per_dim, out_cone_sizes, out_cones, out_cone_orientations, out_vertex_coords, out_children, out_parents, out_childids, out_leaves, out_remotes, 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
p8est
:[in] the forestghost
:[out] the ghost layerlnodes
:[out] the lnodesctype
:[in] the type of adjacency for the overlapoverlap
:[in] the number of layers of overlap (zero is acceptable)first_local_quad
:[out] the local quadrants are assigned contiguous plex indices, starting with this indexout_points_per_dim
:[in,out] filled with argument for DMPlexCreateFromDAG()out_cone_sizes
:[in,out] filled with argument for DMPlexCreateFromDAG()out_cones
:[in,out] filled with argument for DMPlexCreateFromDAG()out_cone_orientations
:[in,out] filled with argument for DMPlexCreateFromDAG()out_vertex_coords
:[in,out] filled with argument for DMPlexCreateFromDAG()out_children
:[in,out] filled with argument for DMPlexSetTree()out_parents
:[in,out] filled with argument for DMPlexSetTree()out_childids
:[in,out] filled with argument for DMPlexSetTree()out_leaves
:[in,out] filled with argument for PetscSFSetGraph()out_remotes
:[in,out] filled with argument for PetscSFSetGraph()custom_numbering
:[in] Whether or use the default numbering (0) of DMPlex child ids or the custom (1).
Prototype
void p8est_get_plex_data_ext (p8est_t * p8est, p8est_ghost_t ** ghost, p8est_lnodes_t ** lnodes, p8est_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);
P4est.LibP4est.p8est_ghost_bsearch
— Methodp8est_ghost_bsearch(ghost, which_proc, which_tree, q)
Conduct binary search for exact match on a range of the ghost layer.
Parameters
ghost
:[in] The ghost layer.which_proc
:[in] The owner of the searched quadrant. Can be -1.which_tree
:[in] The tree of the searched quadrant. Can be -1.q
:[in] Valid quadrant is searched in the ghost layer.
Returns
Offset in the ghost layer, or -1 if not found.
Prototype
ssize_t p8est_ghost_bsearch (p8est_ghost_t * ghost, int which_proc, p4est_topidx_t which_tree, const p8est_quadrant_t * q);
P4est.LibP4est.p8est_ghost_checksum
— Methodp8est_ghost_checksum(p8est_, ghost)
Compute the parallel checksum of a ghost layer.
Parameters
p8est
:[in] The MPI information of thisp8est
will be used.ghost
:[in] A ghost layer obtained from thep8est
.
Returns
Parallel checksum on rank 0, 0 otherwise.
Prototype
unsigned p8est_ghost_checksum (p8est_t * p8est, p8est_ghost_t * ghost);
P4est.LibP4est.p8est_ghost_destroy
— Methodp8est_ghost_destroy(ghost)
Frees all memory used for the ghost layer.
Prototype
void p8est_ghost_destroy (p8est_ghost_t * ghost);
P4est.LibP4est.p8est_ghost_exchange_custom
— Methodp8est_ghost_exchange_custom(p8est_, ghost, data_size, mirror_data, ghost_data)
Transfer data for local quadrants that are ghosts to other processors. The data size is the same for all quadrants and can be chosen arbitrarily.
Parameters
p8est
:[in] The forest used for reference.ghost
:[in] The ghost layer used for reference.data_size
:[in] The data size to transfer per quadrant.mirror_data
:[in] One data pointer per mirror quadrant.ghost_data
:[in,out] Pre-allocated contiguous data for all ghosts in sequence, which must hold at leastdata_size
for each ghost.
Prototype
void p8est_ghost_exchange_custom (p8est_t * p8est, p8est_ghost_t * ghost, size_t data_size, void **mirror_data, void *ghost_data);
P4est.LibP4est.p8est_ghost_exchange_custom_begin
— Methodp8est_ghost_exchange_custom_begin(p8est_, ghost, data_size, mirror_data, ghost_data)
Begin an asynchronous ghost data exchange by posting messages. The arguments are identical to p8est_ghost_exchange_custom
. The return type is always non-NULL and must be passed to p8est_ghost_exchange_custom_end
to complete the exchange. The ghost data must not be accessed before completion. The mirror data can be safely discarded right after this function returns since it is copied into internal send buffers.
Parameters
mirror_data
:[in] Not required to stay alive any longer.ghost_data
:[in,out] Must stay alive into the completion call.
Returns
Transient storage for messages in progress.
Prototype
p8est_ghost_exchange_t *p8est_ghost_exchange_custom_begin (p8est_t * p8est, p8est_ghost_t * ghost, size_t data_size, void **mirror_data, void *ghost_data);
P4est.LibP4est.p8est_ghost_exchange_custom_end
— Methodp8est_ghost_exchange_custom_end(exc)
Complete an asynchronous ghost data exchange. This function waits for all pending MPI communications.
Parameters
Data
:[in,out] created ONLY byp8est_ghost_exchange_custom_begin
. It is deallocated before this function returns.
Prototype
void p8est_ghost_exchange_custom_end (p8est_ghost_exchange_t * exc);
P4est.LibP4est.p8est_ghost_exchange_custom_levels
— Methodp8est_ghost_exchange_custom_levels(p8est_, ghost, minlevel, maxlevel, data_size, mirror_data, ghost_data)
Transfer data for local quadrants that are ghosts to other processors. The data size is the same for all quadrants and can be chosen arbitrarily. This function restricts the transfer to a range of refinement levels. The memory for quadrants outside the level range is not dereferenced.
Parameters
p8est
:[in] The forest used for reference.ghost
:[in] The ghost layer used for reference.minlevel
:[in] Level of the largest quads to be exchanged. Use <= 0 for no restriction.maxlevel
:[in] Level of the smallest quads to be exchanged. Use >=P8EST_QMAXLEVEL
for no restriction.data_size
:[in] The data size to transfer per quadrant.mirror_data
:[in] One data pointer per mirror quadrant as input.ghost_data
:[in,out] Pre-allocated contiguous data for all ghosts in sequence, which must hold at leastdata_size
for each ghost.
Prototype
void p8est_ghost_exchange_custom_levels (p8est_t * p8est, p8est_ghost_t * ghost, int minlevel, int maxlevel, size_t data_size, void **mirror_data, void *ghost_data);
P4est.LibP4est.p8est_ghost_exchange_custom_levels_begin
— Methodp8est_ghost_exchange_custom_levels_begin(p8est_, ghost, minlevel, maxlevel, data_size, mirror_data, ghost_data)
Begin an asynchronous ghost data exchange by posting messages. The arguments are identical to p8est_ghost_exchange_custom_levels
. The return type is always non-NULL and must be passed to p8est_ghost_exchange_custom_levels_end
to complete the exchange. The ghost data must not be accessed before completion. The mirror data can be safely discarded right after this function returns since it is copied into internal send buffers.
Parameters
mirror_data
:[in] Not required to stay alive any longer.ghost_data
:[in,out] Must stay alive into the completion call.
Returns
Transient storage for messages in progress.
Prototype
p8est_ghost_exchange_t *p8est_ghost_exchange_custom_levels_begin (p8est_t * p8est, p8est_ghost_t * ghost, int minlevel, int maxlevel, size_t data_size, void **mirror_data, void *ghost_data);
P4est.LibP4est.p8est_ghost_exchange_custom_levels_end
— Methodp8est_ghost_exchange_custom_levels_end(exc)
Complete an asynchronous ghost data exchange. This function waits for all pending MPI communications.
Parameters
exc
:[in,out] created ONLY byp8est_ghost_exchange_custom_levels_begin
. It is deallocated before this function returns.
Prototype
void p8est_ghost_exchange_custom_levels_end (p8est_ghost_exchange_t * exc);
P4est.LibP4est.p8est_ghost_exchange_data
— Methodp8est_ghost_exchange_data(p8est_, ghost, ghost_data)
Transfer data for local quadrants that are ghosts to other processors. Send the data stored in the quadrant's user_data. This is either the pointer variable itself if p8est
->datasize is 0, or the content of the referenced memory field if p8est
->data\size is positive.
Parameters
p8est
:[in] The forest used for reference.ghost
:[in] The ghost layer used for reference.ghost_data
:[in,out] Pre-allocated contiguous data for all ghost quadrants in sequence. Ifp8est
->data_size is 0, must at least hold sizeof (void *) bytes for each, otherwisep8est
->data_size each.
Prototype
void p8est_ghost_exchange_data (p8est_t * p8est, p8est_ghost_t * ghost, void *ghost_data);
P4est.LibP4est.p8est_ghost_exchange_data_begin
— Methodp8est_ghost_exchange_data_begin(p8est_, ghost, ghost_data)
Begin an asynchronous ghost data exchange by posting messages. The arguments are identical to p8est_ghost_exchange_data
. The return type is always non-NULL and must be passed to p8est_ghost_exchange_data_end
to complete the exchange. The ghost data must not be accessed before completion.
Parameters
ghost_data
:[in,out] Must stay alive into the completion call.
Returns
Transient storage for messages in progress.
Prototype
p8est_ghost_exchange_t *p8est_ghost_exchange_data_begin (p8est_t * p8est, p8est_ghost_t * ghost, void *ghost_data);
P4est.LibP4est.p8est_ghost_exchange_data_end
— Methodp8est_ghost_exchange_data_end(exc)
Complete an asynchronous ghost data exchange. This function waits for all pending MPI communications.
Parameters
exc
:[in,out] Created ONLY byp8est_ghost_exchange_data_begin
. It is deallocated before this function returns.
Prototype
void p8est_ghost_exchange_data_end (p8est_ghost_exchange_t * exc);
P4est.LibP4est.p8est_ghost_expand
— Methodp8est_ghost_expand(p8est_, ghost)
Expand the size of the ghost layer and mirrors by one additional layer of adjacency.
Parameters
p8est
:[in] The forest from which the ghost layer was generated.ghost
:[in,out] The ghost layer to be expanded.
Prototype
void p8est_ghost_expand (p8est_t * p8est, p8est_ghost_t * ghost);
P4est.LibP4est.p8est_ghost_expand_by_lnodes
— Methodp8est_ghost_expand_by_lnodes(p4est_, lnodes, ghost)
Expand the ghost layer as in p8est_ghost_expand
(), but use node support to define adjacency instead of geometric adjacency.
Parameters
p8est
:[in] The forest from which the ghost layer was generated.lnodes
:[in] The nodes to support.ghost
:[in,out] The ghost layer to be expanded.
Prototype
void p8est_ghost_expand_by_lnodes (p8est_t * p4est, p8est_lnodes_t * lnodes, p8est_ghost_t * ghost);
P4est.LibP4est.p8est_ghost_is_valid
— Methodp8est_ghost_is_valid(p8est_, ghost)
Examine if a ghost structure is valid as desribed above. Test if within a ghost-structure the arrays ghosts and mirrors are in p8est_quadrant_compare_piggy order. Test if local_num in piggy3 data member of the quadrants in ghosts and mirrors are in ascending order (ascending within each rank for ghost).
Test if the p4est_locidx_t
arrays are in ascending order (for mirror_proc_mirrors ascending within each rank)
Parameters
p8est
:[in] the forest.ghost
:[in] Ghost layer structure.
Returns
true if ghost is valid
Prototype
int p8est_ghost_is_valid (p8est_t * p8est, p8est_ghost_t * ghost);
P4est.LibP4est.p8est_ghost_memory_used
— Methodp8est_ghost_memory_used(ghost)
Calculate the memory usage of the ghost layer.
Parameters
ghost
:[in] Ghost layer structure.
Returns
Memory used in bytes.
Prototype
size_t p8est_ghost_memory_used (p8est_ghost_t * ghost);
P4est.LibP4est.p8est_ghost_new
— Methodp8est_ghost_new(p8est_, btype)
Builds the ghost layer.
This will gather the quadrants from each neighboring proc to build one layer of face, edge and corner based ghost elements around the ones they own.
Parameters
p8est
:[in] The forest for which the ghost layer will be generated.btype
:[in] Which ghosts to include (across face, edge, or corner/full).
Returns
A fully initialized ghost layer.
Prototype
p8est_ghost_t *p8est_ghost_new (p8est_t * p8est, p8est_connect_type_t btype);
P4est.LibP4est.p8est_ghost_support_lnodes
— Methodp8est_ghost_support_lnodes(p8est_, lnodes, ghost)
Expand the ghost layer to include the support of all nodes supported on the local partition.
Parameters
p8est
:[in] The forest from which the ghost layer was generated.lnodes
:[in] The nodes to support.ghost
:[in,out] The ghost layer to be expanded.
Prototype
void p8est_ghost_support_lnodes (p8est_t * p8est, p8est_lnodes_t * lnodes, p8est_ghost_t * ghost);
P4est.LibP4est.p8est_ghost_tree_contains
— Methodp8est_ghost_tree_contains(ghost, which_proc, which_tree, q)
Conduct binary search for ancestor on range of the ghost layer.
Parameters
ghost
:[in] The ghost layer.which_proc
:[in] The owner of the searched quadrant. Can be -1.which_tree
:[in] The tree of the searched quadrant. Can be -1.q
:[in] Valid quadrant's ancestor is searched.
Returns
Offset in the ghost layer, or -1 if not found.
Prototype
ssize_t p8est_ghost_tree_contains (p8est_ghost_t * ghost, int which_proc, p4est_topidx_t which_tree, const p8est_quadrant_t * q);
P4est.LibP4est.p8est_is_balanced
— Methodp8est_is_balanced(p8est_, btype)
Check a forest to see if it is balanced.
This function builds the ghost layer and discards it when done.
Parameters
p8est
:[in] Thep8est
to be tested.btype
:[in] Balance type (face, edge, corner or default, full).
Returns
Returns true if balanced, false otherwise.
Prototype
int p8est_is_balanced (p8est_t * p8est, p8est_connect_type_t btype);
P4est.LibP4est.p8est_iterate
— Methodp8est_iterate(p4est_, ghost_layer, user_data, iter_volume, iter_face, iter_edge, iter_corner)
Execute the user-supplied callback functions at every volume, face, edge and corner in the local forest.
The ghost_layer may be NULL. The user_data pointer is not touched by p8est_iterate
, but is passed to each of the callbacks. Any of the callback functions may be NULL. The callback functions are interspersed with each other, i.e. some face callbacks will occur between volume callbacks, and some edge callbacks will occur between face callbacks, etc.:
- volume callbacks occur in the sorted Morton-index order. 2) a face callback is not executed until after the volume callbacks have been executed for the quadrants that share it. 3) an edge callback is not executed until the face callbacks have been executed for all faces that touch the edge. 4) a corner callback is not executed until the edge callbacks have been executed for all edges that touch the corner. 5) it is not always the case that every face callback for a given quadrant is executed before any of the edge or corner callbacks, and it is not always the case that every edge callback for a given quadrant is executed before any of the corner callbacks. 6) callbacks are not executed at faces, edges or corners that only involve ghost quadrants, i.e. that are not adjacent in the local section of the forest.
Parameters
p4est
:[in] the forestghost_layer
:[in] optional: when not given, callbacks at the boundaries of the local partition cannot provide quadrant data about ghost quadrants: missing (p8est_quadrant_t
*) pointers are set to NULL, missing indices are set to -1.user_data
:[in,out] optional context to supply to each callbackiter_volume
:[in] callback function for every quadrant's interioriter_face
:[in] callback function for every face between quadrantsiter_edge
:[in] callback function for every edge between quadrantsiter_corner
:[in] callback function for every corner between quadrants
Prototype
void p8est_iterate (p8est_t * p4est, p8est_ghost_t * ghost_layer, void *user_data, p8est_iter_volume_t iter_volume, p8est_iter_face_t iter_face, p8est_iter_edge_t iter_edge, p8est_iter_corner_t iter_corner);
P4est.LibP4est.p8est_iterate_ext
— Methodp8est_iterate_ext(p8est_, ghost_layer, user_data, iter_volume, iter_face, iter_edge, iter_corner, remote)
p8est_iterate_ext
adds the option remote: if this is false, then it is the same as p8est_iterate
; if this is true, then corner/edge callbacks are also called on corners/edges for hanging faces/edges touched by local quadrants.
Prototype
void p8est_iterate_ext (p8est_t * p8est, p8est_ghost_t * ghost_layer, void *user_data, p8est_iter_volume_t iter_volume, p8est_iter_face_t iter_face, p8est_iter_edge_t iter_edge, p8est_iter_corner_t iter_corner, int remote);
P4est.LibP4est.p8est_lid_add
— Methodp8est_lid_add(a, b, result)
Adds the uint128_t b to the uint128_t a. result == a or result == b is not allowed. a == b is allowed.
Parameters
a
:[in] A pointer to ap8est_lid_t
.b
:[in] A pointer to ap8est_lid_t
.result
:[out] A pointer to ap8est_lid_t
. The sum a + b will be saved in result.
Prototype
void p8est_lid_add (const p8est_lid_t * a, const p8est_lid_t * b, p8est_lid_t * result);
P4est.LibP4est.p8est_lid_add_inplace
— Methodp8est_lid_add_inplace(a, b)
Adds the p8est_lid_t
b to the p8est_lid_t
a. The result is saved in a. a == b is allowed.
Parameters
a
:[in,out] A pointer to ap8est_lid_t
. a will be overwritten by a + b.b
:[in] A pointer to ap8est_lid_t
.
Prototype
void p8est_lid_add_inplace (p8est_lid_t * a, const p8est_lid_t * b);
P4est.LibP4est.p8est_lid_bitwise_and
— Methodp8est_lid_bitwise_and(a, b, 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
a
:[in] A pointer to ap8est_lid_t
.b
:[in] A pointer to ap8est_lid_t
.result
:[out] A pointer to ap8est_lid_t
. The bitwise and of a and b will be saved. in result.
Prototype
void p8est_lid_bitwise_and (const p8est_lid_t * a, const p8est_lid_t * b, p8est_lid_t * result);
P4est.LibP4est.p8est_lid_bitwise_and_inplace
— Methodp8est_lid_bitwise_and_inplace(a, b)
Calculates the bitwise and of the uint128_t a and the uint128_t b. a == b is allowed.
Parameters
a
:[in,out] A pointer to ap8est_lid_t
. The bitwise and will be saved in a.b
:[in] A pointer to ap8est_lid_t
.
Prototype
void p8est_lid_bitwise_and_inplace (p8est_lid_t * a, const p8est_lid_t * b);
P4est.LibP4est.p8est_lid_bitwise_neg
— Methodp8est_lid_bitwise_neg(a, result)
Calculates the bitwise negation of the uint128_t a. a == result is allowed.
Parameters
a
:[in] A pointer to ap8est_lid_t
.result
:[out] A pointer to ap8est_lid_t
. The bitwise negation of a will be saved in result.
Prototype
void p8est_lid_bitwise_neg (const p8est_lid_t * a, p8est_lid_t * result);
P4est.LibP4est.p8est_lid_bitwise_or
— Methodp8est_lid_bitwise_or(a, b, 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
a
:[in] A pointer to ap8est_lid_t
.b
:[in] A pointer to ap8est_lid_t
.result
:[out] A pointer to ap8est_lid_t
. The bitwise or of a and b will be saved in result.
Prototype
void p8est_lid_bitwise_or (const p8est_lid_t * a, const p8est_lid_t * b, p8est_lid_t * result);
P4est.LibP4est.p8est_lid_bitwise_or_inplace
— Methodp8est_lid_bitwise_or_inplace(a, b)
Calculates the bitwise or of the uint128_t a and the uint128_t b. a == b is allowed.
Parameters
a
:[in,out] A pointer to ap8est_lid_t
. The bitwise or will be saved in a.b
:[in] A pointer to ap8est_lid_t
.
Prototype
void p8est_lid_bitwise_or_inplace (p8est_lid_t * a, const p8est_lid_t * b);
P4est.LibP4est.p8est_lid_chk_bit
— Methodp8est_lid_chk_bit(input, bit_number)
Returns the bit_number-th bit of input. This function checks a bit of an existing, initialized value.
Parameters
input
:[in] A pointer to ap8est_lid_t
.bit_number
:[in] The bit (counted from the right hand side) that is checked by logical and. Require 0 <= bit_number < 128.
Returns
True if bit is set, false if not.
Prototype
int p8est_lid_chk_bit (const p8est_lid_t * input, int bit_number);
P4est.LibP4est.p8est_lid_compare
— Methodp8est_lid_compare(a, b)
Compare the p8est_lid_t
a and the p8est_lid_t
b.
Parameters
a
:[in] A pointer to ap8est_lid_t
.b
:[in] A pointer to ap8est_lid_t
.
Returns
Returns -1 if a < b, 1 if a > b and 0 if a == b.
Prototype
int p8est_lid_compare (const p8est_lid_t * a, const p8est_lid_t * b);
P4est.LibP4est.p8est_lid_copy
— Methodp8est_lid_copy(input, output)
Copies an initialized p8est_lid_t
to a p8est_lid_t
.
Parameters
input
:[in] A pointer to thesc_uint128
that is copied.output
:[in,out] A pointer to ap8est_lid_t
. The high and low bits of output will be set to the high and low bits of input, respectively.
Prototype
void p8est_lid_copy (const p8est_lid_t * input, p8est_lid_t * output);
P4est.LibP4est.p8est_lid_init
— Methodp8est_lid_init(input, high, low)
Initializes a linear index to a given value.
Parameters
a
:[in,out] A pointer to thep8est_lid_t
that will be initialized.high
:[in] The given high bits to intialize a.low
:[in] The given low bits to initialize a.
Prototype
void p8est_lid_init (p8est_lid_t * input, uint64_t high, uint64_t low);
P4est.LibP4est.p8est_lid_is_equal
— Methodp8est_lid_is_equal(a, b)
Checks if the p8est_lid_t
a and the p8est_lid_t
b are equal.
Parameters
a
:[in] A pointer to ap8est_lid_t
.b
:[in] A pointer to ap8est_lid_t
.
Returns
Returns a true value if a and b are equal, false otherwise
Prototype
int p8est_lid_is_equal (const p8est_lid_t * a, const p8est_lid_t * b);
P4est.LibP4est.p8est_lid_set_bit
— Methodp8est_lid_set_bit(input, bit_number)
Sets the exponent-th bit of input to one. This function modifies an existing, initialized value.
Parameters
input
:[in,out] A pointer to ap8est_lid_t
.bit_number
:[in] The bit (counted from the right hand side) that is set to one by logical or. Require 0 <= bit_number < 128.
Prototype
void p8est_lid_set_bit (p8est_lid_t * input, int bit_number);
P4est.LibP4est.p8est_lid_set_one
— Methodp8est_lid_set_one(input)
Initializes a linear index to one.
Parameters
input
:[out] A pointer to ap4est_lid_t
that will be intialized.
Prototype
void p8est_lid_set_one (p8est_lid_t * input);
P4est.LibP4est.p8est_lid_set_uint64
— Methodp8est_lid_set_uint64(input, u)
Initializes a linear index to an unsigned 64 bit integer.
Parameters
input
:[out] A pointer to ap4est_lid_t
that will be intialized.
Prototype
void p8est_lid_set_uint64 (p8est_lid_t * input, uint64_t u);
P4est.LibP4est.p8est_lid_set_zero
— Methodp8est_lid_set_zero(input)
Initializes a linear index to zero.
Parameters
input
:[out] A pointer to ap4est_lid_t
that will be intialized.
Prototype
void p8est_lid_set_zero (p8est_lid_t * input);
P4est.LibP4est.p8est_lid_shift_left
— Methodp8est_lid_shift_left(input, shift_count, result)
Calculates the bit left shift of uint128_t input by shift_count bits. We shift in zeros from the right. If shift_count >= 128, result is 0. All bits left from the 127th bit (counted zero based from the right hand side) drop out. input == result is allowed.
Parameters
input
:[in] A pointer to ap8est_lid_t
.shift_count
:[in] Bits to shift. shift_count >= 0.result
:[in,out] A pointer to ap8est_lid_t
. The left shifted number will be saved in result.
Prototype
void p8est_lid_shift_left (const p8est_lid_t * input, unsigned shift_count, p8est_lid_t * result);
P4est.LibP4est.p8est_lid_shift_right
— Methodp8est_lid_shift_right(input, shift_count, result)
Calculates the bit right shift of uint128_t input by shift_count bits. We shift in zeros from the left. If shift_count >= 128, result is 0. All bits right from the zeroth bit (counted from the right hand side) drop out. input == result is allowed.
Parameters
input
:[in] A pointer to ap8est_lid_t
.shift_count
:[in] Bits to shift. shift_count >= 0.result
:[in,out] A pointer to ap8est_lid_t
. The right shifted number will be saved in result.
Prototype
void p8est_lid_shift_right (const p8est_lid_t * input, unsigned shift_count, p8est_lid_t * result);
P4est.LibP4est.p8est_lid_sub
— Methodp8est_lid_sub(a, b, result)
Substracts the p8est_lid_t
b from the p8est_lid_t
a. This function assumes that the result is >= 0. result == a or result == b is not allowed. a == b is allowed.
Parameters
a
:[in] A pointer to ap8est_lid_t
.b
:[in] A pointer to ap8est_lid_t
.result
:[out] A pointer to ap8est_lid_t
. The difference a - b will be saved in result.
Prototype
void p8est_lid_sub (const p8est_lid_t * a, const p8est_lid_t * b, p8est_lid_t * result);
P4est.LibP4est.p8est_lid_sub_inplace
— Methodp8est_lid_sub_inplace(a, b)
Substracts 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
a
:[in,out] A pointer to ap8est_lid_t
. a will be overwritten by a - b.b
:[in] A pointer to ap8est_lid_t
.
Prototype
void p8est_lid_sub_inplace (p8est_lid_t * a, const p8est_lid_t * b);
P4est.LibP4est.p8est_lnodes_buffer_destroy
— Methodp8est_lnodes_buffer_destroy(buffer)
Prototype
void p8est_lnodes_buffer_destroy (p8est_lnodes_buffer_t * buffer);
P4est.LibP4est.p8est_lnodes_destroy
— Methodp8est_lnodes_destroy(lnodes)
Prototype
void p8est_lnodes_destroy (p8est_lnodes_t * lnodes);
P4est.LibP4est.p8est_lnodes_new
— Methodp8est_lnodes_new(p8est_, ghost_layer, degree)
Prototype
p8est_lnodes_t *p8est_lnodes_new (p8est_t * p8est, p8est_ghost_t * ghost_layer, int degree);
P4est.LibP4est.p8est_lnodes_share_all
— Methodp8est_lnodes_share_all(node_data, lnodes)
Equivalend to calling p8est_lnodes_share_all_end
directly after p8est_lnodes_share_all_begin
. Use if there is no local work that can be done to mask the communication cost.
Returns
A fully initialized buffer that contains the received data. After processing this data, the buffer must be freed with p8est_lnodes_buffer_destroy
.
Prototype
p8est_lnodes_buffer_t *p8est_lnodes_share_all (sc_array_t * node_data, p8est_lnodes_t * lnodes);
P4est.LibP4est.p8est_lnodes_share_all_begin
— Methodp8est_lnodes_share_all_begin(node_data, lnodes)
node_data is a user_defined array of arbitrary type, where each entry is associated with the lnodes local nodes entry of matching index. For every process that shares an entry with the current one, the value in the node_data array of that process is written into a buffer->recvbuffers entry as described above. The user can then perform some arbitrary work that requires the data from all processes that share a node (such as reduce, max, min, etc.). When the work concludes, the buffer should be destroyed with [`p8estlnodesbufferdestroy`](@ref).
Values of node_data are not guaranteed to be send, and buffer->recvbuffer entries are not guaranteed to be received until the buffer created by [`p8estlnodesshareallbegin](@ref) is passed to [
p8estlnodesshareall_end`](@ref).
Prototype
p8est_lnodes_buffer_t *p8est_lnodes_share_all_begin (sc_array_t * node_data, p8est_lnodes_t * lnodes);
P4est.LibP4est.p8est_lnodes_share_all_end
— Methodp8est_lnodes_share_all_end(buffer)
Prototype
void p8est_lnodes_share_all_end (p8est_lnodes_buffer_t * buffer);
P4est.LibP4est.p8est_lnodes_share_owned
— Methodp8est_lnodes_share_owned(node_data, lnodes)
Equivalent to calling p8est_lnodes_share_owned_end
directly after p8est_lnodes_share_owned_begin
. Use if there is no local work that can be done to mask the communication cost.
Prototype
void p8est_lnodes_share_owned (sc_array_t * node_data, p8est_lnodes_t * lnodes);
P4est.LibP4est.p8est_lnodes_share_owned_begin
— Methodp8est_lnodes_share_owned_begin(node_data, lnodes)
p8est_lnodes_share_owned_begin
node_data is a user-defined array of arbitrary type, where each entry is associated with the lnodes local nodes entry of matching index. For every local nodes entry that is owned by a process other than the current one, the value in the node_data array of the owning process is written directly into the node_data array of the current process. Values of node_data are not guaranteed to be sent or received until the buffer created by p8est_lnodes_share_owned_begin
is passed to p8est_lnodes_share_owned_end
.
To be memory neutral, the buffer created by p8est_lnodes_share_owned_begin
must be destroying with p8est_lnodes_buffer_destroy
(it is not destroyed by p8est_lnodes_share_owned_end
).
Prototype
p8est_lnodes_buffer_t *p8est_lnodes_share_owned_begin (sc_array_t * node_data, p8est_lnodes_t * lnodes);
P4est.LibP4est.p8est_lnodes_share_owned_end
— Methodp8est_lnodes_share_owned_end(buffer)
Prototype
void p8est_lnodes_share_owned_end (p8est_lnodes_buffer_t * buffer);
P4est.LibP4est.p8est_load
— Methodp8est_load(filename, mpicomm, data_size, load_data, user_pointer, connectivity)
Prototype
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);
P4est.LibP4est.p8est_load_ext
— Methodp8est_load_ext(filename, mpicomm, data_size, load_data, autopartition, broadcasthead, user_pointer, connectivity)
Prototype
p8est_t *p8est_load_ext (const char *filename, sc_MPI_Comm mpicomm, size_t data_size, int load_data, int autopartition, int broadcasthead, void *user_pointer, p8est_connectivity_t ** connectivity);
P4est.LibP4est.p8est_memory_used
— Methodp8est_memory_used(p8est_)
Calculate local memory usage of a forest structure. Not collective. The memory used on the current rank is returned. The connectivity structure is not counted since it is not owned; use p8est_connectivity_memory_usage (p8est
->connectivity).
Parameters
p8est
:[in] Valid forest structure.
Returns
Memory used in bytes.
Prototype
size_t p8est_memory_used (p8est_t * p8est);
P4est.LibP4est.p8est_mesh_destroy
— Methodp8est_mesh_destroy(mesh)
Destroy a p8est_mesh structure.
Parameters
mesh
:[in] Mesh structure previously created byp8est_mesh_new
.
Prototype
void p8est_mesh_destroy (p8est_mesh_t * mesh);
P4est.LibP4est.p8est_mesh_face_neighbor_data
— Methodp8est_mesh_face_neighbor_data(mfn, ghost_data)
Get the user data for the current face neighbor.
Parameters
mfn
:[in] Internal status of the iterator.ghost_data
:[in] Data for the ghost quadrants that has been synchronized withp4est_ghost_exchange_data
.
Returns
A pointer to the user data for the current neighbor.
Prototype
void *p8est_mesh_face_neighbor_data (p8est_mesh_face_neighbor_t * mfn, void *ghost_data);
P4est.LibP4est.p8est_mesh_face_neighbor_init
— Methodp8est_mesh_face_neighbor_init(mfn, p8est_, ghost, mesh, which_tree, quadrant)
Initialize a mesh neighbor iterator by quadrant pointer.
Parameters
mfn
:[out] Ap8est_mesh_face_neighbor_t
to be initialized.which_tree
:[in] Tree of quadrant whose neighbors are looped over.quadrant
:[in] Pointer to quadrant contained in which_tree.
Prototype
void p8est_mesh_face_neighbor_init (p8est_mesh_face_neighbor_t * mfn, p8est_t * p8est, p8est_ghost_t * ghost, p8est_mesh_t * mesh, p4est_topidx_t which_tree, p8est_quadrant_t * quadrant);
P4est.LibP4est.p8est_mesh_face_neighbor_init2
— Methodp8est_mesh_face_neighbor_init2(mfn, p8est_, ghost, mesh, which_tree, quadrant_id)
Initialize a mesh neighbor iterator by quadrant index.
Parameters
mfn
:[out] Ap8est_mesh_face_neighbor_t
to be initialized.which_tree
:[in] Tree of quadrant whose neighbors are looped over.quadrant_id
:[in] Index relative to which_tree of quadrant.
Prototype
void p8est_mesh_face_neighbor_init2 (p8est_mesh_face_neighbor_t * mfn, p8est_t * p8est, p8est_ghost_t * ghost, p8est_mesh_t * mesh, p4est_topidx_t which_tree, p4est_locidx_t quadrant_id);
P4est.LibP4est.p8est_mesh_face_neighbor_next
— Methodp8est_mesh_face_neighbor_next(mfn, ntree, nquad, nface, nrank)
Move the iterator forward to loop around neighbors of the quadrant.
Parameters
mfn
:[in,out] Internal status of the iterator.ntree
:[out] If not NULL, the tree number of the neighbor.nquad
:[out] If not NULL, the quadrant number within tree. For ghosts instead the number in ghost layer.nface
:[out] If not NULL, neighbor's face as inp8est_mesh_t
.nrank
:[out] If not NULL, the owner process of the neighbor.
Returns
Either a real quadrant or one from the ghost layer. Returns NULL when the iterator is done.
Prototype
p8est_quadrant_t *p8est_mesh_face_neighbor_next (p8est_mesh_face_neighbor_t * mfn, p4est_topidx_t * ntree, p4est_locidx_t * nquad, int *nface, int *nrank);
P4est.LibP4est.p8est_mesh_get_neighbors
— Methodp8est_mesh_get_neighbors(p4est_, ghost, mesh, curr_quad_id, direction, neighboring_quads, neighboring_encs, neighboring_qids)
Lookup neighboring quads of quadrant in a specific direction
Parameters
p4est
:[in] Forest to be worked with.ghost
:[in] Ghost quadrants.mesh
:[in] Mesh structure.curr_quad_id
:[in] Process-local ID of current quad.direction
:[in] Direction in which to look for adjacent quadrants is encoded as follows: 0 .. 5 neighbor(-s) across f_i, 6 .. 17 neighbor(-s) across e_{i-6} 18 .. 25 neighbor(-s) across c_{i-18}neighboring_quads
:[out] Array containing neighboring quad(-s) Needs to be empty, containsp4est_quadrant_t
*. May be NULL, then neighboring_qids must not be NULL.neighboring_encs
:[out] Array containing encodings for neighboring quads as described below Needs to be empty, contains int. CAUTION: Note, that the encodings differ from the encodings saved in the mesh. Positive values are for local quadrants, negative values indicate ghost quadrants. Faces: 1 .. 24 => same size neighbor (r * 6 + nf) + 1; nf = 0 .. 5 face index; r = 0 .. 3 relative orientation 25 .. 120 => double size neighbor 25 + h * 24 + r * 6 + nf; h = 0 .. 3 number of the subface; r, nf as above 121 .. 144 => half size neighbors 121 + r * 6 + nf; r, nf as above Edges: 1 .. 24 => same size neighbor r * 12 + ne + 1; ne = 0 .. 11 edge index; r = 0 .. 1 relative orientation 25 .. 72 => double size neighbor 25 + h * 24 + r * 12 + ne; h = 0 .. 1 number of the subedge; r, ne as above 73 .. 96 => half size neighbors 73 + r * 12 + ne; r, ne as above Corners: 1 .. 8 => nc + 1; nc = 0 .. 7 corner indexneighboring_qids
:[out] Array containing quadrant ids for neighboring quadrants. May be NULL, then no neighboring qids are collected. If non-NULL the array needs to be empty and will contain int.
Prototype
p4est_locidx_t p8est_mesh_get_neighbors (p8est_t * p4est, p8est_ghost_t * ghost, p8est_mesh_t * mesh, p4est_locidx_t curr_quad_id, p4est_locidx_t direction, sc_array_t * neighboring_quads, sc_array_t * neighboring_encs, sc_array_t * neighboring_qids);
P4est.LibP4est.p8est_mesh_get_quadrant
— Methodp8est_mesh_get_quadrant(p4est_, mesh, qid)
Access a process-local quadrant inside a forest. Needs a mesh with populated quad_to_tree array. This is a special case of p8estmeshquadrant_cumulative.
Parameters
p4est
:[in] The forest.mesh
:[in] The mesh.qid
:[in] Process-local id of the quadrant (cumulative over trees).
Returns
A pointer to the requested quadrant.
Prototype
p8est_quadrant_t *p8est_mesh_get_quadrant (p8est_t * p4est, p8est_mesh_t * mesh, p4est_locidx_t qid);
P4est.LibP4est.p8est_mesh_memory_used
— Methodp8est_mesh_memory_used(mesh)
Calculate the memory usage of the mesh structure.
Parameters
mesh
:[in] Mesh structure.
Returns
Memory used in bytes.
Prototype
size_t p8est_mesh_memory_used (p8est_mesh_t * mesh);
P4est.LibP4est.p8est_mesh_new
— Methodp8est_mesh_new(p8est_, ghost, btype)
Create a p8est_mesh structure. This function does not populate the quad_to_tree and quad_level fields. To populate them, use p8estmeshnew_ext.
Parameters
p8est
:[in] A forest that is fully 2:1 balanced.ghost
:[in] The ghost layer created from the providedp4est
.btype
:[in] Determines the highest codimension of neighbors.
Returns
A fully allocated mesh structure.
Prototype
p8est_mesh_t *p8est_mesh_new (p8est_t * p8est, p8est_ghost_t * ghost, p8est_connect_type_t btype);
P4est.LibP4est.p8est_mesh_new_ext
— Methodp8est_mesh_new_ext(p4est_, ghost, compute_tree_index, compute_level_lists, btype)
Create a new mesh.
Parameters
p8est
:[in] A forest that is fully 2:1 balanced.ghost
:[in] The ghost layer created from the providedp4est
.compute_tree_index
:[in] Boolean to decide whether to allocate and compute the quad_to_tree list.compute_level_lists
:[in] Boolean to decide whether to compute the level lists in quad_level.btype
:[in] Currently ignored, only face neighbors are stored.
Returns
A fully allocated mesh structure.
Prototype
p8est_mesh_t *p8est_mesh_new_ext (p8est_t * p4est, p8est_ghost_t * ghost, int compute_tree_index, int compute_level_lists, p8est_connect_type_t btype);
P4est.LibP4est.p8est_mesh_quadrant_cumulative
— Methodp8est_mesh_quadrant_cumulative(p8est_, mesh, cumulative_id, which_tree, quadrant_id)
Find a quadrant based on its cumulative number in the local forest. If the quad_to_tree field of the mesh structure exists, this is O(1). Otherwise, we perform a binary search over the processor-local trees.
Parameters
p8est
:[in] Forest to be worked with.mesh
:[in] A mesh derived from the forest.cumulative_id
:[in] Cumulative index over all trees of quadrant. Must refer to a local (non-ghost) quadrant.which_tree
:[in,out] If not NULL, the input value can be -1 or an initial guess for the quadrant's tree and output is the tree of returned quadrant.quadrant_id
:[out] If not NULL, the number of quadrant in tree.
Returns
The identified quadrant.
Prototype
p8est_quadrant_t *p8est_mesh_quadrant_cumulative (p8est_t * p8est, p8est_mesh_t * mesh, p4est_locidx_t cumulative_id, p4est_topidx_t * which_tree, p4est_locidx_t * quadrant_id);
P4est.LibP4est.p8est_new
— Methodp8est_new(mpicomm, connectivity, data_size, init_fn, user_pointer)
Prototype
p8est_t *p8est_new (sc_MPI_Comm mpicomm, p8est_connectivity_t * connectivity, size_t data_size, p8est_init_t init_fn, void *user_pointer);
P4est.LibP4est.p8est_new_ext
— Methodp8est_new_ext(mpicomm, connectivity, min_quadrants, min_level, fill_uniform, data_size, init_fn, user_pointer)
Prototype
p8est_t *p8est_new_ext (sc_MPI_Comm mpicomm, p8est_connectivity_t * connectivity, p4est_locidx_t min_quadrants, int min_level, int fill_uniform, size_t data_size, p8est_init_t init_fn, void *user_pointer);
P4est.LibP4est.p8est_partition
— Methodp8est_partition(p8est_, allow_for_coarsening, 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).
On one process, the function noops and does not call the weight callback. Otherwise, the weight callback is called once per quadrant in order.
Parameters
p8est
:[in,out] The forest that will be partitioned.allow_for_coarsening
:[in] Slightly modify partition such that quadrant families are not split between ranks.weight_fn
:[in] A weighting function or NULL for uniform partitioning. When running with mpisize == 1, never called. Otherwise, called in order for all quadrants if not NULL. 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.
Prototype
void p8est_partition (p8est_t * p8est, int allow_for_coarsening, p8est_weight_t weight_fn);
P4est.LibP4est.p8est_partition_ext
— Methodp8est_partition_ext(p8est_, partition_for_coarsening, 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
p8est
:[in,out] The forest that will be partitioned.partition_for_coarsening
:[in] If true, the partition is modified to allow one level of coarsening.weight_fn
:[in] A 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
Prototype
p4est_gloidx_t p8est_partition_ext (p8est_t * p8est, int partition_for_coarsening, p8est_weight_t weight_fn);
P4est.LibP4est.p8est_partition_for_coarsening
— Methodp8est_partition_for_coarsening(p8est_, num_quadrants_in_proc)
Correct partition to allow one level of coarsening.
Parameters
p8est
:[in] forest whose partition is correctednum_quadrants_in_proc
:[in,out] partition that will be corrected
Returns
absolute number of moved quadrants
Prototype
p4est_gloidx_t p8est_partition_for_coarsening (p8est_t * p8est, p4est_locidx_t * num_quadrants_in_proc);
P4est.LibP4est.p8est_partition_lnodes
— Methodp8est_partition_lnodes(p8est_, ghost, degree, partition_for_coarsening)
Partition using weights based on the number of nodes assigned to each element in lnodes
Parameters
p8est
:[in,out] the forest to be repartitionedghost
:[in] the ghost layerdegree
:[in] the degree that would be passed top8est_lnodes_new
()partition_for_coarsening
:[in] whether the partition should allow coarsening (i.e. group siblings who might merge)
Prototype
void p8est_partition_lnodes (p8est_t * p8est, p8est_ghost_t * ghost, int degree, int partition_for_coarsening);
P4est.LibP4est.p8est_partition_lnodes_detailed
— Methodp8est_partition_lnodes_detailed(p4est_, ghost, nodes_per_volume, nodes_per_face, nodes_per_edge, nodes_per_corner, partition_for_coarsening)
Partition using weights that are broken down by where they reside: in volumes, on faces, on edges, or on corners.
Prototype
void p8est_partition_lnodes_detailed (p8est_t * p4est, p8est_ghost_t * ghost, int nodes_per_volume, int nodes_per_face, int nodes_per_edge, int nodes_per_corner, int partition_for_coarsening);
P4est.LibP4est.p8est_qcoord_to_vertex
— Methodp8est_qcoord_to_vertex(connectivity, treeid, x, y, z, vxyz)
Transform a quadrant coordinate into the space spanned by tree vertices.
Parameters
connectivity
:[in] Connectivity must provide the vertices.treeid
:[in] Identify the tree that contains x, y, z.x,
:[in] y, z Quadrant coordinates relative to treeid.vxyz
:[out] Transformed coordinates in vertex space.
Prototype
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]);
P4est.LibP4est.p8est_quadrant_exists
— Methodp8est_quadrant_exists(p8est_, ghost, treeid, q, exists_arr, rproc_arr, rquad_arr)
Checks if quadrant exists in the local forest or the ghost layer.
For quadrants across tree corners it checks if the quadrant exists in any of the corner neighbors, thus it can execute multiple queries.
Parameters
p8est
:[in] The forest in which to search for qghost
:[in] The ghost layer in which to search for qtreeid
:[in] The tree to which q belongs (can be extended).q
:[in] The quadrant that is being searched for.exists_arr
:[in,out] Must exist and be of of elem_size = sizeof (int) for inter-tree corner cases. Is resized by this function to one entry for each corner search and set to true/false depending on its existence in the local forest or ghost_layer.rproc_arr
:[in,out] If not NULL is filled with one rank per query.rquad_arr
:[in,out] If not NULL is filled with one quadrant per query. Its piggy3 member is defined as well.
Returns
true if the quadrant exists in the local forest or in the ghost_layer, and false if doesn't exist in either.
Prototype
int p8est_quadrant_exists (p8est_t * p8est, p8est_ghost_t * ghost, p4est_topidx_t treeid, const p8est_quadrant_t * q, sc_array_t * exists_arr, sc_array_t * rproc_arr, sc_array_t * rquad_arr);
P4est.LibP4est.p8est_quadrant_find_owner
— Methodp8est_quadrant_find_owner(p8est_, treeid, face, q)
Gets the processor id of a quadrant's owner. The quadrant can lie outside of a tree across faces (and only faces).
Does not work for tree edge or corner neighbors.
Parameters
p8est
:[in] The forest in which to search for a quadrant.treeid
:[in] The tree to which the quadrant belongs.face
:[in] Supply a face direction if known, or -1 otherwise.q
:[in] The quadrant that is being searched for.
Returns
Processor id of the owner or -1 if the quadrant lies outside of the mesh.
Prototype
int p8est_quadrant_find_owner (p8est_t * p8est, p4est_topidx_t treeid, int face, const p8est_quadrant_t * q);
P4est.LibP4est.p8est_quadrant_linear_id_ext128
— Methodp8est_quadrant_linear_id_ext128(quadrant, level, id)
Computes the linear position as p8est_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 p4estquadrantset_morton.
The user_data of quadrant is never modified.
Parameters
quadrant
:[in] Quadrant 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.level
:[in] The level of the regular grid compared to which the linear position is to be computed.id
:[in,out] A pointer to an allocated or staticp8est_lid_t
. id will be the linear position of this quadrant on a uniform grid.
Prototype
void p8est_quadrant_linear_id_ext128 (const p8est_quadrant_t * quadrant, int level, p8est_lid_t * id);
P4est.LibP4est.p8est_quadrant_set_morton_ext128
— Methodp8est_quadrant_set_morton_ext128(quadrant, level, id)
Set quadrant Morton indices based on linear position given as p8est_lid_t
in uniform grid. This is the inverse operation of p4estquadrantlinear_id.
The user_data of quadrant is never modified.
Parameters
quadrant
:[in,out] Quadrant whose Morton indices will be set.level
:[in] Level of the grid and of the resulting quadrant.id
:[in] Linear index of the quadrant on a uniform grid.
Prototype
void p8est_quadrant_set_morton_ext128 (p8est_quadrant_t * quadrant, int level, const p8est_lid_t * id);
P4est.LibP4est.p8est_refine
— Methodp8est_refine(p8est_, refine_recursive, refine_fn, init_fn)
Refine a forest.
Parameters
p8est
:[in,out] The forest is changed in place.refine_recursive
:[in] Boolean to decide on recursive refinement.refine_fn
:[in] 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 usep8est_refine_ext
in p8est_extended.h and examine whether replace_fn gets called.init_fn
:[in] Callback function to initialize the user_data of newly created quadrants, which is already allocated. This function pointer may be NULL.
Prototype
void p8est_refine (p8est_t * p8est, int refine_recursive, p8est_refine_t refine_fn, p8est_init_t init_fn);
P4est.LibP4est.p8est_refine_ext
— Methodp8est_refine_ext(p8est_, refine_recursive, maxlevel, refine_fn, init_fn, replace_fn)
Refine a forest with a bounded refinement level and a replace option.
Parameters
p8est
:[in,out] The forest is changed in place.refine_recursive
:[in] Boolean to decide on recursive refinement.maxlevel
:[in] Maximum allowed refinement level (inclusive). If this is negative the level is restricted only by the compile-time constant QMAXLEVEL inp8est.h
.refine_fn
:[in] 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.init_fn
:[in] Callback function to initialize the user_data for newly created quadrants, which is guaranteed to be allocated. This function pointer may be NULL.replace_fn
:[in] Callback function that allows the user to change incoming quadrants based on the quadrants they replace; may be NULL.
Prototype
void p8est_refine_ext (p8est_t * p8est, int refine_recursive, int maxlevel, p8est_refine_t refine_fn, p8est_init_t init_fn, p8est_replace_t replace_fn);
P4est.LibP4est.p8est_reset_data
— Methodp8est_reset_data(p8est_, data_size, init_fn, 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.
Parameters
data_size
:[in] This is the size of data for each quadrant which can be zero. Then user_data_pool is set to NULL.init_fn
:[in] Callback function to initialize the user_data which is already allocated automatically. May be NULL.user_pointer
:[in] Assign to the user_pointer member of thep8est
before init_fn is called the first time.
Prototype
void p8est_reset_data (p8est_t * p8est, size_t data_size, p8est_init_t init_fn, void *user_pointer);
P4est.LibP4est.p8est_revision
— Methodp8est_revision(p8est_)
Return the revision counter of the forest. Not collective, even though the revision value is the same on all ranks. A newly created forest starts with a revision counter of zero. Every refine, coarsen, partition, and balance that actually changes the mesh increases the counter by one. Operations with no effect keep the old value.
Parameters
p8est
:[in] The forest must be valid.
Returns
Non-negative number.
Prototype
long p8est_revision (p8est_t * p8est);
P4est.LibP4est.p8est_save
— Methodp8est_save(filename, p8est_, 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.
The revision counter is not saved to the file, since that would make files different that come from different revisions but store the same mesh.
Aborts on file errors.
If p4est
is not configured to use MPI-IO, some processes return from this function before the file is complete, in which case immediate read-access to the file may require a call to sc_MPI_Barrier
.
Parameters
filename
:[in] Name of the file to write.p8est
:[in] Valid forest structure.save_data
:[in] If true, the element data is saved. Otherwise, a data size of 0 is saved.
Prototype
void p8est_save (const char *filename, p8est_t * p8est, int save_data);
P4est.LibP4est.p8est_save_ext
— Methodp8est_save_ext(filename, p8est_, save_data, save_partition)
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. See p8est_load_ext
for information on the autopartition parameter.
Aborts on file errors.
Parameters
filename
:[in] Name of the file to write.p8est
:[in] Valid forest structure.save_data
:[in] If true, the element data is saved. Otherwise, a data size of 0 is saved.save_partition
:[in] 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.
Prototype
void p8est_save_ext (const char *filename, p8est_t * p8est, int save_data, int save_partition);
P4est.LibP4est.p8est_search
— Methodp8est_search(p4est_, quadrant_fn, point_fn, points)
This function is provided for backwards compatibility. We call p8estsearchlocal with call_post = 0.
Prototype
void p8est_search (p8est_t * p4est, p8est_search_query_t quadrant_fn, p8est_search_query_t point_fn, sc_array_t * points);
P4est.LibP4est.p8est_search_all
— Methodp8est_search_all(p4est_, call_post, quadrant_fn, point_fn, points)
Perform a top-down search on the whole forest.
This function combines the functionality of p4estsearchlocal and p4estsearchpartition; their documentation applies for the most part.
The recursion proceeds from the root quadrant of each tree until (a) we encounter a remote quadrant that covers only one processor, or (b) we encounter a local leaf quadrant. In other words, we proceed with the recursion into a quadrant's children if (a) the quadrant is split between two or more processors, no matter whether one of them is the calling processor or not, or (b) if the quadrant is on the local processor but we have not reached a leaf yet.
The search can track one or more points, which are abstract placeholders. They are matched against the quadrants traversed using a callback function. The result of the callback function can be used to stop a recursion early. The user determines how a point is interpreted, we only pass it around.
Note that in the remote case (a), we may terminate the recursion even if the quadrant is not a leaf, which we have no means of knowing. Still, this case is sufficient to determine the processor ownership of a point.
This is a very powerful function that can become slow if not used carefully.
As with the two other search functions in this file, calling it once with many points is generally much faster than calling it once for each point. Using multiple points also allows for a per-quadrant termination of the recursion in addition to a more costly per-point termination.
This function works fine when used for the special cases that either the partition or the local quadrants are not of interest. However, in the case of querying only local information we expect that p4estsearchlocal will be faster since it employs specific local optimizations.
Parameters
p4est
:[in] The forest to be searched.call_post
:[in] If true, call quadrant callback both pre and post.quadrant_fn
:[in] Executed once for each quadrant that is entered. If the callback returns false, this quadrant and its descendants are excluded from the search, and the points in this branch are not queried further. Its point argument is always NULL. Callback may be NULL in which case it is ignored.point_fn
:[in] Executed once for each point that is relevant for a quadrant of the search. If it returns true, the point is tracked further down that branch, else it is discarded from the queries for the children. If points is not NULL, this callback must be not NULL. If points is NULL, it is not called.points
:[in] User-defined array of points. We do not interpret a point, just pass it into the callbacks. If NULL, only the quadrant_fn callback is executed. If that is NULL, the whole function noops. If not NULL, the point_fn is called on its members during the search.
Prototype
void p8est_search_all (p8est_t * p4est, int call_post, p8est_search_all_t quadrant_fn, p8est_search_all_t point_fn, sc_array_t * points);
P4est.LibP4est.p8est_search_local
— Methodp8est_search_local(p4est_, call_post, quadrant_fn, point_fn, points)
Search through the local part of a forest. The search is especially efficient if multiple targets, called "points" below, are searched for simultaneously.
The search runs over all local quadrants and proceeds recursively top-down. For each tree, it may start at the root of that tree, or further down at the root of the subtree that contains all of the tree's local quadrants. Likewise, some intermediate levels in the recursion may be skipped if the processor-local part is contained in a single deeper subtree. The outer loop is thus a depth-first, processor-local forest traversal. Each quadrant in that loop either is a leaf, or a (direct or indirect) strict ancestor of a leaf. On entering a new quadrant, a user-provided quadrant-callback is executed.
As a convenience, the user may provide anonymous "points" that are tracked down the forest. This way one search call may be used for multiple targets. The set of points that potentially matches a given quadrant diminishes from the root down to the leaves: For each quadrant, an inner loop over the potentially matching points executes a point-callback for each candidate that determines whether the point may be a match. If not, it is discarded in the current branch, otherwise it is passed to the next deeper level. The callback is allowed to return true for the same point and more than one quadrant; in this case more than one matching quadrant may be identified. The callback is also allowed to return false for all children of a quadrant that it returned true for earlier. If the point callback returns false for all points relevant to a quadrant, the recursion stops. The points can really be anything, p4est
does not perform any interpretation, just passes the pointer along to the callback function.
If points are present and the first quadrant callback returned true, we execute it a second time after calling the point callback for all current points. This can be used to gather and postprocess information about the points more easily. If it returns false, the recursion stops.
If the points are a NULL array, they are ignored and the recursion proceeds by querying the per-quadrant callback. If the points are not NULL but an empty array, the recursion will stop immediately!
Parameters
p4est
:[in] The forest to be searched.call_post
:[in] If true, call quadrant callback both pre and post.quadrant_fn
:[in] Executed once when a quadrant is entered, and once when it is left (the second time only if points are present and the first call returned true). This quadrant is always local, if not completely than at least one descendant of it. If the callback returns false, this quadrant and its descendants are excluded from the search recursion. Its point argument is always NULL. Callback may be NULL in which case it is ignored.point_fn
:[in] If points is not NULL, must be not NULL. Shall return true for any possible matching point. If points is NULL, this callback is ignored.points
:[in] User-defined array of "points". If NULL, only the quadrant_fn callback is executed. If that is NULL, this function noops. If not NULL, the point_fn is called on its members during the search.
Prototype
void p8est_search_local (p8est_t * p4est, int call_post, p8est_search_local_t quadrant_fn, p8est_search_local_t point_fn, sc_array_t * points);
P4est.LibP4est.p8est_search_partition
— Methodp8est_search_partition(p4est_, call_post, quadrant_fn, point_fn, points)
Traverse the global partition top-down. We proceed top-down through the partition, identically on all processors except for the results of two user-provided callbacks. The recursion will only go down branches that are split between multiple processors. The callback functions can be used to stop a branch recursion even for split branches. This function offers the option to search for arbitrary user-defined points analogously to p4estsearchlocal.
Traversing the whole processor partition will be at least O(P), so sensible use of the callback function is advised to cut it short.
Parameters
p4est
:[in] The forest to traverse. Its local quadrants are never accessed.call_post
:[in] If true, call quadrant callback both pre and post.quadrant_fn
:[in] This function controls the recursion, which only continues deeper if this callback returns true for a branch quadrant. It is allowed to set this to NULL.point_fn
:[in] This function decides per-point whether it is followed down the recursion. Must be non-NULL if points are not NULL.points
:[in] User-provided array of points that are passed to the callback point_fn. See p8estsearchlocal for details.
Prototype
void p8est_search_partition (p8est_t * p4est, int call_post, p8est_search_partition_t quadrant_fn, p8est_search_partition_t point_fn, sc_array_t * points);
P4est.LibP4est.p8est_source_ext
— Methodp8est_source_ext(src, mpicomm, data_size, load_data, autopartition, broadcasthead, user_pointer, connectivity)
Prototype
p8est_t *p8est_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, p8est_connectivity_t ** connectivity);
P4est.LibP4est.p8est_split_array
— Methodp8est_split_array(array, level, indices)
Split an array of quadrants by the children of an ancestor.
Given a sorted array of quadrants that have a common ancestor at level level, compute the indices of the first quadrant in each of the common ancestor's children at level level + 1.
Parameters
array
:[in] The sorted array of quadrants of level > level.level
:[in] The level at which there is a common ancestor.indices
:[in,out] The indices of the first quadrant in each of the ancestors's children, plus an additional index on the end. The quadrants of array that are descendants of child i have indices between indices[i] and indices[i + 1] - 1. If indices[i] = indices[i+1], this indicates that no quadrant in the array is contained in child i.
Prototype
void p8est_split_array (sc_array_t * array, int level, size_t indices[]);
P4est.LibP4est.sc_abort
— Methodsc_abort()
Print a stack trace, call the abort handler and then call abort ().
Prototype
void sc_abort (void) __attribute__ ((noreturn));
P4est.LibP4est.sc_abort_collective
— Methodsc_abort_collective(msg)
Collective abort where only root prints a message
Prototype
void sc_abort_collective (const char *msg) __attribute__ ((noreturn));
P4est.LibP4est.sc_abort_verbose
— Methodsc_abort_verbose(filename, lineno, msg)
Print a message to stderr and then call sc_abort
().
Prototype
void sc_abort_verbose (const char *filename, int lineno, const char *msg) __attribute__ ((noreturn));
P4est.LibP4est.sc_array_bsearch
— Methodsc_array_bsearch(array, key, compar)
Performs a binary search on an array. The array must be sorted.
Parameters
array
:[in] A sorted array to search in.key
:[in] An element to be searched for.compar
:[in] The comparison function to be used.
Returns
Returns the index into array for the item found, or -1.
Prototype
ssize_t sc_array_bsearch (sc_array_t * array, const void *key, int (*compar) (const void *, const void *));
P4est.LibP4est.sc_array_checksum
— Methodsc_array_checksum(array)
Computes the adler32 checksum of array data (see zlib documentation). This is a faster checksum than crc32, and it works with zeros as data.
Prototype
unsigned int sc_array_checksum (sc_array_t * array);
P4est.LibP4est.sc_array_copy
— Methodsc_array_copy(dest, src)
Copy the contents of one array into another. Both arrays must have equal element sizes. The source array may be a view. We use memcpy (3): If the two arrays overlap, results are undefined.
Parameters
dest
:[in] Array (not a view) will be resized and get new data.src
:[in] Array used as source of new data, will not be changed.
Prototype
void sc_array_copy (sc_array_t * dest, sc_array_t * src);
P4est.LibP4est.sc_array_copy_into
— Methodsc_array_copy_into(dest, dest_offset, src)
Copy the contents of one array into some portion of another. Both arrays must have equal element sizes. Either array may be a view. The destination array must be large enough. We use memcpy (3): If the two arrays overlap, results are undefined.
Parameters
dest
:[in] Array will be written into. Its element count must be at least dest_offset + src->elem_count.dest_offset
:[in] First index in dest array to be overwritten. As every index, it refers to elements, not bytes.src
:[in] Array used as source of new data, will not be changed.
Prototype
void sc_array_copy_into (sc_array_t * dest, size_t dest_offset, sc_array_t * src);
P4est.LibP4est.sc_array_destroy
— Methodsc_array_destroy(array)
Destroys an array structure.
Parameters
array
:[in] The array to be destroyed.
Prototype
void sc_array_destroy (sc_array_t * array);
P4est.LibP4est.sc_array_destroy_null
— Methodsc_array_destroy_null(parray)
Destroys an array structure and sets the pointer to NULL.
Parameters
parray
:[in,out] Pointer to address of array to be destroyed. On output, *parray is NULL.
Prototype
void sc_array_destroy_null (sc_array_t ** parray);
P4est.LibP4est.sc_array_init
— Methodsc_array_init(array, elem_size)
Initializes an already allocated (or static) array structure.
Parameters
array
:[in,out] Array structure to be initialized.elem_size
:[in] Size of one array element in bytes.
Prototype
void sc_array_init (sc_array_t * array, size_t elem_size);
P4est.LibP4est.sc_array_init_count
— Methodsc_array_init_count(array, elem_size, elem_count)
Initializes an already allocated (or static) array structure and allocates a given number of elements. This function supersedes scarrayinit_size.
Parameters
array
:[in,out] Array structure to be initialized.elem_size
:[in] Size of one array element in bytes.elem_count
:[in] Number of initial array elements.
Prototype
void sc_array_init_count (sc_array_t * array, size_t elem_size, size_t elem_count);
P4est.LibP4est.sc_array_init_data
— Methodsc_array_init_data(view, base, elem_size, elem_count)
Initializes an already allocated (or static) view from given plain C data. The array view returned does not require sc_array_reset
(doesn't hurt though).
Parameters
view
:[in,out] Array structure to be initialized.base
:[in] The data must not be moved while view is alive.elem_size
:[in] Size of one array element in bytes.elem_count
:[in] The length of the view in element units. The view cannot be resized to exceed this length. It is not necessary to callsc_array_reset
later.
Prototype
void sc_array_init_data (sc_array_t * view, void *base, size_t elem_size, size_t elem_count);
P4est.LibP4est.sc_array_init_size
— Methodsc_array_init_size(array, elem_size, elem_count)
Initializes an already allocated (or static) array structure and allocates a given number of elements. Deprecated: use scarrayinit_count.
Parameters
array
:[in,out] Array structure to be initialized.elem_size
:[in] Size of one array element in bytes.elem_count
:[in] Number of initial array elements.
Prototype
void sc_array_init_size (sc_array_t * array, size_t elem_size, size_t elem_count);
P4est.LibP4est.sc_array_init_view
— Methodsc_array_init_view(view, array, offset, length)
Initializes an already allocated (or static) view from existing sc_array_t
. The array view returned does not require sc_array_reset
(doesn't hurt though).
Parameters
view
:[in,out] Array structure to be initialized.array
:[in] The array must not be resized while view is alive.offset
:[in] The offset of the viewed section in element units. This offset cannot be changed until the view is reset.length
:[in] The length of the view in element units. The view cannot be resized to exceed this length. It is not necessary to callsc_array_reset
later.
Prototype
void sc_array_init_view (sc_array_t * view, sc_array_t * array, size_t offset, size_t length);
P4est.LibP4est.sc_array_is_equal
— Methodsc_array_is_equal(array, other)
Check whether two arrays have equal size, count, and content. Either array may be a view. Both arrays will not be changed.
Parameters
array
:[in] One array to be compared.other
:[in] A second array to be compared.
Returns
True if array and other are equal, false otherwise.
Prototype
int sc_array_is_equal (sc_array_t * array, sc_array_t * other);
P4est.LibP4est.sc_array_is_permutation
— Methodsc_array_is_permutation(array)
Determine whether array is an array of size_t's whose entries include every integer 0 <= i < array->elem_count.
Parameters
array
:[in] An array.
Returns
Returns 1 if array contains size_t elements whose entries include every integer 0 <= i < array->elem_count, 0 otherwise.
Prototype
int sc_array_is_permutation (sc_array_t * array);
P4est.LibP4est.sc_array_is_sorted
— Methodsc_array_is_sorted(array, compar)
Check whether the array is sorted wrt. the comparison function.
Parameters
array
:[in] The array to check.compar
:[in] The comparison function to be used.
Returns
True if array is sorted, false otherwise.
Prototype
int sc_array_is_sorted (sc_array_t * array, int (*compar) (const void *, const void *));
P4est.LibP4est.sc_array_memory_used
— Methodsc_array_memory_used(array, is_dynamic)
Calculate the memory used by an array.
Parameters
array
:[in] The array.is_dynamic
:[in] True if created withsc_array_new
, false if initialized withsc_array_init
Returns
Memory used in bytes.
Prototype
size_t sc_array_memory_used (sc_array_t * array, int is_dynamic);
P4est.LibP4est.sc_array_memset
— Methodsc_array_memset(array, c)
Run memset on the array storage. We pass the character to memset unchanged. Thus, care must be taken when setting values below -1 or above 127, just as with standard memset (3).
Parameters
array
:[in,out] This array's storage will be overwritten.c
:[in] Character to overwrite every byte with.
Prototype
void sc_array_memset (sc_array_t * array, int c);
P4est.LibP4est.sc_array_move_part
— Methodsc_array_move_part(dest, dest_offset, src, src_offset, count)
Copy part of one array into another using memmove (3). Both arrays must have equal element sizes. Either array may be a view. The destination array must be large enough. We use memmove (3): The two arrays may overlap.
Parameters
dest
:[in] Array will be written into. Its element count must be at least dest_offset + count.dest_offset
:[in] First index in dest array to be overwritten. As every index, it refers to elements, not bytes.src
:[in] Array will be read from. Its element count must be at least src_offset + count.src_offset
:[in] First index in src array to be used. As every index, it refers to elements, not bytes.count
:[in] Number of entries copied.
Prototype
void sc_array_move_part (sc_array_t * dest, size_t dest_offset, sc_array_t * src, size_t src_offset, size_t count);
P4est.LibP4est.sc_array_new
— Methodsc_array_new(elem_size)
Creates a new array structure with 0 elements.
Parameters
elem_size
:[in] Size of one array element in bytes.
Returns
Return an allocated array of zero length.
Prototype
sc_array_t *sc_array_new (size_t elem_size);
P4est.LibP4est.sc_array_new_count
— Methodsc_array_new_count(elem_size, elem_count)
Creates a new array structure with a given length (number of elements).
Parameters
elem_size
:[in] Size of one array element in bytes.elem_count
:[in] Initial number of array elements.
Returns
Return an allocated array with allocated but uninitialized elements.
Prototype
sc_array_t *sc_array_new_count (size_t elem_size, size_t elem_count);
P4est.LibP4est.sc_array_new_data
— Methodsc_array_new_data(base, elem_size, elem_count)
Creates a new view of an existing plain C array.
Parameters
base
:[in] The data must not be moved while view is alive.elem_size
:[in] Size of one array element in bytes.elem_count
:[in] The length of the view in element units. The view cannot be resized to exceed this length.
Prototype
sc_array_t *sc_array_new_data (void *base, size_t elem_size, size_t elem_count);
P4est.LibP4est.sc_array_new_view
— Methodsc_array_new_view(array, offset, length)
Creates a new view of an existing sc_array_t
.
Parameters
array
:[in] The array must not be resized while view is alive.offset
:[in] The offset of the viewed section in element units. This offset cannot be changed until the view is reset.length
:[in] The length of the viewed section in element units. The view cannot be resized to exceed this length.
Prototype
sc_array_t *sc_array_new_view (sc_array_t * array, size_t offset, size_t length);
P4est.LibP4est.sc_array_permute
— Methodsc_array_permute(array, newindices, keepperm)
Given permutation newindices, permute array in place. The data that on input is contained in array[i] will be contained in array[newindices[i]] on output. The entries of newindices will be altered unless keepperm is true.
Parameters
array
:[in,out] An array.newindices
:[in,out] Permutation array (seesc_array_is_permutation
).keepperm
:[in] If true, newindices will be unchanged by the algorithm; if false, newindices will be the identity permutation on output, but the algorithm will only use O(1) space.
Prototype
void sc_array_permute (sc_array_t * array, sc_array_t * newindices, int keepperm);
P4est.LibP4est.sc_array_pqueue_add
— Methodsc_array_pqueue_add(array, temp, compar)
Adds an element to a priority queue. PQUEUE FUNCTIONS ARE UNTESTED AND CURRENTLY DISABLED. This function is not allowed for views. The priority queue is implemented as a heap in ascending order. A heap is a binary tree where the children are not less than their parent. Assumes that elements [0]..[elem_count-2] form a valid heap. Then propagates [elem_count-1] upward by swapping if necessary.
If the return value is zero for all elements in an array, the array is sorted linearly and unchanged.
Parameters
temp
:[in] Pointer to unused allocated memory of elem_size.compar
:[in] The comparison function to be used.
Returns
Returns the number of swap operations.
Prototype
size_t sc_array_pqueue_add (sc_array_t * array, void *temp, int (*compar) (const void *, const void *));
P4est.LibP4est.sc_array_pqueue_pop
— Methodsc_array_pqueue_pop(array, result, compar)
Pops the smallest element from a priority queue. PQUEUE FUNCTIONS ARE UNTESTED AND CURRENTLY DISABLED. This function is not allowed for views. This function assumes that the array forms a valid heap in ascending order.
This function resizes the array to elem_count-1.
Parameters
result
:[out] Pointer to unused allocated memory of elem_size.compar
:[in] The comparison function to be used.
Returns
Returns the number of swap operations.
Prototype
size_t sc_array_pqueue_pop (sc_array_t * array, void *result, int (*compar) (const void *, const void *));
P4est.LibP4est.sc_array_reset
— Methodsc_array_reset(array)
Sets the array count to zero and frees all elements. This function turns a view into a newly initialized array.
Calling sc_array_init
, then any array operations, then sc_array_reset
is memory neutral. As an exception, the two functions sc_array_init_view
and sc_array_init_data
do not require a subsequent call to sc_array_reset
. Regardless, it is legal to call sc_array_reset
anyway.
Parameters
array
:[in,out] Array structure to be reset.
Prototype
void sc_array_reset (sc_array_t * array);
P4est.LibP4est.sc_array_resize
— Methodsc_array_resize(array, new_count)
Sets the element count to new_count. If the array is not a view, reallocation takes place occasionally. If the array is a view, new_count must not be greater than the element count of the view when it was created. The original offset of the view cannot be changed.
Parameters
array
:[in,out] The element count and address is modified.new_count
:[in] New element count of the array. If it is zero and the array is not a view, the effect equals scarrayreset.
Prototype
void sc_array_resize (sc_array_t * array, size_t new_count);
P4est.LibP4est.sc_array_rewind
— Methodsc_array_rewind(array, new_count)
Shorten an array without reallocating it.
Parameters
array
:[in,out] The element count of this array is modified.new_count
:[in] Must be less or equal than the array's count. If it is less, the number of elements in the array is reduced without reallocating memory. The exception is a new_count of zero specified for an array that is not a view: In this case scarrayreset is equivalent.
Prototype
void sc_array_rewind (sc_array_t * array, size_t new_count);
P4est.LibP4est.sc_array_sort
— Methodsc_array_sort(array, compar)
Sorts the array in ascending order wrt. the comparison function.
Parameters
array
:[in] The array to sort.compar
:[in] The comparison function to be used.
Prototype
void sc_array_sort (sc_array_t * array, int (*compar) (const void *, const void *));
P4est.LibP4est.sc_array_split
— Methodsc_array_split(array, offsets, num_types, type_fn, data)
Compute the offsets of groups of enumerable types in an array.
Parameters
array
:[in] Array that is sorted in ascending order by type. If k indexes array, then 0 <= type_fn (array, k, data) < num_types.offsets
:[in,out] An initialized array of type size_t that is resized to num_types + 1 entries. The indices j of array that contain objects of type k are offsets[k] <= j < offsets[k + 1]. If there are no objects of type k, then offsets[k] = offset[k + 1].num_types
:[in] The number of possible types of objects in array.type_fn
:[in] Returns the type of an object in the array.data
:[in] Arbitrary user data passed to type_fn.
Prototype
void sc_array_split (sc_array_t * array, sc_array_t * offsets, size_t num_types, sc_array_type_t type_fn, void *data);
P4est.LibP4est.sc_array_truncate
— Methodsc_array_truncate(array)
Sets the array count to zero, but does not free elements. Not allowed for views.
This is intended to allow an sc_array
to be used as a reusable buffer, where the "high water mark" of the buffer is preserved, so that O(log (max n)) reallocs occur over the life of the buffer.
Parameters
array
:[in,out] Array structure to be truncated.
Prototype
void sc_array_truncate (sc_array_t * array);
P4est.LibP4est.sc_array_uniq
— Methodsc_array_uniq(array, compar)
Removed duplicate entries from a sorted array. This function is not allowed for views.
Parameters
array
:[in,out] The array size will be reduced as necessary.compar
:[in] The comparison function to be used.
Prototype
void sc_array_uniq (sc_array_t * array, int (*compar) (const void *, const void *));
P4est.LibP4est.sc_atoi
— Methodsc_atoi(nptr)
Safe version of the standard library atoi (3) function.
Parameters
nptr
:[in] NUL-terminated string.
Returns
Converted integer value. 0 if no valid number. INT_MAX on overflow, INT_MIN on underflow.
Prototype
int sc_atoi (const char *nptr);
P4est.LibP4est.sc_atol
— Methodsc_atol(nptr)
Safe version of the standard library atol (3) function.
Parameters
nptr
:[in] NUL-terminated string.
Returns
Converted long value. 0 if no valid number. LONG_MAX on overflow, LONG_MIN on underflow.
Prototype
long sc_atol (const char *nptr);
P4est.LibP4est.sc_calloc
— Methodsc_calloc(package, nmemb, size)
Prototype
void *sc_calloc (int package, size_t nmemb, size_t size);
P4est.LibP4est.sc_double_compare
— Methodsc_double_compare(v1, v2)
Prototype
int sc_double_compare (const void *v1, const void *v2);
P4est.LibP4est.sc_fflush_fsync_fclose
— Methodsc_fflush_fsync_fclose(file)
Best effort to flush a file's data to disc and close it.
Parameters
file
:[in,out] File open for writing.
Prototype
void sc_fflush_fsync_fclose (FILE * file);
P4est.LibP4est.sc_finalize
— Methodsc_finalize()
Unregisters all packages, runs the memory check, removes the signal handlers and resets sc_identifier and sc_root_*. This function aborts on any inconsistency found unless the global variable default_abort_mismatch is false. This function is optional. This function does not require sc_init
to be called first.
Prototype
void sc_finalize (void);
P4est.LibP4est.sc_finalize_noabort
— Methodsc_finalize_noabort()
Unregisters all packages, runs the memory check, removes the signal handlers and resets sc_identifier and sc_root_*. This function never aborts but returns the number of errors encountered. This function is optional. This function does not require sc_init
to be called first.
Returns
0 when everything is consistent, nonzero otherwise.
Prototype
int sc_finalize_noabort (void);
P4est.LibP4est.sc_fread
— Methodsc_fread(ptr, size, nmemb, file, errmsg)
Read file content into memory.
This function aborts on file errors.
Parameters
ptr
:[out] Data array to read from disk.size
:[in] Size of one array member.nmemb
:[in] Number of array members.file
:[in,out] File pointer, must be opened for reading.errmsg
:[in] Error message passed toSC_CHECK_ABORT
.
Prototype
void sc_fread (void *ptr, size_t size, size_t nmemb, FILE * file, const char *errmsg);
P4est.LibP4est.sc_free
— Methodsc_free(package, ptr)
Prototype
void sc_free (int package, void *ptr);
P4est.LibP4est.sc_fwrite
— Methodsc_fwrite(ptr, size, nmemb, file, errmsg)
Write memory content to a file.
This function aborts on file errors.
Parameters
ptr
:[in] Data array to write to disk.size
:[in] Size of one array member.nmemb
:[in] Number of array members.file
:[in,out] File pointer, must be opened for writing.errmsg
:[in] Error message passed toSC_CHECK_ABORT
.
Prototype
void sc_fwrite (const void *ptr, size_t size, size_t nmemb, FILE * file, const char *errmsg);
P4est.LibP4est.sc_hash_array_destroy
— Methodsc_hash_array_destroy(hash_array)
Destroy a hash array.
Prototype
void sc_hash_array_destroy (sc_hash_array_t * hash_array);
P4est.LibP4est.sc_hash_array_insert_unique
— Methodsc_hash_array_insert_unique(hash_array, v, position)
Insert an object into a hash array if it is not contained already. The object is not copied into the array. Use the return value for that. New objects are guaranteed to be added at the end of the array.
Parameters
v
:[in] A pointer to the object. Used for search only.position
:[out] If position != NULL, *position is set to the array position of the already contained, or if not present, the new object.
Returns
Returns NULL if the object is already contained. Otherwise returns its new address in the array.
Prototype
void *sc_hash_array_insert_unique (sc_hash_array_t * hash_array, void *v, size_t *position);
P4est.LibP4est.sc_hash_array_is_valid
— Methodsc_hash_array_is_valid(hash_array)
Check the internal consistency of a hash array.
Prototype
int sc_hash_array_is_valid (sc_hash_array_t * hash_array);
P4est.LibP4est.sc_hash_array_lookup
— Methodsc_hash_array_lookup(hash_array, v, position)
Check if an object is contained in a hash array.
Parameters
v
:[in] A pointer to the object.position
:[out] If position != NULL, *position is set to the array position of the already contained object if found.
Returns
Returns true if object is found, false otherwise.
Prototype
int sc_hash_array_lookup (sc_hash_array_t * hash_array, void *v, size_t *position);
P4est.LibP4est.sc_hash_array_memory_used
— Methodsc_hash_array_memory_used(ha)
Calculate the memory used by a hash array.
Parameters
ha
:[in] The hash array.
Returns
Memory used in bytes.
Prototype
size_t sc_hash_array_memory_used (sc_hash_array_t * ha);
P4est.LibP4est.sc_hash_array_new
— Methodsc_hash_array_new(elem_size, hash_fn, equal_fn, user_data)
Create a new hash array.
Parameters
elem_size
:[in] Size of one array element in bytes.hash_fn
:[in] Function to compute the hash value.equal_fn
:[in] Function to test two objects for equality.
Prototype
sc_hash_array_t *sc_hash_array_new (size_t elem_size, sc_hash_function_t hash_fn, sc_equal_function_t equal_fn, void *user_data);
P4est.LibP4est.sc_hash_array_rip
— Methodsc_hash_array_rip(hash_array, rip)
Extract the array data from a hash array and destroy everything else.
Parameters
hash_array
:[in] The hash array is destroyed after extraction.rip
:[in] Array structure that will be overwritten. All previous array data (if any) will be leaked. The filled array can be freed withsc_array_reset
.
Prototype
void sc_hash_array_rip (sc_hash_array_t * hash_array, sc_array_t * rip);
P4est.LibP4est.sc_hash_array_truncate
— Methodsc_hash_array_truncate(hash_array)
Remove all elements from the hash array.
Parameters
hash_array
:[in,out] Hash array to truncate.
Prototype
void sc_hash_array_truncate (sc_hash_array_t * hash_array);
P4est.LibP4est.sc_hash_destroy
— Methodsc_hash_destroy(hash)
Destroy a hash table.
If the allocator is owned, this runs in O(1), otherwise in O(N).
If allocator was provided in sc_hash_new
, it will not be destroyed.
Prototype
void sc_hash_destroy (sc_hash_t * hash);
P4est.LibP4est.sc_hash_destroy_null
— Methodsc_hash_destroy_null(phash)
Destroy a hash table and set its pointer to NULL. Destruction is done using schashdestroy.
Parameters
phash
:[in,out] Address of pointer to hash table. On output, pointer is NULLed.
Prototype
void sc_hash_destroy_null (sc_hash_t ** phash);
P4est.LibP4est.sc_hash_foreach
— Methodsc_hash_foreach(hash, fn)
Invoke a callback for every member of the hash table. The functions hash_fn and equal_fn are not called by this function.
Prototype
void sc_hash_foreach (sc_hash_t * hash, sc_hash_foreach_t fn);
P4est.LibP4est.sc_hash_function_string
— Methodsc_hash_function_string(s, u)
Compute a hash value from a null-terminated string. This hash function is NOT cryptographically safe! Use libcrypt then.
Parameters
s
:[in] Null-terminated string to be hashed.u
:[in] Not used.
Returns
The computed hash value as an unsigned integer.
Prototype
unsigned int sc_hash_function_string (const void *s, const void *u);
P4est.LibP4est.sc_hash_insert_unique
— Methodsc_hash_insert_unique(hash, v, found)
Insert an object into a hash table if it is not contained already.
Parameters
v
:[in] The object to be inserted.found
:[out] If found != NULL, *found is set to the address of the pointer to the already contained, or if not present, the new object. You can assign to **found to override.
Returns
Returns true if object is added, false if it is already contained.
Prototype
int sc_hash_insert_unique (sc_hash_t * hash, void *v, void ***found);
P4est.LibP4est.sc_hash_lookup
— Methodsc_hash_lookup(hash, v, found)
Check if an object is contained in the hash table.
Parameters
v
:[in] The object to be looked up.found
:[out] If found != NULL, *found is set to the address of the pointer to the already contained object if the object is found. You can assign to **found to override.
Returns
Returns true if object is found, false otherwise.
Prototype
int sc_hash_lookup (sc_hash_t * hash, void *v, void ***found);
P4est.LibP4est.sc_hash_memory_used
— Methodsc_hash_memory_used(hash)
Calculate the memory used by a hash table.
Parameters
hash
:[in] The hash table.
Returns
Memory used in bytes.
Prototype
size_t sc_hash_memory_used (sc_hash_t * hash);
P4est.LibP4est.sc_hash_new
— Methodsc_hash_new(hash_fn, equal_fn, user_data, allocator)
Create a new hash table. The number of hash slots is chosen dynamically.
Parameters
hash_fn
:[in] Function to compute the hash value.equal_fn
:[in] Function to test two objects for equality.user_data
:[in] User data passed through to the hash function.allocator
:[in] Memory allocator forsc_link_t
, can be NULL.
Prototype
sc_hash_t *sc_hash_new (sc_hash_function_t hash_fn, sc_equal_function_t equal_fn, void *user_data, sc_mempool_t * allocator);
P4est.LibP4est.sc_hash_print_statistics
— Methodsc_hash_print_statistics(package_id, log_priority, hash)
Compute and print statistical information about the occupancy.
Prototype
void sc_hash_print_statistics (int package_id, int log_priority, sc_hash_t * hash);
P4est.LibP4est.sc_hash_remove
— Methodsc_hash_remove(hash, v, found)
Remove an object from a hash table.
Parameters
v
:[in] The object to be removed.found
:[out] If found != NULL, *found is set to the object that is removed if that exists.
Returns
Returns true if object is found, false if is not contained.
Prototype
int sc_hash_remove (sc_hash_t * hash, void *v, void **found);
P4est.LibP4est.sc_hash_truncate
— Methodsc_hash_truncate(hash)
Remove all entries from a hash table in O(N).
If the allocator is owned, it calls sc_hash_unlink
and sc_mempool_truncate
. Otherwise, it calls sc_list_reset
on every hash slot which is slower.
Prototype
void sc_hash_truncate (sc_hash_t * hash);
P4est.LibP4est.sc_hash_unlink
— Methodsc_hash_unlink(hash)
Unlink all hash elements without returning them to the mempool.
If the allocator is not owned, this runs faster than sc_hash_truncate
, but is dangerous because of potential memory leaks.
Parameters
hash
:[in,out] Hash structure to be unlinked.
Prototype
void sc_hash_unlink (sc_hash_t * hash);
P4est.LibP4est.sc_hash_unlink_destroy
— Methodsc_hash_unlink_destroy(hash)
Same effect as unlink and destroy, but in O(1). This is dangerous because of potential memory leaks.
Parameters
hash
:[in] Hash structure to be unlinked and destroyed.
Prototype
void sc_hash_unlink_destroy (sc_hash_t * hash);
P4est.LibP4est.sc_init
— Methodsc_init(mpicomm, catch_signals, print_backtrace, log_handler, log_threshold)
Prototype
void sc_init (sc_MPI_Comm mpicomm, int catch_signals, int print_backtrace, sc_log_handler_t log_handler, int log_threshold);
P4est.LibP4est.sc_int16_compare
— Methodsc_int16_compare(v1, v2)
Prototype
int sc_int16_compare (const void *v1, const void *v2);
P4est.LibP4est.sc_int32_compare
— Methodsc_int32_compare(v1, v2)
Prototype
int sc_int32_compare (const void *v1, const void *v2);
P4est.LibP4est.sc_int64_compare
— Methodsc_int64_compare(v1, v2)
Prototype
int sc_int64_compare (const void *v1, const void *v2);
P4est.LibP4est.sc_int8_compare
— Methodsc_int8_compare(v1, v2)
Prototype
int sc_int8_compare (const void *v1, const void *v2);
P4est.LibP4est.sc_int_compare
— Methodsc_int_compare(v1, v2)
Prototype
int sc_int_compare (const void *v1, const void *v2);
P4est.LibP4est.sc_io_sink_align
— Methodsc_io_sink_align(sink, bytes_align)
Align sink to a byte boundary by writing zeros.
Parameters
sink
:[in,out] The sink object to align.bytes_align
:[in] Byte boundary.
Returns
0 on success, nonzero on error.
Prototype
int sc_io_sink_align (sc_io_sink_t * sink, size_t bytes_align);
P4est.LibP4est.sc_io_sink_complete
— Methodsc_io_sink_complete(sink, bytes_in, bytes_out)
Flush all buffered output data to sink. This function may return SC_IO_ERROR_AGAIN if another write is required. Currently this may happen if BUFFER requires an integer multiple of bytes. If successful, the updated value of bytes read and written is returned in bytes_in/out, and the sink status is reset as if the sink had just been created. In particular, the bytes counters are reset to zero. The internal state of the sink is not changed otherwise. It is legal to continue writing to the sink hereafter. The sink actions taken depend on its type. BUFFER, FILEFILE: none. FILENAME: call fclose on sink->file.
Parameters
sink
:[in,out] The sink object to write to.bytes_in
:[in,out] Bytes received since the last new or complete call. May be NULL.bytes_out
:[in,out] Bytes written since the last new or complete call. May be NULL.
Returns
0 if completed, nonzero on error.
Prototype
int sc_io_sink_complete (sc_io_sink_t * sink, size_t * bytes_in, size_t * bytes_out);
P4est.LibP4est.sc_io_sink_destroy
— Methodsc_io_sink_destroy(sink)
Free data sink. Calls sc_io_sink_complete
and discards the final counts. Errors from complete lead to SC_IO_ERROR_FATAL returned from this function. Call sc_io_sink_complete
yourself if bytes_out is of interest.
Parameters
sink
:[in,out] The sink object to complete and free.
Returns
0 on success, nonzero on error.
Prototype
int sc_io_sink_destroy (sc_io_sink_t * sink);
P4est.LibP4est.sc_io_sink_write
— Methodsc_io_sink_write(sink, data, bytes_avail)
Write data to a sink. Data may be buffered and sunk in a later call. The internal counters sink->bytes_in and sink->bytes_out are updated.
Parameters
sink
:[in,out] The sink object to write to.data
:[in] Data passed into sink.bytes_avail
:[in] Number of data bytes passed in.
Returns
0 on success, nonzero on error.
Prototype
int sc_io_sink_write (sc_io_sink_t * sink, const void *data, size_t bytes_avail);
P4est.LibP4est.sc_io_source_activate_mirror
— Methodsc_io_source_activate_mirror(source)
Activate a buffer that mirrors (i.e., stores) the data that was read.
Parameters
source
:[in,out] The source object to activate mirror in.
Returns
0 on success, nonzero on error.
Prototype
int sc_io_source_activate_mirror (sc_io_source_t * source);
P4est.LibP4est.sc_io_source_align
— Methodsc_io_source_align(source, bytes_align)
Align source to a byte boundary by skipping.
Parameters
source
:[in,out] The source object to align.bytes_align
:[in] Byte boundary.
Returns
0 on success, nonzero on error.
Prototype
int sc_io_source_align (sc_io_source_t * source, size_t bytes_align);
P4est.LibP4est.sc_io_source_complete
— Methodsc_io_source_complete(source, bytes_in, bytes_out)
Determine whether all data buffered from source has been returned by read. If it returns SC_IO_ERROR_AGAIN, another sc_io_source_read
is required. If the call returns no error, the internal counters source->bytes_in and source->bytes_out are returned to the caller if requested, and reset to 0. The internal state of the source is not changed otherwise. It is legal to continue reading from the source hereafter.
Parameters
source
:[in,out] The source object to read from.bytes_in
:[in,out] If not NULL and true is returned, the total size of the data sourced.bytes_out
:[in,out] If not NULL and true is returned, total bytes passed out by source_read.
Returns
SC_IO_ERROR_AGAIN if buffered data remaining. Otherwise return ERROR_NONE and reset counters.
Prototype
int sc_io_source_complete (sc_io_source_t * source, size_t * bytes_in, size_t * bytes_out);
P4est.LibP4est.sc_io_source_destroy
— Methodsc_io_source_destroy(source)
Free data source. Calls sc_io_source_complete
and requires it to return no error. This is to avoid discarding buffered data that has not been passed to read.
Parameters
source
:[in,out] The source object to free.
Returns
0 on success. Nonzero if an error is encountered or is_complete returns one.
Prototype
int sc_io_source_destroy (sc_io_source_t * source);
P4est.LibP4est.sc_io_source_read
— Methodsc_io_source_read(source, data, bytes_avail, bytes_out)
Read data from a source. The internal counters source->bytes_in and source->bytes_out are updated. Data is read until the data buffer has not enough room anymore, or source becomes empty. It is possible that data already read internally remains in the source object for the next call. Call sc_io_source_complete
and check its return value to find out. Returns an error if bytes_out is NULL and less than bytes_avail are read.
Parameters
source
:[in,out] The source object to read from.data
:[in] Data buffer for reading from sink. If NULL the output data will be thrown away.bytes_avail
:[in] Number of bytes available in data buffer.bytes_out
:[in,out] If not NULL, byte count read into data buffer. Otherwise, requires to read exactly bytes_avail.
Returns
0 on success, nonzero on error.
Prototype
int sc_io_source_read (sc_io_source_t * source, void *data, size_t bytes_avail, size_t * bytes_out);
P4est.LibP4est.sc_io_source_read_mirror
— Methodsc_io_source_read_mirror(source, data, bytes_avail, bytes_out)
Read data from the source's mirror. Same behaviour as sc_io_source_read
.
Parameters
source
:[in,out] The source object to read mirror data from.
Returns
0 on success, nonzero on error.
Prototype
int sc_io_source_read_mirror (sc_io_source_t * source, void *data, size_t bytes_avail, size_t * bytes_out);
P4est.LibP4est.sc_is_root
— Methodsc_is_root()
Identify the root process. Only meaningful between sc_init
and sc_finalize
and with a communicator that is not sc_MPI_COMM_NULL
(otherwise always true).
Returns
Return true for the root process and false otherwise.
Prototype
int sc_is_root (void);
P4est.LibP4est.sc_list_append
— Methodsc_list_append(list, data)
Insert a list element at the end of the list.
Parameters
list
:[in,out] Valid list object.data
:[in] A new link is created holding this data.
Returns
The link that has been created for data.
Prototype
sc_link_t *sc_list_append (sc_list_t * list, void *data);
P4est.LibP4est.sc_list_destroy
— Methodsc_list_destroy(list)
Destroy a linked list structure in O(N).
If allocator was provided in sc_list_new
, it will not be destroyed.
Parameters
list
:[in,out] All memory allocated for this list is freed.
Prototype
void sc_list_destroy (sc_list_t * list);
P4est.LibP4est.sc_list_init
— Methodsc_list_init(list, allocator)
Initialize a list object with an external link allocator.
Parameters
list
:[in,out] List structure to be initialized.allocator
:[in] External memory allocator forsc_link_t
, which must exist already.
Prototype
void sc_list_init (sc_list_t * list, sc_mempool_t * allocator);
P4est.LibP4est.sc_list_insert
— Methodsc_list_insert(list, pred, data)
Insert an element after a given list position.
Parameters
list
:[in,out] Valid list object.pred
:[in,out] The predecessor of the element to be inserted.data
:[in] A new link is created holding this data.
Returns
The link that has been created for data.
Prototype
sc_link_t *sc_list_insert (sc_list_t * list, sc_link_t * pred, void *data);
P4est.LibP4est.sc_list_memory_used
— Methodsc_list_memory_used(list, is_dynamic)
Calculate the total memory used by a list.
Parameters
list
:[in] The list.is_dynamic
:[in] True if created withsc_list_new
, false if initialized withsc_list_init
Returns
Memory used in bytes.
Prototype
size_t sc_list_memory_used (sc_list_t * list, int is_dynamic);
P4est.LibP4est.sc_list_new
— Methodsc_list_new(allocator)
Allocate a new, empty linked list.
Parameters
allocator
:[in] Memory allocator forsc_link_t
, can be NULL in which case an internal allocator is created.
Returns
Pointer to a newly allocated, empty list object.
Prototype
sc_list_t *sc_list_new (sc_mempool_t * allocator);
P4est.LibP4est.sc_list_pop
— Methodsc_list_pop(list)
Remove an element from the front of the list.
Parameters
list
:[in,out] Valid, non-empty list object.
Returns
Returns the data of the removed first list element.
Prototype
void *sc_list_pop (sc_list_t * list);
P4est.LibP4est.sc_list_prepend
— Methodsc_list_prepend(list, data)
Insert a list element at the beginning of the list.
Parameters
list
:[in,out] Valid list object.data
:[in] A new link is created holding this data.
Returns
The link that has been created for data.
Prototype
sc_link_t *sc_list_prepend (sc_list_t * list, void *data);
P4est.LibP4est.sc_list_remove
— Methodsc_list_remove(list, pred)
Remove an element after a given list position.
Parameters
list
:[in,out] Valid, non-empty list object.pred
:[in] The predecessor of the element to be removed. If pred == NULL, the first element is removed, which is equivalent to callingsc_list_pop
(list).
Returns
The data of the removed and freed link.
Prototype
void *sc_list_remove (sc_list_t * list, sc_link_t * pred);
P4est.LibP4est.sc_list_reset
— Methodsc_list_reset(list)
Remove all elements from a list in O(N).
Calling sc_list_init
, then any list operations, then sc_list_reset
is memory neutral.
Parameters
list
:[in,out] List structure to be emptied.
Prototype
void sc_list_reset (sc_list_t * list);
P4est.LibP4est.sc_list_unlink
— Methodsc_list_unlink(list)
Unlink all list elements without returning them to the mempool. This runs in O(1) but is dangerous because the link memory stays alive.
Parameters
list
:[in,out] List structure to be unlinked.
Prototype
void sc_list_unlink (sc_list_t * list);
P4est.LibP4est.sc_log
— Methodsc_log(filename, lineno, package, category, priority, msg)
The central log function to be called by all packages. Dispatches the log calls by package and filters by category and priority.
Parameters
package
:[in] Must be a registered package id or -1.category
:[in] Must beSC_LC_NORMAL
orSC_LC_GLOBAL
.priority
:[in] Must be >SC_LP_ALWAYS
and <SC_LP_SILENT
.
Prototype
void sc_log (const char *filename, int lineno, int package, int category, int priority, const char *msg);
P4est.LibP4est.sc_log_indent_pop
— Methodsc_log_indent_pop()
Remove one space from the start of a sc's default log format.
Prototype
void sc_log_indent_pop (void);
P4est.LibP4est.sc_log_indent_pop_count
— Methodsc_log_indent_pop_count(package, count)
Remove spaces from the start of a package's default log format.
Prototype
void sc_log_indent_pop_count (int package, int count);
P4est.LibP4est.sc_log_indent_push
— Methodsc_log_indent_push()
Add one space to the start of sc's default log format.
Prototype
void sc_log_indent_push (void);
P4est.LibP4est.sc_log_indent_push_count
— Methodsc_log_indent_push_count(package, count)
Add spaces to the start of a package's default log format.
Prototype
void sc_log_indent_push_count (int package, int count);
P4est.LibP4est.sc_malloc
— Methodsc_malloc(package, size)
Prototype
void *sc_malloc (int package, size_t size);
P4est.LibP4est.sc_memory_check
— Methodsc_memory_check(package)
Prototype
void sc_memory_check (int package);
P4est.LibP4est.sc_memory_check_noerr
— Methodsc_memory_check_noerr(package)
Return error count or zero if all is ok.
Prototype
int sc_memory_check_noerr (int package);
P4est.LibP4est.sc_memory_status
— Methodsc_memory_status(package)
Prototype
int sc_memory_status (int package);
P4est.LibP4est.sc_mempool_destroy
— Methodsc_mempool_destroy(mempool)
Destroy a mempool structure. All elements that are still in use are invalidated.
Parameters
mempool
:[in,out] Its memory is freed.
Prototype
void sc_mempool_destroy (sc_mempool_t * mempool);
P4est.LibP4est.sc_mempool_destroy_null
— Methodsc_mempool_destroy_null(pmempool)
Destroy a mempool structure. All elements that are still in use are invalidated.
Parameters
pmempool
:[in,out] Address of pointer to memory pool. Its memory is freed, pointer is NULLed.
Prototype
void sc_mempool_destroy_null (sc_mempool_t ** pmempool);
P4est.LibP4est.sc_mempool_init
— Methodsc_mempool_init(mempool, elem_size)
Same as sc_mempool_new
, but for an already allocated sc_mempool_t
pointer.
Prototype
void sc_mempool_init (sc_mempool_t * mempool, size_t elem_size);
P4est.LibP4est.sc_mempool_memory_used
— Methodsc_mempool_memory_used(mempool)
Calculate the memory used by a memory pool.
Parameters
array
:[in] The memory pool.
Returns
Memory used in bytes.
Prototype
size_t sc_mempool_memory_used (sc_mempool_t * mempool);
P4est.LibP4est.sc_mempool_new
— Methodsc_mempool_new(elem_size)
Creates a new mempool structure with the zero_and_persist option off. The contents of any elements returned by sc_mempool_alloc are undefined.
Parameters
elem_size
:[in] Size of one element in bytes.
Returns
Returns an allocated and initialized memory pool.
Prototype
sc_mempool_t *sc_mempool_new (size_t elem_size);
P4est.LibP4est.sc_mempool_new_zero_and_persist
— Methodsc_mempool_new_zero_and_persist(elem_size)
Creates a new mempool structure with the zero_and_persist option on. The memory of newly created elements is zero'd out, and the contents of an element are not touched between freeing and re-returning it.
Parameters
elem_size
:[in] Size of one element in bytes.
Returns
Returns an allocated and initialized memory pool.
Prototype
sc_mempool_t *sc_mempool_new_zero_and_persist (size_t elem_size);
P4est.LibP4est.sc_mempool_reset
— Methodsc_mempool_reset(mempool)
Same as sc_mempool_destroy
, but does not free the pointer
Prototype
void sc_mempool_reset (sc_mempool_t * mempool);
P4est.LibP4est.sc_mempool_truncate
— Methodsc_mempool_truncate(mempool)
Invalidates all previously returned pointers, resets count to 0.
Prototype
void sc_mempool_truncate (sc_mempool_t * mempool);
P4est.LibP4est.sc_mpi_comm_attach_node_comms
— Methodsc_mpi_comm_attach_node_comms(comm, processes_per_node)
Prototype
void sc_mpi_comm_attach_node_comms (sc_MPI_Comm comm, int processes_per_node);
P4est.LibP4est.sc_mpi_comm_detach_node_comms
— Methodsc_mpi_comm_detach_node_comms(comm)
Prototype
void sc_mpi_comm_detach_node_comms (sc_MPI_Comm comm);
P4est.LibP4est.sc_mpi_comm_get_and_attach
— Methodsc_mpi_comm_get_and_attach(comm)
Prototype
int sc_mpi_comm_get_and_attach (sc_MPI_Comm comm);
P4est.LibP4est.sc_mpi_comm_get_node_comms
— Methodsc_mpi_comm_get_node_comms(comm, intranode, internode)
Prototype
void sc_mpi_comm_get_node_comms (sc_MPI_Comm comm, sc_MPI_Comm * intranode, sc_MPI_Comm * internode);
P4est.LibP4est.sc_mpi_read
— Methodsc_mpi_read(mpifile, ptr, zcount, t, errmsg)
Prototype
void sc_mpi_read (MPI_File mpifile, const void *ptr, size_t zcount, sc_MPI_Datatype t, const char *errmsg);
P4est.LibP4est.sc_mpi_sizeof
— Methodsc_mpi_sizeof(t)
Prototype
size_t sc_mpi_sizeof (sc_MPI_Datatype t);
P4est.LibP4est.sc_mpi_write
— Methodsc_mpi_write(mpifile, ptr, zcount, t, errmsg)
Prototype
void sc_mpi_write (MPI_File mpifile, const void *ptr, size_t zcount, sc_MPI_Datatype t, const char *errmsg);
P4est.LibP4est.sc_mstamp_alloc
— Methodsc_mstamp_alloc(mst)
Return a new item. The memory returned will stay legal until container is destroyed or truncated.
Parameters
Properly
:[in,out] initialized stamp container.
Returns
Pointer to an item ready to use. Legal until scstampdestroy or scstamptruncate is called on mst.
Prototype
void *sc_mstamp_alloc (sc_mstamp_t * mst);
P4est.LibP4est.sc_mstamp_init
— Methodsc_mstamp_init(mst, stamp_unit, elem_size)
Initialize a memory stamp container. We provide allocation of fixed-size memory items without allocating new memory in every request. Instead we block the allocations in what we call a stamp of multiple items. Even if no allocations are done, the container's internal memory must be freed eventually by scmstampreset.
Parameters
mst
:[in,out] Legal pointer to a stamp structure.stamp_unit
:[in] Size of each memory block that we allocate. If it is larger than the element size, we may place more than one element in it. Passing 0 is legal and forces stamps that hold one item each.elem_size
:[in] Size of each item. Passing 0 is legal. In that case, scmstampalloc returns NULL.
Prototype
void sc_mstamp_init (sc_mstamp_t * mst, size_t stamp_unit, size_t elem_size);
P4est.LibP4est.sc_mstamp_memory_used
— Methodsc_mstamp_memory_used(mst)
Return memory size in bytes of all data allocated in the container.
Parameters
Properly
:[in] initialized stamp container.
Returns
Total container memory size in bytes.
Prototype
size_t sc_mstamp_memory_used (sc_mstamp_t * mst);
P4est.LibP4est.sc_mstamp_reset
— Methodsc_mstamp_reset(mst)
Free all memory in a stamp structure and all items previously returned.
Parameters
Properly
:[in,out] initialized stamp container. On output, the structure is undefined.
Prototype
void sc_mstamp_reset (sc_mstamp_t * mst);
P4est.LibP4est.sc_mstamp_truncate
— Methodsc_mstamp_truncate(mst)
Free all memory in a stamp structure and initialize it anew. Equivalent to calling scmstampreset followed by scmstampinit with the same stamp_unit and elem_size.
Parameters
Properly
:[in,out] initialized stamp container. On output, its elements have been freed and it is ready for further use.
Prototype
void sc_mstamp_truncate (sc_mstamp_t * mst);
P4est.LibP4est.sc_package_is_registered
— Methodsc_package_is_registered(package_id)
Query whether an identifier matches a registered package.
Parameters
package_id
:[in] Only a non-negative id can be registered.
Returns
True if and only if the package id is non-negative and package is registered.
Prototype
int sc_package_is_registered (int package_id);
P4est.LibP4est.sc_package_lock
— Methodsc_package_lock(package_id)
Acquire a pthread mutex lock. If configured without –enable-pthread, this function does nothing. This function must be followed with a matching scpackageunlock.
Parameters
package_id
:[in] Either -1 for an undefined package or an id returned from scpackageregister. Depending on the value, the appropriate mutex is chosen. Thus, we may overlap locking calls with distinct package_id.
Prototype
void sc_package_lock (int package_id);
P4est.LibP4est.sc_package_print_summary
— Methodsc_package_print_summary(log_priority)
Print a summary of all packages registered with SC. Uses the SC_LC_GLOBAL
log category which by default only prints on rank 0.
Parameters
log_priority
:[in] Priority passed to sc log functions.
Prototype
void sc_package_print_summary (int log_priority);
P4est.LibP4est.sc_package_register
— Methodsc_package_register(log_handler, log_threshold, name, full)
Register a software package with SC. This function must only be called before additional threads are created. The logging parameters are as in sc_set_log_defaults
.
Returns
Returns a unique package id.
Prototype
int sc_package_register (sc_log_handler_t log_handler, int log_threshold, const char *name, const char *full);
P4est.LibP4est.sc_package_set_abort_alloc_mismatch
— Methodsc_package_set_abort_alloc_mismatch(package_id, set_abort)
Set the unregister behavior of sc_package_unregister
().
Parameters
package_id
:[in] Must be -1 for the default package or the identifier of a registered package.set_abort
:[in] True ifsc_package_unregister
() should abort if the number of allocs does not match the number of frees; false otherwise.
Prototype
void sc_package_set_abort_alloc_mismatch (int package_id, int set_abort);
P4est.LibP4est.sc_package_set_verbosity
— Methodsc_package_set_verbosity(package_id, log_priority)
Set the logging verbosity of a registered package. This can be called at any point in the program, any number of times. It can only lower the verbosity at and below the value of SC_LP_THRESHOLD
.
Parameters
package_id
:[in] Must be a registered package identifier.
Prototype
void sc_package_set_verbosity (int package_id, int log_priority);
P4est.LibP4est.sc_package_unlock
— Methodsc_package_unlock(package_id)
Release a pthread mutex lock. If configured without –enable-pthread, this function does nothing. This function must be follow a matching scpackagelock.
Parameters
package_id
:[in] Either -1 for an undefined package or an id returned from scpackageregister. Depending on the value, the appropriate mutex is chosen. Thus, we may overlap locking calls with distinct package_id.
Prototype
void sc_package_unlock (int package_id);
P4est.LibP4est.sc_package_unregister
— Methodsc_package_unregister(package_id)
Unregister a software package with SC. This function must only be called after additional threads are finished.
Prototype
void sc_package_unregister (int package_id);
P4est.LibP4est.sc_realloc
— Methodsc_realloc(package, ptr, size)
Prototype
void *sc_realloc (int package, void *ptr, size_t size);
P4est.LibP4est.sc_recycle_array_init
— Methodsc_recycle_array_init(rec_array, elem_size)
Initialize a recycle array.
Parameters
elem_size
:[in] Size of the objects to be stored in the array.
Prototype
void sc_recycle_array_init (sc_recycle_array_t * rec_array, size_t elem_size);
P4est.LibP4est.sc_recycle_array_insert
— Methodsc_recycle_array_insert(rec_array, position)
Insert an object into the recycle array. The object is not copied into the array. Use the return value for that.
Parameters
position
:[out] If position != NULL, *position is set to the array position of the inserted object.
Returns
Returns the new address of the object in the array.
Prototype
void *sc_recycle_array_insert (sc_recycle_array_t * rec_array, size_t *position);
P4est.LibP4est.sc_recycle_array_remove
— Methodsc_recycle_array_remove(rec_array, position)
Remove an object from the recycle array. It must be valid.
Parameters
position
:[in] Index into the array for the object to remove.
Returns
The pointer to the removed object. Will be valid as long as no other function is called on this recycle array.
Prototype
void *sc_recycle_array_remove (sc_recycle_array_t * rec_array, size_t position);
P4est.LibP4est.sc_recycle_array_reset
— Methodsc_recycle_array_reset(rec_array)
Reset a recycle array.
As with all _reset functions, calling _init, then any array operations, then _reset is memory neutral.
Prototype
void sc_recycle_array_reset (sc_recycle_array_t * rec_array);
P4est.LibP4est.sc_set_abort_handler
— Methodsc_set_abort_handler(abort_handler)
Controls the default SC abort behavior.
Parameters
abort_handler
:[in] Set default SC above handler (NULL selects builtin). ***This function should not return!***
Prototype
void sc_set_abort_handler (sc_abort_handler_t abort_handler);
P4est.LibP4est.sc_set_log_defaults
— Methodsc_set_log_defaults(log_stream, log_handler, log_thresold)
Controls the default SC log behavior.
Parameters
log_stream
:[in] Set stream to use bysc_logf
(or NULL for stdout).log_handler
:[in] Set default SC log handler (NULL selects builtin).log_threshold
:[in] Set default SC log threshold (orSC_LP_DEFAULT
). May beSC_LP_ALWAYS
orSC_LP_SILENT
.
Prototype
void sc_set_log_defaults (FILE * log_stream, sc_log_handler_t log_handler, int log_thresold);
P4est.LibP4est.sc_strcopy
— Methodsc_strcopy(dest, size, src)
Provide a string copy function.
Parameters
dest
:[out] Buffer of length at least size. On output, not touched if NULL or size == 0.size
:[in] Allocation length of dest.src
:[in] Null-terminated string.
Returns
Equivalent to sc_snprintf (dest, size, "s", src).
Prototype
void sc_strcopy (char *dest, size_t size, const char *src);
P4est.LibP4est.sc_strdup
— Methodsc_strdup(package, s)
Prototype
char *sc_strdup (int package, const char *s);
P4est.LibP4est.sc_uint128_add
— Methodsc_uint128_add(a, b, result)
Adds the uint128_t b to the uint128_t a. result == a or result == b is not allowed. a == b is allowed.
Parameters
a
:[in] A pointer to asc_uint128_t
.b
:[in] A pointer to asc_uint128_t
.result
:[out] A pointer to asc_uint128_t
. The sum a + b will be saved in result.
Prototype
void sc_uint128_add (const sc_uint128_t * a, const sc_uint128_t * b, sc_uint128_t * result);
P4est.LibP4est.sc_uint128_add_inplace
— Methodsc_uint128_add_inplace(a, b)
Adds the uint128 b to the uint128_t a. The result is saved in a. a == b is allowed.
Parameters
a
:[in,out] A pointer to asc_uint128_t
. a will be overwritten by a + b.b
:[in] A pointer to asc_uint128_t
.
Prototype
void sc_uint128_add_inplace (sc_uint128_t * a, const sc_uint128_t * b);
P4est.LibP4est.sc_uint128_bitwise_and
— Methodsc_uint128_bitwise_and(a, b, 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
a
:[in] A pointer to asc_uint128_t
.b
:[in] A pointer to asc_uint128_t
.result
:[out] A pointer to asc_uint128_t
. The bitwise and of a and b will be saved. in result.
Prototype
void sc_uint128_bitwise_and (const sc_uint128_t * a, const sc_uint128_t * b, sc_uint128_t * result);
P4est.LibP4est.sc_uint128_bitwise_and_inplace
— Methodsc_uint128_bitwise_and_inplace(a, b)
Calculates the bitwise and of the uint128_t a and the uint128_t b. a == b is allowed.
Parameters
a
:[in,out] A pointer to asc_uint128_t
. The bitwise and will be saved in a.b
:[in] A pointer to asc_uint128_t
.
Prototype
void sc_uint128_bitwise_and_inplace (sc_uint128_t * a, const sc_uint128_t * b);
P4est.LibP4est.sc_uint128_bitwise_neg
— Methodsc_uint128_bitwise_neg(a, result)
Calculates the bitwise negation of the uint128_t a. a == result is allowed.
Parameters
a
:[in] A pointer to asc_uint128_t
.result
:[out] A pointer to asc_uint128_t
. The bitwise negation of a will be saved in result.
Prototype
void sc_uint128_bitwise_neg (const sc_uint128_t * a, sc_uint128_t * result);
P4est.LibP4est.sc_uint128_bitwise_or
— Methodsc_uint128_bitwise_or(a, b, 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
a
:[in] A pointer to asc_uint128_t
.b
:[in] A pointer to asc_uint128_t
.result
:[out] A pointer to asc_uint128_t
. The bitwise or of a and b will be saved in result.
Prototype
void sc_uint128_bitwise_or (const sc_uint128_t * a, const sc_uint128_t * b, sc_uint128_t * result);
P4est.LibP4est.sc_uint128_bitwise_or_inplace
— Methodsc_uint128_bitwise_or_inplace(a, b)
Calculates the bitwise or of the uint128_t a and the uint128_t b. a == b is allowed.
Parameters
a
:[in,out] A pointer to asc_uint128_t
. The bitwise or will be saved in a.b
:[in] A pointer to asc_uint128_t
.
Prototype
void sc_uint128_bitwise_or_inplace (sc_uint128_t * a, const sc_uint128_t * b);
P4est.LibP4est.sc_uint128_chk_bit
— Methodsc_uint128_chk_bit(input, exponent)
Returns the bit_number-th bit of input. This function checks a bit of an existing, initialized value.
Parameters
input
:[in] A pointer to asc_uint128_t
.bit_number
:[in] The bit (counted from the right hand side) that is checked by logical and. Require 0 <= bit_number < 128.
Returns
True if the checked bit is set, false if not.
Prototype
int sc_uint128_chk_bit (const sc_uint128_t * input, int exponent);
P4est.LibP4est.sc_uint128_compare
— Methodsc_uint128_compare(a, b)
Compare the sc_uint128_t
a and the sc_uint128_t
b.
Parameters
a
:[in] A pointer to asc_uint128_t
.b
:[in] A pointer to asc_uint128_t
.
Returns
Returns -1 if a < b, 1 if a > b and 0 if a == b.
Prototype
int sc_uint128_compare (const void *a, const void *b);
P4est.LibP4est.sc_uint128_copy
— Methodsc_uint128_copy(input, output)
Copies an initialized sc_uint128_t
to a sc_uint128_t
.
Parameters
input
:[in] A pointer to thesc_uint128
that is copied.output
:[in,out] A pointer to asc_uint128_t
. The high and low bits of output will be set to the high and low bits of input, respectively.
Prototype
void sc_uint128_copy (const sc_uint128_t * input, sc_uint128_t * output);
P4est.LibP4est.sc_uint128_init
— Methodsc_uint128_init(a, high, low)
Initializes an unsigned 128 bit integer to a given value.
Parameters
a
:[in,out] A pointer to thesc_uint128_t
that will be initialized.high
:[in] The given high bits to initialize a.low
:[in] The given low bits to initialize a.
Prototype
void sc_uint128_init (sc_uint128_t * a, uint64_t high, uint64_t low);
P4est.LibP4est.sc_uint128_is_equal
— Methodsc_uint128_is_equal(a, b)
Checks if the sc_uint128_t
a and the sc_uint128_t
b are equal.
Parameters
a
:[in] A pointer to asc_uint128_t
.b
:[in] A pointer to asc_uint128_t
.
Returns
Returns a true value if a and b are equal, false otherwise.
Prototype
int sc_uint128_is_equal (const sc_uint128_t * a, const sc_uint128_t * b);
P4est.LibP4est.sc_uint128_set_bit
— Methodsc_uint128_set_bit(a, exponent)
Sets the exponent-th bit of a to one and keep all other bits. This function modifies an existing, initialized value.
Parameters
a
:[in,out] A pointer to asc_uint128_t
.exponent
:[in] The bit (0-based from the rightmost bit) that is set to one by logical or. 0 <= exponent < 128.
Prototype
void sc_uint128_set_bit (sc_uint128_t * a, int exponent);
P4est.LibP4est.sc_uint128_shift_left
— Methodsc_uint128_shift_left(input, shift_count, result)
Calculates the bit left shift of uint128_t input by shift_count bits. We shift in zeros from the right. If shift_count >= 128, result is 0. All bits left from the 127th bit (counted zero based from the right hand side) drop out. input == result is allowed.
Parameters
input
:[in] A pointer to asc_uint128_t
.shift_count
:[in] Bits to shift. shift_count >= 0.result
:[in,out] A pointer to asc_uint128_t
. The left shifted number will be saved in result.
Prototype
void sc_uint128_shift_left (const sc_uint128_t * input, int shift_count, sc_uint128_t * result);
P4est.LibP4est.sc_uint128_shift_right
— Methodsc_uint128_shift_right(input, shift_count, result)
Calculates the bit right shift of uint128_t input by shift_count bits. We shift in zeros from the left. If shift_count >= 128, result is 0. All bits right from the zeroth bit (counted from the right hand side) drop out. input == result is allowed.
Parameters
input
:[in] A pointer to asc_uint128_t
.shift_count
:[in] Bits to shift. shift_count >= 0.result
:[in,out] A pointer to asc_uint128_t
. The right shifted number will be saved in result.
Prototype
void sc_uint128_shift_right (const sc_uint128_t * input, int shift_count, sc_uint128_t * result);
P4est.LibP4est.sc_uint128_sub
— Methodsc_uint128_sub(a, b, result)
Subtracts the uint128_t b from the uint128_t a. This function assumes that the result is >= 0. result == a or result == b is not allowed. a == b is allowed.
Parameters
a
:[in] A pointer to asc_uint128_t
.b
:[in] A pointer to asc_uint128_t
.result
:[out] A pointer to asc_uint128_t
. The difference a - b will be saved in result.
Prototype
void sc_uint128_sub (const sc_uint128_t * a, const sc_uint128_t * b, sc_uint128_t * result);
P4est.LibP4est.sc_uint128_sub_inplace
— Methodsc_uint128_sub_inplace(a, 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
a
:[in,out] A pointer to asc_uint128_t
. a will be overwritten by a - b.b
:[in] A pointer to asc_uint128_t
.
Prototype
void sc_uint128_sub_inplace (sc_uint128_t * a, const sc_uint128_t * b);
P4est.LibP4est.sc_version
— Methodsc_version()
Return the full version of libsc.
Returns
Return the version of libsc using the format VERSION\_MAJOR.VERSION\_MINOR.VERSION\_POINT
, where VERSION_POINT
can contain dots and characters, e.g. to indicate the additional number of commits and a git commit hash.
Prototype
const char *sc_version (void);
P4est.LibP4est.sc_version_major
— Methodsc_version_major()
Return the major version of libsc.
Returns
Return the major version of libsc.
Prototype
int sc_version_major (void);
P4est.LibP4est.sc_version_minor
— Methodsc_version_minor()
Return the minor version of libsc.
Returns
Return the minor version of libsc.
Prototype
int sc_version_minor (void);
P4est.LibP4est.sc_vtk_write_binary
— Methodsc_vtk_write_binary(vtkfile, numeric_data, byte_length)
This function writes numeric binary data in VTK base64 encoding.
Parameters
vtkfile
: Stream opened for writing.numeric_data
: A pointer to a numeric data array.byte_length
: The length of the data array in bytes.
Returns
Returns 0 on success, -1 on file error.
Prototype
int sc_vtk_write_binary (FILE * vtkfile, char *numeric_data, size_t byte_length);
P4est.LibP4est.sc_vtk_write_compressed
— Methodsc_vtk_write_compressed(vtkfile, numeric_data, byte_length)
This function writes numeric binary data in VTK compressed format.
Parameters
vtkfile
: Stream opened for writing.numeric_data
: A pointer to a numeric data array.byte_length
: The length of the data array in bytes.
Returns
Returns 0 on success, -1 on file error.
Prototype
int sc_vtk_write_compressed (FILE * vtkfile, char *numeric_data, size_t byte_length);