p4est  1.0
src/p8est_iterate.h
Go to the documentation of this file.
00001 /*
00002   This file is part of p4est.
00003   p4est is a C library to manage a collection (a forest) of multiple
00004   connected adaptive quadtrees or octrees in parallel.
00005 
00006   Copyright (C) 2010 The University of Texas System
00007   Written by Carsten Burstedde, Lucas C. Wilcox, and Tobin Isaac
00008 
00009   p4est is free software; you can redistribute it and/or modify
00010   it under the terms of the GNU General Public License as published by
00011   the Free Software Foundation; either version 2 of the License, or
00012   (at your option) any later version.
00013 
00014   p4est is distributed in the hope that it will be useful,
00015   but WITHOUT ANY WARRANTY; without even the implied warranty of
00016   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017   GNU General Public License for more details.
00018 
00019   You should have received a copy of the GNU General Public License
00020   along with p4est; if not, write to the Free Software Foundation, Inc.,
00021   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00022 */
00023 
00031 #ifndef P8EST_ITERATE_H
00032 #define P8EST_ITERATE_H
00033 
00034 #include <p8est.h>
00035 #include <p8est_ghost.h>
00036 
00037 SC_EXTERN_C_BEGIN;
00038 
00046 typedef struct p8est_iter_volume_info
00047 {
00048   p8est_t            *p4est;
00049   p8est_ghost_t      *ghost_layer;
00050   p8est_quadrant_t   *quad;    
00051   p4est_locidx_t      quadid;  
00053   p4est_topidx_t      treeid;  
00054 }
00055 p8est_iter_volume_info_t;
00056 
00062 typedef void        (*p8est_iter_volume_t) (p8est_iter_volume_info_t * info,
00063                                             void *user_data);
00064 
00072 typedef struct p8est_iter_face_side
00073 {
00074   p4est_topidx_t      treeid;          
00075   int8_t              face;            
00077   int8_t              is_hanging;      
00079   union p8est_iter_face_side_data
00080   {
00081     struct
00082     {
00083       int8_t              is_ghost;    
00084       p8est_quadrant_t   *quad;        
00085       p4est_locidx_t      quadid;      
00086     }
00087     full; 
00089     struct
00090     {
00091       int8_t              is_ghost[4]; 
00092       p8est_quadrant_t   *quad[4];     
00093       p4est_locidx_t      quadid[4];   
00094     }
00095     hanging; 
00097   }
00098   is;
00099 }
00100 p8est_iter_face_side_t;
00101 
00113 typedef struct p8est_iter_face_info
00114 {
00115   p8est_t            *p4est;
00116   p8est_ghost_t      *ghost_layer;
00117   int8_t              orientation; 
00120   int8_t              tree_boundary; 
00122   sc_array_t          sides;    /* array of p8est_iter_face_side_t type */
00123 }
00124 p8est_iter_face_info_t;
00125 
00136 typedef void        (*p8est_iter_face_t) (p8est_iter_face_info_t * info,
00137                                           void *user_data);
00138 
00139 /* The information that is available to the user-defined p8est_iter_edge_t
00140  * callback.
00141  *
00142  * If a \a quad is local (\a is_ghost is false), then its \a quadid indexes
00143  * the tree's quadrant array; otherwise, it indexes the ghosts array. If the
00144  * edge is hanging, then the quadrants are listed in z-order. If an edge is in
00145  * the interior of a tree, orientation is 0; if an edge is between trees,
00146  * orientation is the same as edge orientation in the connectivity. If a
00147  * quadrant should be present, but it is not included in the ghost layer, then
00148  * quad = NULL, is_ghost is true, and quadid = -1.
00149                       *
00150  * the \a faces field provides some additional information about the local
00151  * neighborhood: if side[i]->faces[j] == side[k]->faces[l], this indicates that
00152  * there is a common face between these two sides of the edge.
00153  */
00154 typedef struct p8est_iter_edge_side
00155 {
00156   p4est_topidx_t      treeid;          
00157   int8_t              edge;            
00159   int8_t              orientation; 
00163   int8_t              is_hanging;      
00165   union p8est_iter_edge_side_data
00166   {
00167     struct
00168     {
00169       int8_t              is_ghost;    
00170       p8est_quadrant_t   *quad;        
00171       p4est_locidx_t      quadid;      
00172     }
00173     full; 
00176     struct
00177     {
00178       int8_t              is_ghost[2]; 
00179       p8est_quadrant_t   *quad[2];     
00180       p4est_locidx_t      quadid[2];   
00181     }
00182     hanging; 
00184   }
00185   is;
00186   int8_t              faces[2];
00187 }
00188 p8est_iter_edge_side_t;
00189 
00197 typedef struct p8est_iter_edge_info
00198 {
00199   p8est_t            *p4est;
00200   p8est_ghost_t      *ghost_layer;
00201   int8_t              tree_boundary;  
00203   sc_array_t          sides; 
00204 }
00205 p8est_iter_edge_info_t;
00206 
00217 typedef void        (*p8est_iter_edge_t) (p8est_iter_edge_info_t * info,
00218                                           void *user_data);
00219 
00220 /* Information about one side of a corner in the forest.  If a \a quad is local,
00221  * then its \a quadid indexes the tree's quadrant array; otherwise, it indexes
00222  * the ghosts array.
00223  *
00224  * the \a faces and \a edges field provides some additional information about
00225  * the local neighborhood: if side[i]->faces[j] == side[k]->faces[l], this
00226  * indicates that there is a common face between these two sides of the
00227  * corner.
00228  */
00229 typedef struct p8est_iter_corner_side
00230 {
00231   p4est_topidx_t      treeid;   
00232   int8_t              corner;   
00234   int8_t              is_ghost; 
00235   p8est_quadrant_t   *quad;
00236   p4est_locidx_t      quadid;   
00237   int8_t              faces[3]; 
00238   int8_t              edges[3]; 
00239 }
00240 p8est_iter_corner_side_t;
00241 
00251 typedef struct p8est_iter_corner_info
00252 {
00253   p8est_t            *p4est;
00254   p8est_ghost_t      *ghost_layer;
00255   int8_t              tree_boundary; 
00257   sc_array_t          sides; 
00258 }
00259 p8est_iter_corner_info_t;
00260 
00273 typedef void        (*p8est_iter_corner_t) (p8est_iter_corner_info_t * info,
00274                                             void *user_data);
00275 
00315 void                p8est_iterate (p8est_t * p4est,
00316                                    p8est_ghost_t * ghost_layer,
00317                                    void *user_data,
00318                                    p8est_iter_volume_t iter_volume,
00319                                    p8est_iter_face_t iter_face,
00320                                    p8est_iter_edge_t iter_edge,
00321                                    p8est_iter_corner_t iter_corner);
00322 
00325 /*@unused@*/
00326 static inline p8est_iter_corner_side_t *
00327 p8est_iter_cside_array_index_int (sc_array_t * array, int it)
00328 {
00329   P4EST_ASSERT (array->elem_size == sizeof (p8est_iter_corner_side_t));
00330   P4EST_ASSERT (it >= 0 && (size_t) it < array->elem_count);
00331 
00332   return (p8est_iter_corner_side_t *)
00333     (array->array + sizeof (p8est_iter_corner_side_t) * it);
00334 }
00335 
00338 /*@unused@*/
00339 static inline p8est_iter_corner_side_t *
00340 p8est_iter_cside_array_index (sc_array_t * array, size_t it)
00341 {
00342   P4EST_ASSERT (array->elem_size == sizeof (p8est_iter_corner_side_t));
00343   P4EST_ASSERT (it < array->elem_count);
00344 
00345   return (p8est_iter_corner_side_t *)
00346     (array->array + sizeof (p8est_iter_corner_side_t) * it);
00347 }
00348 
00351 /*@unused@*/
00352 static inline p8est_iter_edge_side_t *
00353 p8est_iter_eside_array_index_int (sc_array_t * array, int it)
00354 {
00355   P4EST_ASSERT (array->elem_size == sizeof (p8est_iter_edge_side_t));
00356   P4EST_ASSERT (it >= 0 && (size_t) it < array->elem_count);
00357 
00358   return (p8est_iter_edge_side_t *)
00359     (array->array + sizeof (p8est_iter_edge_side_t) * it);
00360 }
00361 
00364 /*@unused@*/
00365 static inline p8est_iter_edge_side_t *
00366 p8est_iter_eside_array_index (sc_array_t * array, size_t it)
00367 {
00368   P4EST_ASSERT (array->elem_size == sizeof (p8est_iter_edge_side_t));
00369   P4EST_ASSERT (it < array->elem_count);
00370 
00371   return (p8est_iter_edge_side_t *)
00372     (array->array + sizeof (p8est_iter_edge_side_t) * it);
00373 }
00374 
00377 /*@unused@*/
00378 static inline p8est_iter_face_side_t *
00379 p8est_iter_fside_array_index_int (sc_array_t * array, int it)
00380 {
00381   P4EST_ASSERT (array->elem_size == sizeof (p8est_iter_face_side_t));
00382   P4EST_ASSERT (it >= 0 && (size_t) it < array->elem_count);
00383 
00384   return (p8est_iter_face_side_t *)
00385     (array->array + sizeof (p8est_iter_face_side_t) * it);
00386 }
00387 
00390 /*@unused@*/
00391 static inline p8est_iter_face_side_t *
00392 p8est_iter_fside_array_index (sc_array_t * array, size_t it)
00393 {
00394   P4EST_ASSERT (array->elem_size == sizeof (p8est_iter_face_side_t));
00395   P4EST_ASSERT (it < array->elem_count);
00396 
00397   return (p8est_iter_face_side_t *)
00398     (array->array + sizeof (p8est_iter_face_side_t) * it);
00399 }
00400 
00401 SC_EXTERN_C_END;
00402 
00403 #endif /* !P8EST_ITERATE_H */
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines