1
#ifndef DUNE_GRID_INTERSECTIONITERATOR_HH
2
#define DUNE_GRID_INTERSECTIONITERATOR_HH
4
#include <dune/common/iteratorfacades.hh>
6
#include <dune/grid/common/intersection.hh>
11
/** \brief Mesh entities of codimension 0 ("elements") allow to visit all
12
intersections with "neighboring" elements and with the domain
15
Template parameters are:
17
- <tt>GridImp</tt> Type that is a model of Dune::Grid
18
- <tt>IntersectionIteratorImp</tt> Class template that is a model of
19
Dune::IntersectionIterator
21
@warning the IntersectionIterator used to be both, Intersection and IntersectionIterator,
22
at the same time. The two concepts are now properly separated. The IntersectionIterator
23
still offers the old methods, but these are forwarded to the Intersection. All these methods
24
are now marked deprecated.
26
\deprecated All Intersection methods on the IntersectionIterator are deprecated,
27
dereference IntersectionIterator to get the Intersection and call methods there.
29
@warning The number of neigbors may be different from the number of
30
faces/edges of an element!
34
Intersections are codimension 1 objects. These
35
intersections are accessed via an IntersectionIterator. This allows
36
the implementation of non-matching grids, as one face can now
37
consist of several intersections.
38
In a conforming mesh such an intersection corresponds to an entity of
39
codimension 1 but in the general non-conforming case there will be no entity
40
in the mesh that directly corresponds to the intersection. Thus, the
41
IntersectionIterator describes these intersections implicitly.
43
<H2>Engine Concept</H2>
45
The IntersectionIterator class template wraps an object of type IntersectionIteratorImp
46
and forwards all member
47
function calls to corresponding members of this class. In that sense IntersectionIterator
48
defines the interface and IntersectionIteratorImp supplies the implementation.
50
<h2>Intersections, leaf grid and level grid</h2>
52
On an entity \b e of codimension zero there are two ways to create
53
IntersectionIterators by either using ilevelbegin() / ilevelend() or
54
ileafbegin()/ileafend(). In the first case intersections with
55
neighboring entities having the same level as \b e are traversed; in
56
the second case ileafbegin()==ileafend() if \b e is not a leaf otherwise
57
all intersections with neighboring leaf entities are traversed.
59
Consider a situation where two elements \b a and \b b have a common intersection.
60
%Element \b b has been refined into an element \b c and \b d, while \b a has not
62
In one space dimension this situation is depicted in the figure below.
64
\image html islocalref.png "IntersectionIterator in a locally refined mesh."
65
\image latex islocalref.eps "IntersectionIterator in a locally refined mesh." width=\textwidth
67
Here the rule is the following: The %LevelIntersectionIterator
68
delivers all intersections
69
with elements on the same level, the %LeafIntersectionIterator delivers
70
the intersections with all leaf elements
71
if it has been started on a leaf element. Both iterators also stop at intersections
72
with the grid boundary.
73
According to this rule the level intersection iterator started at element \b a
74
in the example above delivers an intersection with \b b and the left grid boundary,
75
whereas the leaf intersection iterator returns \b c instead of \b b.
76
Starting on entity \b c the level intersection iterator returns \b d and the
77
intersection with the left boundary of the level 1 grid,
78
but the leaf intersection iterator returns both \b d and \b a.
79
Finally, starting on \b b the level intersection
80
iterator returns \b a and the right boundary, but the leaf intersection iterator is empty since
81
\b b is not a leaf entity of the grid. Starting on \b d both the
82
level and the leaf intersection iterators will return the element \b c
83
together with the right grid boundary.
85
@ingroup GIIntersectionIterator
87
template<class GridImp, template<class> class IntersectionIteratorImp, template<class> class IntersectionImp>
88
class IntersectionIterator
90
#if DUNE_GRID_EXPERIMENTAL_GRID_EXTENSIONS
94
// give the GridDefaultImplementation class access to the realImp
95
friend class GridDefaultImplementation<
96
GridImp::dimension, GridImp::dimensionworld,
97
typename GridImp::ctype,
98
typename GridImp::GridFamily> ;
100
// type of underlying implementation, for internal use only
101
typedef IntersectionIteratorImp< const GridImp > Implementation;
103
//! return reference to the real implementation
104
Implementation &impl () { return realIterator; }
105
//! return reference to the real implementation
106
const Implementation &impl () const { return realIterator; }
109
Implementation realIterator;
112
/** \brief Type of Intersection this IntersectionIterator points to */
113
typedef Dune::Intersection< const GridImp, IntersectionImp > Intersection;
115
//===========================================================
116
/** @name Dereferencing
119
//===========================================================
121
/** \brief Dereferencing operator. */
122
const Intersection & operator*() const
124
return this->realIterator.dereference();
127
/** \brief Pointer operator. */
128
const Intersection * operator->() const
130
return & this->realIterator.dereference();
135
//===========================================================
136
/** @name Compare methods
139
//===========================================================
141
/** @brief Checks for equality.
142
Only Iterators pointing to the same intersection from the same Entity
143
are equal. Pointing to the same intersection from neighbor is
144
unequal as inside and outside are permuted.
146
bool operator==(const IntersectionIterator& rhs) const
148
return rhs.equals(*this);
151
/** @brief Checks for inequality.
152
Only Iterators pointing to the same intersection from the same Entity
153
are equal. Pointing to the same intersection from neighbor is
154
unequal as inside and outside are permuted.
156
bool operator!=(const IntersectionIterator& rhs) const
158
return ! rhs.equals(*this);
162
/** @brief Preincrement operator. Proceed to next intersection.*/
163
IntersectionIterator& operator++()
165
this->realIterator.increment();
169
//===========================================================
170
/** @name Implementor interface
173
//===========================================================
175
/** @brief forward equality check to realIterator */
176
bool equals(const IntersectionIterator& rhs) const
178
return this->realIterator.equals(rhs.realIterator);
181
/** Copy Constructor from IntersectionIteratorImp */
182
IntersectionIterator(const IntersectionIteratorImp<const GridImp> & i) :
185
/** Copy constructor */
186
IntersectionIterator(const IntersectionIterator& i) :
187
realIterator(i.realIterator) {}
190
typedef typename remove_const<GridImp>::type mutableGridImp;
195
#include "intersection.hh"
197
#endif // DUNE_GRID_INTERSECTIONITERATOR_HH