p4est  2.8.643-dbc7-dirty
p4est is a software library for parallel adaptive mesh refinement.
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 
35 #include <p4est_mesh.h>
36 #include <p4est_extended.h>
37 #include <sc_refcount.h>
38 
39 SC_EXTERN_C_BEGIN;
40 
41 /*** COMPLETE INTERNAL STATE OF P4EST ***/
42 
43 typedef enum p4est_wrap_flags
44 {
45  P4EST_WRAP_NONE = 0,
46  P4EST_WRAP_REFINE = 0x01,
47  P4EST_WRAP_COARSEN = 0x02
48 }
49 p4est_wrap_flags_t;
50 
51 typedef struct p4est_wrap
52 {
53  /* this member is never used or changed by p4est_wrap */
54  void *user_pointer;
58  int hollow;
59 
63 
67 
75  struct p4est_wrap *conn_owner;
76 
77  /* these members are considered public and read-only */
78  int p4est_dim;
79  int p4est_half;
80  int p4est_faces;
81  int p4est_children;
83  p4est_replace_t replace_fn;
86  /* anything below here is considered private und should not be touched */
87  int weight_exponent;
88  uint8_t *flags, *temp_flags;
89  p4est_locidx_t num_refine_flags, inside_counter, num_replaced;
90 
91  /* for ghost and mesh use p4est_wrap_get_ghost, _mesh declared below */
92  p4est_ghost_t *ghost;
93  p4est_mesh_t *mesh;
94  p4est_ghost_t *ghost_aux;
95  p4est_mesh_t *mesh_aux;
96  int match_aux;
97 }
99 
109  p4est_connectivity_t * conn,
110  int initial_level);
111 
126  p4est_connect_type_t btype,
127  p4est_replace_t replace_fn,
128  void *user_pointer);
129 
146  p4est_connectivity_t * conn,
147  int initial_level, int hollow,
148  p4est_connect_type_t btype,
149  p4est_replace_t replace_fn,
150  void *user_pointer);
151 
165  size_t data_size,
166  p4est_replace_t replace_fn,
167  void *user_pointer);
168 
173  int initial_level);
174 p4est_wrap_t *p4est_wrap_new_periodic (sc_MPI_Comm mpicomm,
175  int initial_level);
176 p4est_wrap_t *p4est_wrap_new_rotwrap (sc_MPI_Comm mpicomm,
177  int initial_level);
178 p4est_wrap_t *p4est_wrap_new_corner (sc_MPI_Comm mpicomm,
179  int initial_level);
180 p4est_wrap_t *p4est_wrap_new_pillow (sc_MPI_Comm mpicomm,
181  int initial_level);
182 p4est_wrap_t *p4est_wrap_new_moebius (sc_MPI_Comm mpicomm,
183  int initial_level);
184 p4est_wrap_t *p4est_wrap_new_cubed (sc_MPI_Comm mpicomm,
185  int initial_level);
186 p4est_wrap_t *p4est_wrap_new_disk (sc_MPI_Comm mpicomm, int px, int py,
187  int initial_level);
188 p4est_wrap_t *p4est_wrap_new_brick (sc_MPI_Comm mpicomm,
189  int bx, int by, int px, int py,
190  int initial_level);
191 
193 p4est_wrap_t *p4est_wrap_new_world (int initial_level);
194 void p4est_wrap_destroy (p4est_wrap_t * pp);
195 
206 
223  int coarsen_delay,
224  int coarsen_affect);
225 
232 
239 
247  p4est_topidx_t which_tree,
248  p4est_locidx_t which_quad);
249 
257  p4est_topidx_t which_tree,
258  p4est_locidx_t which_quad);
259 
271 
301  int weight_exponent,
302  p4est_locidx_t * unchanged_first,
303  p4est_locidx_t * unchanged_length,
305  unchanged_old_first);
306 
314 
315 /*** ITERATOR OVER THE FOREST LEAVES ***/
316 
317 typedef struct p4est_wrap_leaf
318 {
321  /* Information about the current quadrant */
328 #if 0 /* DEPRECATED -- anyone using them? */
329  int level;
330  double lowerleft[3];
331  double upperright[3];
332 #endif
333 
334  /* Information about parallel neighbors */
335  int is_mirror;
339 }
341 
343 #define P4EST_LEAF_IS_FIRST_IN_TREE(wleaf) ((wleaf)->which_quad == 0)
344 
345 /* Create an iterator over the local leaves in the forest.
346  * Returns a newly allocated state containing the first leaf,
347  * or NULL if the local partition of the tree is empty.
348  * \param [in] pp Legal p4est_wrap structure, hollow or not.
349  * \param [in] track_mirrors If true, \a pp must not be hollow and mirror
350  * information from the ghost layer is stored.
351  * \return NULL if processor is empty, otherwise a leaf iterator for
352  * subsequent use with \a p4est_wrap_leaf_next.
353  */
354 p4est_wrap_leaf_t *p4est_wrap_leaf_first (p4est_wrap_t * pp,
355  int track_mirrors);
356 
357 /* Move the forest leaf iterator forward.
358  * \param [in,out] leaf A non-NULL leaf iterator created by
359  * \ref p4est_wrap_leaf_first.
360  * \return The state that was input with updated information for the
361  * next leaf, or NULL and deallocates the input if called with
362  * the last leaf on this processor.
363  */
364 p4est_wrap_leaf_t *p4est_wrap_leaf_next (p4est_wrap_leaf_t * leaf);
365 
366 SC_EXTERN_C_END;
367 
368 #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
p4est_connect_type_t
Characterize a type of adjacency.
Definition: p4est_connectivity.h:88
Interface routines with extended capabilities.
void(* p4est_replace_t)(p4est_t *p4est, p4est_topidx_t which_tree, int num_outgoing, p4est_quadrant_t *outgoing[], int num_incoming, p4est_quadrant_t *incoming[])
Callback function prototype to replace one set of quadrants with another.
Definition: p4est_extended.h:110
forest topology in a conventional mesh format
void p4est_wrap_mark_coarsen(p4est_wrap_t *pp, p4est_topidx_t which_tree, p4est_locidx_t which_quad)
Mark a local element for coarsening.
p4est_ghost_t * p4est_wrap_get_ghost(p4est_wrap_t *pp)
Return the appropriate ghost layer.
p4est_wrap_t * p4est_wrap_new_copy(p4est_wrap_t *source, size_t data_size, p4est_replace_t replace_fn, void *user_pointer)
Create a p4est wrapper from an existing one.
p4est_wrap_t * p4est_wrap_new_unitsquare(sc_MPI_Comm mpicomm, int initial_level)
Create p4est and auxiliary data structures.
void p4est_wrap_set_hollow(p4est_wrap_t *pp, int hollow)
Change hollow status of the wrap.
void p4est_wrap_complete(p4est_wrap_t *pp)
Free memory for the intermediate mesh.
int p4est_wrap_adapt(p4est_wrap_t *pp)
Call p4est_refine, coarsen, and balance to update pp->p4est.
p4est_wrap_t * p4est_wrap_new_ext(sc_MPI_Comm mpicomm, p4est_connectivity_t *conn, int initial_level, int hollow, p4est_connect_type_t btype, p4est_replace_t replace_fn, void *user_pointer)
Create a p4est wrapper from a given connectivity structure.
p4est_wrap_t * p4est_wrap_new_p4est(p4est_t *p4est, int hollow, p4est_connect_type_t btype, p4est_replace_t replace_fn, void *user_pointer)
Create a wrapper for a given p4est structure.
void p4est_wrap_mark_refine(p4est_wrap_t *pp, p4est_topidx_t which_tree, p4est_locidx_t which_quad)
Mark a local element for refinement.
void p4est_wrap_set_coarsen_delay(p4est_wrap_t *pp, int coarsen_delay, int coarsen_affect)
Set a parameter that delays coarsening after adaptation.
p4est_wrap_t * p4est_wrap_new_world(int initial_level)
Passes sc_MPI_COMM_WORLD to p4est_wrap_new_unitsquare.
int p4est_wrap_partition(p4est_wrap_t *pp, int weight_exponent, p4est_locidx_t *unchanged_first, p4est_locidx_t *unchanged_length, p4est_locidx_t *unchanged_old_first)
Call p4est_partition for equal leaf distribution.
p4est_mesh_t * p4est_wrap_get_mesh(p4est_wrap_t *pp)
Return the appropriate mesh structure.
p4est_wrap_t * p4est_wrap_new_conn(sc_MPI_Comm mpicomm, p4est_connectivity_t *conn, int initial_level)
Create a p4est wrapper from a given connectivity structure.
sc3_MPI_Comm_t sc_MPI_Comm
This structure holds the 2D inter-tree connectivity information.
Definition: p4est_connectivity.h:153
quadrants that neighbor the local domain
Definition: p4est_ghost.h:41
This structure contains complete mesh information on a 2:1 balanced forest.
Definition: p4est_mesh.h:101
The 2D quadrant datatype.
Definition: p4est.h:72
The p4est tree datatype.
Definition: p4est.h:115
Definition: p4est_wrap.h:318
p4est_locidx_t local_quad
Quadrant number relative to proc.
Definition: p4est_wrap.h:324
p4est_locidx_t nm
Internal: mirror counter.
Definition: p4est_wrap.h:337
p4est_locidx_t which_quad
Quadrant number relative to tree.
Definition: p4est_wrap.h:323
p4est_tree_t * tree
Current tree.
Definition: p4est_wrap.h:325
p4est_topidx_t which_tree
Current tree number.
Definition: p4est_wrap.h:322
sc_array_t * mirrors
If not NULL, from pp's ghost.
Definition: p4est_wrap.h:336
int is_mirror
Quadrant at parallel boundary?
Definition: p4est_wrap.h:335
p4est_locidx_t next_mirror_quadrant
Internal: next.
Definition: p4est_wrap.h:338
p4est_wrap_t * pp
Must contain a valid ghost.
Definition: p4est_wrap.h:319
p4est_quadrant_t * quad
Current quadrant.
Definition: p4est_wrap.h:327
sc_array_t * tquadrants
Current tree's quadrants.
Definition: p4est_wrap.h:326
Definition: p4est_wrap.h:52
p4est_t * p4est
p4est->user_pointer is used internally
Definition: p4est_wrap.h:84
int coarsen_delay
Non-negative integer tells us how many adaptations to wait before any given quadrant may be coarsened...
Definition: p4est_wrap.h:62
int coarsen_affect
Boolean: If true, we delay coarsening not only after refinement, but also between subsequent coarseni...
Definition: p4est_wrap.h:66
int hollow
If true, this wrap has NULL for ghost, mesh, and flag members.
Definition: p4est_wrap.h:58
sc_refcount_t conn_rc
This reference counter is a workaround for internal use only.
Definition: p4est_wrap.h:73
void * user_pointer
Convenience member for users.
Definition: p4est_wrap.h:54
The p4est forest datatype.
Definition: p4est.h:136