4 #ifndef DUNE_ALU3DGRIDITERATOR_HH
5 #define DUNE_ALU3DGRIDITERATOR_HH
22 template<
int cd,
int dim,
class Gr
idImp>
23 class ALU3dGridEntity;
24 template<
int cd, PartitionIteratorType pitype,
class Gr
idImp >
25 class ALU3dGridLevelIterator;
26 template<
int cd,
class Gr
idImp >
27 class ALU3dGridEntityPointer;
28 template<
int mydim,
int coorddim,
class Gr
idImp>
29 class ALU3dGridGeometry;
30 template<
class Gr
idImp>
31 class ALU3dGridHierarchicIterator;
32 template<
class Gr
idImp>
33 class ALU3dGridIntersectionIterator;
34 template<
int codim, PartitionIteratorType pitype,
class Gr
idImp>
35 class ALU3dGridLeafIterator;
36 template< ALU3dGr
idElementType,
class >
38 template< ALU3dGr
idElementType,
class >
39 class ALU3dGridFaceInfo;
40 template< ALU3dGr
idElementType,
class >
54 template<
class Gr
idImp>
58 enum { dim = GridImp::dimension };
59 enum { dimworld = GridImp::dimensionworld };
61 typedef typename GridImp::MPICommunicatorType Comm;
63 typedef ALU3dImplTraits< GridImp::elementType, Comm > ImplTraits;
65 typedef typename ImplTraits::HElementType HElementType ;
66 typedef typename ImplTraits::HBndSegType HBndSegType;
67 typedef typename ImplTraits::GEOElementType GEOElementType;
68 typedef typename ImplTraits::IMPLElementType IMPLElementType;
69 typedef typename ImplTraits::GEOFaceType GEOFaceType;
70 typedef typename ImplTraits::NeighbourPairType NeighbourPairType;
71 typedef typename ImplTraits::BNDFaceType BNDFaceType;
78 typedef ALU3dGridFaceInfo< GridImp::elementType, Comm > FaceInfoType;
79 typedef typename std::auto_ptr< FaceInfoType > FaceInfoPointer;
81 typedef typename SelectType<
82 tetra == GridImp::elementType,
83 ALU3dGridGeometricFaceInfoTetra< Comm >,
84 ALU3dGridGeometricFaceInfoHexa< Comm > >::Type GeometryInfoType;
86 typedef ElementTopologyMapping<GridImp::elementType> ElementTopo;
87 typedef FaceTopologyMapping<GridImp::elementType> FaceTopo;
89 enum { numFaces = EntityCount<GridImp::elementType>::numFaces };
90 enum { numVerticesPerFace =
91 EntityCount<GridImp::elementType>::numVerticesPerFace };
92 enum { numVertices = EntityCount<GridImp::elementType>::numVertices };
94 typedef ALU3dGridIntersectionIterator<GridImp> ThisType;
102 typedef typename GridImp::Traits::template Codim< 1 >::GeometryImpl
GeometryImpl;
108 typedef typename GridImp::template Codim<0>::Entity
Entity;
109 typedef typename GridImp::template Codim<1>::Geometry
Geometry;
125 int wLevel,
bool end=
false);
137 return reinterpret_cast< const Intersection &
>( *this );
239 template<
class EntityType >
void done (
const EntityType &en ) {
done(); }
242 void setFirstItem(
const HElementType & elem,
int wLevel);
246 const BNDFaceType& bnd,
int wLevel);
249 template <
class EntityType>
250 void first(
const EntityType & en,
int wLevel);
257 void setGhostFace(
const GEOFaceType& newFace);
265 getFace (
const GEOTriangleBndType &bnd,
int index )
const;
269 getFace (
const GEOQuadBndType &bnd,
int index )
const;
273 getFace (
const GEOTetraElementType &elem,
int index )
const;
276 getFace (
const GEOHexaElementType &elem,
int index )
const;
306 template<
class Gr
idImp>
310 enum { dim = GridImp::dimension };
311 enum { dimworld = GridImp::dimensionworld };
313 typedef typename GridImp::MPICommunicatorType Comm;
315 typedef ALU3dImplTraits< GridImp::elementType, Comm > ImplTraits;
317 typedef typename ImplTraits::HElementType HElementType ;
318 typedef typename ImplTraits::GEOElementType GEOElementType;
319 typedef typename ImplTraits::IMPLElementType IMPLElementType;
320 typedef typename ImplTraits::GEOFaceType GEOFaceType;
321 typedef typename ImplTraits::NeighbourPairType NeighbourPairType;
322 typedef typename ImplTraits::BNDFaceType BNDFaceType;
324 typedef ALU3dGridFaceInfo< GridImp::elementType, Comm > FaceInfoType;
325 typedef typename std::auto_ptr< FaceInfoType > FaceInfoPointer;
327 typedef typename SelectType<
328 tetra == GridImp::elementType,
329 ALU3dGridGeometricFaceInfoTetra< Comm >,
330 ALU3dGridGeometricFaceInfoHexa< Comm > >::Type GeometryInfoType;
332 typedef ElementTopologyMapping<GridImp::elementType> ElementTopo;
333 typedef FaceTopologyMapping<GridImp::elementType> FaceTopo;
335 enum { numFaces = EntityCount<GridImp::elementType>::numFaces };
336 enum { numVerticesPerFace =
337 EntityCount<GridImp::elementType>::numVerticesPerFace };
338 enum { numVertices = EntityCount<GridImp::elementType>::numVertices };
340 typedef ALU3dGridIntersectionIterator<GridImp> BaseType;
341 typedef ALU3dGridLevelIntersectionIterator<GridImp> ThisType;
369 int wLevel,
bool end=
false);
383 template <
class EntityType>
384 void first(
const EntityType & en,
int wLevel);
403 void setNewFace(
const GEOFaceType& newFace);
406 void setFirstItem(
const HElementType & elem,
int wLevel);
409 void setInteriorItem(
const HElementType & elem,
410 const BNDFaceType& bnd,
int wLevel);
421 template <
class InternalIteratorType >
425 typedef typename InternalIteratorType :: val_t
val_t;
428 template <
class Gr
idImp,
int codim>
432 template <
class ItemType>
433 static int getLevel(
const GridImp & grid,
const ItemType & item,
int level )
436 return (level < 0) ? item.level() : level;
441 template <
class Gr
idImp>
445 template <
class ItemType>
446 static int getLevel(
const GridImp & grid,
const ItemType & item,
int level )
452 template <
class Gr
idImp>
456 template <
class ItemType>
457 static int getLevel(
const GridImp & grid,
const ItemType & item,
int level)
459 return (level < 0) ? grid.getLevelOfLeafVertex(item) : level;
465 template <
class Gr
idImp,
class IteratorImp>
466 void firstItem(
const GridImp & grid, IteratorImp & it,
int level )
468 InternalIteratorType & iter = it.internalIterator();
472 assert( iter.size() > 0 );
482 template <
class Gr
idImp,
class IteratorImp>
483 void setItem (
const GridImp & grid, IteratorImp & it, InternalIteratorType & iter,
int level)
485 enum { codim = IteratorImp :: codimension };
486 val_t & item = iter.item();
487 assert( item.first || item.second );
490 it.updateEntityPointer( item.first ,
491 GetLevel<GridImp,codim>::getLevel(grid, *(item.first) , level) );
494 it.updateGhostPointer( *item.second );
498 template <
class Gr
idImp,
class IteratorImp>
502 InternalIteratorType & iter = it.internalIterator();
524 template<
int cd, PartitionIteratorType pitype,
class Gr
idImp>
525 class ALU3dGridLevelIterator
526 :
public ALU3dGridEntityPointer< cd, GridImp >,
527 public ALU3dGridTreeIterator< ALU3DSPACE ALU3dGridLevelIteratorWrapper< cd, pitype, typename GridImp::MPICommunicatorType > >
529 enum { dim = GridImp::dimension };
530 enum { dimworld = GridImp::dimensionworld };
532 typedef typename GridImp::MPICommunicatorType Comm;
605 template<
int cdim, PartitionIteratorType pitype,
class Gr
idImp>
606 class ALU3dGridLeafIterator
607 :
public ALU3dGridEntityPointer< cdim, GridImp >,
608 public ALU3dGridTreeIterator< ALU3DSPACE ALU3dGridLeafIteratorWrapper< cdim, pitype, typename GridImp::MPICommunicatorType > >
610 enum { dim = GridImp :: dimension };
613 enum { codim = cdim };
615 typedef typename GridImp::MPICommunicatorType Comm;
620 typedef typename GridImp::template Codim<cdim>::Entity
Entity;
677 template<
class Gr
idImp>
678 class ALU3dGridHierarchicIterator
679 :
public ALU3dGridEntityPointer<0,GridImp>
682 typedef ALU3dGridHierarchicIterator<GridImp> ThisType;
683 enum { dim = GridImp::dimension };
685 typedef typename GridImp::MPICommunicatorType Comm;
687 typedef ALU3dImplTraits< GridImp::elementType, Comm > ImplTraits;
688 typedef typename ImplTraits::HElementType HElementType;
689 typedef typename ImplTraits::HBndSegType HBndSegType;
691 template <
class Po
interType,
class CommT >
692 class GhostElementStorage;
695 template <
class Po
interType >
696 class GhostElementStorage< PointerType, No_Comm >
699 GhostElementStorage() {}
700 explicit GhostElementStorage(
const PointerType& ) {}
701 PointerType& operator * () { PointerType* p = 0; assert(
false ); abort();
return *p; }
702 const PointerType* ghost ()
const {
return 0; }
703 PointerType* nextGhost ()
const {
return 0; }
704 PointerType* operator -> ()
const {
return 0; }
705 bool operator != (
const PointerType* )
const {
return false; }
706 bool operator ! ()
const {
return true ; }
707 GhostElementStorage&
operator= (
const GhostElementStorage& ) {
return *
this; }
708 GhostElementStorage&
operator= (
const PointerType* ) {
return *
this; }
709 bool valid ()
const {
return false; }
712 #if ALU3DGRID_PARALLEL
714 template <
class Po
interType >
715 class GhostElementStorage< PointerType, MPI_Comm >
719 const HBndSegType * ghost_;
720 HBndSegType * nextGhost_;
722 GhostElementStorage() : ghost_( 0 ), nextGhost_( 0 ) {}
723 explicit GhostElementStorage(
const PointerType& gh ) : ghost_( &gh ), nextGhost_( 0 ) {}
724 GhostElementStorage(
const GhostElementStorage& org )
725 : ghost_( org.ghost_ ), nextGhost_( org.nextGhost_ ) {}
727 PointerType& operator * () { assert( nextGhost_ );
return *nextGhost_; }
728 const PointerType* ghost ()
const {
return ghost_; }
729 PointerType* nextGhost ()
const {
return nextGhost_; }
730 PointerType* operator -> () {
return nextGhost_; }
731 bool operator != (
const PointerType* p )
const {
return (nextGhost_ != p); }
732 bool operator ! ()
const {
return nextGhost_ == 0; }
733 GhostElementStorage&
operator= (
const GhostElementStorage& org)
736 nextGhost_ = org.nextGhost_;
739 GhostElementStorage&
operator= (PointerType* p)
744 bool valid ()
const {
return (ghost_ != 0); }
751 typedef typename GridImp::template Codim<0>::Entity
Entity;
752 typedef typename GridImp::ctype
ctype;
756 const HElementType & elem,
757 int maxlevel,
bool end );
761 const HBndSegType& ghost,
782 void assign(
const ThisType & org);
785 int getLevel(
const HElementType* item)
const;
788 int getLevel(
const HBndSegType* face)
const;
791 template <
class HItemType>
792 HItemType* goNextElement (
const HItemType* startElem, HItemType * oldEl);
795 const HElementType * elem_;
798 GhostElementStorage< HBndSegType, Comm > ghostElem_;
807 #include "iterator_imp.cc"