p4est 2.8.8
p4est is a software library for parallel adaptive mesh refinement.
Loading...
Searching...
No Matches
p4est_wrap.h
Go to the documentation of this file.
1/*
2 This file is part of p4est.
3 p4est is a C library to manage a collection (a forest) of multiple
4 connected adaptive quadtrees or octrees in parallel.
5
6 Copyright (C) 2010 The University of Texas System
7 Additional copyright (C) 2011 individual authors
8 Written by Carsten Burstedde, Lucas C. Wilcox, and Tobin Isaac
9
10 p4est is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
14
15 p4est is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with p4est; if not, write to the Free Software Foundation, Inc.,
22 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23*/
24
25#ifndef P4EST_WRAP_H
26#define P4EST_WRAP_H
27
40#include <p4est_extended.h>
41#include <sc_refcount.h>
42
43SC_EXTERN_C_BEGIN;
44
45/*** COMPLETE INTERNAL STATE OF P4EST ***/
46
47typedef enum p4est_wrap_flags
48{
49 P4EST_WRAP_NONE = 0,
50 P4EST_WRAP_REFINE = 0x01,
51 P4EST_WRAP_COARSEN = 0x02
52}
53p4est_wrap_flags_t;
54
93
96typedef struct p4est_wrap
97{
98 /* collection of wrap-related parameters */
100
106 sc_refcount_t conn_rc;
108 struct p4est_wrap *conn_owner;
109
110 /* these members are considered public and read-only */
111 int p4est_dim;
112 int p4est_half;
113 int p4est_faces;
114 int p4est_children;
117 /* If \a params.store_adapted is true, these arrays store the indices of the
118 * quadrants refined and coarsened during the most recent call to
119 * \ref p4est_wrap_adapt. The wrap's \a p4est has to be balanced when entering
120 * the adaptation, to avoid multi-level refinement.
121 * The arrays are allocated during the first call of \ref p4est_wrap_adapt.
122 * At every time the arrays index into the local quadrants of the p4est as it
123 * was directly after completion of \ref p4est_wrap_adapt. So, they are not
124 * updated in \ref p4est_wrap_partition. Newly_refined only stores newly
125 * refined quadrants with child id 0. */
126 sc_array_t *newly_refined;
128 sc_array_t *newly_coarsened;
131 /* anything below here is considered private und should not be touched */
132 int weight_exponent;
133 uint8_t *flags, *temp_flags;
134 p4est_locidx_t num_refine_flags, inside_counter, num_replaced;
135 p4est_gloidx_t *old_global_first_quadrant;
136
137 /* for ghost and mesh use p4est_wrap_get_ghost, _mesh declared below */
138 p4est_ghost_t *ghost;
139 p4est_mesh_t *mesh;
140 p4est_ghost_t *ghost_aux;
141 p4est_mesh_t *mesh_aux;
142 int match_aux;
143}
145
148void p4est_wrap_params_init (p4est_wrap_params_t * params);
149
160p4est_wrap_t *p4est_wrap_new_conn (sc_MPI_Comm mpicomm,
162 int initial_level);
163
179p4est_wrap_t *p4est_wrap_new_p4est (p4est_t * p4est, int hollow,
181 p4est_replace_t replace_fn,
182 void *user_pointer);
183
197p4est_wrap_t *p4est_wrap_new_p4est_params (p4est_t * p4est,
198 p4est_wrap_params_t * params);
199
217p4est_wrap_t *p4est_wrap_new_ext (sc_MPI_Comm mpicomm,
219 int initial_level, int hollow,
221 p4est_replace_t replace_fn,
222 void *user_pointer);
223
236p4est_wrap_t *p4est_wrap_new_params (sc_MPI_Comm mpicomm,
238 int initial_level,
239 p4est_wrap_params_t * params);
240
253p4est_wrap_t *p4est_wrap_new_copy (p4est_wrap_t * source,
254 size_t data_size,
255 p4est_replace_t replace_fn,
256 void *user_pointer);
257
262 int initial_level);
263
264p4est_wrap_t *p4est_wrap_new_periodic (sc_MPI_Comm mpicomm,
265 int initial_level);
266p4est_wrap_t *p4est_wrap_new_rotwrap (sc_MPI_Comm mpicomm,
267 int initial_level);
268p4est_wrap_t *p4est_wrap_new_corner (sc_MPI_Comm mpicomm,
269 int initial_level);
270p4est_wrap_t *p4est_wrap_new_pillow (sc_MPI_Comm mpicomm,
271 int initial_level);
272p4est_wrap_t *p4est_wrap_new_moebius (sc_MPI_Comm mpicomm,
273 int initial_level);
274p4est_wrap_t *p4est_wrap_new_cubed (sc_MPI_Comm mpicomm,
275 int initial_level);
276
278p4est_wrap_t *p4est_wrap_new_disk (sc_MPI_Comm mpicomm, int px, int py,
279 int initial_level);
280
282p4est_wrap_t *p4est_wrap_new_brick (sc_MPI_Comm mpicomm,
283 int bx, int by, int px, int py,
284 int initial_level);
285
287p4est_wrap_t *p4est_wrap_new_world (int initial_level);
288void p4est_wrap_destroy (p4est_wrap_t * pp);
289
299void p4est_wrap_set_hollow (p4est_wrap_t * pp, int hollow);
300
316void p4est_wrap_set_coarsen_delay (p4est_wrap_t * pp,
317 int coarsen_delay,
318 int coarsen_affect);
319
336void p4est_wrap_set_partitioning (p4est_wrap_t *pp,
337 int partition_for_coarsening);
338
344p4est_ghost_t *p4est_wrap_get_ghost (p4est_wrap_t * pp);
345
351p4est_mesh_t *p4est_wrap_get_mesh (p4est_wrap_t * pp);
352
359void p4est_wrap_mark_refine (p4est_wrap_t * pp,
360 p4est_topidx_t which_tree,
361 p4est_locidx_t which_quad);
362
369void p4est_wrap_mark_coarsen (p4est_wrap_t * pp,
370 p4est_topidx_t which_tree,
371 p4est_locidx_t which_quad);
372
383int p4est_wrap_adapt (p4est_wrap_t * pp);
384
413int p4est_wrap_partition (p4est_wrap_t * pp,
414 int weight_exponent,
415 p4est_locidx_t * unchanged_first,
416 p4est_locidx_t * unchanged_length,
418 unchanged_old_first);
419
426void p4est_wrap_complete (p4est_wrap_t * pp);
427
428/*** ITERATOR OVER THE FOREST LEAVES ***/
429
430typedef struct p4est_wrap_leaf
431{
434 /* Information about the current quadrant */
439 sc_array_t *tquadrants;
441#if 0 /* DEPRECATED -- anyone using them? */
442 int level;
443 double lowerleft[3];
444 double upperright[3];
445#endif
446
447 /* Information about parallel neighbors */
449 sc_array_t *mirrors;
452}
454
456#define P4EST_LEAF_IS_FIRST_IN_TREE(wleaf) ((wleaf)->which_quad == 0)
457
458/* Create an iterator over the local leaves in the forest.
459 * Returns a newly allocated state containing the first leaf,
460 * or NULL if the local partition of the tree is empty.
461 * \param [in] pp Legal p4est_wrap structure, hollow or not.
462 * \param [in] track_mirrors If true, \a pp must not be hollow and mirror
463 * information from the ghost layer is stored.
464 * \return NULL if processor is empty, otherwise a leaf iterator for
465 * subsequent use with \a p4est_wrap_leaf_next.
466 */
467p4est_wrap_leaf_t *p4est_wrap_leaf_first (p4est_wrap_t * pp,
468 int track_mirrors);
469
470/* Move the forest leaf iterator forward.
471 * \param [in,out] leaf A non-NULL leaf iterator created by
472 * \ref p4est_wrap_leaf_first.
473 * \return The state that was input with updated information for the
474 * next leaf, or NULL and deallocates the input if called with
475 * the last leaf on this processor.
476 */
477p4est_wrap_leaf_t *p4est_wrap_leaf_next (p4est_wrap_leaf_t * leaf);
478
479SC_EXTERN_C_END;
480
481#endif /* !P4EST_WRAP_H */
int32_t p4est_topidx_t
Typedef for counting topological entities (trees, tree vertices).
Definition p4est_base.h:93
int32_t p4est_locidx_t
Typedef for processor-local indexing of quadrants and nodes.
Definition p4est_base.h:106
int64_t p4est_gloidx_t
Typedef for globally unique indexing of quadrants.
Definition p4est_base.h:118
p4est_connect_type_t
Characterize a type of adjacency.
Definition p4est_connectivity.h:113
Interface routines with extended capabilities.
p4est_wrap_t * p4est_wrap_new_unitsquare(sc_MPI_Comm mpicomm, int initial_level)
Create a p4est_wrap and internal helper data structures.
p4est_wrap_t * p4est_wrap_new_disk(sc_MPI_Comm mpicomm, int px, int py, int initial_level)
Create a five-tree setup suitable to build a 2D disk.
struct p4est_wrap p4est_wrap_t
Wrapping a p4est object for an alternative API.
This structure holds the 2D inter-tree connectivity information.
Definition p4est_connectivity.h:190
Quadrants that neighbor the local domain.
Definition p4est_ghost.h:46
This structure contains the different parameters of mesh creation.
Definition p4est_mesh.h:55
This structure contains complete mesh information on a 2:1 balanced forest.
Definition p4est_mesh.h:130
The 2D quadrant datatype.
Definition p4est.h:76
The p4est tree datatype.
Definition p4est.h:129
Definition p4est_wrap.h:431
p4est_locidx_t local_quad
Quadrant number relative to proc.
Definition p4est_wrap.h:437
p4est_locidx_t nm
Internal: mirror counter.
Definition p4est_wrap.h:450
p4est_locidx_t which_quad
Quadrant number relative to tree.
Definition p4est_wrap.h:436
p4est_tree_t * tree
Current tree.
Definition p4est_wrap.h:438
p4est_topidx_t which_tree
Current tree number.
Definition p4est_wrap.h:435
sc_array_t * mirrors
If not NULL, from pp's ghost.
Definition p4est_wrap.h:449
int is_mirror
Quadrant at parallel boundary?
Definition p4est_wrap.h:448
p4est_locidx_t next_mirror_quadrant
Internal: next.
Definition p4est_wrap.h:451
p4est_wrap_t * pp
Must contain a valid ghost.
Definition p4est_wrap.h:432
p4est_quadrant_t * quad
Current quadrant.
Definition p4est_wrap.h:440
sc_array_t * tquadrants
Current tree's quadrants.
Definition p4est_wrap.h:439
This structure contains the different parameters of wrap creation.
Definition p4est_wrap.h:59
int coarsen_affect
Boolean: If true, we delay coarsening not only after refinement, but also between subsequent coarseni...
Definition p4est_wrap.h:75
int hollow
Do not allocate flags, ghost, and mesh members.
Definition p4est_wrap.h:60
int coarsen_delay
Non-negative integer telling how many adaptations to wait before any given quadrant may be coarsened ...
Definition p4est_wrap.h:71
p4est_mesh_params_t mesh_params
Parameters for mesh creation.
Definition p4est_wrap.h:62
p4est_replace_t replace_fn
This member may be removed soon.
Definition p4est_wrap.h:65
void * user_pointer
Set the user pointer in the p4est_wrap.
Definition p4est_wrap.h:88
int partition_for_coarsening
If true, the partition is modified to allow one level of coarsening when calling p4est_wrap_partition...
Definition p4est_wrap.h:79
int store_adapted
Boolean: If true, the indices of most recently adapted quadrants are stored in the newly_refined and ...
Definition p4est_wrap.h:83
Wrapping a p4est object for an alternative API.
Definition p4est_wrap.h:97
p4est_t * p4est
p4est->user_pointer is used internally
Definition p4est_wrap.h:115
sc_array_t * newly_refined
Indices of quadrants refined during most recent p4est_wrap_adapt.
Definition p4est_wrap.h:126
sc_array_t * newly_coarsened
Indices of quadrants coarsened during most recent p4est_wrap_adapt.
Definition p4est_wrap.h:128
sc_refcount_t conn_rc
This reference counter is a workaround for internal use only.
Definition p4est_wrap.h:106
The p4est forest datatype.
Definition p4est.h:150