p4est  1.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
p8est_iterate.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  Written by Carsten Burstedde, Lucas C. Wilcox, and Tobin Isaac
8 
9  p4est is free software; you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation; either version 2 of the License, or
12  (at your option) any later version.
13 
14  p4est is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with p4est; if not, write to the Free Software Foundation, Inc.,
21  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 */
23 
31 #ifndef P8EST_ITERATE_H
32 #define P8EST_ITERATE_H
33 
34 #include <p8est.h>
35 #include <p8est_ghost.h>
36 
37 SC_EXTERN_C_BEGIN;
38 
46 typedef struct p8est_iter_volume_info
47 {
48  p8est_t *p4est;
49  p8est_ghost_t *ghost_layer;
54 }
56 
63  void *user_data);
64 
72 typedef struct p8est_iter_face_side
73 {
75  int8_t face;
77  int8_t is_hanging;
80  {
81  struct
82  {
83  int8_t is_ghost;
86  }
87  full;
89  struct
90  {
91  int8_t is_ghost[4];
92  p8est_quadrant_t *quad[4];
93  p4est_locidx_t quadid[4];
94  }
95  hanging;
97  }
98  is;
99 }
101 
113 typedef struct p8est_iter_face_info
114 {
115  p8est_t *p4est;
116  p8est_ghost_t *ghost_layer;
117  int8_t orientation;
120  int8_t tree_boundary;
122  sc_array_t sides; /* array of p8est_iter_face_side_t type */
123 }
125 
137  void *user_data);
138 
139 /* The information that is available to the user-defined p8est_iter_edge_t
140  * callback.
141  *
142  * If a \a quad is local (\a is_ghost is false), then its \a quadid indexes
143  * the tree's quadrant array; otherwise, it indexes the ghosts array. If the
144  * edge is hanging, then the quadrants are listed in z-order. If an edge is in
145  * the interior of a tree, orientation is 0; if an edge is between trees,
146  * orientation is the same as edge orientation in the connectivity. If a
147  * quadrant should be present, but it is not included in the ghost layer, then
148  * quad = NULL, is_ghost is true, and quadid = -1.
149  *
150  * the \a faces field provides some additional information about the local
151  * neighborhood: if side[i]->faces[j] == side[k]->faces[l], this indicates that
152  * there is a common face between these two sides of the edge.
153  */
154 typedef struct p8est_iter_edge_side
155 {
157  int8_t edge;
159  int8_t orientation;
163  int8_t is_hanging;
166  {
167  struct
168  {
169  int8_t is_ghost;
172  }
173  full;
176  struct
177  {
178  int8_t is_ghost[2];
179  p8est_quadrant_t *quad[2];
180  p4est_locidx_t quadid[2];
181  }
182  hanging;
184  }
185  is;
186  int8_t faces[2];
187 }
189 
197 typedef struct p8est_iter_edge_info
198 {
199  p8est_t *p4est;
200  p8est_ghost_t *ghost_layer;
201  int8_t tree_boundary;
204 }
206 
218  void *user_data);
219 
220 /* Information about one side of a corner in the forest. If a \a quad is local,
221  * then its \a quadid indexes the tree's quadrant array; otherwise, it indexes
222  * the ghosts array.
223  *
224  * the \a faces and \a edges field provides some additional information about
225  * the local neighborhood: if side[i]->faces[j] == side[k]->faces[l], this
226  * indicates that there is a common face between these two sides of the
227  * corner.
228  */
229 typedef struct p8est_iter_corner_side
230 {
232  int8_t corner;
234  int8_t is_ghost;
235  p8est_quadrant_t *quad;
237  int8_t faces[3];
238  int8_t edges[3];
239 }
241 
251 typedef struct p8est_iter_corner_info
252 {
253  p8est_t *p4est;
254  p8est_ghost_t *ghost_layer;
255  int8_t tree_boundary;
258 }
260 
274  void *user_data);
275 
315 void p8est_iterate (p8est_t * p4est,
316  p8est_ghost_t * ghost_layer,
317  void *user_data,
318  p8est_iter_volume_t iter_volume,
319  p8est_iter_face_t iter_face,
320  p8est_iter_edge_t iter_edge,
321  p8est_iter_corner_t iter_corner);
322 
325 /*@unused@*/
326 static inline p8est_iter_corner_side_t *
328 {
329  P4EST_ASSERT (array->elem_size == sizeof (p8est_iter_corner_side_t));
330  P4EST_ASSERT (it >= 0 && (size_t) it < array->elem_count);
331 
332  return (p8est_iter_corner_side_t *)
333  (array->array + sizeof (p8est_iter_corner_side_t) * it);
334 }
335 
338 /*@unused@*/
339 static inline p8est_iter_corner_side_t *
341 {
342  P4EST_ASSERT (array->elem_size == sizeof (p8est_iter_corner_side_t));
343  P4EST_ASSERT (it < array->elem_count);
344 
345  return (p8est_iter_corner_side_t *)
346  (array->array + sizeof (p8est_iter_corner_side_t) * it);
347 }
348 
351 /*@unused@*/
352 static inline p8est_iter_edge_side_t *
354 {
355  P4EST_ASSERT (array->elem_size == sizeof (p8est_iter_edge_side_t));
356  P4EST_ASSERT (it >= 0 && (size_t) it < array->elem_count);
357 
358  return (p8est_iter_edge_side_t *)
359  (array->array + sizeof (p8est_iter_edge_side_t) * it);
360 }
361 
364 /*@unused@*/
365 static inline p8est_iter_edge_side_t *
367 {
368  P4EST_ASSERT (array->elem_size == sizeof (p8est_iter_edge_side_t));
369  P4EST_ASSERT (it < array->elem_count);
370 
371  return (p8est_iter_edge_side_t *)
372  (array->array + sizeof (p8est_iter_edge_side_t) * it);
373 }
374 
377 /*@unused@*/
378 static inline p8est_iter_face_side_t *
380 {
381  P4EST_ASSERT (array->elem_size == sizeof (p8est_iter_face_side_t));
382  P4EST_ASSERT (it >= 0 && (size_t) it < array->elem_count);
383 
384  return (p8est_iter_face_side_t *)
385  (array->array + sizeof (p8est_iter_face_side_t) * it);
386 }
387 
390 /*@unused@*/
391 static inline p8est_iter_face_side_t *
393 {
394  P4EST_ASSERT (array->elem_size == sizeof (p8est_iter_face_side_t));
395  P4EST_ASSERT (it < array->elem_count);
396 
397  return (p8est_iter_face_side_t *)
398  (array->array + sizeof (p8est_iter_face_side_t) * it);
399 }
400 
401 SC_EXTERN_C_END;
402 
403 #endif /* !P8EST_ITERATE_H */
void(* p8est_iter_volume_t)(p8est_iter_volume_info_t *info, void *user_data)
The prototype for a function that p8est_iterate() will execute at every quadrant local to the current...
Definition: p8est_iterate.h:62
p8est_quadrant_t * quad
the actual quadrant
Definition: p8est_iterate.h:170
static p8est_iter_corner_side_t * p8est_iter_cside_array_index(sc_array_t *array, size_t it)
Return a pointer to a iter_corner_side array element indexed by a size_t.
Definition: p8est_iterate.h:340
Information about one side of a face in the forest.
Definition: p8est_iterate.h:72
passing quadrants and data to neighboring processes
p4est_topidx_t treeid
the tree containing quad
Definition: p8est_iterate.h:53
int8_t edge
which quadrant side the edge touches
Definition: p8est_iterate.h:157
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)
Execute the user-supplied callback functions at every volume, face, edge and corner in the local fore...
char * array
linear array to store elements
Definition: sc_containers.h:104
int8_t orientation
the orientation of the sides to each other, as in the definition of p8est_connectivity_t ...
Definition: p8est_iterate.h:117
void(* p8est_iter_face_t)(p8est_iter_face_info_t *info, void *user_data)
The prototype for a function that p8est_iterate() will execute wherever two quadrants share a face: t...
Definition: p8est_iterate.h:136
size_t elem_size
size of a single element
Definition: sc_containers.h:95
The information that is availalbe to the user-defined p8est_iter_corner_t callback.
Definition: p8est_iterate.h:251
p4est_locidx_t quadid
index in tree or ghost array
Definition: p8est_iterate.h:171
int8_t corner
which of the quadrant's corners touches this corner
Definition: p8est_iterate.h:232
quadrants that neighbor the local domain
Definition: p8est_ghost.h:39
static p8est_iter_edge_side_t * p8est_iter_eside_array_index(sc_array_t *array, size_t it)
Return a pointer to a iter_edge_side array element indexed by a size_t.
Definition: p8est_iterate.h:366
static p8est_iter_face_side_t * p8est_iter_fside_array_index(sc_array_t *array, size_t it)
Return a pointer to a iter_face_side array element indexed by a size_t.
Definition: p8est_iterate.h:392
int8_t tree_boundary
boolean: interior face (0), boundary face (1)
Definition: p8est_iterate.h:120
void(* p8est_iter_corner_t)(p8est_iter_corner_info_t *info, void *user_data)
The prototype for a function that p8est_iterate will execute wherever the corner is a corner for all ...
Definition: p8est_iterate.h:273
The top-level 3D p8est interface.
static p8est_iter_edge_side_t * p8est_iter_eside_array_index_int(sc_array_t *array, int it)
Return a pointer to a iter_edge_side array element indexed by a int.
Definition: p8est_iterate.h:353
void(* p8est_iter_edge_t)(p8est_iter_edge_info_t *info, void *user_data)
The prototype for a function that p8est_iterate will execute wherever the edge is an edge of all quad...
Definition: p8est_iterate.h:217
p8est_quadrant_t * quad
the quadrant of the callback
Definition: p8est_iterate.h:50
The information that is available to the user-defined p8est_iter_face_t callback. ...
Definition: p8est_iterate.h:113
p4est_locidx_t quadid
index in tree or ghost array
Definition: p8est_iterate.h:85
Definition: p8est_iterate.h:229
static p8est_iter_face_side_t * p8est_iter_fside_array_index_int(sc_array_t *array, int it)
Return a pointer to a iter_face_side array element indexed by a int.
Definition: p8est_iterate.h:379
p8est_quadrant_t * quad
the actual quadrant
Definition: p8est_iterate.h:84
int8_t orientation
the orientation of each quadrant relative to this edge, as in the definition of p8est_connectivity_t ...
Definition: p8est_iterate.h:159
The 3D quadrant (i.e.
Definition: p8est.h:61
The p8est forest datatype.
Definition: p8est.h:125
sc_array_t sides
array of p8est_iter_corner_side_t type
Definition: p8est_iterate.h:257
p4est_topidx_t treeid
the tree on this side
Definition: p8est_iterate.h:74
The sc_array object provides a large array of equal-size elements.
Definition: sc_containers.h:92
p4est_topidx_t treeid
the tree on this side
Definition: p8est_iterate.h:156
The information about all sides of an edge in the forest.
Definition: p8est_iterate.h:197
The information that is available to the user-defined p8est_iter_volume_t callback function...
Definition: p8est_iterate.h:46
p4est_topidx_t treeid
the tree that contains quad
Definition: p8est_iterate.h:231
int32_t p4est_topidx_t
Typedef for counting topological entities (trees, tree vertices).
Definition: p4est_base.h:63
int8_t is_hanging
boolean: one full quad (0) or four smaller quads (1)
Definition: p8est_iterate.h:77
int32_t p4est_locidx_t
Typedef for processor-local indexing of quadrants and nodes.
Definition: p4est_base.h:74
int8_t is_ghost
boolean: local (0) or ghost (1)
Definition: p8est_iterate.h:83
Definition: p8est_iterate.h:154
static p8est_iter_corner_side_t * p8est_iter_cside_array_index_int(sc_array_t *array, int it)
Return a pointer to a iter_corner_side array element indexed by a int.
Definition: p8est_iterate.h:327
int8_t is_ghost
boolean: local (0) or ghost (1)
Definition: p8est_iterate.h:234
int8_t tree_boundary
boolean: interior face (0), boundary face (1)
Definition: p8est_iterate.h:255
sc_array_t sides
array of p8est_iter_edge_side_t type
Definition: p8est_iterate.h:203
p4est_locidx_t quadid
id in quad's tree array (see p8est_tree_t)
Definition: p8est_iterate.h:51
int8_t is_hanging
boolean: one full quad (0) or two smaller quads (1)
Definition: p8est_iterate.h:163
int8_t tree_boundary
boolean: interior face (0), boundary face (1)
Definition: p8est_iterate.h:201
int8_t face
which quadrant side the face touches
Definition: p8est_iterate.h:75
int8_t is_ghost
boolean: local (0) or ghost (1)
Definition: p8est_iterate.h:169
p4est_locidx_t quadid
the index in the tree or ghost array
Definition: p8est_iterate.h:236