dune-grid
2.1.1
|
00001 #ifndef DUNE_INTERSECTIONITERATORWRAPPER_HH 00002 #define DUNE_INTERSECTIONITERATORWRAPPER_HH 00003 00004 #include <dune/grid/common/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: 00028 typedef typename GridImp :: GridObjectFactoryType FactoryType; 00029 00031 enum { dimension = dim }; 00033 enum { dimensionworld = dimworld }; 00034 00036 typedef typename GridImp :: ctype ctype; 00037 00039 typedef typename GridImp::template Codim<0>::Entity Entity; 00041 typedef typename GridImp::template Codim<0>::EntityPointer EntityPointer; 00042 00044 typedef typename GridImp::template Codim<1>::Geometry Geometry; 00046 typedef typename GridImp::template Codim<1>::LocalGeometry LocalGeometry; 00047 00049 typedef FieldVector<ctype , dimworld> NormalType; 00050 00052 template <class EntityImp> 00053 IntersectionIteratorWrapper(const EntityImp & en, int wLevel , bool end) 00054 : factory_( en.factory() ) 00055 , it_( factory_.getIntersection(wLevel, (IntersectionIteratorImpl *) 0) ) 00056 { 00057 if(end) 00058 it().done( en ); 00059 else 00060 it().first(en,wLevel); 00061 } 00062 00064 IntersectionIteratorWrapper(const ThisType & org) 00065 : factory_( org.factory_ ) 00066 , it_( factory_.getIntersection(-1, (IntersectionIteratorImpl *) 0) ) 00067 { 00068 it().assign( org.it() ); 00069 } 00070 00072 ThisType & operator = (const ThisType & org) 00073 { 00074 it().assign( org.it() ); 00075 return *this; 00076 } 00077 00079 ~IntersectionIteratorWrapper() 00080 { 00081 factory_.freeIntersection( it() ); 00082 } 00083 00085 bool equals (const ThisType & i) const { return it().equals(i.it()); } 00086 00088 void increment () { it().increment(); } 00089 00091 EntityPointer outside() const { return it().outside(); } 00092 00094 EntityPointer inside() const { return it().inside(); } 00095 00098 bool boundary () const { return it().boundary(); } 00099 00101 bool neighbor () const { return it().neighbor(); } 00102 00104 int boundaryId () const { return it().boundaryId(); } 00105 00107 size_t boundarySegmentIndex() const { return it().boundarySegmentIndex(); } 00108 00113 const LocalGeometry &geometryInInside () const 00114 { 00115 return it().geometryInInside(); 00116 } 00117 00122 const Geometry &geometry () const 00123 { 00124 return it().geometry(); 00125 } 00126 00128 GeometryType type () const 00129 { 00130 return it().type(); 00131 } 00132 00135 int indexInInside () const 00136 { 00137 return it().indexInInside(); 00138 } 00139 00143 const LocalGeometry &geometryInOutside () const 00144 { 00145 return it().geometryInOutside(); 00146 } 00147 00150 int indexInOutside () const 00151 { 00152 return it().indexInOutside(); 00153 } 00154 00156 int twistInSelf() const { return it().twistInSelf(); } 00157 00159 int twistInInside() const { return it().twistInInside(); } 00160 00162 int twistInNeighbor() const { return it().twistInNeighbor(); } 00163 00165 int twistInOutside() const { return it().twistInOutside(); } 00166 00169 const NormalType unitOuterNormal ( const FieldVector< ctype, dim-1 > &local ) const 00170 { 00171 return it().unitOuterNormal( local ); 00172 } 00173 00176 const NormalType centerUnitOuterNormal ( ) const 00177 { 00178 GeometryType type = geometry().type(); 00179 const GenericReferenceElement<ctype, dim-1> & refElement = 00180 GenericReferenceElements<ctype, dim-1>::general(type); 00181 return unitOuterNormal(refElement.position(0,0)); 00182 } 00183 00186 const NormalType outerNormal ( const FieldVector< ctype, dim-1 > &local ) const 00187 { 00188 return it().outerNormal( local ); 00189 } 00190 00193 const NormalType integrationOuterNormal ( const FieldVector< ctype, dim-1 > &local ) const 00194 { 00195 return it().integrationOuterNormal( local ); 00196 } 00197 00199 int level () const { return it().level(); } 00200 00202 bool conforming () const { return it().conforming(); } 00203 00204 private: 00206 IntersectionIteratorImp & it() { return it_; } 00207 const IntersectionIteratorImp & it() const { return it_; } 00208 00209 const FactoryType& factory_ ; 00210 IntersectionIteratorImp & it_; 00211 }; // end class IntersectionIteratorWrapper 00212 00213 template <class GridImp> 00214 class LeafIntersectionWrapper 00215 : public IntersectionIteratorWrapper<GridImp,typename GridImp::LeafIntersectionIteratorImp> 00216 { 00217 typedef LeafIntersectionWrapper<GridImp> ThisType; 00218 typedef IntersectionIteratorWrapper<GridImp,typename GridImp::LeafIntersectionIteratorImp> BaseType; 00219 public: 00221 template <class EntityImp> 00222 LeafIntersectionWrapper(const EntityImp & en, int wLevel , bool end ) 00223 : BaseType(en,wLevel,end) 00224 { 00225 } 00226 00228 LeafIntersectionWrapper(const ThisType & org) 00229 : BaseType(org) 00230 { 00231 } 00232 00233 }; 00234 00237 template <class GridImp> 00238 class LeafIntersectionIteratorWrapper 00239 { 00240 typedef LeafIntersectionIteratorWrapper<GridImp> ThisType; 00241 typedef LeafIntersectionWrapper<GridImp> IntersectionImp; 00242 public: 00243 typedef Dune :: Intersection 00244 < const GridImp, Dune :: LeafIntersectionWrapper > Intersection; 00245 00247 enum { dimension = GridImp :: dimension }; 00249 enum { dimensionworld = GridImp :: dimensionworld }; 00250 00252 typedef typename GridImp :: ctype ctype; 00253 00255 typedef typename GridImp::template Codim<0>::Entity Entity; 00257 typedef typename GridImp::template Codim<0>::EntityPointer EntityPointer; 00258 00260 typedef typename GridImp::template Codim<1>::Geometry Geometry; 00262 typedef typename GridImp::template Codim<1>::LocalGeometry LocalGeometry; 00263 00265 typedef FieldVector<ctype , dimensionworld> NormalType; 00266 00268 template <class EntityImp> 00269 LeafIntersectionIteratorWrapper(const EntityImp & en, int wLevel , bool end ) 00270 : intersection_( IntersectionImp(en,wLevel,end) ) 00271 {} 00272 00274 LeafIntersectionIteratorWrapper(const ThisType & org) 00275 : intersection_( IntersectionImp( org.impl() ) ) 00276 {} 00277 00279 ThisType & operator = (const ThisType & org) 00280 { 00281 impl() = org.impl(); 00282 return *this; 00283 } 00284 00286 const Intersection &dereference () const 00287 { 00288 return intersection_; 00289 } 00290 00292 bool equals (const ThisType & i) const { return impl().equals( i.impl() ); } 00293 00295 void increment() 00296 { 00297 impl().increment(); 00298 } 00299 protected: 00300 // intersection object 00301 Intersection intersection_; 00302 00303 // return reference to real implementation 00304 IntersectionImp& impl() { return GridImp :: getRealImplementation( intersection_ ); } 00305 // return reference to real implementation 00306 const IntersectionImp& impl() const { return GridImp :: getRealImplementation( intersection_ ); } 00307 }; // end class IntersectionIteratorWrapper 00308 00311 template <class GridImp> 00312 class LevelIntersectionWrapper 00313 : public IntersectionIteratorWrapper<GridImp,typename GridImp::LevelIntersectionIteratorImp> 00314 { 00315 typedef LevelIntersectionWrapper<GridImp> ThisType; 00316 typedef IntersectionIteratorWrapper<GridImp,typename GridImp::LevelIntersectionIteratorImp> BaseType; 00317 public: 00319 template <class EntityImp> 00320 LevelIntersectionWrapper(const EntityImp & en, int wLevel , bool end ) 00321 : BaseType(en,wLevel,end) 00322 { 00323 } 00324 00326 LevelIntersectionWrapper(const ThisType & org) 00327 : BaseType(org) 00328 { 00329 } 00330 }; 00331 00334 template <class GridImp> 00335 class LevelIntersectionIteratorWrapper 00336 { 00337 typedef LevelIntersectionIteratorWrapper<GridImp> ThisType; 00338 typedef LevelIntersectionWrapper<GridImp> IntersectionImp; 00339 public: 00340 typedef Dune :: Intersection 00341 < const GridImp, Dune :: LevelIntersectionWrapper > 00342 Intersection; 00343 00345 enum { dimension = GridImp :: dimension }; 00347 enum { dimensionworld = GridImp :: dimensionworld }; 00348 00350 typedef typename GridImp :: ctype ctype; 00351 00353 typedef typename GridImp::template Codim<0>::Entity Entity; 00355 typedef typename GridImp::template Codim<0>::EntityPointer EntityPointer; 00356 00358 typedef typename GridImp::template Codim<1>::Geometry Geometry; 00360 typedef typename GridImp::template Codim<1>::LocalGeometry LocalGeometry; 00361 00363 typedef FieldVector<ctype , dimensionworld> NormalType; 00364 00366 template <class EntityImp> 00367 LevelIntersectionIteratorWrapper(const EntityImp & en, int wLevel , bool end ) 00368 : intersection_( IntersectionImp(en,wLevel,end) ) 00369 {} 00370 00372 LevelIntersectionIteratorWrapper(const ThisType & org) 00373 : intersection_( IntersectionImp( org.impl() ) ) 00374 {} 00375 00377 ThisType & operator = (const ThisType & org) 00378 { 00379 impl() = org.impl(); 00380 return *this; 00381 } 00382 00384 const Intersection &dereference () const 00385 { 00386 return intersection_; 00387 } 00388 00390 bool equals (const ThisType & i) const { return impl().equals( i.impl() ); } 00391 00393 void increment() 00394 { 00395 impl().increment(); 00396 } 00397 protected: 00398 // intersection object 00399 Intersection intersection_; 00400 00401 // return reference to real implementation 00402 IntersectionImp& impl() { return GridImp :: getRealImplementation( intersection_ ); } 00403 // return reference to real implementation 00404 const IntersectionImp& impl() const { return GridImp :: getRealImplementation( intersection_ ); } 00405 }; // end class IntersectionIteratorWrapper 00406 00407 } // end namespace Dune 00408 #endif