intersectioniteratorwrapper.hh

Go to the documentation of this file.
00001 #ifndef DUNE_INTERSECTIONITERATORWRAPPER_HH
00002 #define DUNE_INTERSECTIONITERATORWRAPPER_HH
00003 
00004 #include "intersectioniterator.hh"
00005 
00011 namespace Dune {
00012 
00015 template <class GridImp, class IntersectionIteratorImpl>
00016 class IntersectionIteratorWrapper 
00017 {
00018   enum { dim = GridImp :: dimension };
00019   enum { dimworld = GridImp :: dimensionworld };
00020 
00021   typedef IntersectionIteratorWrapper<GridImp,IntersectionIteratorImpl> ThisType;
00022 
00023   typedef IntersectionIteratorImpl IntersectionIteratorImp;
00024   
00025   typedef typename IntersectionIteratorImp :: StorageType IntersectionIteratorProviderType;
00026 
00027 public:   
00029   enum { dimension      = dim };
00031   enum { dimensionworld = dimworld };
00032 
00034   typedef typename GridImp :: ctype ctype;
00035 
00037   typedef typename GridImp::template Codim<0>::Entity Entity;
00039   typedef typename GridImp::template Codim<0>::EntityPointer EntityPointer;
00040 
00042   typedef typename GridImp::template Codim<1>::Geometry Geometry;
00044   typedef typename GridImp::template Codim<1>::LocalGeometry LocalGeometry;
00045 
00047   typedef FieldVector<ctype , dimworld> NormalType;
00048 
00050   template <class EntityImp>
00051   IntersectionIteratorWrapper(const GridImp & grid , const EntityImp & en, int wLevel , bool end ,
00052                               IntersectionIteratorProviderType & storage) 
00053     : storage_(storage) 
00054     , it_(*(storage_.getObject(grid,wLevel))) 
00055   {
00056     if(end) 
00057       it().done();
00058     else 
00059       it().first(en,wLevel);
00060   } 
00061 
00063   IntersectionIteratorWrapper(const ThisType & org)
00064     : storage_(org.storage_) , it_(*(storage_.getObjectCopy(org.it_)))   
00065   {
00066     it().assign(org.it_);
00067   }
00068 
00070   ThisType & operator = (const ThisType & org)
00071   {
00072     it().assign(org.it_);
00073     return *this;
00074   }
00075 
00077   ~IntersectionIteratorWrapper()
00078   {
00079     storage_.freeObject( &it_ ); 
00080   }
00081 
00083   bool equals (const ThisType & i) const { return it().equals(i.it()); }
00084 
00086   void increment () { it().increment(); }
00087 
00089   EntityPointer outside() const { return it().outside(); }
00090 
00092   EntityPointer inside() const { return it().inside(); }
00093 
00096   bool boundary () const { return it().boundary(); }
00097 
00099   bool neighbor () const { return it().neighbor(); }
00100 
00102   int boundaryId () const { return it().boundaryId(); }
00103 
00108   const LocalGeometry & intersectionSelfLocal () const { return it().intersectionSelfLocal(); }
00109 
00114   const Geometry & intersectionGlobal () const { return it().intersectionGlobal(); }
00115 
00117   GeometryType type () const
00118   {
00119     return it().type();
00120   }
00121 
00124   int numberInSelf () const { return it().numberInSelf(); }
00125 
00129   const LocalGeometry & intersectionNeighborLocal () const { return it().intersectionNeighborLocal(); }
00130 
00133   int numberInNeighbor () const { return it().numberInNeighbor(); }
00134 
00136   int twistInSelf() const { return it().twistInSelf(); }
00137 
00139   int twistInNeighbor() const { return it().twistInNeighbor(); }
00140 
00143   const NormalType unitOuterNormal ( const FieldVector< ctype, dim-1 > &local ) const
00144   {
00145     return it().unitOuterNormal( local );
00146   }
00147 
00150   const NormalType outerNormal ( const FieldVector< ctype, dim-1 > &local ) const
00151   {
00152     return it().outerNormal( local );
00153   }
00154 
00157   const NormalType integrationOuterNormal ( const FieldVector< ctype, dim-1 > &local ) const
00158   {
00159     return it().integrationOuterNormal( local );
00160   }
00161 
00163   int level () const { return it().level(); }
00164 
00166   bool conforming () const { return it().conforming(); }
00167 
00168 private: 
00170   IntersectionIteratorImp & it() { return it_; }
00171   const IntersectionIteratorImp & it() const { return it_; }
00172  
00173   IntersectionIteratorProviderType & storage_;
00174   IntersectionIteratorImp & it_;
00175 }; // end class IntersectionIteratorWrapper 
00176 
00179 template <class GridImp>
00180 class LeafIntersectionIteratorWrapper 
00181 : public IntersectionIteratorWrapper<GridImp,typename GridImp::LeafIntersectionIteratorImp> 
00182 {
00183   typedef LeafIntersectionIteratorWrapper<GridImp> ThisType;
00184   typedef IntersectionIteratorWrapper<GridImp,typename GridImp::LeafIntersectionIteratorImp> BaseType;
00185 public:   
00186   typedef Dune :: Intersection
00187     < const GridImp, Dune :: LeafIntersectionIteratorWrapper >
00188     Intersection;
00189   
00191   enum { dimension      = GridImp :: dimension  };
00193   enum { dimensionworld = GridImp :: dimensionworld };
00194 
00196   typedef typename GridImp :: ctype ctype;
00197 
00199   typedef typename GridImp::template Codim<0>::Entity Entity;
00201   typedef typename GridImp::template Codim<0>::EntityPointer EntityPointer;
00202 
00204   typedef typename GridImp::template Codim<1>::Geometry Geometry;
00206   typedef typename GridImp::template Codim<1>::LocalGeometry LocalGeometry;
00207 
00209   typedef FieldVector<ctype , dimensionworld> NormalType;
00210 
00212   template <class EntityImp>
00213   LeafIntersectionIteratorWrapper(const GridImp & grid , const EntityImp & en, int wLevel , bool end ) 
00214     : BaseType(grid,en,wLevel,end,grid.leafIntersetionIteratorProvider()) 
00215   {
00216   } 
00217 
00219   LeafIntersectionIteratorWrapper(const ThisType & org)
00220     : BaseType(org)
00221   {
00222   }
00223 
00225   ThisType & operator = (const ThisType & org)
00226   {
00227     BaseType::operator = (org);
00228     return *this;
00229   }
00230 
00231   const Intersection &dereference () const
00232   {
00233     return reinterpret_cast< const Intersection & >( *this );
00234   }
00235 }; // end class IntersectionIteratorWrapper 
00236 
00239 template <class GridImp>
00240 class LevelIntersectionIteratorWrapper 
00241 : public IntersectionIteratorWrapper<GridImp,typename GridImp::LevelIntersectionIteratorImp> 
00242 {
00243   typedef LevelIntersectionIteratorWrapper<GridImp> ThisType;
00244   typedef IntersectionIteratorWrapper<GridImp,typename GridImp::LevelIntersectionIteratorImp> BaseType;
00245 public:
00246   typedef Dune :: Intersection
00247     < const GridImp, Dune :: LevelIntersectionIteratorWrapper >
00248     Intersection;
00249   
00251   enum { dimension      = GridImp :: dimension  };
00253   enum { dimensionworld = GridImp :: dimensionworld };
00254 
00256   typedef typename GridImp :: ctype ctype;
00257 
00259   typedef typename GridImp::template Codim<0>::Entity Entity;
00261   typedef typename GridImp::template Codim<0>::EntityPointer EntityPointer;
00262 
00264   typedef typename GridImp::template Codim<1>::Geometry Geometry;
00266   typedef typename GridImp::template Codim<1>::LocalGeometry LocalGeometry;
00267 
00269   typedef FieldVector<ctype , dimensionworld> NormalType;
00270 
00272   template <class EntityImp>
00273   LevelIntersectionIteratorWrapper(const GridImp & grid , const EntityImp & en, int wLevel , bool end ) 
00274     : BaseType(grid,en,wLevel,end,grid.levelIntersetionIteratorProvider()) 
00275   {
00276   } 
00277 
00279   LevelIntersectionIteratorWrapper(const ThisType & org)
00280     : BaseType(org)
00281   {
00282   }
00283 
00285   ThisType & operator = (const ThisType & org)
00286   {
00287     BaseType::operator = (org);
00288     return *this;
00289   }
00290 
00291   const Intersection &dereference () const
00292   {
00293     return reinterpret_cast< const Intersection & >( *this );
00294   }
00295 }; // end class IntersectionIteratorWrapper 
00296 
00297 } // end namespace Dune 
00298 #endif

Generated on Sun Nov 15 22:28:42 2009 for dune-grid by  doxygen 1.5.6