p4est  2.8.643-dbc7-dirty
p4est is a software library for parallel adaptive mesh refinement.
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  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 
32 #ifndef P8EST_ITERATE_H
33 #define P8EST_ITERATE_H
34 
35 #include <p8est.h>
36 #include <p8est_ghost.h>
37 
38 SC_EXTERN_C_BEGIN;
39 
47 typedef struct p8est_iter_volume_info
48 {
49  p8est_t *p4est;
50  p8est_ghost_t *ghost_layer;
55 }
57 
64  void *user_data);
65 
73 typedef struct p8est_iter_face_side
74 {
76  int8_t face;
78  int8_t is_hanging;
81  {
82  struct
83  {
84  int8_t is_ghost;
87  }
88  full;
90  struct
91  {
92  int8_t is_ghost[4];
95  }
96  hanging;
98  }
99  is;
100 }
102 
114 typedef struct p8est_iter_face_info
115 {
116  p8est_t *p4est;
117  p8est_ghost_t *ghost_layer;
118  int8_t orientation;
121  int8_t tree_boundary;
123  sc_array_t sides; /* array of p8est_iter_face_side_t type */
124 }
126 
138  void *user_data);
139 
140 /* The information that is available to the user-defined p8est_iter_edge_t
141  * callback.
142  *
143  * If a \a quad is local (\a is_ghost is false), then its \a quadid indexes
144  * the tree's quadrant array; otherwise, it indexes the ghosts array. If the
145  * edge is hanging, then the quadrants are listed in z-order. If an edge is in
146  * the interior of a tree, orientation is 0; if an edge is between trees,
147  * orientation is the same as edge orientation in the connectivity. If a
148  * quadrant should be present, but it is not included in the ghost layer, then
149  * quad = NULL, is_ghost is true, and quadid = -1.
150  *
151  * the \a faces field provides some additional information about the local
152  * neighborhood: if side[i]->faces[j] == side[k]->faces[l], this indicates that
153  * there is a common face between these two sides of the edge.
154  */
155 typedef struct p8est_iter_edge_side
156 {
158  int8_t edge;
160  int8_t orientation;
164  int8_t is_hanging;
167  {
168  struct
169  {
170  int8_t is_ghost;
173  }
174  full;
177  struct
178  {
179  int8_t is_ghost[2];
180  p8est_quadrant_t *quad[2];
182  }
183  hanging;
185  }
186  is;
187  int8_t faces[2];
188 }
190 
198 typedef struct p8est_iter_edge_info
199 {
200  p8est_t *p4est;
201  p8est_ghost_t *ghost_layer;
202  int8_t tree_boundary;
205 }
207 
219  void *user_data);
220 
221 /* Information about one side of a corner in the forest. If a \a quad is local,
222  * then its \a quadid indexes the tree's quadrant array; otherwise, it indexes
223  * the ghosts array.
224  *
225  * the \a faces and \a edges field provides some additional information about
226  * the local neighborhood: if side[i]->faces[j] == side[k]->faces[l], this
227  * indicates that there is a common face between these two sides of the
228  * corner.
229  */
231 {
233  int8_t corner;
235  int8_t is_ghost;
236  p8est_quadrant_t *quad;
238  int8_t faces[3];
239  int8_t edges[3];
240 }
242 
253 {
254  p8est_t *p4est;
255  p8est_ghost_t *ghost_layer;
256  int8_t tree_boundary;
259 }
261 
275  void *user_data);
276 
317  p8est_ghost_t * ghost_layer,
318  void *user_data,
319  p8est_iter_volume_t iter_volume,
320  p8est_iter_face_t iter_face,
321  p8est_iter_edge_t iter_edge,
322  p8est_iter_corner_t iter_corner);
323 
326 /*@unused@*/
327 static inline p8est_iter_corner_side_t *
328 p8est_iter_cside_array_index_int (sc_array_t * array, int it)
329 {
330  P4EST_ASSERT (array->elem_size == sizeof (p8est_iter_corner_side_t));
331  P4EST_ASSERT (it >= 0 && (size_t) it < array->elem_count);
332 
333  return (p8est_iter_corner_side_t *)
334  (array->array + sizeof (p8est_iter_corner_side_t) * (size_t) it);
335 }
336 
339 /*@unused@*/
340 static inline p8est_iter_corner_side_t *
341 p8est_iter_cside_array_index (sc_array_t * array, size_t it)
342 {
343  P4EST_ASSERT (array->elem_size == sizeof (p8est_iter_corner_side_t));
344  P4EST_ASSERT (it < array->elem_count);
345 
346  return (p8est_iter_corner_side_t *)
347  (array->array + sizeof (p8est_iter_corner_side_t) * it);
348 }
349 
352 /*@unused@*/
353 static inline p8est_iter_edge_side_t *
354 p8est_iter_eside_array_index_int (sc_array_t * array, int it)
355 {
356  P4EST_ASSERT (array->elem_size == sizeof (p8est_iter_edge_side_t));
357  P4EST_ASSERT (it >= 0 && (size_t) it < array->elem_count);
358 
359  return (p8est_iter_edge_side_t *)
360  (array->array + sizeof (p8est_iter_edge_side_t) * (size_t) it);
361 }
362 
365 /*@unused@*/
366 static inline p8est_iter_edge_side_t *
367 p8est_iter_eside_array_index (sc_array_t * array, size_t it)
368 {
369  P4EST_ASSERT (array->elem_size == sizeof (p8est_iter_edge_side_t));
370  P4EST_ASSERT (it < array->elem_count);
371 
372  return (p8est_iter_edge_side_t *)
373  (array->array + sizeof (p8est_iter_edge_side_t) * it);
374 }
375 
378 /*@unused@*/
379 static inline p8est_iter_face_side_t *
380 p8est_iter_fside_array_index_int (sc_array_t * array, int it)
381 {
382  P4EST_ASSERT (array->elem_size == sizeof (p8est_iter_face_side_t));
383  P4EST_ASSERT (it >= 0 && (size_t) it < array->elem_count);
384 
385  return (p8est_iter_face_side_t *)
386  (array->array + sizeof (p8est_iter_face_side_t) * (size_t) it);
387 }
388 
391 /*@unused@*/
392 static inline p8est_iter_face_side_t *
393 p8est_iter_fside_array_index (sc_array_t * array, size_t it)
394 {
395  P4EST_ASSERT (array->elem_size == sizeof (p8est_iter_face_side_t));
396  P4EST_ASSERT (it < array->elem_count);
397 
398  return (p8est_iter_face_side_t *)
399  (array->array + sizeof (p8est_iter_face_side_t) * it);
400 }
401 
402 SC_EXTERN_C_END;
403 
404 #endif /* !P8EST_ITERATE_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
The top-level 3D p8est interface.
passing quadrants and data to neighboring processes
struct p8est_iter_volume_info p8est_iter_volume_info_t
The information that is available to the user-defined p8est_iter_volume_t callback function.
struct p8est_iter_face_side p8est_iter_face_side_t
Information about one side of a face in the forest.
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:218
struct p8est_iter_corner_info p8est_iter_corner_info_t
The information that is availalbe to the user-defined p8est_iter_corner_t callback.
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:274
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:63
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:137
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...
struct p8est_iter_edge_info p8est_iter_edge_info_t
The information about all sides of an edge in the forest.
struct p8est_iter_face_info p8est_iter_face_info_t
The information that is available to the user-defined p8est_iter_face_t callback.
The p4est forest datatype.
Definition: p4est.h:136
quadrants that neighbor the local domain
Definition: p8est_ghost.h:41
The information that is availalbe to the user-defined p8est_iter_corner_t callback.
Definition: p8est_iterate.h:253
int8_t tree_boundary
boolean: interior face (0), tree boundary face (true)
Definition: p8est_iterate.h:256
sc_array_t sides
array of p8est_iter_corner_side_t type
Definition: p8est_iterate.h:258
Definition: p8est_iterate.h:231
p4est_locidx_t quadid
the index in the tree or ghost array
Definition: p8est_iterate.h:237
int8_t corner
which of the quadrant's corners touches this corner
Definition: p8est_iterate.h:233
int8_t faces[3]
internal work data
Definition: p8est_iterate.h:238
int8_t edges[3]
internal work data
Definition: p8est_iterate.h:239
p4est_topidx_t treeid
the tree that contains quad
Definition: p8est_iterate.h:232
int8_t is_ghost
boolean: local (0) or ghost (1)
Definition: p8est_iterate.h:235
The information about all sides of an edge in the forest.
Definition: p8est_iterate.h:199
int8_t tree_boundary
boolean: interior face (0), tree boundary face (true)
Definition: p8est_iterate.h:202
sc_array_t sides
array of p8est_iter_edge_side_t type
Definition: p8est_iterate.h:204
Definition: p8est_iterate.h:156
int8_t edge
which quadrant side the edge touches
Definition: p8est_iterate.h:158
int8_t orientation
the orientation of each quadrant relative to this edge, as in the definition of p8est_connectivity_t
Definition: p8est_iterate.h:160
int8_t is_hanging
boolean: one full quad (0) or two smaller quads (1)
Definition: p8est_iterate.h:164
p4est_topidx_t treeid
the tree on this side
Definition: p8est_iterate.h:157
The information that is available to the user-defined p8est_iter_face_t callback.
Definition: p8est_iterate.h:115
int8_t orientation
the orientation of the sides to each other, as in the definition of p8est_connectivity_t
Definition: p8est_iterate.h:118
int8_t tree_boundary
boolean: interior face (0), tree boundary face (true)
Definition: p8est_iterate.h:121
Information about one side of a face in the forest.
Definition: p8est_iterate.h:74
int8_t face
which quadrant side the face touches
Definition: p8est_iterate.h:76
p4est_topidx_t treeid
the tree on this side
Definition: p8est_iterate.h:75
int8_t is_hanging
boolean: one full quad (0) or four smaller quads (1)
Definition: p8est_iterate.h:78
The information that is available to the user-defined p8est_iter_volume_t callback function.
Definition: p8est_iterate.h:48
p8est_quadrant_t * quad
the quadrant of the callback
Definition: p8est_iterate.h:51
p4est_locidx_t quadid
id in quad's tree array (see p8est_tree_t)
Definition: p8est_iterate.h:52
p4est_topidx_t treeid
the tree containing quad
Definition: p8est_iterate.h:54
The 3D quadrant (i.e., octant) datatype.
Definition: p8est.h:68
The p8est forest datatype.
Definition: p8est.h:132
size_t elem_size
char * array
struct p8est_iter_edge_side::p8est_iter_edge_side_data::@21 hanging
if is_hanging = 1, use is.hanging to access per-quadrant data
p8est_quadrant_t * quad
the actual quadrant
Definition: p8est_iterate.h:171
p4est_locidx_t quadid
index in tree or ghost array
Definition: p8est_iterate.h:172
struct p8est_iter_edge_side::p8est_iter_edge_side_data::@20 full
if is_hanging = 0, use is.full to access per-quadrant data
int8_t is_ghost
boolean: local (0) or ghost (1)
Definition: p8est_iterate.h:170
struct p8est_iter_face_side::p8est_iter_face_side_data::@18 full
if is_hanging = 0, use is.full to access per-quadrant data
p8est_quadrant_t * quad
the actual quadrant
Definition: p8est_iterate.h:85
int8_t is_ghost
boolean: local (0) or ghost (1)
Definition: p8est_iterate.h:84
struct p8est_iter_face_side::p8est_iter_face_side_data::@19 hanging
if is_hanging = 1, use is.hanging to access per-quadrant data
p4est_locidx_t quadid
index in tree or ghost array
Definition: p8est_iterate.h:86