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 >
41 class ALU3dGridGeometricFaceInfo;
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;
79 typedef typename std::auto_ptr< FaceInfoType > FaceInfoPointer;
81 typedef typename SelectType<
82 tetra == GridImp::elementType,
90 enum { numVerticesPerFace =
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;
325 typedef typename std::auto_ptr< FaceInfoType > FaceInfoPointer;
327 typedef typename SelectType<
328 tetra == GridImp::elementType,
336 enum { numVerticesPerFace =
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 >
424 typedef typename InternalIteratorType :: val_t
val_t;
427 template <
class Gr
idImp,
int codim>
430 template <
class ItemType>
431 static int getLevel(
const GridImp & grid,
const ItemType & item,
int level )
434 return (level < 0) ? item.level() : level;
439 template <
class Gr
idImp>
442 template <
class ItemType>
443 static int getLevel(
const GridImp & grid,
const ItemType & item,
int level )
449 template <
class Gr
idImp>
452 template <
class ItemType>
453 static int getLevel(
const GridImp & grid,
const ItemType & item,
int level)
455 return (level < 0) ? grid.getLevelOfLeafVertex(item) : level;
461 template <
class Gr
idImp,
class IteratorImp>
462 void firstItem(
const GridImp & grid, IteratorImp & it,
int level )
464 InternalIteratorType & iter = it.internalIterator();
468 assert( iter.size() > 0 );
478 template <
class Gr
idImp,
class IteratorImp>
479 void setItem (
const GridImp & grid, IteratorImp & it, InternalIteratorType & iter,
int level)
481 enum { codim = IteratorImp :: codimension };
482 val_t & item = iter.item();
483 assert( item.first || item.second );
486 it.updateEntityPointer( item.first ,
487 GetLevel<GridImp,codim>::getLevel(grid, *(item.first) , level) );
490 it.updateGhostPointer( *item.second );
494 template <
class Gr
idImp,
class IteratorImp>
498 InternalIteratorType & iter = it.internalIterator();
520 template<
int cd, PartitionIteratorType pitype,
class Gr
idImp>
523 public ALU3dGridTreeIterator< ALU3DSPACE ALU3dGridLevelIteratorWrapper< cd, pitype, typename GridImp::MPICommunicatorType > >
525 enum { dim = GridImp::dimension };
526 enum { dimworld = GridImp::dimensionworld };
528 typedef typename GridImp::MPICommunicatorType
Comm;
601 template<
int cdim, PartitionIteratorType pitype,
class Gr
idImp>
604 public ALU3dGridTreeIterator< ALU3DSPACE ALU3dGridLeafIteratorWrapper< cdim, pitype, typename GridImp::MPICommunicatorType > >
606 enum { dim = GridImp :: dimension };
609 enum { codim = cdim };
611 typedef typename GridImp::MPICommunicatorType Comm;
616 typedef typename GridImp::template Codim<cdim>::Entity
Entity;
673 template<
class Gr
idImp>
679 enum { dim = GridImp::dimension };
681 typedef typename GridImp::MPICommunicatorType
Comm;
683 typedef ALU3dImplTraits< GridImp::elementType, Comm >
ImplTraits;
684 typedef typename ImplTraits::HElementType HElementType;
685 typedef typename ImplTraits::HBndSegType
HBndSegType;
687 template <
class Po
interType,
class CommT >
688 class GhostElementStorage;
691 template <
class Po
interType >
692 struct GhostElementStorage< PointerType, No_Comm >
694 GhostElementStorage() {}
695 explicit GhostElementStorage(
const PointerType& ) {}
696 PointerType& operator * () { PointerType* p = 0; assert(
false ); abort();
return *p; }
697 const PointerType* ghost ()
const {
return 0; }
698 PointerType* nextGhost ()
const {
return 0; }
699 PointerType* operator -> ()
const {
return 0; }
700 bool operator != (
const PointerType* )
const {
return false; }
701 bool operator ! ()
const {
return true ; }
702 GhostElementStorage&
operator= (
const GhostElementStorage& ) {
return *
this; }
703 GhostElementStorage&
operator= (
const PointerType* ) {
return *
this; }
704 bool valid ()
const {
return false; }
707 #if ALU3DGRID_PARALLEL
709 template <
class Po
interType >
710 struct GhostElementStorage< PointerType, MPI_Comm >
717 GhostElementStorage() : ghost_( 0 ), nextGhost_( 0 ) {}
718 explicit GhostElementStorage(
const PointerType& gh ) : ghost_( &gh ), nextGhost_( 0 ) {}
719 GhostElementStorage(
const GhostElementStorage& org )
720 : ghost_( org.ghost_ ), nextGhost_( org.nextGhost_ ) {}
722 PointerType& operator * () { assert( nextGhost_ );
return *nextGhost_; }
723 const PointerType* ghost ()
const {
return ghost_; }
724 PointerType* nextGhost ()
const {
return nextGhost_; }
725 PointerType* operator -> () {
return nextGhost_; }
726 bool operator != (
const PointerType* p )
const {
return (nextGhost_ != p); }
727 bool operator ! ()
const {
return nextGhost_ == 0; }
728 GhostElementStorage&
operator= (
const GhostElementStorage& org)
731 nextGhost_ = org.nextGhost_;
734 GhostElementStorage&
operator= (PointerType* p)
739 bool valid ()
const {
return (ghost_ != 0); }
746 typedef typename GridImp::template Codim<0>::Entity
Entity;
747 typedef typename GridImp::ctype
ctype;
751 const HElementType & elem,
752 int maxlevel,
bool end );
777 void assign(
const ThisType & org);
780 int getLevel(
const HElementType* item)
const;
783 int getLevel(
const HBndSegType* face)
const;
786 template <
class HItemType>
787 HItemType* goNextElement (
const HItemType* startElem, HItemType * oldEl);
790 const HElementType * elem_;
793 GhostElementStorage< HBndSegType, Comm > ghostElem_;
802 #include "iterator_imp.cc"