~ubuntu-branches/ubuntu/vivid/dune-grid/vivid

« back to all changes in this revision

Viewing changes to dune/grid/common/intersectioniterator.hh

  • Committer: Package Import Robot
  • Author(s): Ansgar Burchardt
  • Date: 2012-04-06 11:31:20 UTC
  • Revision ID: package-import@ubuntu.com-20120406113120-x0z4e0qqgfhmaj2a
Tags: upstream-2.2~svn7982
ImportĀ upstreamĀ versionĀ 2.2~svn7982

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef DUNE_GRID_INTERSECTIONITERATOR_HH
 
2
#define DUNE_GRID_INTERSECTIONITERATOR_HH
 
3
 
 
4
#include <dune/common/iteratorfacades.hh>
 
5
 
 
6
#include <dune/grid/common/intersection.hh>
 
7
 
 
8
namespace Dune
 
9
{
 
10
 
 
11
/** \brief Mesh entities of codimension 0 ("elements") allow to visit all
 
12
   intersections with "neighboring" elements and with the domain
 
13
   boundary.  
 
14
 
 
15
   Template parameters are:
 
16
 
 
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
 
20
 
 
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.
 
25
 
 
26
   \deprecated All Intersection methods on the IntersectionIterator are deprecated,
 
27
     dereference IntersectionIterator to get the Intersection and call methods there.
 
28
   
 
29
   @warning The number of neigbors may be different from the number of
 
30
   faces/edges of an element!
 
31
 
 
32
   <h2>Overview</h2>
 
33
   
 
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.
 
42
 
 
43
   <H2>Engine Concept</H2>
 
44
 
 
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.
 
49
 
 
50
   <h2>Intersections, leaf grid and level grid</h2>
 
51
   
 
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.
 
58
 
 
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
 
61
   been refined.
 
62
   In one space dimension this situation is depicted in the figure below.
 
63
 
 
64
   \image html  islocalref.png "IntersectionIterator in a locally refined mesh."
 
65
   \image latex islocalref.eps "IntersectionIterator in a locally refined mesh." width=\textwidth
 
66
 
 
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.
 
84
 
 
85
   @ingroup GIIntersectionIterator
 
86
 */
 
87
template<class GridImp, template<class> class IntersectionIteratorImp, template<class> class IntersectionImp>
 
88
class IntersectionIterator
 
89
{
 
90
#if DUNE_GRID_EXPERIMENTAL_GRID_EXTENSIONS
 
91
public:
 
92
#else
 
93
protected:
 
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> ;
 
99
#endif
 
100
  // type of underlying implementation, for internal use only 
 
101
  typedef IntersectionIteratorImp< const GridImp > Implementation;
 
102
 
 
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; }
 
107
 
 
108
protected:
 
109
  Implementation realIterator;
 
110
 
 
111
public:
 
112
    /** \brief Type of Intersection this IntersectionIterator points to */
 
113
  typedef Dune::Intersection< const GridImp, IntersectionImp > Intersection;
 
114
 
 
115
  //===========================================================
 
116
  /** @name Dereferencing
 
117
   */
 
118
  //@{
 
119
  //===========================================================
 
120
 
 
121
  /** \brief Dereferencing operator. */
 
122
  const Intersection & operator*() const
 
123
    {
 
124
      return this->realIterator.dereference();
 
125
    }
 
126
 
 
127
  /** \brief Pointer operator. */
 
128
  const Intersection * operator->() const
 
129
    {
 
130
      return & this->realIterator.dereference();
 
131
    }
 
132
  //@}
 
133
 
 
134
 
 
135
  //===========================================================
 
136
  /** @name Compare methods
 
137
   */
 
138
  //@{
 
139
  //===========================================================
 
140
 
 
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.
 
145
   */
 
146
  bool operator==(const IntersectionIterator& rhs) const
 
147
    {
 
148
      return rhs.equals(*this);
 
149
    }
 
150
 
 
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.
 
155
  */
 
156
  bool operator!=(const IntersectionIterator& rhs) const
 
157
    {
 
158
      return ! rhs.equals(*this);
 
159
    }
 
160
  //@}
 
161
 
 
162
  /** @brief Preincrement operator. Proceed to next intersection.*/
 
163
  IntersectionIterator& operator++()
 
164
    {
 
165
      this->realIterator.increment();
 
166
      return *this;
 
167
    }
 
168
  
 
169
  //===========================================================
 
170
  /** @name Implementor interface
 
171
   */
 
172
  //@{
 
173
  //===========================================================
 
174
 
 
175
  /** @brief forward equality check to realIterator */
 
176
  bool equals(const IntersectionIterator& rhs) const
 
177
    {
 
178
      return this->realIterator.equals(rhs.realIterator);
 
179
    }
 
180
 
 
181
  /** Copy Constructor from IntersectionIteratorImp */
 
182
  IntersectionIterator(const IntersectionIteratorImp<const GridImp> & i) :
 
183
    realIterator(i) {};
 
184
 
 
185
  /** Copy constructor */
 
186
  IntersectionIterator(const IntersectionIterator& i) :
 
187
    realIterator(i.realIterator) {}
 
188
  //@}
 
189
 
 
190
  typedef typename remove_const<GridImp>::type mutableGridImp;
 
191
};
 
192
 
 
193
} // namespace Dune
 
194
 
 
195
#include "intersection.hh"
 
196
 
 
197
#endif // DUNE_GRID_INTERSECTIONITERATOR_HH