dune-grid  2.2.1
alugrid/common/intersectioniteratorwrapper.hh
Go to the documentation of this file.
1 #ifndef DUNE_INTERSECTIONITERATORWRAPPER_HH
2 #define DUNE_INTERSECTIONITERATORWRAPPER_HH
3 
5 
11 namespace Dune {
12 
15 template <class GridImp, class IntersectionIteratorImpl>
17 {
18  enum { dim = GridImp :: dimension };
19  enum { dimworld = GridImp :: dimensionworld };
20 
22 
23  typedef IntersectionIteratorImpl IntersectionIteratorImp;
24 
25  typedef typename IntersectionIteratorImp :: StorageType IntersectionIteratorProviderType;
26 
27 public:
28  typedef typename GridImp :: GridObjectFactoryType FactoryType;
29 
31  enum { dimension = dim };
33  enum { dimensionworld = dimworld };
34 
36  typedef typename GridImp :: ctype ctype;
37 
39  typedef typename GridImp::template Codim<0>::Entity Entity;
41  typedef typename GridImp::template Codim<0>::EntityPointer EntityPointer;
42 
44  typedef typename GridImp::template Codim<1>::Geometry Geometry;
46  typedef typename GridImp::template Codim<1>::LocalGeometry LocalGeometry;
47 
49  typedef FieldVector<ctype , dimworld> NormalType;
50 
52  template <class EntityImp>
53  IntersectionIteratorWrapper(const EntityImp & en, int wLevel , bool end)
54  : factory_( en.factory() )
55  , it_( factory_.getIntersection(wLevel, (IntersectionIteratorImpl *) 0) )
56  {
57  if(end)
58  it().done( en );
59  else
60  it().first(en,wLevel);
61  }
62 
65  : factory_( org.factory_ )
66  , it_( factory_.getIntersection(-1, (IntersectionIteratorImpl *) 0) )
67  {
68  it().assign( org.it() );
69  }
70 
72  ThisType & operator = (const ThisType & org)
73  {
74  it().assign( org.it() );
75  return *this;
76  }
77 
80  {
81  factory_.freeIntersection( it() );
82  }
83 
85  bool equals (const ThisType & i) const { return it().equals(i.it()); }
86 
88  void increment () { it().increment(); }
89 
91  EntityPointer outside() const { return it().outside(); }
92 
94  EntityPointer inside() const { return it().inside(); }
95 
98  bool boundary () const { return it().boundary(); }
99 
101  bool neighbor () const { return it().neighbor(); }
102 
104  int boundaryId () const { return it().boundaryId(); }
105 
107  size_t boundarySegmentIndex() const { return it().boundarySegmentIndex(); }
108 
114  {
115  return it().geometryInInside();
116  }
117 
123  {
124  return it().geometry();
125  }
126 
129  {
130  return it().type();
131  }
132 
135  int indexInInside () const
136  {
137  return it().indexInInside();
138  }
139 
144  {
145  return it().geometryInOutside();
146  }
147 
150  int indexInOutside () const
151  {
152  return it().indexInOutside();
153  }
154 
156  int twistInSelf() const { return it().twistInSelf(); }
157 
159  int twistInInside() const { return it().twistInInside(); }
160 
162  int twistInNeighbor() const { return it().twistInNeighbor(); }
163 
165  int twistInOutside() const { return it().twistInOutside(); }
166 
169  const NormalType unitOuterNormal ( const FieldVector< ctype, dim-1 > &local ) const
170  {
171  return it().unitOuterNormal( local );
172  }
173 
177  {
178  GeometryType type = geometry().type();
179  const GenericReferenceElement<ctype, dim-1> & refElement =
180  GenericReferenceElements<ctype, dim-1>::general(type);
181  return unitOuterNormal(refElement.position(0,0));
182  }
183 
186  const NormalType outerNormal ( const FieldVector< ctype, dim-1 > &local ) const
187  {
188  return it().outerNormal( local );
189  }
190 
193  const NormalType integrationOuterNormal ( const FieldVector< ctype, dim-1 > &local ) const
194  {
195  return it().integrationOuterNormal( local );
196  }
197 
199  int level () const { return it().level(); }
200 
202  bool conforming () const { return it().conforming(); }
203 
205  IntersectionIteratorImp & it() { return it_; }
206  const IntersectionIteratorImp & it() const { return it_; }
207 
208 private:
209  const FactoryType& factory_ ;
210  IntersectionIteratorImp & it_;
211 }; // end class IntersectionIteratorWrapper
212 
213 template <class GridImp>
215 : public IntersectionIteratorWrapper<GridImp,typename GridImp::LeafIntersectionIteratorImp>
216 {
219 public:
221  template <class EntityImp>
222  LeafIntersectionWrapper(const EntityImp & en, int wLevel , bool end )
223  : BaseType(en,wLevel,end)
224  {
225  }
226 
229  : BaseType(org)
230  {
231  }
232 
233 };
234 
237 template <class GridImp>
239 {
242 public:
243  typedef Dune :: Intersection
245 
247  enum { dimension = GridImp :: dimension };
249  enum { dimensionworld = GridImp :: dimensionworld };
250 
252  typedef typename GridImp :: ctype ctype;
253 
255  typedef typename GridImp::template Codim<0>::Entity Entity;
257  typedef typename GridImp::template Codim<0>::EntityPointer EntityPointer;
258 
260  typedef typename GridImp::template Codim<1>::Geometry Geometry;
262  typedef typename GridImp::template Codim<1>::LocalGeometry LocalGeometry;
263 
265  typedef FieldVector<ctype , dimensionworld> NormalType;
266 
268  template <class EntityImp>
269  LeafIntersectionIteratorWrapper(const EntityImp & en, int wLevel , bool end )
270  : intersection_( IntersectionImp(en,wLevel,end) )
271  {}
272 
275  : intersection_( IntersectionImp( org.impl() ) )
276  {}
277 
280  {
281  impl() = org.impl();
282  return *this;
283  }
284 
286  const Intersection &dereference () const
287  {
288  return intersection_;
289  }
290 
292  bool equals (const ThisType & i) const { return impl().equals( i.impl() ); }
293 
295  void increment()
296  {
297  impl().increment();
298  }
299 protected:
300  // intersection object
302 
303  // return reference to real implementation
304  IntersectionImp& impl() { return GridImp :: getRealImplementation( intersection_ ); }
305  // return reference to real implementation
306  const IntersectionImp& impl() const { return GridImp :: getRealImplementation( intersection_ ); }
307 }; // end class IntersectionIteratorWrapper
308 
311 template <class GridImp>
313 : public IntersectionIteratorWrapper<GridImp,typename GridImp::LevelIntersectionIteratorImp>
314 {
317 public:
319  template <class EntityImp>
320  LevelIntersectionWrapper(const EntityImp & en, int wLevel , bool end )
321  : BaseType(en,wLevel,end)
322  {
323  }
324 
327  : BaseType(org)
328  {
329  }
330 };
331 
334 template <class GridImp>
336 {
339 public:
340  typedef Dune :: Intersection
341  < const GridImp, Dune :: LevelIntersectionWrapper >
343 
345  enum { dimension = GridImp :: dimension };
347  enum { dimensionworld = GridImp :: dimensionworld };
348 
350  typedef typename GridImp :: ctype ctype;
351 
353  typedef typename GridImp::template Codim<0>::Entity Entity;
355  typedef typename GridImp::template Codim<0>::EntityPointer EntityPointer;
356 
358  typedef typename GridImp::template Codim<1>::Geometry Geometry;
360  typedef typename GridImp::template Codim<1>::LocalGeometry LocalGeometry;
361 
363  typedef FieldVector<ctype , dimensionworld> NormalType;
364 
366  template <class EntityImp>
367  LevelIntersectionIteratorWrapper(const EntityImp & en, int wLevel , bool end )
368  : intersection_( IntersectionImp(en,wLevel,end) )
369  {}
370 
373  : intersection_( IntersectionImp( org.impl() ) )
374  {}
375 
378  {
379  impl() = org.impl();
380  return *this;
381  }
382 
384  const Intersection &dereference () const
385  {
386  return intersection_;
387  }
388 
390  bool equals (const ThisType & i) const { return impl().equals( i.impl() ); }
391 
393  void increment()
394  {
395  impl().increment();
396  }
397 protected:
398  // intersection object
400 
401  // return reference to real implementation
402  IntersectionImp& impl() { return GridImp :: getRealImplementation( intersection_ ); }
403  // return reference to real implementation
404  const IntersectionImp& impl() const { return GridImp :: getRealImplementation( intersection_ ); }
405 }; // end class IntersectionIteratorWrapper
406 
407 } // end namespace Dune
408 #endif