dune-grid  2.4.1-rc2
intersectioniteratorwrapper.hh
Go to the documentation of this file.
1 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=4 sw=2 sts=2:
3 #ifndef DUNE_INTERSECTIONITERATORWRAPPER_HH
4 #define DUNE_INTERSECTIONITERATORWRAPPER_HH
5 
7 
13 namespace Dune {
14 
17  template <class GridImp, class IntersectionIteratorImpl>
19  {
20  enum { dim = GridImp :: dimension };
21  enum { dimworld = GridImp :: dimensionworld };
22 
24 
25  typedef IntersectionIteratorImpl IntersectionIteratorImp;
26 
27  typedef typename IntersectionIteratorImp :: StorageType IntersectionIteratorProviderType;
28 
29  public:
30  typedef typename GridImp :: GridObjectFactoryType FactoryType;
31 
33  enum { dimension = dim };
35  enum { dimensionworld = dimworld };
36 
38  typedef typename GridImp :: ctype ctype;
39 
41  typedef typename GridImp::template Codim<0>::Entity Entity;
43  typedef typename GridImp::template Codim<0>::EntityPointer EntityPointer;
44 
46  typedef typename GridImp::template Codim<1>::Geometry Geometry;
48  typedef typename GridImp::template Codim<1>::LocalGeometry LocalGeometry;
49 
51  typedef FieldVector<ctype , dimworld> NormalType;
52 
54  template <class EntityImp>
55  IntersectionIteratorWrapper(const EntityImp & en, int wLevel , bool end)
56  : factory_( en.factory() )
57  , it_( factory_.getIntersection(wLevel, (IntersectionIteratorImpl *) 0) )
58  {
59  if(end)
60  it().done( en );
61  else
62  it().first(en,wLevel);
63  }
64 
66  IntersectionIteratorWrapper(const ThisType & org)
67  : factory_( org.factory_ )
68  , it_( factory_.getIntersection(-1, (IntersectionIteratorImpl *) 0) )
69  {
70  it().assign( org.it() );
71  }
72 
74  ThisType & operator = (const ThisType & org)
75  {
76  it().assign( org.it() );
77  return *this;
78  }
79 
82  {
83  factory_.freeIntersection( it() );
84  }
85 
87  bool equals (const ThisType & i) const { return it().equals(i.it()); }
88 
90  void increment () { it().increment(); }
91 
93  EntityPointer outside() const { return it().outside(); }
94 
96  EntityPointer inside() const { return it().inside(); }
97 
100  bool boundary () const { return it().boundary(); }
101 
103  bool neighbor () const { return it().neighbor(); }
104 
106  int boundaryId () const { return it().boundaryId(); }
107 
109  size_t boundarySegmentIndex() const { return it().boundarySegmentIndex(); }
110 
115  LocalGeometry geometryInInside () const
116  {
117  return it().geometryInInside();
118  }
119 
124  Geometry geometry () const
125  {
126  return it().geometry();
127  }
128 
131  {
132  return it().type();
133  }
134 
137  int indexInInside () const
138  {
139  return it().indexInInside();
140  }
141 
145  LocalGeometry geometryInOutside () const
146  {
147  return it().geometryInOutside();
148  }
149 
152  int indexInOutside () const
153  {
154  return it().indexInOutside();
155  }
156 
158  int twistInInside() const { return it().twistInInside(); }
159 
161  int twistInOutside() const { return it().twistInOutside(); }
162 
165  const NormalType unitOuterNormal ( const FieldVector< ctype, dim-1 > &local ) const
166  {
167  return it().unitOuterNormal( local );
168  }
169 
172  const NormalType centerUnitOuterNormal ( ) const
173  {
174  GeometryType type = geometry().type();
175  const ReferenceElement<ctype, dim-1> & refElement =
176  ReferenceElements<ctype, dim-1>::general(type);
177  return unitOuterNormal(refElement.position(0,0));
178  }
179 
182  const NormalType outerNormal ( const FieldVector< ctype, dim-1 > &local ) const
183  {
184  return it().outerNormal( local );
185  }
186 
189  const NormalType integrationOuterNormal ( const FieldVector< ctype, dim-1 > &local ) const
190  {
191  return it().integrationOuterNormal( local );
192  }
193 
195  int level () const { return it().level(); }
196 
198  bool conforming () const { return it().conforming(); }
199 
201  IntersectionIteratorImp & it() { return it_; }
202  const IntersectionIteratorImp & it() const { return it_; }
203 
204  private:
205  const FactoryType& factory_ ;
206  IntersectionIteratorImp & it_;
207  }; // end class IntersectionIteratorWrapper
208 
209  template <class GridImp>
211  : public IntersectionIteratorWrapper<GridImp,typename GridImp::LeafIntersectionIteratorImp>
212  {
215  public:
217  template <class EntityImp>
218  LeafIntersectionWrapper(const EntityImp & en, int wLevel , bool end )
219  : BaseType(en,wLevel,end)
220  {}
221 
223  LeafIntersectionWrapper(const ThisType & org)
224  : BaseType(org)
225  {}
226 
227  };
228 
231  template <class GridImp>
233  {
236 
237  public:
239 
241  enum { dimension = GridImp :: dimension };
243  enum { dimensionworld = GridImp :: dimensionworld };
244 
246  typedef typename GridImp :: ctype ctype;
247 
249  typedef typename GridImp::template Codim<0>::Entity Entity;
251  typedef typename GridImp::template Codim<0>::EntityPointer EntityPointer;
252 
254  typedef typename GridImp::template Codim<1>::Geometry Geometry;
256  typedef typename GridImp::template Codim<1>::LocalGeometry LocalGeometry;
257 
259  typedef FieldVector<ctype , dimensionworld> NormalType;
260 
262  template <class EntityImp>
263  LeafIntersectionIteratorWrapper(const EntityImp & en, int wLevel , bool end )
264  : intersection_( IntersectionImp(en,wLevel,end) )
265  {}
266 
268  LeafIntersectionIteratorWrapper(const ThisType & org)
269  : intersection_( IntersectionImp( org.impl() ) )
270  {}
271 
273  ThisType & operator = (const ThisType & org)
274  {
275  impl() = org.impl();
276  return *this;
277  }
278 
280  const Intersection &dereference () const
281  {
282  return intersection_;
283  }
284 
286  bool equals (const ThisType & i) const { return impl().equals( i.impl() ); }
287 
289  void increment()
290  {
291  impl().increment();
292  }
293  protected:
294  // intersection object
295  Intersection intersection_;
296 
297  // return reference to real implementation
298  IntersectionImp& impl() { return GridImp :: getRealImplementation( intersection_ ); }
299  // return reference to real implementation
300  const IntersectionImp& impl() const { return GridImp :: getRealImplementation( intersection_ ); }
301  }; // end class IntersectionIteratorWrapper
302 
305  template <class GridImp>
307  : public IntersectionIteratorWrapper<GridImp,typename GridImp::LevelIntersectionIteratorImp>
308  {
311  public:
313  template <class EntityImp>
314  LevelIntersectionWrapper(const EntityImp & en, int wLevel , bool end )
315  : BaseType(en,wLevel,end)
316  {}
317 
319  LevelIntersectionWrapper(const ThisType & org)
320  : BaseType(org)
321  {}
322  };
323 
326  template <class GridImp>
328  {
331  public:
333 
335  enum { dimension = GridImp :: dimension };
337  enum { dimensionworld = GridImp :: dimensionworld };
338 
340  typedef typename GridImp :: ctype ctype;
341 
343  typedef typename GridImp::template Codim<0>::Entity Entity;
345  typedef typename GridImp::template Codim<0>::EntityPointer EntityPointer;
346 
348  typedef typename GridImp::template Codim<1>::Geometry Geometry;
350  typedef typename GridImp::template Codim<1>::LocalGeometry LocalGeometry;
351 
353  typedef FieldVector<ctype , dimensionworld> NormalType;
354 
356  template <class EntityImp>
357  LevelIntersectionIteratorWrapper(const EntityImp & en, int wLevel , bool end )
358  : intersection_( IntersectionImp(en,wLevel,end) )
359  {}
360 
362  LevelIntersectionIteratorWrapper(const ThisType & org)
363  : intersection_( IntersectionImp( org.impl() ) )
364  {}
365 
367  ThisType & operator = (const ThisType & org)
368  {
369  impl() = org.impl();
370  return *this;
371  }
372 
374  const Intersection &dereference () const
375  {
376  return intersection_;
377  }
378 
380  bool equals (const ThisType & i) const { return impl().equals( i.impl() ); }
381 
383  void increment()
384  {
385  impl().increment();
386  }
387  protected:
388  // intersection object
389  Intersection intersection_;
390 
391  // return reference to real implementation
392  IntersectionImp& impl() { return GridImp :: getRealImplementation( intersection_ ); }
393  // return reference to real implementation
394  const IntersectionImp& impl() const { return GridImp :: getRealImplementation( intersection_ ); }
395  }; // end class IntersectionIteratorWrapper
396 
397 } // end namespace Dune
398 #endif
IntersectionIteratorImp & it()
returns reference to underlying intersection iterator implementation
Definition: intersectioniteratorwrapper.hh:201
const NormalType unitOuterNormal(const FieldVector< ctype, dim-1 > &local) const
Definition: intersectioniteratorwrapper.hh:165
Definition: intersectioniteratorwrapper.hh:33
const NormalType integrationOuterNormal(const FieldVector< ctype, dim-1 > &local) const
Definition: intersectioniteratorwrapper.hh:189
int indexInInside() const
Definition: intersectioniteratorwrapper.hh:137
GridImp::template Codim< 1 >::LocalGeometry LocalGeometry
type of intersection*Local
Definition: intersectioniteratorwrapper.hh:48
Class that wraps IntersectionIteratorImp of a grid and gets it&#39;s internal object from a object stack ...
Definition: intersectioniteratorwrapper.hh:306
void increment()
increment iterator
Definition: intersectioniteratorwrapper.hh:383
Intersection of a mesh entities of codimension 0 ("elements") with a "neighboring" element or with th...
Definition: albertagrid/dgfparser.hh:26
LevelIntersectionWrapper(const ThisType &org)
The copy constructor.
Definition: intersectioniteratorwrapper.hh:319
LevelIntersectionIteratorWrapper(const EntityImp &en, int wLevel, bool end)
constructor called from the ibegin and iend method
Definition: intersectioniteratorwrapper.hh:357
LevelIntersectionWrapper(const EntityImp &en, int wLevel, bool end)
constructor called from the ibegin and iend method
Definition: intersectioniteratorwrapper.hh:314
Definition: intersectioniteratorwrapper.hh:35
bool boundary() const
Definition: intersectioniteratorwrapper.hh:100
Definition: intersectioniteratorwrapper.hh:210
Intersection intersection_
Definition: intersectioniteratorwrapper.hh:295
IntersectionIteratorWrapper(const ThisType &org)
The copy constructor.
Definition: intersectioniteratorwrapper.hh:66
const NormalType outerNormal(const FieldVector< ctype, dim-1 > &local) const
Definition: intersectioniteratorwrapper.hh:182
const IntersectionIteratorImp & it() const
Definition: intersectioniteratorwrapper.hh:202
Dune::Intersection< GridImp, IntersectionImp > Intersection
Definition: intersectioniteratorwrapper.hh:238
LeafIntersectionWrapper(const ThisType &org)
The copy constructor.
Definition: intersectioniteratorwrapper.hh:223
GeometryType
Type representing VTK&#39;s entity geometry types.
Definition: common.hh:178
GridImp::template Codim< 1 >::Geometry Geometry
type of intersectionGlobal
Definition: intersectioniteratorwrapper.hh:348
const Intersection & dereference() const
return reference to intersection
Definition: intersectioniteratorwrapper.hh:374
LocalGeometry geometryInInside() const
Definition: intersectioniteratorwrapper.hh:115
LeafIntersectionIteratorWrapper(const EntityImp &en, int wLevel, bool end)
constructor called from the ibegin and iend method
Definition: intersectioniteratorwrapper.hh:263
EntityPointer inside() const
access entity where iteration started
Definition: intersectioniteratorwrapper.hh:96
IntersectionImp & impl()
Definition: intersectioniteratorwrapper.hh:392
Intersection intersection_
Definition: intersectioniteratorwrapper.hh:389
const IntersectionImp & impl() const
Definition: intersectioniteratorwrapper.hh:300
const Intersection & dereference() const
return reference to intersection
Definition: intersectioniteratorwrapper.hh:280
~IntersectionIteratorWrapper()
The Destructor puts internal object back to stack.
Definition: intersectioniteratorwrapper.hh:81
GeometryType type() const
obtain the type of reference element for this intersection
Definition: intersectioniteratorwrapper.hh:130
FieldVector< ctype, dimensionworld > NormalType
type of normal vector
Definition: intersectioniteratorwrapper.hh:259
GridImp::template Codim< 0 >::Entity Entity
Entity type.
Definition: intersectioniteratorwrapper.hh:41
int level() const
return level of iterator
Definition: intersectioniteratorwrapper.hh:195
GridImp::template Codim< 1 >::Geometry Geometry
type of intersectionGlobal
Definition: intersectioniteratorwrapper.hh:46
GridImp::GridObjectFactoryType FactoryType
Definition: intersectioniteratorwrapper.hh:30
Class that wraps IntersectionIteratorImp of a grid and gets it&#39;s internal object from a object stack ...
Definition: intersectioniteratorwrapper.hh:327
GridImp::ctype ctype
define type used for coordinates in grid module
Definition: intersectioniteratorwrapper.hh:246
LeafIntersectionIteratorWrapper(const ThisType &org)
The copy constructor.
Definition: intersectioniteratorwrapper.hh:268
FieldVector< ctype, dimworld > NormalType
type of normal vector
Definition: intersectioniteratorwrapper.hh:51
GridImp::template Codim< 0 >::Entity Entity
Entity type.
Definition: intersectioniteratorwrapper.hh:343
GridImp::template Codim< 0 >::EntityPointer EntityPointer
type of EntityPointer
Definition: intersectioniteratorwrapper.hh:345
int twistInInside() const
twist of the face seen from the inner element
Definition: intersectioniteratorwrapper.hh:158
Class that wraps IntersectionIteratorImp of a grid and gets it&#39;s internal object from a object stack ...
Definition: intersectioniteratorwrapper.hh:18
LocalGeometry geometryInOutside() const
Definition: intersectioniteratorwrapper.hh:145
GridImp::template Codim< 0 >::EntityPointer EntityPointer
type of EntityPointer
Definition: intersectioniteratorwrapper.hh:251
GridImp::template Codim< 1 >::LocalGeometry LocalGeometry
type of intersection*Local
Definition: intersectioniteratorwrapper.hh:256
GridImp::template Codim< 1 >::LocalGeometry LocalGeometry
type of intersection*Local
Definition: intersectioniteratorwrapper.hh:350
Geometry geometry() const
Definition: intersectioniteratorwrapper.hh:124
GridImp::template Codim< 0 >::EntityPointer EntityPointer
type of EntityPointer
Definition: intersectioniteratorwrapper.hh:43
IntersectionImp & impl()
Definition: intersectioniteratorwrapper.hh:298
LevelIntersectionIteratorWrapper(const ThisType &org)
The copy constructor.
Definition: intersectioniteratorwrapper.hh:362
IntersectionIteratorWrapper(const EntityImp &en, int wLevel, bool end)
constructor called from the ibegin and iend method
Definition: intersectioniteratorwrapper.hh:55
bool equals(const ThisType &i) const
the equality method
Definition: intersectioniteratorwrapper.hh:286
int indexInOutside() const
Definition: intersectioniteratorwrapper.hh:152
Include standard header files.
Definition: agrid.hh:59
void increment()
increment iterator
Definition: intersectioniteratorwrapper.hh:289
bool equals(const ThisType &i) const
the equality method
Definition: intersectioniteratorwrapper.hh:87
Dune::Intersection< GridImp, IntersectionImp > Intersection
Definition: intersectioniteratorwrapper.hh:332
bool equals(const ThisType &i) const
the equality method
Definition: intersectioniteratorwrapper.hh:380
FieldVector< ctype, dimensionworld > NormalType
type of normal vector
Definition: intersectioniteratorwrapper.hh:353
EntityPointer outside() const
access neighbor
Definition: intersectioniteratorwrapper.hh:93
const IntersectionImp & impl() const
Definition: intersectioniteratorwrapper.hh:394
ThisType & operator=(const ThisType &org)
the f*cking assignment operator
Definition: intersectioniteratorwrapper.hh:74
GridImp::template Codim< 1 >::Geometry Geometry
type of intersectionGlobal
Definition: intersectioniteratorwrapper.hh:254
int twistInOutside() const
twist of the face seen from the outer element
Definition: intersectioniteratorwrapper.hh:161
void increment()
increment iterator
Definition: intersectioniteratorwrapper.hh:90
bool neighbor() const
return true if across the intersection a neighbor on this level exists
Definition: intersectioniteratorwrapper.hh:103
LeafIntersectionWrapper(const EntityImp &en, int wLevel, bool end)
constructor called from the ibegin and iend method
Definition: intersectioniteratorwrapper.hh:218
int boundaryId() const
return information about the Boundary
Definition: intersectioniteratorwrapper.hh:106
GridImp::template Codim< 0 >::Entity Entity
Entity type.
Definition: intersectioniteratorwrapper.hh:249
GridImp::ctype ctype
define type used for coordinates in grid module
Definition: intersectioniteratorwrapper.hh:340
Class that wraps IntersectionIteratorImp of a grid and gets it&#39;s internal object from a object stack ...
Definition: intersectioniteratorwrapper.hh:232
GridImp::ctype ctype
define type used for coordinates in grid module
Definition: intersectioniteratorwrapper.hh:38
const NormalType centerUnitOuterNormal() const
Definition: intersectioniteratorwrapper.hh:172
size_t boundarySegmentIndex() const
return the boundary segment index
Definition: intersectioniteratorwrapper.hh:109
bool conforming() const
return true if intersection is conform (i.e. only one neighbor)
Definition: intersectioniteratorwrapper.hh:198