p4est  1.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
p4est_wrap.h
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) 2012 Carsten Burstedde
7 
8  p4est is free software; you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation; either version 2 of the License, or
11  (at your option) any later version.
12 
13  p4est is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with p4est; if not, write to the Free Software Foundation, Inc.,
20  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 */
22 
23 #ifndef P4EST_WRAP_H
24 #define P4EST_WRAP_H
25 
26 #include <p4est_mesh.h>
27 
28 SC_EXTERN_C_BEGIN;
29 
30 /*** COMPLETE INTERNAL STATE OF P4EST ***/
31 
32 typedef enum p4est_wrap_flags
33 {
34  P4EST_WRAP_NONE = 0,
35  P4EST_WRAP_REFINE = 0x01,
36  P4EST_WRAP_COARSEN = 0x02
37 }
38 p4est_wrap_flags_t;
39 
40 typedef struct p4est_wrap
41 {
42  /* this member is never used or changed by p4est_wrap */
43  void *user_pointer;
45  /* these members are considered public and read-only */
46  int p4est_dim;
47  int p4est_half;
48  int p4est_faces;
49  int p4est_children;
53  /* anything below here is considered private und should not be touched */
54  int weight_exponent;
55  uint8_t *flags, *temp_flags;
56  p4est_locidx_t num_refine_flags, inside_counter, num_replaced;
57 
58  /* for ghost and mesh use p4est_wrap_get_ghost, _mesh declared below */
59  p4est_ghost_t *ghost;
60  p4est_mesh_t *mesh;
61  p4est_ghost_t *ghost_aux;
62  p4est_mesh_t *mesh_aux;
63  int match_aux;
64 }
66 
73 p4est_wrap_t *p4est_wrap_new_conn (sc_MPI_Comm mpicomm,
74  p4est_connectivity_t * conn,
75  int initial_level);
76 
80 p4est_wrap_t *p4est_wrap_new_unitsquare (sc_MPI_Comm mpicomm,
81  int initial_level);
82 p4est_wrap_t *p4est_wrap_new_periodic (sc_MPI_Comm mpicomm,
83  int initial_level);
84 p4est_wrap_t *p4est_wrap_new_rotwrap (sc_MPI_Comm mpicomm,
85  int initial_level);
86 p4est_wrap_t *p4est_wrap_new_corner (sc_MPI_Comm mpicomm,
87  int initial_level);
88 p4est_wrap_t *p4est_wrap_new_pillow (sc_MPI_Comm mpicomm,
89  int initial_level);
90 p4est_wrap_t *p4est_wrap_new_moebius (sc_MPI_Comm mpicomm,
91  int initial_level);
92 p4est_wrap_t *p4est_wrap_new_cubed (sc_MPI_Comm mpicomm,
93  int initial_level);
94 p4est_wrap_t *p4est_wrap_new_disk (sc_MPI_Comm mpicomm,
95  int initial_level);
96 
98 p4est_wrap_t *p4est_wrap_new_world (int initial_level);
99 void p4est_wrap_destroy (p4est_wrap_t * pp);
100 
105 p4est_ghost_t *p4est_wrap_get_ghost (p4est_wrap_t * pp);
106 
111 p4est_mesh_t *p4est_wrap_get_mesh (p4est_wrap_t * pp);
112 
119 void p4est_wrap_mark_refine (p4est_wrap_t * pp,
120  p4est_topidx_t which_tree,
121  p4est_locidx_t which_quad);
122 
129 void p4est_wrap_mark_coarsen (p4est_wrap_t * pp,
130  p4est_topidx_t which_tree,
131  p4est_locidx_t which_quad);
132 
142 int p4est_wrap_adapt (p4est_wrap_t * pp);
143 
157 int p4est_wrap_partition (p4est_wrap_t * pp,
158  int weight_exponent);
159 
165 void p4est_wrap_complete (p4est_wrap_t * pp);
166 
167 /*** ITERATOR OVER THE FOREST LEAVES ***/
168 
169 typedef struct p4est_wrap_leaf
170 {
171  p4est_wrap_t *pp;
172  int level;
173  p4est_topidx_t which_tree;
174  p4est_locidx_t which_quad;
175  p4est_locidx_t total_quad;
176  p4est_tree_t *tree;
177  p4est_quadrant_t *quad;
178  double lowerleft[3];
179  double upperright[3];
180 }
182 
183 /* Create an iterator over the leaves in the forest.
184  * Returns a newly allocated state containing the first leaf,
185  * or NULL if the local partition of the tree is empty.
186  */
187 p4est_wrap_leaf_t *p4est_wrap_leaf_first (p4est_wrap_t * pp);
188 
189 /* Move the forest leaf iterator forward.
190  * Returns the state that was input with information for the next leaf,
191  * or NULL and deallocates the input if called with the last leaf.
192  */
193 p4est_wrap_leaf_t *p4est_wrap_leaf_next (p4est_wrap_leaf_t * leaf);
194 
195 SC_EXTERN_C_END;
196 
197 #endif /* !P4EST_WRAP_H */
quadrants that neighbor the local domain
Definition: p4est_ghost.h:39
Definition: p4est_wrap.h:169
p4est_t * p4est
p4est->user_pointer is used internally
Definition: p4est_wrap.h:51
The p4est forest datatype.
Definition: p4est.h:129
This structure holds the 2D inter-tree connectivity information.
Definition: p4est_connectivity.h:139
Definition: p4est_wrap.h:40
void * user_pointer
Convenience member for users.
Definition: p4est_wrap.h:43
forest topology in a conventional mesh format
The p4est tree datatype.
Definition: p4est.h:108
int32_t p4est_topidx_t
Typedef for counting topological entities (trees, tree vertices).
Definition: p4est_base.h:63
int32_t p4est_locidx_t
Typedef for processor-local indexing of quadrants and nodes.
Definition: p4est_base.h:74
The 2D quadrant datatype.
Definition: p4est.h:65
This structure contains complete mesh information on the forest.
Definition: p4est_mesh.h:88