3#ifndef DUNE_GRAPEGRIDDISPLAY_HH
4#define DUNE_GRAPEGRIDDISPLAY_HH
18#include "grape/grapeinclude.hh"
46 g_HierarchicIterator = 2,
53 template<
class Gr
idType>
58 enum { dim = GridType::dimension };
59 enum { dimworld = GridType::dimensionworld };
64 typedef typename GrapeInterface<dim,dimworld>::DUNE_ELEM DUNE_ELEM;
65 typedef typename GrapeInterface<dim,dimworld>::DUNE_DAT DUNE_DAT;
66 typedef typename GrapeInterface<dim,dimworld>::DUNE_FDATA DUNE_FDATA;
67 typedef typename GrapeInterface<dim,dimworld>::F_DATA F_DATA;
68 typedef typename GrapeInterface<dim,dimworld>::STACKENTRY STACKENTRY;
70 typedef typename std::stack < STACKENTRY * > StackEntryType;
71 typedef void setGridPartIterators_t (DUNE_DAT * ,
void * gridPart);
74 typedef typename GridType::HierarchicIterator HierarchicIteratorType;
76 typedef typename GridType::Traits::LocalIdSet LocalIdSetType;
77 typedef typename GridType::Traits::LeafIndexSet LeafIndexSetType;
80 typedef std::list<HierarchicIteratorType *> HierarchicIteratorList;
81 typedef typename HierarchicIteratorList::iterator ListIteratorType;
91 template <
class Gr
idPartType>
92 inline GrapeGridDisplay(
const GridPartType &gridPart,
const int myrank = -1);
108 inline const GridType&
getGrid()
const ;
112 inline void * getHmesh();
115 DUNE_DAT & getDuneDat () {
return dune_; }
118 inline void addMyMeshToTimeScene(
void * timescene,
double time,
int proc);
120 bool hasData () {
return false; }
124 inline void * setupHmesh();
126 inline void deleteHmesh();
128 typedef typename GridType::template Codim<0>::Entity EntityCodim0Type;
131 typedef int EntityIndexFuncType (
void * iset,
const EntityCodim0Type & en);
133 typedef int VertexIndexFuncType (
void * iset,
const EntityCodim0Type & en,
int vx);
136 template <
class IndexSetType>
137 static int getEntityIndex(
void * iset,
const EntityCodim0Type & en)
140 const IndexSetType * set = ((
const IndexSetType *) iset);
141 return (en.isLeaf()) ? set->index(en) : -1;
145 template<
class IndexSet >
146 static int getVertexIndex (
void *iset,
const EntityCodim0Type &entity,
int vx )
149 const IndexSet *indexSet = (
const IndexSet *)iset;
151 return indexSet->subIndex( entity, vx, dim );
161 template <
class IntersectionIteratorType>
162 inline void checkNeighbors(IntersectionIteratorType&,
163 const IntersectionIteratorType&, DUNE_ELEM *) ;
166 template <
class Entity>
167 inline void el_update_base (Entity& en , DUNE_ELEM *) ;
170 template <
class EntityPo
interType,
class Gr
idView>
171 inline int el_update (EntityPointerType *, DUNE_ELEM *,
const GridView& );
174 template <
class EntityPo
interType>
175 inline int child_update (EntityPointerType * , DUNE_ELEM *) ;
177 template <
class EntityPo
interType>
178 inline int child_n_update (EntityPointerType *, DUNE_ELEM *) ;
181 template <PartitionIteratorType pitype>
182 inline int first_leaf (DUNE_ELEM * he) ;
183 template <PartitionIteratorType pitype>
184 inline int next_leaf (DUNE_ELEM * he) ;
187 template <
class Gr
idPartImp>
188 inline int first_item (DUNE_ELEM * he) ;
189 template <
class Gr
idPartImp>
190 inline int next_item (DUNE_ELEM * he) ;
193 template <PartitionIteratorType pitype>
194 inline int first_level (DUNE_ELEM * he,
int level) ;
196 template <PartitionIteratorType pitype>
197 inline int next_level (DUNE_ELEM * he) ;
200 inline int firstMacro (DUNE_ELEM * elem) {
return dune_.first_macro(elem); }
201 inline int nextMacro (DUNE_ELEM * elem) {
return dune_.next_macro(elem); }
202 inline int firstChild (DUNE_ELEM * elem) {
return (dune_.first_child) ? dune_.first_child(elem) : 0; }
203 inline int nextChild (DUNE_ELEM * elem) {
return (dune_.next_child) ? dune_.next_child(elem) : 0; }
206 inline int first_child (DUNE_ELEM * he) ;
207 inline int next_child (DUNE_ELEM * he) ;
211 template <PartitionIteratorType pitype>
212 inline void delete_leaf (DUNE_ELEM * he) ;
214 template <PartitionIteratorType pitype>
215 inline void delete_level (DUNE_ELEM * he) ;
217 template <PartitionIteratorType pitype>
218 inline void delete_hier (DUNE_ELEM * he) ;
221 template <
class IteratorType>
222 inline void delete_iterators(DUNE_ELEM * he) ;
226 inline static void * copy_iterator (
const void * i) ;
229 inline void local2world (DUNE_ELEM * he,
const double * c,
double * w);
232 inline int world2local (DUNE_ELEM * he,
const double * w,
double * c);
235 inline int checkWhetherInside (DUNE_ELEM * he,
const double * w);
241 inline static void ctow (DUNE_ELEM * he,
const double * c,
double * w);
244 inline static int wtoc (DUNE_ELEM * he,
const double * w,
double * c);
247 inline static int check_inside (DUNE_ELEM * he,
const double * w);
250 template<
class Entity >
251 int checkInside (
const Entity &entity,
const double *w );
254 template<
class Entity >
255 int world_to_local (
const Entity &entity,
const double *w,
double *c );
258 template <
class EntityType>
259 inline void local_to_world(
const EntityType &en,
const double * c,
double * w);
261 template <PartitionIteratorType pitype>
262 inline void selectIterators(DUNE_DAT *,
void *, setGridPartIterators_t *)
const;
264 inline void setIterationMethods(DUNE_DAT *, DUNE_FDATA * )
const;
266 inline void changeIterationMethods(
int iterType,
int partType, DUNE_FDATA *);
268 template <PartitionIteratorType pitype>
269 struct IterationMethods
272 inline static int first_mac (DUNE_ELEM * he)
274 MyDisplayType & disp = *((MyDisplayType *) he->display);
275 return disp.template first_level<pitype>(he,0);
279 inline static int first_lev (DUNE_ELEM * he)
281 MyDisplayType & disp = *((MyDisplayType *) he->display);
282 return disp.template first_level<pitype>(he,he->level_of_interest);
285 inline static int next_lev (DUNE_ELEM * he)
287 MyDisplayType & disp = *((MyDisplayType *) he->display);
288 return disp.template next_level<pitype>(he);
292 inline static int fst_leaf (DUNE_ELEM * he)
294 MyDisplayType & disp = *((MyDisplayType *) he->display);
295 return disp.template first_leaf<pitype>(he);
297 inline static int nxt_leaf (DUNE_ELEM * he)
299 MyDisplayType & disp = *((MyDisplayType *) he->display);
300 return disp.template next_leaf<pitype>(he);
304 inline static int fst_child (DUNE_ELEM * he)
306 MyDisplayType & disp = *((MyDisplayType *) he->display);
307 return disp.first_child(he);
309 inline static int nxt_child (DUNE_ELEM * he)
311 MyDisplayType & disp = *((MyDisplayType *) he->display);
312 return disp.next_child(he);
316 inline static void del_leaf (DUNE_ELEM * he)
318 MyDisplayType & disp = *((MyDisplayType *) he->display);
319 disp.template delete_leaf<pitype>(he);
323 inline static void del_level (DUNE_ELEM * he)
325 MyDisplayType & disp = *((MyDisplayType *) he->display);
326 disp.template delete_level<pitype>(he);
330 inline static void del_hier (DUNE_ELEM * he)
332 MyDisplayType & disp = *((MyDisplayType *) he->display);
333 disp.template delete_hier<pitype>(he);
339 template <
class Gr
idPartType>
340 struct IterationMethodsGP
343 inline static int fst_item (DUNE_ELEM * he)
345 assert( he->display );
346 MyDisplayType & disp = *((MyDisplayType *) he->display);
347 return disp.template first_item<GridPartType>(he);
349 inline static int nxt_item (DUNE_ELEM * he)
351 assert( he->display );
352 MyDisplayType & disp = *((MyDisplayType *) he->display);
353 return disp.template next_item<GridPartType>(he);
357 inline static void del_iter (DUNE_ELEM * he)
359 assert( he->display );
360 MyDisplayType & disp = *((MyDisplayType *) he->display);
361 typedef typename GridPartType :: template Codim<0> :: IteratorType IteratorType;
362 disp.template delete_iterators<IteratorType> (he);
366 template <
class Gr
idPartImp>
369 static void setGPIterator (DUNE_DAT * dune ,
void * gridPart)
372 dune->gridPart = gridPart;
373 dune->first_macro = &IterationMethodsGP<GridPartImp>::fst_item;
374 dune->next_macro = &IterationMethodsGP<GridPartImp>::nxt_item;
375 dune->delete_iter = &IterationMethodsGP<GridPartImp>::del_iter;
377 dune->first_child = 0;
378 dune->next_child = 0;
382 template<
class ViewTraits >
383 struct GridViewIterators
386 typedef typename GridView::template Codim< 0 >::Iterator Iterator;
388 static int first_macro ( DUNE_ELEM *he )
390 assert( he->display != 0 );
391 MyDisplayType &
display = *
static_cast< MyDisplayType *
>( he->display );
394 display.template delete_iterators< Iterator >( he );
396 assert( he->gridPart != 0 );
397 const GridView &gridView = *
static_cast< const GridView *
>( he->gridPart );
399 assert( he->liter == 0 );
400 assert( he->enditer == 0 );
402 Iterator *it =
new Iterator( gridView.template begin< 0 >() );
403 Iterator *end =
new Iterator( gridView.template end < 0 >() );
410 display.template delete_iterators< Iterator >( he );
414 return display.el_update( it, he, gridView );
417 static int next_macro ( DUNE_ELEM *he )
419 assert( he->display != 0 );
420 MyDisplayType &
display = *
static_cast< MyDisplayType *
>( he->display );
422 assert( he->gridPart != 0 );
423 const GridView &gridView = *
static_cast< const GridView *
>( he->gridPart );
425 Iterator *it =
static_cast< Iterator *
>( he->liter );
426 Iterator *end =
static_cast< Iterator *
>( he->enditer );
427 assert( (it != 0) && (end != 0) );
432 display.template delete_iterators< Iterator >( he );
436 return display.el_update( it, he, gridView );
439 static void delete_iter ( DUNE_ELEM *he )
441 assert( he->display );
442 MyDisplayType &
display = *
static_cast< MyDisplayType *
>( he->display );
443 display.template delete_iterators< Iterator >( he );
446 static void set ( DUNE_DAT *dune,
void *gridView )
449 dune->gridPart = gridView;
450 dune->first_macro = &first_macro;
451 dune->next_macro = &next_macro;
452 dune->delete_iter = &delete_iter;
454 dune->first_child = 0;
455 dune->next_child = 0;
459 inline static void setIterationModus(DUNE_DAT * , DUNE_FDATA *);
463 inline static void * getStackEntry(StackEntryType & stackEntry);
466 inline static void * getStackEn(DUNE_DAT * dune);
469 inline static void freeStackEn(DUNE_DAT * dune,
void * entry);
471 inline static void deleteStackEntry(StackEntryType &);
474 inline static void freeStackEntry(StackEntryType & stackEntry,
void * entry);
480 setGridPartIterators_t * setGridPartIter_;
483 const EntityIndexFuncType * entityIndex;
485 const VertexIndexFuncType * vertexIndex;
487 StackEntryType stackEntry_;
491 const GridType &grid_;
494 const bool hasLevelIntersections_;
502 const LocalIdSetType & lid_;
511 HierarchicIteratorList hierList_;
518 enum GRAPE_ElementType
520 g_vertex = GrapeInterface_three_three::gr_vertex
521 , g_line = GrapeInterface_three_three::gr_line
522 , g_triangle = GrapeInterface_three_three::gr_triangle
523 , g_quadrilateral = GrapeInterface_three_three::gr_quadrilateral
524 , g_tetrahedron = GrapeInterface_three_three::gr_tetrahedron
525 , g_pyramid = GrapeInterface_three_three::gr_pyramid
526 , g_prism = GrapeInterface_three_three::gr_prism
527 , g_hexahedron = GrapeInterface_three_three::gr_hexahedron
528 , g_iso_triangle = GrapeInterface_three_three::gr_iso_triangle
529 , g_iso_quadrilateral = GrapeInterface_three_three::gr_iso_quadrilateral
530 , g_unknown = GrapeInterface_three_three::gr_unknown
534 static inline GRAPE_ElementType convertToGrapeType ( GeometryType duneType ,
int dim )
536 static std::vector< GRAPE_ElementType > convertedType;
537 if( convertedType.size() == 0 )
540 convertedType.resize( geomSize, g_unknown );
552 type.makeQuadrilateral();
558 type.makeTetrahedron();
560 type.makeHexahedron();
575 static const int *
const * vxMap = GrapeInterface_three_three::dune2GrapeVertex;
576 static inline int mapDune2GrapeVertex(
int geomType ,
int vx )
578 enum { usedTypes = GrapeInterface_three_three::numberOfUsedGrapeElementTypes };
579 assert( geomType >= 0 );
580 assert( geomType < usedTypes );
581 return vxMap[geomType][vx];
586 static const int *
const * faceMap = GrapeInterface_three_three::dune2GrapeFace;
587 static inline int mapDune2GrapeFace(
int geomType ,
int duneFace )
589 enum { usedTypes = GrapeInterface_three_three::numberOfUsedGrapeElementTypes };
590 assert( geomType >= 0 );
591 assert( geomType < usedTypes );
592 return faceMap[geomType][ duneFace ];
598#include "grape/grapegriddisplay.cc"
static std::size_t size(std::size_t maxdim)
Compute total number of geometry types up to and including the given dimension.
Definition: typeindex.hh:132
static std::size_t index(const GeometryType >)
Compute the index for the given geometry type over all dimensions.
Definition: typeindex.hh:145
Definition: grapegriddisplay.hh:55
~GrapeGridDisplay()
Destructor for GrapeGridDisplay.
Definition: grapegriddisplay.cc:101
int myRank() const
return rank of this display, for visualisation of parallel grid
Definition: grapegriddisplay.hh:105
void display()
Definition: grapegriddisplay.cc:975
const GridType & getGrid() const
return reference to Dune Grid
Definition: grapegriddisplay.cc:985
Grid view abstract base class.
Definition: gridview.hh:57
Different resources needed by all grid implementations.
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:178
Contains #undefs for all preprocessor macros defined by grape.
Dune namespace.
Definition: alignment.hh:14
GrapeIteratorType
the internal grape partition iterator types need to be these exact values to associate with combo but...
Definition: grapegriddisplay.hh:43
@ All_Partition
all entities
Definition: gridenums.hh:135
@ OverlapFront_Partition
interior, border, overlap and front entities
Definition: gridenums.hh:134
@ Interior_Partition
only interior entities
Definition: gridenums.hh:131
@ InteriorBorder_Partition
interior and border entities
Definition: gridenums.hh:132
@ Overlap_Partition
interior, border, and overlap entities
Definition: gridenums.hh:133
@ Ghost_Partition
only ghost entities
Definition: gridenums.hh:136
GrapePartitionIteratorType
the internal grape partition iterator types
Definition: grapegriddisplay.hh:31
Standard Dune debug streams.
Helper classes to provide indices for geometrytypes for use in a vector.