p4est  1.0
src/p8est_wrap.h
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) 2012 Carsten Burstedde
00007 
00008   p4est is free software; you can redistribute it and/or modify
00009   it under the terms of the GNU General Public License as published by
00010   the Free Software Foundation; either version 2 of the License, or
00011   (at your option) any later version.
00012 
00013   p4est is distributed in the hope that it will be useful,
00014   but WITHOUT ANY WARRANTY; without even the implied warranty of
00015   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016   GNU General Public License for more details.
00017 
00018   You should have received a copy of the GNU General Public License
00019   along with p4est; if not, write to the Free Software Foundation, Inc.,
00020   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00021 */
00022 
00023 #ifndef P8EST_WRAP_H
00024 #define P8EST_WRAP_H
00025 
00026 #include <p8est_mesh.h>
00027 
00028 SC_EXTERN_C_BEGIN;
00029 
00030 /*** COMPLETE INTERNAL STATE OF P4EST ***/
00031 
00032 typedef enum p8est_wrap_flags
00033 {
00034   P8EST_WRAP_NONE = 0,
00035   P8EST_WRAP_REFINE = 0x01,
00036   P8EST_WRAP_COARSEN = 0x02
00037 }
00038 p8est_wrap_flags_t;
00039 
00040 typedef struct p8est_wrap
00041 {
00042   /* these members are considered public and read-only */
00043   int                 p4est_dim;
00044   int                 p4est_half;
00045   int                 p4est_faces;
00046   int                 p4est_children;
00047   p8est_connectivity_t *conn;
00048   p8est_t            *p4est;
00049 
00050   /* anything below here is considered private und should not be touched */
00051   int                 weight_exponent;
00052   uint8_t            *flags, *temp_flags;
00053   p4est_locidx_t      num_refine_flags, inside_counter, num_replaced;
00054 
00055   /* for ghost and mesh use p4est_wrap_get_ghost, _mesh declared below */
00056   p8est_ghost_t      *ghost;
00057   p8est_mesh_t       *mesh;
00058   p8est_ghost_t      *ghost_aux;
00059   p8est_mesh_t       *mesh_aux;
00060   int                 match_aux;
00061 }
00062 p8est_wrap_t;
00063 
00067 p8est_wrap_t       *p8est_wrap_new_unitcube (sc_MPI_Comm mpicomm,
00068                                              int initial_level);
00069 p8est_wrap_t       *p8est_wrap_new_rotwrap (sc_MPI_Comm mpicomm,
00070                                             int initial_level);
00071 
00073 p8est_wrap_t       *p8est_wrap_new_world (int initial_level);
00074 void                p8est_wrap_destroy (p8est_wrap_t * pp);
00075 
00080 p8est_ghost_t      *p8est_wrap_get_ghost (p8est_wrap_t * pp);
00081 
00086 p8est_mesh_t       *p8est_wrap_get_mesh (p8est_wrap_t * pp);
00087 
00094 void                p8est_wrap_mark_refine (p8est_wrap_t * pp,
00095                                             p4est_topidx_t which_tree,
00096                                             p4est_locidx_t which_quad);
00097 
00104 void                p8est_wrap_mark_coarsen (p8est_wrap_t * pp,
00105                                              p4est_topidx_t which_tree,
00106                                              p4est_locidx_t which_quad);
00107 
00117 int                 p8est_wrap_adapt (p8est_wrap_t * pp);
00118 
00131 int                 p8est_wrap_partition (p8est_wrap_t * pp,
00132                                           int weight_exponent);
00133 
00139 void                p8est_wrap_complete (p8est_wrap_t * pp);
00140 
00141 /*** ITERATOR OVER THE FOREST LEAVES ***/
00142 
00143 typedef struct p8est_wrap_leaf
00144 {
00145   p8est_wrap_t       *pp;
00146   int                 level;
00147   p4est_topidx_t      which_tree;
00148   p4est_locidx_t      which_quad;
00149   p4est_locidx_t      total_quad;
00150   p8est_tree_t       *tree;
00151   p8est_quadrant_t   *quad;
00152   double              lowerleft[3];
00153   double              upperright[3];
00154 }
00155 p8est_wrap_leaf_t;
00156 
00157 /* Create an iterator over the leaves in the forest.
00158  * Returns a newly allocated state containing the first leaf,
00159  * or NULL if the local partition of the tree is empty.
00160  */
00161 p8est_wrap_leaf_t  *p8est_wrap_leaf_first (p8est_wrap_t * pp);
00162 
00163 /* Move the forest leaf iterator forward.
00164  * Returns the state that was input with information for the next leaf,
00165  * or NULL and deallocates the input if called with the last leaf.
00166  */
00167 p8est_wrap_leaf_t  *p8est_wrap_leaf_next (p8est_wrap_leaf_t * leaf);
00168 
00169 SC_EXTERN_C_END;
00170 
00171 #endif /* !P8EST_WRAP_H */
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines