1 #ifndef DUNE_GRAPEGRIDDISPLAY_HH
2 #define DUNE_GRAPEGRIDDISPLAY_HH
10 #include <dune/common/stdstreams.hh>
11 #include <dune/geometry/typeindex.hh>
51 template<
class Gr
idType>
56 enum { dim = GridType::dimension };
57 enum { dimworld = GridType::dimensionworld };
62 typedef typename GrapeInterface<dim,dimworld>::DUNE_ELEM DUNE_ELEM;
63 typedef typename GrapeInterface<dim,dimworld>::DUNE_DAT DUNE_DAT;
64 typedef typename GrapeInterface<dim,dimworld>::DUNE_FDATA DUNE_FDATA;
65 typedef typename GrapeInterface<dim,dimworld>::F_DATA F_DATA;
68 typedef typename std::stack < STACKENTRY * > StackEntryType;
69 typedef void setGridPartIterators_t(DUNE_DAT * ,
void * gridPart);
70 #endif // #if HAVE_GRAPE
89 template <
class Gr
idPartType>
90 inline GrapeGridDisplay(
const GridPartType &gridPart,
const int myrank = -1);
106 inline const GridType&
getGrid()
const ;
110 inline void * getHmesh();
113 DUNE_DAT & getDuneDat () {
return dune_; }
116 inline void addMyMeshToTimeScene(
void * timescene,
double time,
int proc);
118 bool hasData () {
return false; }
126 typedef typename GridType::template Codim<0>::Entity EntityCodim0Type;
129 typedef int EntityIndexFuncType(
void * iset,
const EntityCodim0Type & en);
131 typedef int VertexIndexFuncType(
void * iset,
const EntityCodim0Type & en,
int vx);
134 template <
class IndexSetType>
135 static int getEntityIndex(
void * iset,
const EntityCodim0Type & en)
138 const IndexSetType *
set = ((
const IndexSetType *) iset);
139 return (en.isLeaf()) ? set->index(en) : -1;
143 template<
class IndexSet >
144 static int getVertexIndex (
void *iset,
const EntityCodim0Type &entity,
int vx )
147 const IndexSet *indexSet = (
const IndexSet *)iset;
149 return indexSet->subIndex( entity, vx, dim );
159 template <
class IntersectionIteratorType>
160 inline void checkNeighbors(IntersectionIteratorType&,
161 const IntersectionIteratorType&, DUNE_ELEM *) ;
164 template <
class Entity>
165 inline void el_update_base (
Entity& en , DUNE_ELEM *) ;
168 template <
class EntityPo
interType>
169 inline int el_update (EntityPointerType *, DUNE_ELEM *) ;
172 template <
class EntityPo
interType,
class Gr
idPartType>
173 inline int el_update (EntityPointerType *, DUNE_ELEM *, GridPartType& );
175 template<
class EntityPo
inter,
class VT >
176 int el_update ( EntityPointer *, DUNE_ELEM *,
const GridView< VT > & );
179 template <
class EntityPo
interType>
180 inline int child_update (EntityPointerType * , DUNE_ELEM *) ;
182 template <
class EntityPo
interType>
183 inline int child_n_update (EntityPointerType *, DUNE_ELEM *) ;
186 template <PartitionIteratorType pitype>
187 inline int first_leaf (DUNE_ELEM * he) ;
188 template <PartitionIteratorType pitype>
189 inline int next_leaf (DUNE_ELEM * he) ;
192 template <
class Gr
idPartImp>
193 inline int first_item (DUNE_ELEM * he) ;
194 template <
class Gr
idPartImp>
195 inline int next_item (DUNE_ELEM * he) ;
198 template <PartitionIteratorType pitype>
199 inline int first_level (DUNE_ELEM * he,
int level) ;
201 template <PartitionIteratorType pitype>
202 inline int next_level (DUNE_ELEM * he) ;
205 inline int firstMacro (DUNE_ELEM * elem) {
return dune_.first_macro(elem); }
206 inline int nextMacro (DUNE_ELEM * elem) {
return dune_.next_macro(elem); }
207 inline int firstChild (DUNE_ELEM * elem) {
return (dune_.first_child) ? dune_.first_child(elem) : 0; }
208 inline int nextChild (DUNE_ELEM * elem) {
return (dune_.next_child) ? dune_.next_child(elem) : 0; }
216 template <PartitionIteratorType pitype>
217 inline void delete_leaf (DUNE_ELEM * he) ;
219 template <PartitionIteratorType pitype>
220 inline void delete_level (DUNE_ELEM * he) ;
222 template <PartitionIteratorType pitype>
223 inline void delete_hier (DUNE_ELEM * he) ;
226 template <
class IteratorType>
227 inline void delete_iterators(DUNE_ELEM * he) ;
231 inline static void * copy_iterator (
const void * i) ;
234 inline void local2world (DUNE_ELEM * he,
const double * c,
double * w);
237 inline int world2local (DUNE_ELEM * he,
const double * w,
double * c);
240 inline int checkWhetherInside (DUNE_ELEM * he,
const double * w);
246 inline static void ctow (DUNE_ELEM * he,
const double * c,
double * w);
249 inline static int wtoc (DUNE_ELEM * he,
const double * w,
double * c);
252 inline static int check_inside (DUNE_ELEM * he,
const double * w);
255 template<
class Entity >
256 int checkInside (
const Entity &entity,
const double *w );
259 template<
class Entity >
260 int world_to_local (
const Entity &entity,
const double *w,
double *c );
263 template <
class EntityType>
264 inline void local_to_world(
const EntityType &en,
const double * c,
double * w);
266 template <PartitionIteratorType pitype>
267 inline void selectIterators(DUNE_DAT *,
void *, setGridPartIterators_t *)
const;
269 inline void setIterationMethods(DUNE_DAT *, DUNE_FDATA * )
const;
271 inline void changeIterationMethods(
int iterType,
int partType, DUNE_FDATA *);
273 template <PartitionIteratorType pitype>
274 struct IterationMethods
277 inline static int first_mac (DUNE_ELEM * he)
279 MyDisplayType & disp = *((MyDisplayType *) he->display);
280 return disp.template first_level<pitype>(he,0);
284 inline static int first_lev (DUNE_ELEM * he)
286 MyDisplayType & disp = *((MyDisplayType *) he->display);
287 return disp.template first_level<pitype>(he,he->level_of_interest);
290 inline static int next_lev (DUNE_ELEM * he)
292 MyDisplayType & disp = *((MyDisplayType *) he->display);
293 return disp.template next_level<pitype>(he);
297 inline static int fst_leaf (DUNE_ELEM * he)
299 MyDisplayType & disp = *((MyDisplayType *) he->display);
300 return disp.template first_leaf<pitype>(he);
302 inline static int nxt_leaf (DUNE_ELEM * he)
304 MyDisplayType & disp = *((MyDisplayType *) he->display);
305 return disp.template next_leaf<pitype>(he);
309 inline static int fst_child (DUNE_ELEM * he)
311 MyDisplayType & disp = *((MyDisplayType *) he->display);
312 return disp.first_child(he);
314 inline static int nxt_child (DUNE_ELEM * he)
316 MyDisplayType & disp = *((MyDisplayType *) he->display);
317 return disp.next_child(he);
321 inline static void del_leaf (DUNE_ELEM * he)
323 MyDisplayType & disp = *((MyDisplayType *) he->display);
324 disp.template delete_leaf<pitype>(he);
328 inline static void del_level (DUNE_ELEM * he)
330 MyDisplayType & disp = *((MyDisplayType *) he->display);
331 disp.template delete_level<pitype>(he);
335 inline static void del_hier (DUNE_ELEM * he)
337 MyDisplayType & disp = *((MyDisplayType *) he->display);
338 disp.template delete_hier<pitype>(he);
344 template <
class Gr
idPartType>
345 struct IterationMethodsGP
348 inline static int fst_item (DUNE_ELEM * he)
350 assert( he->display );
351 MyDisplayType & disp = *((MyDisplayType *) he->display);
352 return disp.template first_item<GridPartType>(he);
354 inline static int nxt_item (DUNE_ELEM * he)
356 assert( he->display );
357 MyDisplayType & disp = *((MyDisplayType *) he->display);
358 return disp.template next_item<GridPartType>(he);
362 inline static void del_iter (DUNE_ELEM * he)
364 assert( he->display );
365 MyDisplayType & disp = *((MyDisplayType *) he->display);
366 typedef typename GridPartType :: template Codim<0> :: IteratorType IteratorType;
367 disp.template delete_iterators<IteratorType> (he);
371 template <
class Gr
idPartImp>
374 static void setGPIterator (DUNE_DAT * dune ,
void * gridPart)
377 dune->gridPart = gridPart;
378 dune->first_macro = &IterationMethodsGP<GridPartImp>::fst_item;
379 dune->next_macro = &IterationMethodsGP<GridPartImp>::nxt_item;
380 dune->delete_iter = &IterationMethodsGP<GridPartImp>::del_iter;
382 dune->first_child = 0;
383 dune->next_child = 0;
387 template<
class ViewTraits >
388 struct GridViewIterators
391 typedef typename GridView::template Codim< 0 >::Iterator Iterator;
395 assert( he->display != 0 );
396 MyDisplayType &
display = *
static_cast< MyDisplayType *
>( he->display );
399 display.template delete_iterators< Iterator >( he );
401 assert( he->gridPart != 0 );
402 const GridView &gridView = *
static_cast< const GridView *
>( he->gridPart );
404 assert( he->liter == 0 );
405 assert( he->enditer == 0 );
407 Iterator *it =
new Iterator( gridView.template begin< 0 >() );
408 Iterator *end =
new Iterator( gridView.template end < 0 >() );
415 display.template delete_iterators< Iterator >( he );
419 return display.el_update( it, he, gridView );
424 assert( he->display != 0 );
425 MyDisplayType &display = *
static_cast< MyDisplayType *
>( he->display );
427 assert( he->gridPart != 0 );
428 const GridView &gridView = *
static_cast< const GridView *
>( he->gridPart );
430 Iterator *it =
static_cast< Iterator *
>( he->liter );
431 Iterator *end =
static_cast< Iterator *
>( he->enditer );
432 assert( (it != 0) && (end != 0) );
437 display.template delete_iterators< Iterator >( he );
441 return display.el_update( it, he, gridView );
444 static void delete_iter ( DUNE_ELEM *he )
446 assert( he->display );
447 MyDisplayType &display = *
static_cast< MyDisplayType *
>( he->display );
448 display.template delete_iterators< Iterator >( he );
451 static void set ( DUNE_DAT *dune,
void *gridView )
454 dune->gridPart = gridView;
457 dune->delete_iter = &delete_iter;
459 dune->first_child = 0;
460 dune->next_child = 0;
464 inline static void setIterationModus(DUNE_DAT * , DUNE_FDATA *);
468 inline static void * getStackEntry(StackEntryType & stackEntry);
471 inline static void * getStackEn(DUNE_DAT * dune);
474 inline static void freeStackEn(DUNE_DAT * dune,
void * entry);
476 inline static void deleteStackEntry(StackEntryType &);
479 inline static void freeStackEntry(StackEntryType & stackEntry,
void * entry);
485 setGridPartIterators_t * setGridPartIter_;
488 const EntityIndexFuncType * entityIndex;
490 const VertexIndexFuncType * vertexIndex;
492 StackEntryType stackEntry_;
493 #endif // #if HAVE_GRAPE
523 enum GRAPE_ElementType
524 { g_vertex = GrapeInterface_three_three::gr_vertex
525 , g_line = GrapeInterface_three_three::gr_line
526 , g_triangle = GrapeInterface_three_three::gr_triangle
527 , g_quadrilateral = GrapeInterface_three_three::gr_quadrilateral
528 , g_tetrahedron = GrapeInterface_three_three::gr_tetrahedron
529 , g_pyramid = GrapeInterface_three_three::gr_pyramid
530 , g_prism = GrapeInterface_three_three::gr_prism
531 , g_hexahedron = GrapeInterface_three_three::gr_hexahedron
532 , g_iso_triangle = GrapeInterface_three_three::gr_iso_triangle
533 , g_iso_quadrilateral = GrapeInterface_three_three::gr_iso_quadrilateral
534 , g_unknown = GrapeInterface_three_three::gr_unknown
538 static inline GRAPE_ElementType convertToGrapeType (
GeometryType duneType ,
int dim )
540 static std::vector< GRAPE_ElementType > convertedType;
541 if( convertedType.size() == 0 )
543 const size_t geomSize = GlobalGeometryTypeIndex :: size( 3 ) ;
544 convertedType.resize( geomSize, g_unknown );
551 convertedType[ GlobalGeometryTypeIndex :: index( type ) ] = g_vertex;
553 convertedType[ GlobalGeometryTypeIndex :: index( type ) ] = g_line;
555 convertedType[ GlobalGeometryTypeIndex :: index( type ) ] = g_triangle;
556 type.makeQuadrilateral();
557 convertedType[ GlobalGeometryTypeIndex :: index( type ) ] = g_quadrilateral;
562 type.makeTetrahedron();
563 convertedType[ GlobalGeometryTypeIndex :: index( type ) ] = g_tetrahedron;
564 type.makeHexahedron();
565 convertedType[ GlobalGeometryTypeIndex :: index( type ) ] = g_hexahedron;
567 convertedType[ GlobalGeometryTypeIndex :: index( type ) ] = g_pyramid;
569 convertedType[ GlobalGeometryTypeIndex :: index( type ) ] = g_prism;
572 assert( GlobalGeometryTypeIndex :: index( duneType ) < convertedType.size() );
573 assert( convertedType[ GlobalGeometryTypeIndex :: index( duneType ) ] != g_unknown );
574 return convertedType[ GlobalGeometryTypeIndex :: index( duneType ) ];
579 static const int *
const * vxMap = GrapeInterface_three_three::dune2GrapeVertex;
580 static inline int mapDune2GrapeVertex(
int geomType ,
int vx )
582 enum { usedTypes = GrapeInterface_three_three::numberOfUsedGrapeElementTypes };
583 assert( geomType >= 0 );
584 assert( geomType < usedTypes );
585 return vxMap[geomType][vx];
590 static const int *
const * faceMap = GrapeInterface_three_three::dune2GrapeFace;
591 static inline int mapDune2GrapeFace(
int geomType ,
int duneFace )
593 enum { usedTypes = GrapeInterface_three_three::numberOfUsedGrapeElementTypes };
594 assert( geomType >= 0 );
595 assert( geomType < usedTypes );
596 return faceMap[geomType][ duneFace ];