dune-alugrid  2.6-git
intersectioniteratorwrapper.hh
Go to the documentation of this file.
1 #ifndef DUNE_INTERSECTIONITERATORWRAPPER_HH
2 #define DUNE_INTERSECTIONITERATORWRAPPER_HH
3 
4 #include <dune/common/version.hh>
5 #if !DUNE_VERSION_NEWER( DUNE_GRID,2,5)
6 #include <dune/common/nullptr.hh>
7 #endif //#if !DUNE_VERSION_NEWER( DUNE_GRID,2,5)
8 
9 #include <dune/grid/common/intersectioniterator.hh>
11 
14 
20 namespace Dune {
21 
24 template <class GridImp, class IntersectionIteratorImpl>
26 {
27  enum { dim = GridImp :: dimension };
28  enum { dimworld = GridImp :: dimensionworld };
29 
31 
32  typedef IntersectionIteratorImpl IntersectionIteratorImp;
33 
34 public:
36  enum { dimension = dim };
38  enum { dimensionworld = dimworld };
39 
41  typedef typename GridImp :: ctype ctype;
42 
44  typedef typename GridImp::template Codim<0>::Entity Entity;
45 #if !DUNE_VERSION_NEWER(DUNE_GRID,2,5)
47  typedef typename GridImp::template Codim<0>::EntityPointer EntityPointer;
48 #endif // #if !DUNE_VERSION_NEWER(DUNE_GRID,2,5)
49 
51  typedef typename GridImp::template Codim<1>::Geometry Geometry;
53  typedef typename GridImp::template Codim<1>::LocalGeometry LocalGeometry;
54 
56  typedef FieldVector<ctype , dimworld> NormalType;
57 
58  typedef typename IntersectionIteratorImpl::Twists Twists;
59  typedef typename Twists::Twist Twist;
60 
62 
64  template <class EntityImp>
65  IntersectionIteratorWrapper(const GridImp& grid, const EntityImp & en, int wLevel , bool end)
66  : itPtr_()
67  {
68  if(end)
69  it().done( en );
70  else
71  it().first( en, wLevel, grid );
72  }
73 
74  operator bool () const { return bool( itPtr_ ); }
75 
77  bool equals ( const ThisType &other ) const
78  {
79  return (itPtr_ && other.itPtr_ ) ? it().equals( other.it() ) : itPtr_ == other.itPtr_;
80  }
81 
83  void increment ()
84  {
85  // if the shared pointer is unique we can increment
86  if( itPtr_.unique() )
87  {
88  it().increment();
89  }
90  else
91  {
92  // otherwise make a copy and assign the same intersection
93  // and then increment
94  ALU3DSPACE SharedPointer< IntersectionIteratorImp > copy( itPtr_ );
95  itPtr_.invalidate();
96  it().assign( *copy );
97  it().increment();
98  }
99  }
100 
102  Entity outside() const { return it().outside(); }
103 
105  Entity inside() const { return it().inside(); }
106 
109  bool boundary () const { return it().boundary(); }
110 
112  bool neighbor () const { return it().neighbor(); }
113 
115  int boundaryId () const { return it().boundaryId(); }
116 
118  size_t boundarySegmentIndex() const { return it().boundarySegmentIndex(); }
119 
121  int segmentId() const { return it().segmentId(); }
122 
128  {
129  return it().geometryInInside();
130  }
131 
137  {
138  return it().geometry();
139  }
140 
142  GeometryType type () const
143  {
144  return it().type();
145  }
146 
149  int indexInInside () const
150  {
151  return it().indexInInside();
152  }
153 
158  {
159  return it().geometryInOutside();
160  }
161 
164  int indexInOutside () const
165  {
166  return it().indexInOutside();
167  }
168 
170  Twist twistInInside() const { return it().twistInInside(); }
171 
173  Twist twistInOutside() const { return it().twistInOutside(); }
174 
177  const NormalType unitOuterNormal ( const FieldVector< ctype, dim-1 > &local ) const
178  {
179  return it().unitOuterNormal( local );
180  }
181 
185  {
186  const auto& refElement = GridImp::faceReferenceElement();
187  assert( refElement.type() == type() );
188  return unitOuterNormal(refElement.position(0,0));
189  }
190 
193  const NormalType outerNormal ( const FieldVector< ctype, dim-1 > &local ) const
194  {
195  return it().outerNormal( local );
196  }
197 
200  const NormalType integrationOuterNormal ( const FieldVector< ctype, dim-1 > &local ) const
201  {
202  return it().integrationOuterNormal( local );
203  }
204 
206  int level () const { return it().level(); }
207 
209  bool conforming () const { return it().conforming(); }
210 
212  IntersectionIteratorImp & it() { return *itPtr_; }
213  const IntersectionIteratorImp & it() const { return *itPtr_; }
214 
216  int weight() const
217  {
218  return it().weight();
219  }
220 
221 private:
222  mutable ALU3DSPACE SharedPointer< IntersectionIteratorImp > itPtr_;
223 }; // end class IntersectionIteratorWrapper
224 
225 template <class GridImp>
227 : public IntersectionIteratorWrapper<GridImp,typename GridImp::LeafIntersectionIteratorImp>
228 {
231 public:
233 
235  template <class EntityImp>
236  LeafIntersectionWrapper(const GridImp& grid, const EntityImp & en, int wLevel , bool end )
237  : BaseType( grid, en, wLevel, end )
238  {
239  }
240 
243  : BaseType(org)
244  {
245  }
246 
247 };
248 
251 template <class GridImp>
253 {
256 
257 public:
258  typedef Dune::Intersection< GridImp, IntersectionImp > Intersection;
259 
261  enum { dimension = GridImp :: dimension };
263  enum { dimensionworld = GridImp :: dimensionworld };
264 
266  typedef typename GridImp :: ctype ctype;
267 
269  typedef typename GridImp::template Codim<0>::Entity Entity;
270 #if !DUNE_VERSION_NEWER(DUNE_GRID,2,5)
272  typedef typename GridImp::template Codim<0>::EntityPointer EntityPointer;
273 #endif // #if !DUNE_VERSION_NEWER(DUNE_GRID,2,5)
274 
276  typedef typename GridImp::template Codim<1>::Geometry Geometry;
278  typedef typename GridImp::template Codim<1>::LocalGeometry LocalGeometry;
279 
281  typedef FieldVector<ctype , dimensionworld> NormalType;
282 
285 
287  template <class EntityImp>
288  LeafIntersectionIteratorWrapper(const GridImp& grid, const EntityImp & en, int wLevel , bool end )
289  : intersection_( IntersectionImp( grid, en, wLevel, end) )
290  {}
291 
294  : intersection_( IntersectionImp( org.impl() ) )
295  {}
296 
299  {
300  impl() = org.impl();
301  return *this;
302  }
303 
305  const Intersection &dereference () const
306  {
307  return intersection_;
308  }
309 
311  bool equals (const ThisType & i) const { return impl().equals( i.impl() ); }
312 
314  void increment()
315  {
316  impl().increment();
317  }
318 protected:
319  // intersection object
321 
322  // return reference to real implementation
323  IntersectionImp& impl() { return GridImp :: getRealImplementation( intersection_ ); }
324  // return reference to real implementation
325  const IntersectionImp& impl() const { return GridImp :: getRealImplementation( intersection_ ); }
326 }; // end class IntersectionIteratorWrapper
327 
330 template <class GridImp>
332 : public IntersectionIteratorWrapper<GridImp,typename GridImp::LevelIntersectionIteratorImp>
333 {
336 public:
338 
340  template <class EntityImp>
341  LevelIntersectionWrapper(const GridImp& grid, const EntityImp & en, int wLevel , bool end )
342  : BaseType( grid, en, wLevel, end )
343  {
344  }
345 
348  : BaseType(org)
349  {
350  }
351 };
352 
355 template <class GridImp>
357 {
360 public:
361  typedef Dune::Intersection< GridImp, IntersectionImp > Intersection;
362 
364  enum { dimension = GridImp :: dimension };
366  enum { dimensionworld = GridImp :: dimensionworld };
367 
369  typedef typename GridImp :: ctype ctype;
370 
372  typedef typename GridImp::template Codim<0>::Entity Entity;
373 #if !DUNE_VERSION_NEWER(DUNE_GRID,2,5)
375  typedef typename GridImp::template Codim<0>::EntityPointer EntityPointer;
376 #endif // #if !DUNE_VERSION_NEWER(DUNE_GRID,2,5)
377 
379  typedef typename GridImp::template Codim<1>::Geometry Geometry;
381  typedef typename GridImp::template Codim<1>::LocalGeometry LocalGeometry;
382 
384  typedef FieldVector<ctype , dimensionworld> NormalType;
385 
387 
389  template <class EntityImp>
390  LevelIntersectionIteratorWrapper(const GridImp& grid, const EntityImp & en, int wLevel , bool end )
391  : intersection_( IntersectionImp( grid, en, wLevel, end ) )
392  {}
393 
396  : intersection_( IntersectionImp( org.impl() ) )
397  {}
398 
401  {
402  impl() = org.impl();
403  return *this;
404  }
405 
407  const Intersection &dereference () const
408  {
409  return intersection_;
410  }
411 
413  bool equals (const ThisType & i) const { return impl().equals( i.impl() ); }
414 
416  void increment()
417  {
418  impl().increment();
419  }
420 
421  // template <class,PartitionIteratorType> friend class MacroGridView; // specialize
422 protected:
423  // intersection object
425 
426  // return reference to real implementation
427  IntersectionImp& impl() { return GridImp :: getRealImplementation( intersection_ ); }
428  // return reference to real implementation
429  const IntersectionImp& impl() const { return GridImp :: getRealImplementation( intersection_ ); }
430 }; // end class IntersectionIteratorWrapper
431 
432 } // end namespace Dune
433 #endif
#define ALU3DSPACE
Definition: alu3dinclude.hh:24
Definition: alu3dinclude.hh:80
Class that wraps IntersectionIteratorImp of a grid and gets it's internal object from a object stack ...
Definition: intersectioniteratorwrapper.hh:26
const NormalType centerUnitOuterNormal() const
Definition: intersectioniteratorwrapper.hh:184
Geometry geometry() const
Definition: intersectioniteratorwrapper.hh:136
const NormalType outerNormal(const FieldVector< ctype, dim-1 > &local) const
Definition: intersectioniteratorwrapper.hh:193
GridImp ::ctype ctype
define type used for coordinates in grid module
Definition: intersectioniteratorwrapper.hh:41
size_t boundarySegmentIndex() const
return the boundary segment index
Definition: intersectioniteratorwrapper.hh:118
int weight() const
return weight associated with graph edge between the neighboring elements
Definition: intersectioniteratorwrapper.hh:216
bool boundary() const
Definition: intersectioniteratorwrapper.hh:109
Entity inside() const
access entity where iteration started
Definition: intersectioniteratorwrapper.hh:105
IntersectionIteratorImpl::Twists Twists
Definition: intersectioniteratorwrapper.hh:58
int segmentId() const
return the segment index (non-consecutive)
Definition: intersectioniteratorwrapper.hh:121
const IntersectionIteratorImp & it() const
Definition: intersectioniteratorwrapper.hh:213
void increment()
increment iterator
Definition: intersectioniteratorwrapper.hh:83
@ dimensionworld
Definition: intersectioniteratorwrapper.hh:38
IntersectionIteratorWrapper()
Definition: intersectioniteratorwrapper.hh:61
bool conforming() const
return true if intersection is conform (i.e. only one neighbor)
Definition: intersectioniteratorwrapper.hh:209
Entity outside() const
access neighbor
Definition: intersectioniteratorwrapper.hh:102
int boundaryId() const
return information about the Boundary
Definition: intersectioniteratorwrapper.hh:115
GridImp::template Codim< 0 >::Entity Entity
Entity type.
Definition: intersectioniteratorwrapper.hh:44
Twists::Twist Twist
Definition: intersectioniteratorwrapper.hh:59
IntersectionIteratorImp & it()
returns reference to underlying intersection iterator implementation
Definition: intersectioniteratorwrapper.hh:212
GeometryType type() const
obtain the type of reference element for this intersection
Definition: intersectioniteratorwrapper.hh:142
GridImp::template Codim< 1 >::LocalGeometry LocalGeometry
type of intersection*Local
Definition: intersectioniteratorwrapper.hh:53
const NormalType integrationOuterNormal(const FieldVector< ctype, dim-1 > &local) const
Definition: intersectioniteratorwrapper.hh:200
IntersectionIteratorWrapper(const GridImp &grid, const EntityImp &en, int wLevel, bool end)
constructor called from the ibegin and iend method
Definition: intersectioniteratorwrapper.hh:65
LocalGeometry geometryInInside() const
Definition: intersectioniteratorwrapper.hh:127
int level() const
return level of iterator
Definition: intersectioniteratorwrapper.hh:206
@ dimension
Definition: intersectioniteratorwrapper.hh:36
FieldVector< ctype, dimworld > NormalType
type of normal vector
Definition: intersectioniteratorwrapper.hh:56
LocalGeometry geometryInOutside() const
Definition: intersectioniteratorwrapper.hh:157
GridImp::template Codim< 1 >::Geometry Geometry
type of intersectionGlobal
Definition: intersectioniteratorwrapper.hh:51
Twist twistInOutside() const
twist of the face seen from the outer element
Definition: intersectioniteratorwrapper.hh:173
Twist twistInInside() const
twist of the face seen from the inner element
Definition: intersectioniteratorwrapper.hh:170
int indexInInside() const
Definition: intersectioniteratorwrapper.hh:149
int indexInOutside() const
Definition: intersectioniteratorwrapper.hh:164
bool neighbor() const
return true if across the intersection a neighbor on this level exists
Definition: intersectioniteratorwrapper.hh:112
const NormalType unitOuterNormal(const FieldVector< ctype, dim-1 > &local) const
Definition: intersectioniteratorwrapper.hh:177
bool equals(const ThisType &other) const
the equality method
Definition: intersectioniteratorwrapper.hh:77
GridImp::template Codim< 0 >::EntityPointer EntityPointer
type of EntityPointer
Definition: intersectioniteratorwrapper.hh:47
Definition: intersectioniteratorwrapper.hh:228
LeafIntersectionWrapper(const ThisType &org)
The copy constructor.
Definition: intersectioniteratorwrapper.hh:242
LeafIntersectionWrapper(const GridImp &grid, const EntityImp &en, int wLevel, bool end)
constructor called from the ibegin and iend method
Definition: intersectioniteratorwrapper.hh:236
LeafIntersectionWrapper()
Definition: intersectioniteratorwrapper.hh:232
Class that wraps IntersectionIteratorImp of a grid and gets it's internal object from a object stack ...
Definition: intersectioniteratorwrapper.hh:253
bool equals(const ThisType &i) const
the equality method
Definition: intersectioniteratorwrapper.hh:311
GridImp::template Codim< 1 >::LocalGeometry LocalGeometry
type of intersection*Local
Definition: intersectioniteratorwrapper.hh:278
GridImp::template Codim< 0 >::Entity Entity
Entity type.
Definition: intersectioniteratorwrapper.hh:269
Intersection intersection_
Definition: intersectioniteratorwrapper.hh:320
const IntersectionImp & impl() const
Definition: intersectioniteratorwrapper.hh:325
LeafIntersectionIteratorWrapper(const ThisType &org)
The copy constructor.
Definition: intersectioniteratorwrapper.hh:293
GridImp::template Codim< 0 >::EntityPointer EntityPointer
type of EntityPointer
Definition: intersectioniteratorwrapper.hh:272
Dune::Intersection< GridImp, IntersectionImp > Intersection
Definition: intersectioniteratorwrapper.hh:258
GridImp ::ctype ctype
define type used for coordinates in grid module
Definition: intersectioniteratorwrapper.hh:266
@ dimension
Definition: intersectioniteratorwrapper.hh:261
LeafIntersectionIteratorWrapper(const GridImp &grid, const EntityImp &en, int wLevel, bool end)
constructor called from the ibegin and iend method
Definition: intersectioniteratorwrapper.hh:288
void increment()
increment iterator
Definition: intersectioniteratorwrapper.hh:314
GridImp::template Codim< 1 >::Geometry Geometry
type of intersectionGlobal
Definition: intersectioniteratorwrapper.hh:276
LeafIntersectionIteratorWrapper()
default constructor
Definition: intersectioniteratorwrapper.hh:284
IntersectionImp & impl()
Definition: intersectioniteratorwrapper.hh:323
@ dimensionworld
Definition: intersectioniteratorwrapper.hh:263
const Intersection & dereference() const
return reference to intersection
Definition: intersectioniteratorwrapper.hh:305
ThisType & operator=(const ThisType &org)
the f*cking assignment operator
Definition: intersectioniteratorwrapper.hh:298
FieldVector< ctype, dimensionworld > NormalType
type of normal vector
Definition: intersectioniteratorwrapper.hh:281
Class that wraps IntersectionIteratorImp of a grid and gets it's internal object from a object stack ...
Definition: intersectioniteratorwrapper.hh:333
LevelIntersectionWrapper()
Definition: intersectioniteratorwrapper.hh:337
LevelIntersectionWrapper(const ThisType &org)
The copy constructor.
Definition: intersectioniteratorwrapper.hh:347
LevelIntersectionWrapper(const GridImp &grid, const EntityImp &en, int wLevel, bool end)
constructor called from the ibegin and iend method
Definition: intersectioniteratorwrapper.hh:341
Class that wraps IntersectionIteratorImp of a grid and gets it's internal object from a object stack ...
Definition: intersectioniteratorwrapper.hh:357
@ dimension
Definition: intersectioniteratorwrapper.hh:364
IntersectionImp & impl()
Definition: intersectioniteratorwrapper.hh:427
Intersection intersection_
Definition: intersectioniteratorwrapper.hh:424
GridImp::template Codim< 0 >::Entity Entity
Entity type.
Definition: intersectioniteratorwrapper.hh:372
LevelIntersectionIteratorWrapper()
Definition: intersectioniteratorwrapper.hh:386
bool equals(const ThisType &i) const
the equality method
Definition: intersectioniteratorwrapper.hh:413
GridImp::template Codim< 1 >::Geometry Geometry
type of intersectionGlobal
Definition: intersectioniteratorwrapper.hh:379
FieldVector< ctype, dimensionworld > NormalType
type of normal vector
Definition: intersectioniteratorwrapper.hh:384
GridImp::template Codim< 1 >::LocalGeometry LocalGeometry
type of intersection*Local
Definition: intersectioniteratorwrapper.hh:381
const IntersectionImp & impl() const
Definition: intersectioniteratorwrapper.hh:429
void increment()
increment iterator
Definition: intersectioniteratorwrapper.hh:416
GridImp ::ctype ctype
define type used for coordinates in grid module
Definition: intersectioniteratorwrapper.hh:369
const Intersection & dereference() const
return reference to intersection
Definition: intersectioniteratorwrapper.hh:407
@ dimensionworld
Definition: intersectioniteratorwrapper.hh:366
LevelIntersectionIteratorWrapper(const ThisType &org)
The copy constructor.
Definition: intersectioniteratorwrapper.hh:395
GridImp::template Codim< 0 >::EntityPointer EntityPointer
type of EntityPointer
Definition: intersectioniteratorwrapper.hh:375
LevelIntersectionIteratorWrapper(const GridImp &grid, const EntityImp &en, int wLevel, bool end)
constructor called from the ibegin and iend method
Definition: intersectioniteratorwrapper.hh:390
Dune::Intersection< GridImp, IntersectionImp > Intersection
Definition: intersectioniteratorwrapper.hh:361
ThisType & operator=(const ThisType &org)
the f*cking assignment operator
Definition: intersectioniteratorwrapper.hh:400