p4est  1.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
p4est_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 P4EST_ITERATE_H
32 #define P4EST_ITERATE_H
33 
34 #include <p4est.h>
35 #include <p4est_ghost.h>
36 
37 SC_EXTERN_C_BEGIN;
38 
46 typedef struct p4est_iter_volume_info
47 {
48  p4est_t *p4est;
49  p4est_ghost_t *ghost_layer;
54 }
56 
63  void *user_data);
64 
74 typedef struct p4est_iter_face_side
75 {
77  int8_t face;
79  int8_t is_hanging;
82  {
83  struct
84  {
85  int8_t is_ghost;
88  }
89  full;
91  struct
92  {
93  int8_t is_ghost[2];
94  p4est_quadrant_t *quad[2];
95  p4est_locidx_t quadid[2];
96  }
97  hanging;
99  }
100  is;
101 }
103 
115 typedef struct p4est_iter_face_info
116 {
117  p4est_t *p4est;
118  p4est_ghost_t *ghost_layer;
119  int8_t orientation;
122  int8_t tree_boundary;
124  sc_array_t sides; /* array of p4est_iter_face_side_t type */
125 }
127 
139  void *user_data);
140 
151 typedef struct p4est_iter_corner_side
152 {
154  int8_t corner;
156  int8_t is_ghost;
157  p4est_quadrant_t *quad;
159  int8_t faces[2];
160 }
162 
172 typedef struct p4est_iter_corner_info
173 {
174  p4est_t *p4est;
175  p4est_ghost_t *ghost_layer;
176  int8_t tree_boundary;
179 }
181 
195  void *user_data);
196 
232 void p4est_iterate (p4est_t * p4est,
233  p4est_ghost_t * ghost_layer,
234  void *user_data,
235  p4est_iter_volume_t iter_volume,
236  p4est_iter_face_t iter_face,
237  p4est_iter_corner_t iter_corner);
238 
241 /*@unused@*/
242 static inline p4est_iter_corner_side_t *
244 {
245  P4EST_ASSERT (array->elem_size == sizeof (p4est_iter_corner_side_t));
246  P4EST_ASSERT (it >= 0 && (size_t) it < array->elem_count);
247 
248  return (p4est_iter_corner_side_t *)
249  (array->array + sizeof (p4est_iter_corner_side_t) * it);
250 }
251 
254 /*@unused@*/
255 static inline p4est_iter_corner_side_t *
257 {
258  P4EST_ASSERT (array->elem_size == sizeof (p4est_iter_corner_side_t));
259  P4EST_ASSERT (it < array->elem_count);
260 
261  return (p4est_iter_corner_side_t *)
262  (array->array + sizeof (p4est_iter_corner_side_t) * it);
263 }
264 
267 /*@unused@*/
268 static inline p4est_iter_face_side_t *
270 {
271  P4EST_ASSERT (array->elem_size == sizeof (p4est_iter_face_side_t));
272  P4EST_ASSERT (it >= 0 && (size_t) it < array->elem_count);
273 
274  return (p4est_iter_face_side_t *)
275  (array->array + sizeof (p4est_iter_face_side_t) * it);
276 }
277 
280 /*@unused@*/
281 static inline p4est_iter_face_side_t *
283 {
284  P4EST_ASSERT (array->elem_size == sizeof (p4est_iter_face_side_t));
285  P4EST_ASSERT (it < array->elem_count);
286 
287  return (p4est_iter_face_side_t *)
288  (array->array + sizeof (p4est_iter_face_side_t) * it);
289 }
290 
291 SC_EXTERN_C_END;
292 
293 #endif /* !P4EST_ITERATE_H */
quadrants that neighbor the local domain
Definition: p4est_ghost.h:39
int8_t tree_boundary
boolean: interior face (0), boundary face (1)
Definition: p4est_iterate.h:122
int8_t is_hanging
boolean: one full quad (0) or two smaller quads (1)
Definition: p4est_iterate.h:79
static p4est_iter_face_side_t * p4est_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: p4est_iterate.h:282
int8_t corner
which of the quadrant's corners touches this corner
Definition: p4est_iterate.h:154
static p4est_iter_corner_side_t * p4est_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: p4est_iterate.h:256
char * array
linear array to store elements
Definition: sc_containers.h:104
The information that is available to the user-defined p4est_iter_corner_t callback.
Definition: p4est_iterate.h:172
size_t elem_size
size of a single element
Definition: sc_containers.h:95
Information about one side of a face in the forest.
Definition: p4est_iterate.h:74
void(* p4est_iter_corner_t)(p4est_iter_corner_info_t *info, void *user_data)
The prototype for a function that p4est_iterate will execute wherever quadrants meet at a conformal c...
Definition: p4est_iterate.h:194
The information that is available to the user-defined p4est_iter_face_t callback. ...
Definition: p4est_iterate.h:115
int8_t is_ghost
boolean: local (0) or ghost (1)
Definition: p4est_iterate.h:156
sc_array_t sides
array of type p4est_iter_corner_side_t type
Definition: p4est_iterate.h:178
void p4est_iterate(p4est_t *p4est, p4est_ghost_t *ghost_layer, void *user_data, p4est_iter_volume_t iter_volume, p4est_iter_face_t iter_face, p4est_iter_corner_t iter_corner)
Execute user supplied callbacks at every volume, face, and corner in the local forest.
Definition: p4est_iterate.c:3297
int8_t orientation
the orientation of the sides to each other, as in the definition of p4est_connectivity_t ...
Definition: p4est_iterate.h:119
void(* p4est_iter_volume_t)(p4est_iter_volume_info_t *info, void *user_data)
The prototype for a function that p4est_iterate will execute at every quadrant local to the current p...
Definition: p4est_iterate.h:62
The information that is available to the user-defined p4est_iter_volume_t callback function...
Definition: p4est_iterate.h:46
The p4est forest datatype.
Definition: p4est.h:129
p4est_topidx_t treeid
the tree containing quad
Definition: p4est_iterate.h:53
The top-level 2D p4est interface.
Information about one side of a corner in the forest.
Definition: p4est_iterate.h:151
int8_t is_ghost
boolean: local (0) or ghost (1)
Definition: p4est_iterate.h:85
static p4est_iter_corner_side_t * p4est_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: p4est_iterate.h:243
p4est_locidx_t quadid
index in tree or ghost array
Definition: p4est_iterate.h:87
static p4est_iter_face_side_t * p4est_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: p4est_iterate.h:269
The sc_array object provides a large array of equal-size elements.
Definition: sc_containers.h:92
p4est_quadrant_t * quad
the actual quadrant
Definition: p4est_iterate.h:86
p4est_locidx_t quadid
the index in the tree or ghost array
Definition: p4est_iterate.h:158
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
void(* p4est_iter_face_t)(p4est_iter_face_info_t *info, void *user_data)
The prototype for a function that p4est_iterate will execute wherever two quadrants share a face: the...
Definition: p4est_iterate.h:138
int8_t face
which quadrant side the face touches
Definition: p4est_iterate.h:77
p4est_topidx_t treeid
the tree on this side
Definition: p4est_iterate.h:76
p4est_topidx_t treeid
the tree that contains quad
Definition: p4est_iterate.h:153
int8_t tree_boundary
boolean: interior face (0), boundary face (1)
Definition: p4est_iterate.h:176
p4est_locidx_t quadid
id in quad's tree array (see p4est_tree_t)
Definition: p4est_iterate.h:51
The 2D quadrant datatype.
Definition: p4est.h:65
passing quadrants and data to neighboring processes
p4est_quadrant_t * quad
the quadrant of the callback
Definition: p4est_iterate.h:50