Dune Core Modules (2.9.0)

intersectioniteratorwrapper.hh
Go to the documentation of this file.
1#ifndef DUNE_INTERSECTIONITERATORWRAPPER_HH
2#define DUNE_INTERSECTIONITERATORWRAPPER_HH
3
5
6#include <dune/grid/common/intersectioniterator.hh>
7#include <dune/alugrid/common/macrogridview.hh>
8
9#include <dune/alugrid/common/memory.hh>
10#include <dune/alugrid/3d/alu3dinclude.hh>
11
17namespace Dune {
18
21template <class GridImp, class IntersectionIteratorImpl>
23{
24 enum { dim = GridImp :: dimension };
25 enum { dimworld = GridImp :: dimensionworld };
26
28
29 typedef IntersectionIteratorImpl IntersectionIteratorImp;
30
31public:
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;
42
44 typedef typename GridImp::template Codim<1>::Geometry Geometry;
46 typedef typename GridImp::template Codim<1>::LocalGeometry LocalGeometry;
47
50
51 typedef typename IntersectionIteratorImpl::Twists Twists;
52 typedef typename Twists::Twist Twist;
53
54 IntersectionIteratorWrapper() : itPtr_() {}
55
57 template <class EntityImp>
58 IntersectionIteratorWrapper(const GridImp& grid, const EntityImp & en, int wLevel , bool end)
59 : itPtr_()
60 {
61 if(end)
62 it().done( en );
63 else
64 it().first( en, wLevel, grid );
65 }
66
67 operator bool () const { return bool( itPtr_ ); }
68
70 bool equals ( const ThisType &other ) const
71 {
72 return (itPtr_ && other.itPtr_ ) ? it().equals( other.it() ) : itPtr_ == other.itPtr_;
73 }
74
76 void increment ()
77 {
78 // if the shared pointer is unique we can increment
79 if( itPtr_.unique() )
80 {
81 it().increment();
82 }
83 else
84 {
85 // otherwise make a copy and assign the same intersection
86 // and then increment
87 ALU3DSPACE SharedPointer< IntersectionIteratorImp > copy( itPtr_ );
88 itPtr_.invalidate();
89 it().assign( *copy );
90 it().increment();
91 }
92 }
93
95 Entity outside() const { return it().outside(); }
96
98 Entity inside() const { return it().inside(); }
99
102 bool boundary () const { return it().boundary(); }
103
105 bool neighbor () const { return it().neighbor(); }
106
108 int boundaryId () const { return it().boundaryId(); }
109
111 size_t boundarySegmentIndex() const { return it().boundarySegmentIndex(); }
112
114 int segmentId() const { return it().segmentId(); }
115
121 {
122 return it().geometryInInside();
123 }
124
130 {
131 return it().geometry();
132 }
133
136 {
137 return it().type();
138 }
139
142 int indexInInside () const
143 {
144 return it().indexInInside();
145 }
146
151 {
152 return it().geometryInOutside();
153 }
154
157 int indexInOutside () const
158 {
159 return it().indexInOutside();
160 }
161
163 Twist twistInInside() const { return it().twistInInside(); }
164
166 Twist twistInOutside() const { return it().twistInOutside(); }
167
171 {
172 return it().unitOuterNormal( local );
173 }
174
178 {
179 const auto& refElement = GridImp::faceReferenceElement();
180 assert( refElement.type() == type() );
181 return unitOuterNormal(refElement.position(0,0));
182 }
183
187 {
188 return it().outerNormal( local );
189 }
190
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 *itPtr_; }
206 const IntersectionIteratorImp & it() const { return *itPtr_; }
207
209 int weight() const
210 {
211 return it().weight();
212 }
213
214private:
215 mutable ALU3DSPACE SharedPointer< IntersectionIteratorImp > itPtr_;
216}; // end class IntersectionIteratorWrapper
217
218template <class GridImp>
219class LeafIntersectionWrapper
220: public IntersectionIteratorWrapper<GridImp,typename GridImp::LeafIntersectionIteratorImp>
221{
222 typedef LeafIntersectionWrapper<GridImp> ThisType;
223 typedef IntersectionIteratorWrapper<GridImp,typename GridImp::LeafIntersectionIteratorImp> BaseType;
224public:
225 LeafIntersectionWrapper () {}
226
228 template <class EntityImp>
229 LeafIntersectionWrapper(const GridImp& grid, const EntityImp & en, int wLevel , bool end )
230 : BaseType( grid, en, wLevel, end )
231 {
232 }
233
235 LeafIntersectionWrapper(const ThisType & org)
236 : BaseType(org)
237 {
238 }
239
240};
241
244template <class GridImp>
246{
248 typedef LeafIntersectionWrapper<GridImp> IntersectionImp;
249
250public:
252
254 enum { dimension = GridImp :: dimension };
256 enum { dimensionworld = GridImp :: dimensionworld };
257
259 typedef typename GridImp :: ctype ctype;
260
262 typedef typename GridImp::template Codim<0>::Entity Entity;
263
265 typedef typename GridImp::template Codim<1>::Geometry Geometry;
267 typedef typename GridImp::template Codim<1>::LocalGeometry LocalGeometry;
268
271
274
276 template <class EntityImp>
277 LeafIntersectionIteratorWrapper(const GridImp& grid, const EntityImp & en, int wLevel , bool end )
278 : intersection_( IntersectionImp( grid, en, wLevel, end) )
279 {}
280
283 : intersection_( IntersectionImp( org.impl() ) )
284 {}
285
288 {
289 impl() = org.impl();
290 return *this;
291 }
292
294 const Intersection &dereference () const
295 {
296 return intersection_;
297 }
298
300 bool equals (const ThisType & i) const { return impl().equals( i.impl() ); }
301
304 {
305 impl().increment();
306 }
307protected:
308 // intersection object
309 Intersection intersection_;
310
311 // return reference to real implementation
312 IntersectionImp& impl() { return intersection_.impl(); }
313 // return reference to real implementation
314 const IntersectionImp& impl() const { return intersection_.impl(); }
315}; // end class IntersectionIteratorWrapper
316
319template <class GridImp>
321: public IntersectionIteratorWrapper<GridImp,typename GridImp::LevelIntersectionIteratorImp>
322{
325public:
327
329 template <class EntityImp>
330 LevelIntersectionWrapper(const GridImp& grid, const EntityImp & en, int wLevel , bool end )
331 : BaseType( grid, en, wLevel, end )
332 {
333 }
334
337 : BaseType(org)
338 {
339 }
340};
341
344template <class GridImp>
346{
349public:
351
353 enum { dimension = GridImp :: dimension };
355 enum { dimensionworld = GridImp :: dimensionworld };
356
358 typedef typename GridImp :: ctype ctype;
359
361 typedef typename GridImp::template Codim<0>::Entity Entity;
362
364 typedef typename GridImp::template Codim<1>::Geometry Geometry;
366 typedef typename GridImp::template Codim<1>::LocalGeometry LocalGeometry;
367
370
372
374 template <class EntityImp>
375 LevelIntersectionIteratorWrapper(const GridImp& grid, const EntityImp & en, int wLevel , bool end )
376 : intersection_( IntersectionImp( grid, en, wLevel, end ) )
377 {
378 if( wLevel > 0 && grid.conformingRefinement() )
379 {
380 // conceptually the level intersection iterator does not work for
381 // bisection type grids, only on the macro level. Therefore,
382 // an exception is thrown here
383 DUNE_THROW( NotImplemented, "LevelIntersectionIterator does not work for bisection refinement type grids on higher levels!");
384 }
385 }
386
389 : intersection_( IntersectionImp( org.impl() ) )
390 {}
391
394 {
395 impl() = org.impl();
396 return *this;
397 }
398
400 const Intersection &dereference () const
401 {
402 return intersection_;
403 }
404
406 bool equals (const ThisType & i) const { return impl().equals( i.impl() ); }
407
410 {
411 impl().increment();
412 }
413
414 // template <class,PartitionIteratorType> friend class MacroGridView; // specialize
415protected:
416 // intersection object
417 Intersection intersection_;
418
419 // return reference to real implementation
420 IntersectionImp& impl() { return intersection_.impl(); }
421 // return reference to real implementation
422 const IntersectionImp& impl() const { return intersection_.impl(); }
423}; // end class IntersectionIteratorWrapper
424
425} // end namespace Dune
426#endif
vector space out of a tensor product of fields.
Definition: fvector.hh:95
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:125
Class that wraps IntersectionIteratorImp of a grid and gets it's internal object from a object stack ...
Definition: intersectioniteratorwrapper.hh:23
const NormalType centerUnitOuterNormal() const
Definition: intersectioniteratorwrapper.hh:177
Geometry geometry() const
Definition: intersectioniteratorwrapper.hh:129
const NormalType outerNormal(const FieldVector< ctype, dim-1 > &local) const
Definition: intersectioniteratorwrapper.hh:186
size_t boundarySegmentIndex() const
return the boundary segment index
Definition: intersectioniteratorwrapper.hh:111
int weight() const
return weight associated with graph edge between the neighboring elements
Definition: intersectioniteratorwrapper.hh:209
bool boundary() const
Definition: intersectioniteratorwrapper.hh:102
Entity inside() const
access entity where iteration started
Definition: intersectioniteratorwrapper.hh:98
int segmentId() const
return the segment index (non-consecutive)
Definition: intersectioniteratorwrapper.hh:114
void increment()
increment iterator
Definition: intersectioniteratorwrapper.hh:76
IntersectionIteratorImp & it()
returns reference to underlying intersection iterator implementation
Definition: intersectioniteratorwrapper.hh:205
bool conforming() const
return true if intersection is conform (i.e. only one neighbor)
Definition: intersectioniteratorwrapper.hh:202
Entity outside() const
access neighbor
Definition: intersectioniteratorwrapper.hh:95
int boundaryId() const
return information about the Boundary
Definition: intersectioniteratorwrapper.hh:108
GridImp::template Codim< 0 >::Entity Entity
Entity type.
Definition: intersectioniteratorwrapper.hh:41
GridImp::ctype ctype
define type used for coordinates in grid module
Definition: intersectioniteratorwrapper.hh:38
GeometryType type() const
obtain the type of reference element for this intersection
Definition: intersectioniteratorwrapper.hh:135
GridImp::template Codim< 1 >::LocalGeometry LocalGeometry
type of intersection*Local
Definition: intersectioniteratorwrapper.hh:46
const NormalType integrationOuterNormal(const FieldVector< ctype, dim-1 > &local) const
Definition: intersectioniteratorwrapper.hh:193
IntersectionIteratorWrapper(const GridImp &grid, const EntityImp &en, int wLevel, bool end)
constructor called from the ibegin and iend method
Definition: intersectioniteratorwrapper.hh:58
LocalGeometry geometryInInside() const
Definition: intersectioniteratorwrapper.hh:120
int level() const
return level of iterator
Definition: intersectioniteratorwrapper.hh:199
FieldVector< ctype, dimworld > NormalType
type of normal vector
Definition: intersectioniteratorwrapper.hh:49
LocalGeometry geometryInOutside() const
Definition: intersectioniteratorwrapper.hh:150
GridImp::template Codim< 1 >::Geometry Geometry
type of intersectionGlobal
Definition: intersectioniteratorwrapper.hh:44
Twist twistInOutside() const
twist of the face seen from the outer element
Definition: intersectioniteratorwrapper.hh:166
Twist twistInInside() const
twist of the face seen from the inner element
Definition: intersectioniteratorwrapper.hh:163
int indexInInside() const
Definition: intersectioniteratorwrapper.hh:142
int indexInOutside() const
Definition: intersectioniteratorwrapper.hh:157
bool neighbor() const
return true if across the intersection a neighbor on this level exists
Definition: intersectioniteratorwrapper.hh:105
const NormalType unitOuterNormal(const FieldVector< ctype, dim-1 > &local) const
Definition: intersectioniteratorwrapper.hh:170
bool equals(const ThisType &other) const
the equality method
Definition: intersectioniteratorwrapper.hh:70
Intersection of a mesh entity of codimension 0 ("element") with a "neighboring" element or with the d...
Definition: intersection.hh:164
Implementation & impl()
access to the underlying implementation
Definition: intersection.hh:178
Class that wraps IntersectionIteratorImp of a grid and gets it's internal object from a object stack ...
Definition: intersectioniteratorwrapper.hh:246
bool equals(const ThisType &i) const
the equality method
Definition: intersectioniteratorwrapper.hh:300
GridImp::template Codim< 1 >::LocalGeometry LocalGeometry
type of intersection*Local
Definition: intersectioniteratorwrapper.hh:267
GridImp::template Codim< 0 >::Entity Entity
Entity type.
Definition: intersectioniteratorwrapper.hh:262
const Intersection & dereference() const
return reference to intersection
Definition: intersectioniteratorwrapper.hh:294
LeafIntersectionIteratorWrapper(const ThisType &org)
The copy constructor.
Definition: intersectioniteratorwrapper.hh:282
GridImp::ctype ctype
define type used for coordinates in grid module
Definition: intersectioniteratorwrapper.hh:259
ThisType & operator=(const ThisType &org)
the f*cking assignment operator
Definition: intersectioniteratorwrapper.hh:287
LeafIntersectionIteratorWrapper(const GridImp &grid, const EntityImp &en, int wLevel, bool end)
constructor called from the ibegin and iend method
Definition: intersectioniteratorwrapper.hh:277
void increment()
increment iterator
Definition: intersectioniteratorwrapper.hh:303
GridImp::template Codim< 1 >::Geometry Geometry
type of intersectionGlobal
Definition: intersectioniteratorwrapper.hh:265
LeafIntersectionIteratorWrapper()
default constructor
Definition: intersectioniteratorwrapper.hh:273
FieldVector< ctype, dimensionworld > NormalType
type of normal vector
Definition: intersectioniteratorwrapper.hh:270
Class that wraps IntersectionIteratorImp of a grid and gets it's internal object from a object stack ...
Definition: intersectioniteratorwrapper.hh:346
GridImp::ctype ctype
define type used for coordinates in grid module
Definition: intersectioniteratorwrapper.hh:358
GridImp::template Codim< 0 >::Entity Entity
Entity type.
Definition: intersectioniteratorwrapper.hh:361
bool equals(const ThisType &i) const
the equality method
Definition: intersectioniteratorwrapper.hh:406
GridImp::template Codim< 1 >::Geometry Geometry
type of intersectionGlobal
Definition: intersectioniteratorwrapper.hh:364
FieldVector< ctype, dimensionworld > NormalType
type of normal vector
Definition: intersectioniteratorwrapper.hh:369
GridImp::template Codim< 1 >::LocalGeometry LocalGeometry
type of intersection*Local
Definition: intersectioniteratorwrapper.hh:366
void increment()
increment iterator
Definition: intersectioniteratorwrapper.hh:409
ThisType & operator=(const ThisType &org)
the f*cking assignment operator
Definition: intersectioniteratorwrapper.hh:393
LevelIntersectionIteratorWrapper(const ThisType &org)
The copy constructor.
Definition: intersectioniteratorwrapper.hh:388
LevelIntersectionIteratorWrapper(const GridImp &grid, const EntityImp &en, int wLevel, bool end)
constructor called from the ibegin and iend method
Definition: intersectioniteratorwrapper.hh:375
const Intersection & dereference() const
return reference to intersection
Definition: intersectioniteratorwrapper.hh:400
Class that wraps IntersectionIteratorImp of a grid and gets it's internal object from a object stack ...
Definition: intersectioniteratorwrapper.hh:322
LevelIntersectionWrapper(const ThisType &org)
The copy constructor.
Definition: intersectioniteratorwrapper.hh:336
LevelIntersectionWrapper(const GridImp &grid, const EntityImp &en, int wLevel, bool end)
constructor called from the ibegin and iend method
Definition: intersectioniteratorwrapper.hh:330
Default exception for dummy implementations.
Definition: exceptions.hh:263
#define DUNE_THROW(E, m)
Definition: exceptions.hh:218
Dune namespace.
Definition: alignedallocator.hh:13
Static tag representing a codimension.
Definition: dimension.hh:24
Various macros to work with Dune module version numbers.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 15, 22:36, 2024)