3 #ifndef DUNE_GRAPEGRIDDISPLAY_HH
4 #define DUNE_GRAPEGRIDDISPLAY_HH
12 #include <dune/common/stdstreams.hh>
13 #include <dune/geometry/typeindex.hh>
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;
70 typedef typename std::stack < STACKENTRY * > StackEntryType;
71 typedef void setGridPartIterators_t (DUNE_DAT * ,
void * gridPart);
72 #endif // #if HAVE_GRAPE
91 template <
class Gr
idPartType>
92 inline GrapeGridDisplay(
const GridPartType &gridPart,
const int myrank = -1);
108 inline const GridType&
getGrid()
const ;
111 inline void * getHmesh();
115 DUNE_DAT & getDuneDat () {
return dune_; }
118 inline void addMyMeshToTimeScene(
void * timescene,
double time,
int proc);
120 bool hasData () {
return false; }
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; }
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;
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 );
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;
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_;
488 #endif // #if HAVE_GRAPE
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 )
539 const size_t geomSize = GlobalGeometryTypeIndex :: size( 3 ) ;
540 convertedType.resize( geomSize, g_unknown );
547 convertedType[ GlobalGeometryTypeIndex :: index( type ) ] = g_vertex;
549 convertedType[ GlobalGeometryTypeIndex :: index( type ) ] = g_line;
551 convertedType[ GlobalGeometryTypeIndex :: index( type ) ] = g_triangle;
552 type.makeQuadrilateral();
553 convertedType[ GlobalGeometryTypeIndex :: index( type ) ] = g_quadrilateral;
558 type.makeTetrahedron();
559 convertedType[ GlobalGeometryTypeIndex :: index( type ) ] = g_tetrahedron;
560 type.makeHexahedron();
561 convertedType[ GlobalGeometryTypeIndex :: index( type ) ] = g_hexahedron;
563 convertedType[ GlobalGeometryTypeIndex :: index( type ) ] = g_pyramid;
565 convertedType[ GlobalGeometryTypeIndex :: index( type ) ] = g_prism;
568 assert( GlobalGeometryTypeIndex :: index( duneType ) < convertedType.size() );
569 assert( convertedType[ GlobalGeometryTypeIndex :: index( duneType ) ] != g_unknown );
570 return convertedType[ GlobalGeometryTypeIndex :: index( duneType ) ];
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 ];
HierarchicIteratorList hierList_
Definition: grapegriddisplay.hh:511
interior, border, overlap and front entities
Definition: gridenums.hh:134
Definition: grapegriddisplay.hh:46
const GridType & getGrid() const
return reference to Dune Grid
Definition: grapegriddisplay.cc:985
all entities
Definition: gridenums.hh:135
Definition: grapegriddisplay.hh:33
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:178
Definition: grapegriddisplay.hh:54
Definition: grapegriddisplay.hh:34
const GridType & grid_
Definition: grapegriddisplay.hh:491
Definition: grapegriddisplay.hh:32
void display()
Definition: grapegriddisplay.cc:975
HierarchicIteratorList::iterator ListIteratorType
Definition: grapegriddisplay.hh:81
const int myRank_
Definition: grapegriddisplay.hh:505
Definition: grapegriddisplay.hh:44
void deleteHmesh(void *hmesh)
Definition: ghmesh.cc:845
Definition: grapegriddisplay.hh:37
GridType::Traits::LeafIndexSet LeafIndexSetType
Definition: grapegriddisplay.hh:77
void * indexSet_
Definition: grapegriddisplay.hh:499
struct stackentry STACKENTRY
interior, border, and overlap entities
Definition: gridenums.hh:133
static HELEMENT * first_macro(GENMESHnD *mesh, MESH_ELEMENT_FLAGS flag)
Definition: ghmesh.cc:190
const bool hasLevelIntersections_
Definition: grapegriddisplay.hh:494
void * setupHmesh(const int noe, const int nov, const int maxlev, DUNE_DAT *dune, const char *meshName)
Definition: ghmesh.cc:794
const LocalIdSetType & lid_
Definition: grapegriddisplay.hh:502
GridType::HierarchicIterator HierarchicIteratorType
Definition: grapegriddisplay.hh:74
only ghost entities
Definition: gridenums.hh:136
Grid view abstract base classInterface class for a view on grids. Grids return two types of view...
Definition: common/gridview.hh:56
int myRank() const
return rank of this display, for visualisation of parallel grid
Definition: grapegriddisplay.hh:105
void * gridPart_
Definition: grapegriddisplay.hh:496
static HELEMENT * next_macro(HELEMENT *el, MESH_ELEMENT_FLAGS flag)
Definition: ghmesh.cc:262
interior and border entities
Definition: gridenums.hh:132
GrapeIteratorType
the internal grape partition iterator types need to be these exact values to associate with combo but...
Definition: grapegriddisplay.hh:42
static HELEMENT * first_child(HELEMENT *ael, MESH_ELEMENT_FLAGS flag)
Definition: ghmesh.cc:286
GrapePartitionIteratorType
the internal grape partition iterator types
Definition: grapegriddisplay.hh:30
Different resources needed by all grid implementations.
Contains #undefs for all preprocessor macros defined by grape.
Definition: grapegriddisplay.hh:36
only interior entities
Definition: gridenums.hh:131
~GrapeGridDisplay()
Destructor for GrapeGridDisplay.
Definition: grapegriddisplay.cc:101
Definition: grapegriddisplay.hh:47
std::list< HierarchicIteratorType * > HierarchicIteratorList
Definition: grapegriddisplay.hh:80
static HELEMENT * next_child(HELEMENT *el, MESH_ELEMENT_FLAGS flag)
Definition: ghmesh.cc:344
Definition: grapegriddisplay.hh:45
Definition: grapegriddisplay.hh:35
void * hmesh_
Definition: grapegriddisplay.hh:509
GridType::Traits::LocalIdSet LocalIdSetType
Definition: grapegriddisplay.hh:76