p4est  1.0
src/p4est_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 P4EST_WRAP_H
00024 #define P4EST_WRAP_H
00025 
00026 #include <p4est_mesh.h>
00027 
00028 SC_EXTERN_C_BEGIN;
00029 
00030 /*** COMPLETE INTERNAL STATE OF P4EST ***/
00031 
00032 typedef enum p4est_wrap_flags
00033 {
00034   P4EST_WRAP_NONE = 0,
00035   P4EST_WRAP_REFINE = 0x01,
00036   P4EST_WRAP_COARSEN = 0x02
00037 }
00038 p4est_wrap_flags_t;
00039 
00040 typedef struct p4est_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   p4est_connectivity_t *conn;
00048   p4est_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   p4est_ghost_t      *ghost;
00057   p4est_mesh_t       *mesh;
00058   p4est_ghost_t      *ghost_aux;
00059   p4est_mesh_t       *mesh_aux;
00060   int                 match_aux;
00061 }
00062 p4est_wrap_t;
00063 
00067 p4est_wrap_t       *p4est_wrap_new_unitsquare (sc_MPI_Comm mpicomm,
00068                                                int initial_level);
00069 p4est_wrap_t       *p4est_wrap_new_periodic (sc_MPI_Comm mpicomm,
00070                                              int initial_level);
00071 p4est_wrap_t       *p4est_wrap_new_rotwrap (sc_MPI_Comm mpicomm,
00072                                             int initial_level);
00073 p4est_wrap_t       *p4est_wrap_new_corner (sc_MPI_Comm mpicomm,
00074                                            int initial_level);
00075 p4est_wrap_t       *p4est_wrap_new_pillow (sc_MPI_Comm mpicomm,
00076                                            int initial_level);
00077 p4est_wrap_t       *p4est_wrap_new_moebius (sc_MPI_Comm mpicomm,
00078                                             int initial_level);
00079 p4est_wrap_t       *p4est_wrap_new_cubed (sc_MPI_Comm mpicomm,
00080                                           int initial_level);
00081 p4est_wrap_t       *p4est_wrap_new_disk (sc_MPI_Comm mpicomm,
00082                                          int initial_level);
00083 
00085 p4est_wrap_t       *p4est_wrap_new_world (int initial_level);
00086 void                p4est_wrap_destroy (p4est_wrap_t * pp);
00087 
00092 p4est_ghost_t      *p4est_wrap_get_ghost (p4est_wrap_t * pp);
00093 
00098 p4est_mesh_t       *p4est_wrap_get_mesh (p4est_wrap_t * pp);
00099 
00106 void                p4est_wrap_mark_refine (p4est_wrap_t * pp,
00107                                             p4est_topidx_t which_tree,
00108                                             p4est_locidx_t which_quad);
00109 
00116 void                p4est_wrap_mark_coarsen (p4est_wrap_t * pp,
00117                                              p4est_topidx_t which_tree,
00118                                              p4est_locidx_t which_quad);
00119 
00129 int                 p4est_wrap_adapt (p4est_wrap_t * pp);
00130 
00144 int                 p4est_wrap_partition (p4est_wrap_t * pp,
00145                                           int weight_exponent);
00146 
00152 void                p4est_wrap_complete (p4est_wrap_t * pp);
00153 
00154 /*** ITERATOR OVER THE FOREST LEAVES ***/
00155 
00156 typedef struct p4est_wrap_leaf
00157 {
00158   p4est_wrap_t       *pp;
00159   int                 level;
00160   p4est_topidx_t      which_tree;
00161   p4est_locidx_t      which_quad;
00162   p4est_locidx_t      total_quad;
00163   p4est_tree_t       *tree;
00164   p4est_quadrant_t   *quad;
00165   double              lowerleft[3];
00166   double              upperright[3];
00167 }
00168 p4est_wrap_leaf_t;
00169 
00170 /* Create an iterator over the leaves in the forest.
00171  * Returns a newly allocated state containing the first leaf,
00172  * or NULL if the local partition of the tree is empty.
00173  */
00174 p4est_wrap_leaf_t  *p4est_wrap_leaf_first (p4est_wrap_t * pp);
00175 
00176 /* Move the forest leaf iterator forward.
00177  * Returns the state that was input with information for the next leaf,
00178  * or NULL and deallocates the input if called with the last leaf.
00179  */
00180 p4est_wrap_leaf_t  *p4est_wrap_leaf_next (p4est_wrap_leaf_t * leaf);
00181 
00182 SC_EXTERN_C_END;
00183 
00184 #endif /* !P4EST_WRAP_H */
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines