alugrid/3d/iterator.hh

Go to the documentation of this file.
00001 // -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
00002 // vi: set et ts=8 sw=2 sts=2:
00003 
00004 #ifndef DUNE_ALU3DGRIDITERATOR_HH
00005 #define DUNE_ALU3DGRIDITERATOR_HH
00006 
00007 // System includes
00008 
00009 // Dune includes
00010 #include <dune/grid/common/grid.hh>
00011 #include <dune/grid/alugrid/common/intersectioniteratorwrapper.hh>
00012 #include <dune/grid/alugrid/common/memory.hh>
00013 
00014 // Local includes
00015 #include "alu3dinclude.hh"
00016 #include "topology.hh"
00017 #include "faceutility.hh"
00018 #include "alu3diterators.hh"
00019 
00020 namespace Dune {
00021   // Forward declarations
00022   template<int cd, int dim, class GridImp> 
00023   class ALU3dGridEntity;
00024   template<int cd, PartitionIteratorType pitype, class GridImp >
00025   class ALU3dGridLevelIterator;
00026   template<int cd, class GridImp > 
00027   class ALU3dGridEntityPointer;
00028   template<int mydim, int coorddim, class GridImp>
00029   class ALU3dGridGeometry;
00030   template<class GridImp> 
00031   class ALU3dGridHierarchicIterator;
00032   template<class GridImp>
00033   class ALU3dGridIntersectionIterator;
00034   template<int codim, PartitionIteratorType pitype, class GridImp>
00035   class ALU3dGridLeafIterator;
00036   template< ALU3dGridElementType, class >
00037   class ALU3dGrid;
00038   template< ALU3dGridElementType, class >
00039   class ALU3dGridFaceInfo;
00040   template< ALU3dGridElementType, class >
00041   class ALU3dGridGeometricFaceInfo;
00042 
00043 //**********************************************************************
00044 //
00045 // --ALU3dGridIntersectionIterator
00046 // --IntersectionIterator
00054 template<class GridImp>
00055 class ALU3dGridIntersectionIterator  
00056 //: public IntersectionIteratorDefaultImplementation <GridImp,ALU3dGridIntersectionIterator>
00057 {
00058   enum { dim       = GridImp::dimension };
00059   enum { dimworld  = GridImp::dimensionworld };
00060     
00061   typedef typename GridImp::MPICommunicatorType Comm;
00062 
00063   typedef ALU3dImplTraits< GridImp::elementType, Comm > ImplTraits;
00064 
00065   typedef typename ImplTraits::HElementType  HElementType ;
00066   typedef typename ImplTraits::HBndSegType   HBndSegType; 
00067   typedef typename ImplTraits::GEOElementType GEOElementType;
00068   typedef typename ImplTraits::IMPLElementType IMPLElementType;
00069   typedef typename ImplTraits::GEOFaceType GEOFaceType;
00070   typedef typename ImplTraits::NeighbourPairType NeighbourPairType;
00071   typedef typename ImplTraits::BNDFaceType BNDFaceType;
00072 
00073   typedef typename ALU3dImplTraits< tetra, Comm >::GEOElementType GEOTetraElementType;
00074   typedef typename ALU3dImplTraits< hexa, Comm >::GEOElementType GEOHexaElementType;
00075   typedef typename ALU3dImplTraits< tetra, Comm >::BNDFaceType GEOTriangleBndType; 
00076   typedef typename ALU3dImplTraits< hexa, Comm >::BNDFaceType GEOQuadBndType; 
00077 
00078   typedef ALU3dGridFaceInfo< GridImp::elementType, Comm > FaceInfoType;
00079   typedef typename std::auto_ptr< FaceInfoType > FaceInfoPointer;
00080 
00081   typedef typename SelectType<
00082     tetra == GridImp::elementType,
00083     ALU3dGridGeometricFaceInfoTetra< Comm >,
00084     ALU3dGridGeometricFaceInfoHexa< Comm > >::Type GeometryInfoType;
00085       
00086   typedef ElementTopologyMapping<GridImp::elementType> ElementTopo;
00087   typedef FaceTopologyMapping<GridImp::elementType> FaceTopo;
00088 
00089   enum { numFaces = EntityCount<GridImp::elementType>::numFaces };
00090   enum { numVerticesPerFace = 
00091          EntityCount<GridImp::elementType>::numVerticesPerFace };
00092   enum { numVertices = EntityCount<GridImp::elementType>::numVertices };
00093 
00094   typedef ALU3dGridIntersectionIterator<GridImp> ThisType;
00095   
00096   friend class ALU3dGridEntity<0,dim,GridImp>;
00097   friend class IntersectionIteratorWrapper<GridImp,ThisType>;
00098 
00099 protected:  
00100   enum IntersectionIteratorType { IntersectionLeaf , IntersectionLevel, IntersectionBoth }; 
00101 
00102 public:
00103   typedef typename GridImp::GridObjectFactoryType FactoryType;
00104 
00105   typedef typename GridImp::template Codim<0>::Entity Entity;
00106   typedef typename GridImp::template Codim<1>::Geometry Geometry;
00107   typedef typename GridImp::template Codim<1>::LocalGeometry LocalGeometry;
00108 
00109   typedef ALU3dGridIntersectionIterator< GridImp > ImplementationType;
00111   typedef Dune::Intersection< GridImp, Dune::ALU3dGridIntersectionIterator > Intersection;
00112   
00113   typedef ALU3dGridGeometry<dim-1,dimworld,GridImp> GeometryImp;
00114   typedef MakeableInterfaceObject<Geometry> GeometryObject;
00115   
00116   typedef FieldVector<alu3d_ctype, dimworld> NormalType;
00117   typedef ALU3dGridEntityPointer<0,GridImp> EntityPointer;
00118 
00119   typedef ALUMemoryProvider< ThisType > StorageType;
00120   
00123   ALU3dGridIntersectionIterator(const FactoryType& factory, 
00124                                 HElementType *el,
00125                                 int wLevel,bool end=false);
00126   
00127   ALU3dGridIntersectionIterator(const FactoryType& factory, int wLevel);
00128   
00130   ALU3dGridIntersectionIterator(const ALU3dGridIntersectionIterator<GridImp> & org);
00131 
00133   void assign(const ALU3dGridIntersectionIterator<GridImp> & org);
00134 
00135   const Intersection &dereference () const
00136   {
00137     return reinterpret_cast< const Intersection & >( *this );
00138   }
00139 
00141   bool equals (const ALU3dGridIntersectionIterator<GridImp> & i) const;
00142 
00144   void increment ();
00145 
00147   EntityPointer outside() const;
00148 
00150   EntityPointer inside() const;
00151 
00153   bool boundary () const;
00154 
00156   bool neighbor () const; 
00157 
00159   bool levelNeighbor () const; 
00160 
00162   bool leafNeighbor () const; 
00163 
00165   int boundaryId () const; 
00166 
00168   size_t boundarySegmentIndex() const;
00169       
00174   const LocalGeometry &geometryInInside () const;
00175 
00180   const Geometry &geometry () const;
00181 
00183   GeometryType type () const;
00184 
00187   int indexInInside () const;
00188 
00192   const LocalGeometry &geometryInOutside () const;
00193 
00196   int indexInOutside () const;
00197  
00199   int twistInSelf() const { return twistInInside(); }
00200 
00202   int twistInNeighbor() const { return twistInOutside(); }
00203 
00205   int twistInInside() const;
00206 
00208   int twistInOutside() const;
00209 
00212   NormalType & unitOuterNormal (const FieldVector<alu3d_ctype, dim-1>& local) const ;
00213   
00216   NormalType & outerNormal (const FieldVector<alu3d_ctype, dim-1>& local) const;
00217 
00220   NormalType & integrationOuterNormal (const FieldVector<alu3d_ctype, dim-1>& local) const;
00221 
00223   int level () const;
00224 
00226   bool conforming () const 
00227   {
00228     return (connector_.conformanceState() == FaceInfoType::CONFORMING);  
00229   }
00230 
00231 protected:
00232   // set interator to end iterator 
00233   void done () ;
00234   template< class EntityType > void done ( const EntityType &en ) { done(); }
00235   
00236   // reset IntersectionIterator to first neighbour 
00237   void setFirstItem(const HElementType & elem, int wLevel);
00238 
00239   // reset IntersectionIterator to first neighbour 
00240   void setInteriorItem(const HElementType  & elem, 
00241                        const BNDFaceType& bnd, int wLevel);
00242 
00243   // reset IntersectionIterator to first neighbour 
00244   template <class EntityType>
00245   void first(const EntityType & en, int wLevel);
00246 
00247   // set new face
00248   void setNewFace(const GEOFaceType& newFace);
00249 
00250 private:  
00251   // set new face (only LeafIntersectionIterator)
00252   void setGhostFace(const GEOFaceType& newFace);
00253 
00254 protected:  
00255   GeometryImp&  intersectionGlobalImp() const 
00256   { 
00257     return GridImp :: getRealImplementation( intersectionGlobal_ ); 
00258   }
00259 
00260   GeometryImp&  intersectionSelfLocalImp() const 
00261   { 
00262     return GridImp :: getRealImplementation( intersectionSelfLocal_ ); 
00263   }
00264 
00265   GeometryImp&  intersectionNeighborLocalImp() const 
00266   { 
00267     return GridImp :: getRealImplementation( intersectionNeighborLocal_ ); 
00268   }
00269 
00270   // generate local geometries 
00271   void buildLocalGeometries() const;
00272   
00273   // get the face corresponding to the index
00274   const typename ALU3dImplTraits< tetra, Comm >::GEOFaceType *
00275   getFace ( const GEOTriangleBndType &bnd, int index ) const;
00276 
00277   // get the face corresponding to the index
00278   const typename ALU3dImplTraits< hexa, Comm >::GEOFaceType *
00279   getFace ( const GEOQuadBndType &bnd, int index ) const;
00280 
00281   // get the face corresponding to the index
00282   const typename ALU3dImplTraits< tetra, Comm >::GEOFaceType *
00283   getFace ( const GEOTetraElementType &elem, int index ) const;
00284 
00285   const typename ALU3dImplTraits< hexa, Comm >::GEOFaceType *
00286   getFace ( const GEOHexaElementType &elem, int index ) const;
00287 
00290   mutable FaceInfoType      connector_;
00291   mutable GeometryInfoType  geoProvider_; // need to initialise
00292 
00293   // reference to factory
00294   const FactoryType& factory_;
00295   
00297   const IMPLElementType* item_;  
00298 
00300   const BNDFaceType* ghost_; 
00301 
00302   mutable int innerLevel_;
00303   mutable int index_;
00304 
00305   mutable GeometryObject intersectionGlobal_;
00306   mutable GeometryObject intersectionSelfLocal_;
00307   mutable GeometryObject intersectionNeighborLocal_;
00308 
00309   // unit outer normal
00310   mutable NormalType unitOuterNormal_;
00311 
00312   // true if end iterator 
00313   bool done_;
00314 };
00315 
00316 template<class GridImp>
00317 class ALU3dGridLevelIntersectionIterator : 
00318 public ALU3dGridIntersectionIterator<GridImp>
00319 {
00320   enum { dim       = GridImp::dimension };
00321   enum { dimworld  = GridImp::dimensionworld };
00322     
00323   typedef typename GridImp::MPICommunicatorType Comm;
00324   
00325   typedef ALU3dImplTraits< GridImp::elementType, Comm > ImplTraits;
00326 
00327   typedef typename ImplTraits::HElementType  HElementType ;
00328   typedef typename ImplTraits::GEOElementType GEOElementType;
00329   typedef typename ImplTraits::IMPLElementType IMPLElementType;
00330   typedef typename ImplTraits::GEOFaceType GEOFaceType;
00331   typedef typename ImplTraits::NeighbourPairType NeighbourPairType;
00332   typedef typename ImplTraits::BNDFaceType BNDFaceType;
00333 
00334   typedef ALU3dGridFaceInfo< GridImp::elementType, Comm > FaceInfoType;
00335   typedef typename std::auto_ptr< FaceInfoType > FaceInfoPointer;
00336 
00337   typedef typename SelectType<
00338     tetra == GridImp::elementType,
00339     ALU3dGridGeometricFaceInfoTetra< Comm >,
00340     ALU3dGridGeometricFaceInfoHexa< Comm > >::Type GeometryInfoType;
00341       
00342   typedef ElementTopologyMapping<GridImp::elementType> ElementTopo;
00343   typedef FaceTopologyMapping<GridImp::elementType> FaceTopo;
00344 
00345   enum { numFaces = EntityCount<GridImp::elementType>::numFaces };
00346   enum { numVerticesPerFace = 
00347          EntityCount<GridImp::elementType>::numVerticesPerFace };
00348   enum { numVertices = EntityCount<GridImp::elementType>::numVertices };
00349 
00350   typedef ALU3dGridIntersectionIterator<GridImp>      BaseType;
00351   typedef ALU3dGridLevelIntersectionIterator<GridImp> ThisType;
00352 
00353   friend class ALU3dGridEntity<0,dim,GridImp>;
00354   friend class IntersectionIteratorWrapper<GridImp,ThisType>;
00355 protected:
00356   using BaseType :: item_;
00357   using BaseType :: ghost_;
00358   using BaseType :: innerLevel_;
00359   using BaseType :: index_;
00360   using BaseType :: connector_;
00361   using BaseType :: geoProvider_;
00362   using BaseType :: factory_;
00363   using BaseType :: done_;
00364   using BaseType :: boundary;
00365   using BaseType :: done ;
00366   using BaseType :: getFace;
00367   using BaseType :: neighbor ;
00368 
00369 public:
00370   typedef typename GridImp::GridObjectFactoryType FactoryType;
00371 
00372   //typedef Dune :: Intersection< const GridImp, ThisType > 
00373   typedef ALUMemoryProvider< ThisType > StorageType;
00374 
00377   ALU3dGridLevelIntersectionIterator(const FactoryType& factory, 
00378                                      HElementType *el,
00379                                      int wLevel,bool end=false);
00380   
00381   ALU3dGridLevelIntersectionIterator(const FactoryType& factory, int wLevel);
00382   
00384   ALU3dGridLevelIntersectionIterator(const ThisType & org);
00385 
00387   void assign(const ThisType & org);
00388 
00390   void increment ();
00391 
00392   // reset IntersectionIterator to first neighbour 
00393   template <class EntityType>
00394   void first(const EntityType & en, int wLevel);
00395 
00397   bool neighbor () const; 
00398 
00400   bool levelNeighbor () const; 
00401 
00403   bool leafNeighbor () const; 
00404 
00406   bool conforming () const 
00407   {
00408     assert( !neighbor() || this->connector_.conformanceState() == FaceInfoType::CONFORMING );  
00409     return true; 
00410   }
00411 private:  
00412   // set new face
00413   void setNewFace(const GEOFaceType& newFace);
00414 
00415   // reset IntersectionIterator to first neighbour 
00416   void setFirstItem(const HElementType & elem, int wLevel);
00417 
00418   // reset IntersectionIterator to first neighbour 
00419   void setInteriorItem(const HElementType  & elem, 
00420                        const BNDFaceType& bnd, int wLevel);
00421 
00422   bool levelNeighbor_; 
00423   bool isLeafItem_; 
00424 };
00425 
00427 //
00428 //  --IterationImpl
00429 //
00431 template <class InternalIteratorType > 
00432 struct ALU3dGridTreeIterator 
00433 {
00434   typedef typename InternalIteratorType :: val_t val_t;
00435 
00436   // here the items level will do 
00437   template <class GridImp, int codim> 
00438   struct GetLevel 
00439   {
00440     template <class ItemType> 
00441     static int getLevel(const GridImp & grid, const ItemType & item, int level )
00442     {
00443       assert( & item );
00444       return (level < 0) ? item.level() : level;
00445     }
00446   };
00447  
00448   // level is not needed for codim = 0 
00449   template <class GridImp> 
00450   struct GetLevel<GridImp,0>
00451   {
00452     template <class ItemType> 
00453     static int getLevel(const GridImp & grid, const ItemType & item, int level )
00454     {
00455       return level;
00456     }
00457   };
00458   
00459   template <class GridImp> 
00460   struct GetLevel<GridImp,3>
00461   {
00462     template <class ItemType> 
00463     static int getLevel(const GridImp & grid, const ItemType & item, int level)
00464     {
00465       return (level < 0) ? grid.getLevelOfLeafVertex(item) : level;
00466     }
00467   };
00468   
00469 protected: 
00470   // set iterator to first item 
00471   template <class GridImp, class IteratorImp> 
00472   void firstItem(const GridImp & grid, IteratorImp & it, int level ) 
00473   {
00474     InternalIteratorType & iter = it.internalIterator();
00475     iter.first(); 
00476     if( ! iter.done() )
00477     {
00478       assert( iter.size() > 0 );
00479       setItem(grid,it,iter,level);
00480     } 
00481     else 
00482     {
00483       it.removeIter();
00484     }
00485   } 
00486 
00487   // set the iterators entity to actual item 
00488   template <class GridImp, class IteratorImp>
00489   void setItem (const GridImp & grid, IteratorImp & it, InternalIteratorType & iter, int level)
00490   {
00491     enum { codim = IteratorImp :: codimension };
00492     val_t & item = iter.item();
00493     assert( item.first || item.second );
00494     if( item.first )
00495     {
00496       it.updateEntityPointer( item.first , 
00497           GetLevel<GridImp,codim>::getLevel(grid, *(item.first) , level) ); 
00498     }
00499     else
00500       it.updateGhostPointer( *item.second );
00501   }
00502 
00503   // increment iterator 
00504   template <class GridImp, class IteratorImp>
00505   void incrementIterator(const GridImp & grid, IteratorImp & it, int level) 
00506   {
00507     // if iter_ is zero, then end iterator 
00508     InternalIteratorType & iter = it.internalIterator();
00509 
00510     iter.next();
00511 
00512     if(iter.done())
00513     {
00514       it.removeIter();
00515       return ;
00516     }
00517 
00518     setItem(grid,it,iter,level);
00519     return ;
00520   }
00521 };
00522 
00523 //**********************************************************************
00524 //
00525 // --ALU3dGridLevelIterator
00526 // --LevelIterator
00530 template<int cd, PartitionIteratorType pitype, class GridImp>
00531 class ALU3dGridLevelIterator
00532 : public ALU3dGridEntityPointer< cd, GridImp >,
00533   public ALU3dGridTreeIterator< ALU3DSPACE ALU3dGridLevelIteratorWrapper< cd, pitype, typename GridImp::MPICommunicatorType > >
00534 {
00535   enum { dim       = GridImp::dimension };
00536   enum { dimworld  = GridImp::dimensionworld };
00537 
00538   typedef typename GridImp::MPICommunicatorType Comm;
00539 
00540   friend class ALU3dGridEntity<3,dim,GridImp>;
00541   friend class ALU3dGridEntity<2,dim,GridImp>;
00542   friend class ALU3dGridEntity<1,dim,GridImp>;
00543   friend class ALU3dGridEntity<0,dim,GridImp>;
00544   friend class ALU3dGrid< GridImp::elementType, Comm >;
00545 
00546   friend class ALU3dGridTreeIterator< ALU3DSPACE ALU3dGridLevelIteratorWrapper< cd, pitype, Comm > >;
00547 
00548 public:
00549   typedef typename GridImp::GridObjectFactoryType FactoryType;
00550 
00551   typedef typename GridImp::template Codim<cd>::Entity Entity;
00552   typedef ALU3dGridVertexList< Comm > VertexListType;
00553     
00555   typedef ALU3dGridLevelIterator<cd,pitype,GridImp> ThisType;
00556   // the wrapper for the original iterator of the ALU3dGrid  
00557   typedef typename ALU3DSPACE ALU3dGridLevelIteratorWrapper< cd, pitype, Comm > IteratorType; 
00558   typedef IteratorType InternalIteratorType; 
00559   typedef typename ALU3DSPACE IteratorElType< cd, Comm >::val_t val_t;
00560  
00562   ALU3dGridLevelIterator(const FactoryType& factory, int level, bool);
00563   
00565   ALU3dGridLevelIterator(const FactoryType& factory, int level);
00566   
00568   ALU3dGridLevelIterator(const ThisType & org);
00569   
00570   // destructor 
00571   ~ALU3dGridLevelIterator();
00572 
00574   void increment ();
00575 
00577   Entity & dereference () const;
00578 
00580   void releaseEntity () {}
00581 
00583   ThisType & operator = (const ThisType & org);
00584 private:
00586   void assign (const ThisType & org);
00587 
00588   // actual level
00589   int level_;
00590 
00591   // the internal iterator 
00592   IteratorType * iter_ ;
00593   
00594   // deletes iter_ 
00595   void removeIter ();
00596 
00597   IteratorType & internalIterator () 
00598   { 
00599     assert( iter_ ); 
00600     return *iter_; 
00601   }
00602 };
00603 
00604 //********************************************************************
00605 //
00606 //  --ALU3dGridLeafIterator 
00607 //  --LeafIterator 
00608 //
00609 //********************************************************************
00611 template<int cdim, PartitionIteratorType pitype, class GridImp>
00612 class ALU3dGridLeafIterator
00613 : public ALU3dGridEntityPointer< cdim, GridImp >,
00614   public ALU3dGridTreeIterator< ALU3DSPACE ALU3dGridLeafIteratorWrapper< cdim, pitype, typename GridImp::MPICommunicatorType > >
00615 {
00616   enum { dim = GridImp :: dimension };
00617   
00618   friend class ALU3dGridEntity<cdim,dim,GridImp>;
00619   enum { codim = cdim }; 
00620 
00621   typedef typename GridImp::MPICommunicatorType Comm;
00622 
00623 public:
00624   typedef typename GridImp::GridObjectFactoryType FactoryType;
00625 
00626   typedef typename GridImp::template Codim<cdim>::Entity Entity;
00627 
00628   typedef typename ALU3DSPACE ALU3dGridLeafIteratorWrapper< cdim, pitype, Comm > IteratorType ;
00629   friend class ALU3dGridTreeIterator< IteratorType > ;
00630 
00631   typedef IteratorType InternalIteratorType;
00632   typedef typename ALU3DSPACE IteratorElType< cdim, Comm >::val_t val_t;
00633   
00634   typedef ALU3dGridLeafIterator<cdim, pitype, GridImp> ThisType;
00635 
00637   ALU3dGridLeafIterator(const FactoryType& factory, int level);
00638 
00640   ALU3dGridLeafIterator(const FactoryType& factory, int level , bool isBegin);
00641 
00643   ALU3dGridLeafIterator(const ThisType & org);
00644   
00646   ~ALU3dGridLeafIterator();
00647 
00649   void increment ();
00650 
00652   Entity & dereference () const;
00653 
00655   void releaseEntity () {}
00656 
00658   ThisType & operator = (const ThisType & org);
00659   
00660 private:
00661   // the internal iterator 
00662   IteratorType * iter_;
00663 
00664   // max level for iteration  
00665   int walkLevel_ ;
00666 
00668   void assign (const ThisType & org);
00669   
00670   // deletes iter_  
00671   void removeIter () ;
00672 
00673   // return reference to iter_ 
00674   InternalIteratorType & internalIterator () 
00675   { 
00676     assert( iter_ );
00677     return *iter_;
00678   }
00679 };
00680 
00681 // - HierarchicIteraor
00682 // --HierarchicIterator
00683 template<class GridImp>
00684 class ALU3dGridHierarchicIterator
00685 : public ALU3dGridEntityPointer<0,GridImp>
00686 // public HierarchicIteratorDefaultImplementation <GridImp,ALU3dGridHierarchicIterator>
00687 {
00688   typedef ALU3dGridHierarchicIterator<GridImp> ThisType;
00689   enum { dim = GridImp::dimension };
00690 
00691   typedef typename GridImp::MPICommunicatorType Comm;
00692 
00693   typedef ALU3dImplTraits< GridImp::elementType, Comm > ImplTraits;
00694   typedef typename ImplTraits::HElementType HElementType;
00695   typedef typename ImplTraits::HBndSegType HBndSegType;
00696 
00697   template < class PointerType, class CommT > 
00698   class GhostElementStorage;
00699 
00701   template < class PointerType > 
00702   struct GhostElementStorage< PointerType, No_Comm >
00703   {
00704     GhostElementStorage() {}
00705     explicit GhostElementStorage( const PointerType& ) {}
00706     PointerType& operator * () {  PointerType* p = 0; assert( false ); abort(); return *p; }
00707     const PointerType* ghost () const { return 0; }
00708     PointerType* nextGhost () const { return 0; }
00709     PointerType* operator -> () const { return 0; }
00710     bool operator != (const PointerType* ) const { return false; }
00711     bool operator ! () const { return true ; }
00712     GhostElementStorage& operator= (const GhostElementStorage& ) { return *this; }
00713     GhostElementStorage& operator= (const PointerType* )  { return *this;  }
00714     bool valid () const { return false; }
00715   };
00716 
00717 #if ALU3DGRID_PARALLEL
00718 
00719   template < class PointerType > 
00720   struct GhostElementStorage< PointerType, MPI_Comm >
00721   {
00722   private:  
00723     // pointers to ghost and current ghost 
00724     const HBndSegType * ghost_;
00725     HBndSegType * nextGhost_;
00726   public:  
00727     GhostElementStorage() : ghost_( 0 ), nextGhost_( 0 ) {}
00728     explicit GhostElementStorage( const PointerType& gh ) : ghost_( &gh ), nextGhost_( 0 ) {}
00729     GhostElementStorage( const GhostElementStorage& org ) 
00730       : ghost_( org.ghost_ ), nextGhost_( org.nextGhost_ ) {}
00731 
00732     PointerType& operator * () { assert( nextGhost_ ); return *nextGhost_; }
00733     const PointerType* ghost () const { return ghost_; }
00734     PointerType* nextGhost () const { return nextGhost_; }
00735     PointerType* operator -> () { return nextGhost_; }
00736     bool operator != (const PointerType* p ) const { return (nextGhost_ != p); }
00737     bool operator ! () const { return nextGhost_ == 0; }
00738     GhostElementStorage& operator= (const GhostElementStorage& org) 
00739     {
00740       ghost_ = org.ghost_;
00741       nextGhost_ = org.nextGhost_;
00742       return *this;
00743     }
00744     GhostElementStorage& operator= (PointerType* p) 
00745     {
00746       nextGhost_ = p;
00747       return *this;
00748     }
00749     bool valid () const { return (ghost_ != 0); }
00750   };
00751 #endif
00752 
00753 public:
00754   typedef typename GridImp::GridObjectFactoryType FactoryType;
00755 
00756   typedef typename GridImp::template Codim<0>::Entity Entity;
00757   typedef typename GridImp::ctype ctype;
00758 
00760   ALU3dGridHierarchicIterator(const FactoryType& factory,
00761                               const HElementType & elem, 
00762                               int maxlevel, bool end );
00763   
00765   ALU3dGridHierarchicIterator(const FactoryType& factory,
00766                               const HBndSegType& ghost, 
00767                               int maxlevel, 
00768                               bool end);
00769   
00771   ALU3dGridHierarchicIterator(const ALU3dGridHierarchicIterator<GridImp> &org);
00772     
00774   void increment();
00775 
00777   Entity & dereference () const;
00778 
00780   void releaseEntity () {}
00781 
00783   ThisType & operator = (const ThisType & org);
00784   
00785 private:
00786   // assign iterator 
00787   void assign(const ThisType & org);
00788 
00790   int getLevel(const HElementType* item) const; 
00791   
00793   int getLevel(const HBndSegType* face) const;
00794   
00795   // go to next valid element 
00796   template <class HItemType>
00797   HItemType* goNextElement (const HItemType* startElem, HItemType * oldEl);
00798   
00800   const HElementType * elem_;
00801 
00802   // pointers to ghost and current ghost 
00803   GhostElementStorage< HBndSegType, Comm > ghostElem_;
00804 
00806   int maxlevel_; 
00807 };
00808 
00809 
00810 } // end namespace Dune
00811 
00812 #include "iterator_imp.cc"
00813 
00814 #endif

Generated on Fri Apr 29 2011 with Doxygen (ver 1.7.1) [doxygen-log,error-log].