dune-alugrid 3.0.0
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, 3, 0 )
6#include <dune/common/nullptr.hh>
7#endif //#if !DUNE_VERSION_NEWER( DUNE_GRID, 3, 0 )
8
9#include <dune/grid/common/intersectioniterator.hh>
11
14
20namespace Dune {
21
24template <class GridImp, class IntersectionIteratorImpl>
26{
27 enum { dim = GridImp :: dimension };
28 enum { dimworld = GridImp :: dimensionworld };
29
31
32 typedef IntersectionIteratorImpl IntersectionIteratorImp;
33
34 typedef ALU3DSPACE ALUMemoryProvider< IntersectionIteratorImpl > IntersectionIteratorProviderType ;
35public:
37 enum { dimension = dim };
39 enum { dimensionworld = dimworld };
40
42 typedef typename GridImp :: ctype ctype;
43
45 typedef typename GridImp::template Codim<0>::Entity Entity;
46#if !DUNE_VERSION_NEWER(DUNE_GRID,3,0)
48 typedef typename GridImp::template Codim<0>::EntityPointer EntityPointer;
49#endif // #if !DUNE_VERSION_NEWER(DUNE_GRID,3,0)
50
52 typedef typename GridImp::template Codim<1>::Geometry Geometry;
54 typedef typename GridImp::template Codim<1>::LocalGeometry LocalGeometry;
55
57 typedef FieldVector<ctype , dimworld> NormalType;
58
59 typedef typename IntersectionIteratorImpl::Twists Twists;
60 typedef typename Twists::Twist Twist;
61
63
65 template <class EntityImp>
66 IntersectionIteratorWrapper(const GridImp& grid, const EntityImp & en, int wLevel , bool end)
67 : itPtr_()
68 {
69 if(end)
70 it().done( en );
71 else
72 it().first( en, wLevel, grid.conformingRefinement(), grid.ghostCellsEnabled() );
73 }
74
75 operator bool () const { return bool( itPtr_ ); }
76
78 bool equals ( const ThisType &other ) const
79 {
80 return (itPtr_ && other.itPtr_ ) ? it().equals( other.it() ) : itPtr_ == other.itPtr_;
81 }
82
84 void increment ()
85 {
86 // if the shared pointer is unique we can increment
87 if( itPtr_.unique() )
88 {
89 it().increment();
90 }
91 else
92 {
93 // otherwise make a copy and assign the same intersection
94 // and then increment
95 ALU3DSPACE SharedPointer< IntersectionIteratorImp > copy( itPtr_ );
96 itPtr_.invalidate();
97 it().assign( *copy );
98 it().increment();
99 }
100 }
101
103 Entity outside() const { return it().outside(); }
104
106 Entity inside() const { return it().inside(); }
107
110 bool boundary () const { return it().boundary(); }
111
113 bool neighbor () const { return it().neighbor(); }
114
116 int boundaryId () const { return it().boundaryId(); }
117
119 size_t boundarySegmentIndex() const { return it().boundarySegmentIndex(); }
120
126 {
127 return it().geometryInInside();
128 }
129
135 {
136 return it().geometry();
137 }
138
140 GeometryType type () const
141 {
142 return it().type();
143 }
144
147 int indexInInside () const
148 {
149 return it().indexInInside();
150 }
151
156 {
157 return it().geometryInOutside();
158 }
159
162 int indexInOutside () const
163 {
164 return it().indexInOutside();
165 }
166
168 Twist twistInInside() const { return it().twistInInside(); }
169
171 Twist twistInOutside() const { return it().twistInOutside(); }
172
175 const NormalType unitOuterNormal ( const FieldVector< ctype, dim-1 > &local ) const
176 {
177 return it().unitOuterNormal( local );
178 }
179
183 {
184 const ReferenceElement<ctype, dim-1> & refElement =
185 ReferenceElements<ctype, dim-1>::general( type() );
186 return unitOuterNormal(refElement.position(0,0));
187 }
188
191 const NormalType outerNormal ( const FieldVector< ctype, dim-1 > &local ) const
192 {
193 return it().outerNormal( local );
194 }
195
198 const NormalType integrationOuterNormal ( const FieldVector< ctype, dim-1 > &local ) const
199 {
200 return it().integrationOuterNormal( local );
201 }
202
204 int level () const { return it().level(); }
205
207 bool conforming () const { return it().conforming(); }
208
210 IntersectionIteratorImp & it() { return *itPtr_; }
211 const IntersectionIteratorImp & it() const { return *itPtr_; }
212
214 int weight() const
215 {
216 return it().weight();
217 }
218
219private:
220 mutable ALU3DSPACE SharedPointer< IntersectionIteratorImp > itPtr_;
221}; // end class IntersectionIteratorWrapper
222
223template <class GridImp>
225: public IntersectionIteratorWrapper<GridImp,typename GridImp::LeafIntersectionIteratorImp>
226{
227 typedef LeafIntersectionWrapper<GridImp> ThisType;
229public:
231
233 template <class EntityImp>
234 LeafIntersectionWrapper(const GridImp& grid, const EntityImp & en, int wLevel , bool end )
235 : BaseType( grid, en, wLevel, end )
236 {
237 }
238
240 LeafIntersectionWrapper(const ThisType & org)
241 : BaseType(org)
242 {
243 }
244
245};
246
249template <class GridImp>
251{
253 typedef LeafIntersectionWrapper<GridImp> IntersectionImp;
254
255public:
256 typedef Dune::Intersection< GridImp, IntersectionImp > Intersection;
257
259 enum { dimension = GridImp :: dimension };
261 enum { dimensionworld = GridImp :: dimensionworld };
262
264 typedef typename GridImp :: ctype ctype;
265
267 typedef typename GridImp::template Codim<0>::Entity Entity;
268#if !DUNE_VERSION_NEWER(DUNE_GRID,3,0)
270 typedef typename GridImp::template Codim<0>::EntityPointer EntityPointer;
271#endif // #if !DUNE_VERSION_NEWER(DUNE_GRID,3,0)
272
274 typedef typename GridImp::template Codim<1>::Geometry Geometry;
276 typedef typename GridImp::template Codim<1>::LocalGeometry LocalGeometry;
277
279 typedef FieldVector<ctype , dimensionworld> NormalType;
280
283
285 template <class EntityImp>
286 LeafIntersectionIteratorWrapper(const GridImp& grid, const EntityImp & en, int wLevel , bool end )
287 : intersection_( IntersectionImp( grid, en, wLevel, end) )
288 {}
289
292 : intersection_( IntersectionImp( org.impl() ) )
293 {}
294
296 ThisType & operator = (const ThisType & org)
297 {
298 impl() = org.impl();
299 return *this;
300 }
301
303 const Intersection &dereference () const
304 {
305 return intersection_;
306 }
307
309 bool equals (const ThisType & i) const { return impl().equals( i.impl() ); }
310
313 {
314 impl().increment();
315 }
316protected:
317 // intersection object
319
320 // return reference to real implementation
321 IntersectionImp& impl() { return GridImp :: getRealImplementation( intersection_ ); }
322 // return reference to real implementation
323 const IntersectionImp& impl() const { return GridImp :: getRealImplementation( intersection_ ); }
324}; // end class IntersectionIteratorWrapper
325
328template <class GridImp>
330: public IntersectionIteratorWrapper<GridImp,typename GridImp::LevelIntersectionIteratorImp>
331{
332 typedef LevelIntersectionWrapper<GridImp> ThisType;
334public:
336
338 template <class EntityImp>
339 LevelIntersectionWrapper(const GridImp& grid, const EntityImp & en, int wLevel , bool end )
340 : BaseType( grid, en, wLevel, end )
341 {
342 }
343
345 LevelIntersectionWrapper(const ThisType & org)
346 : BaseType(org)
347 {
348 }
349};
350
353template <class GridImp>
355{
357 typedef LevelIntersectionWrapper<GridImp> IntersectionImp;
358public:
359 typedef Dune::Intersection< GridImp, IntersectionImp > Intersection;
360
362 enum { dimension = GridImp :: dimension };
364 enum { dimensionworld = GridImp :: dimensionworld };
365
367 typedef typename GridImp :: ctype ctype;
368
370 typedef typename GridImp::template Codim<0>::Entity Entity;
371#if !DUNE_VERSION_NEWER(DUNE_GRID,3,0)
373 typedef typename GridImp::template Codim<0>::EntityPointer EntityPointer;
374#endif // #if !DUNE_VERSION_NEWER(DUNE_GRID,3,0)
375
377 typedef typename GridImp::template Codim<1>::Geometry Geometry;
379 typedef typename GridImp::template Codim<1>::LocalGeometry LocalGeometry;
380
382 typedef FieldVector<ctype , dimensionworld> NormalType;
383
385
387 template <class EntityImp>
388 LevelIntersectionIteratorWrapper(const GridImp& grid, const EntityImp & en, int wLevel , bool end )
389 : intersection_( IntersectionImp( grid, en, wLevel, end ) )
390 {}
391
394 : intersection_( IntersectionImp( org.impl() ) )
395 {}
396
398 ThisType & operator = (const ThisType & org)
399 {
400 impl() = org.impl();
401 return *this;
402 }
403
405 const Intersection &dereference () const
406 {
407 return intersection_;
408 }
409
411 bool equals (const ThisType & i) const { return impl().equals( i.impl() ); }
412
415 {
416 impl().increment();
417 }
418
419 // template <class,PartitionIteratorType> friend class MacroGridView; // specialize
420protected:
421 // intersection object
423
424 // return reference to real implementation
425 IntersectionImp& impl() { return GridImp :: getRealImplementation( intersection_ ); }
426 // return reference to real implementation
427 const IntersectionImp& impl() const { return GridImp :: getRealImplementation( intersection_ ); }
428}; // end class IntersectionIteratorWrapper
429
430} // end namespace Dune
431#endif
#define ALU3DSPACE
Definition alu3dinclude.hh:24
Definition alu3dinclude.hh:80
Definition 3d/grid.hh:82
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:182
Geometry geometry() const
Definition intersectioniteratorwrapper.hh:134
const NormalType outerNormal(const FieldVector< ctype, dim-1 > &local) const
Definition intersectioniteratorwrapper.hh:191
size_t boundarySegmentIndex() const
return the boundary segment index
Definition intersectioniteratorwrapper.hh:119
int weight() const
return weight associated with graph edge between the neighboring elements
Definition intersectioniteratorwrapper.hh:214
bool boundary() const
Definition intersectioniteratorwrapper.hh:110
Entity inside() const
access entity where iteration started
Definition intersectioniteratorwrapper.hh:106
IntersectionIteratorImpl::Twists Twists
Definition intersectioniteratorwrapper.hh:59
void increment()
increment iterator
Definition intersectioniteratorwrapper.hh:84
IntersectionIteratorImp & it()
returns reference to underlying intersection iterator implementation
Definition intersectioniteratorwrapper.hh:210
IntersectionIteratorWrapper()
Definition intersectioniteratorwrapper.hh:62
bool conforming() const
return true if intersection is conform (i.e. only one neighbor)
Definition intersectioniteratorwrapper.hh:207
Entity outside() const
access neighbor
Definition intersectioniteratorwrapper.hh:103
int boundaryId() const
return information about the Boundary
Definition intersectioniteratorwrapper.hh:116
GridImp::template Codim< 0 >::Entity Entity
Entity type.
Definition intersectioniteratorwrapper.hh:45
GridImp::ctype ctype
define type used for coordinates in grid module
Definition intersectioniteratorwrapper.hh:42
Twists::Twist Twist
Definition intersectioniteratorwrapper.hh:60
GeometryType type() const
obtain the type of reference element for this intersection
Definition intersectioniteratorwrapper.hh:140
GridImp::template Codim< 1 >::LocalGeometry LocalGeometry
type of intersection*Local
Definition intersectioniteratorwrapper.hh:54
const IntersectionIteratorImp & it() const
Definition intersectioniteratorwrapper.hh:211
const NormalType integrationOuterNormal(const FieldVector< ctype, dim-1 > &local) const
Definition intersectioniteratorwrapper.hh:198
IntersectionIteratorWrapper(const GridImp &grid, const EntityImp &en, int wLevel, bool end)
constructor called from the ibegin and iend method
Definition intersectioniteratorwrapper.hh:66
LocalGeometry geometryInInside() const
Definition intersectioniteratorwrapper.hh:125
int level() const
return level of iterator
Definition intersectioniteratorwrapper.hh:204
FieldVector< ctype, dimworld > NormalType
type of normal vector
Definition intersectioniteratorwrapper.hh:57
LocalGeometry geometryInOutside() const
Definition intersectioniteratorwrapper.hh:155
GridImp::template Codim< 1 >::Geometry Geometry
type of intersectionGlobal
Definition intersectioniteratorwrapper.hh:52
Twist twistInOutside() const
twist of the face seen from the outer element
Definition intersectioniteratorwrapper.hh:171
@ dimension
Definition intersectioniteratorwrapper.hh:37
Twist twistInInside() const
twist of the face seen from the inner element
Definition intersectioniteratorwrapper.hh:168
int indexInInside() const
Definition intersectioniteratorwrapper.hh:147
int indexInOutside() const
Definition intersectioniteratorwrapper.hh:162
bool neighbor() const
return true if across the intersection a neighbor on this level exists
Definition intersectioniteratorwrapper.hh:113
const NormalType unitOuterNormal(const FieldVector< ctype, dim-1 > &local) const
Definition intersectioniteratorwrapper.hh:175
@ dimensionworld
Definition intersectioniteratorwrapper.hh:39
bool equals(const ThisType &other) const
the equality method
Definition intersectioniteratorwrapper.hh:78
GridImp::template Codim< 0 >::EntityPointer EntityPointer
type of EntityPointer
Definition intersectioniteratorwrapper.hh:48
Definition intersectioniteratorwrapper.hh:226
LeafIntersectionWrapper(const ThisType &org)
The copy constructor.
Definition intersectioniteratorwrapper.hh:240
LeafIntersectionWrapper(const GridImp &grid, const EntityImp &en, int wLevel, bool end)
constructor called from the ibegin and iend method
Definition intersectioniteratorwrapper.hh:234
LeafIntersectionWrapper()
Definition intersectioniteratorwrapper.hh:230
Class that wraps IntersectionIteratorImp of a grid and gets it's internal object from a object stack ...
Definition intersectioniteratorwrapper.hh:251
bool equals(const ThisType &i) const
the equality method
Definition intersectioniteratorwrapper.hh:309
GridImp::template Codim< 1 >::LocalGeometry LocalGeometry
type of intersection*Local
Definition intersectioniteratorwrapper.hh:276
@ dimension
Definition intersectioniteratorwrapper.hh:259
GridImp::template Codim< 0 >::Entity Entity
Entity type.
Definition intersectioniteratorwrapper.hh:267
Intersection intersection_
Definition intersectioniteratorwrapper.hh:318
const Intersection & dereference() const
return reference to intersection
Definition intersectioniteratorwrapper.hh:303
@ dimensionworld
Definition intersectioniteratorwrapper.hh:261
LeafIntersectionIteratorWrapper(const ThisType &org)
The copy constructor.
Definition intersectioniteratorwrapper.hh:291
GridImp::template Codim< 0 >::EntityPointer EntityPointer
type of EntityPointer
Definition intersectioniteratorwrapper.hh:270
GridImp::ctype ctype
define type used for coordinates in grid module
Definition intersectioniteratorwrapper.hh:264
const IntersectionImp & impl() const
Definition intersectioniteratorwrapper.hh:323
ThisType & operator=(const ThisType &org)
the f*cking assignment operator
Definition intersectioniteratorwrapper.hh:296
Dune::Intersection< GridImp, IntersectionImp > Intersection
Definition intersectioniteratorwrapper.hh:256
LeafIntersectionIteratorWrapper(const GridImp &grid, const EntityImp &en, int wLevel, bool end)
constructor called from the ibegin and iend method
Definition intersectioniteratorwrapper.hh:286
void increment()
increment iterator
Definition intersectioniteratorwrapper.hh:312
GridImp::template Codim< 1 >::Geometry Geometry
type of intersectionGlobal
Definition intersectioniteratorwrapper.hh:274
IntersectionImp & impl()
Definition intersectioniteratorwrapper.hh:321
LeafIntersectionIteratorWrapper()
default constructor
Definition intersectioniteratorwrapper.hh:282
FieldVector< ctype, dimensionworld > NormalType
type of normal vector
Definition intersectioniteratorwrapper.hh:279
Class that wraps IntersectionIteratorImp of a grid and gets it's internal object from a object stack ...
Definition intersectioniteratorwrapper.hh:331
LevelIntersectionWrapper()
Definition intersectioniteratorwrapper.hh:335
LevelIntersectionWrapper(const ThisType &org)
The copy constructor.
Definition intersectioniteratorwrapper.hh:345
LevelIntersectionWrapper(const GridImp &grid, const EntityImp &en, int wLevel, bool end)
constructor called from the ibegin and iend method
Definition intersectioniteratorwrapper.hh:339
Class that wraps IntersectionIteratorImp of a grid and gets it's internal object from a object stack ...
Definition intersectioniteratorwrapper.hh:355
GridImp::ctype ctype
define type used for coordinates in grid module
Definition intersectioniteratorwrapper.hh:367
const IntersectionImp & impl() const
Definition intersectioniteratorwrapper.hh:427
@ dimensionworld
Definition intersectioniteratorwrapper.hh:364
Intersection intersection_
Definition intersectioniteratorwrapper.hh:422
GridImp::template Codim< 0 >::Entity Entity
Entity type.
Definition intersectioniteratorwrapper.hh:370
LevelIntersectionIteratorWrapper()
Definition intersectioniteratorwrapper.hh:384
bool equals(const ThisType &i) const
the equality method
Definition intersectioniteratorwrapper.hh:411
@ dimension
Definition intersectioniteratorwrapper.hh:362
IntersectionImp & impl()
Definition intersectioniteratorwrapper.hh:425
GridImp::template Codim< 1 >::Geometry Geometry
type of intersectionGlobal
Definition intersectioniteratorwrapper.hh:377
FieldVector< ctype, dimensionworld > NormalType
type of normal vector
Definition intersectioniteratorwrapper.hh:382
GridImp::template Codim< 1 >::LocalGeometry LocalGeometry
type of intersection*Local
Definition intersectioniteratorwrapper.hh:379
void increment()
increment iterator
Definition intersectioniteratorwrapper.hh:414
ThisType & operator=(const ThisType &org)
the f*cking assignment operator
Definition intersectioniteratorwrapper.hh:398
LevelIntersectionIteratorWrapper(const ThisType &org)
The copy constructor.
Definition intersectioniteratorwrapper.hh:393
GridImp::template Codim< 0 >::EntityPointer EntityPointer
type of EntityPointer
Definition intersectioniteratorwrapper.hh:373
LevelIntersectionIteratorWrapper(const GridImp &grid, const EntityImp &en, int wLevel, bool end)
constructor called from the ibegin and iend method
Definition intersectioniteratorwrapper.hh:388
Dune::Intersection< GridImp, IntersectionImp > Intersection
Definition intersectioniteratorwrapper.hh:359
const Intersection & dereference() const
return reference to intersection
Definition intersectioniteratorwrapper.hh:405