dune-fem  2.4.1-rc
filteredgridpart/intersectioniterator.hh
Go to the documentation of this file.
1 #ifndef DUNE_FEM_GRIDPART_FILTEREDGRIDPART_INTERSECTIONITERATOR_HH
2 #define DUNE_FEM_GRIDPART_FILTEREDGRIDPART_INTERSECTIONITERATOR_HH
3 
4 //- system includes
5 #include <cassert>
6 
7 //- dune-grid includes
8 #include <dune/grid/common/intersectioniterator.hh>
9 
10 //- dune-fem includes
12 
13 namespace Dune
14 {
15 
16  namespace Fem
17  {
18 
19  // FilteredGridPartIntersectionIterator
20  // ------------------------------------
21 
22  template< class FilterType, class GridPartType, class HostIteratorType >
24  {
25  // type of this
27 
28  // type of host intersecton
29  typedef typename HostIteratorType::Intersection HostIntersection;
30 
31  public:
33  static const int dimension = HostIntersection::dimension;
35  static const int dimensionworld = HostIntersection::dimensionworld;
36  static const int mydimension = dimension - 1;
37 
39  typedef typename HostIntersection::ctype ctype;
40 
42  typedef typename HostIntersection::Entity Entity;
43 
45  typedef typename HostIntersection::EntityPointer EntityPointer;
46 
48  typedef typename HostIntersection::Geometry Geometry;
49 
51  typedef typename HostIntersection::LocalGeometry LocalGeometry;
52 
54  typedef typename HostIntersection::LocalCoordinate LocalCoordinate;
55 
57  typedef typename HostIntersection::GlobalCoordinate GlobalCoordinate;
58 
59  protected:
61  {
62  public:
64  : boundaryId_( -1 ),
65  boundary_( false ),
66  neighbor_(false)
67  { }
68 
69  NeighborInfo ( const NeighborInfo & org )
70  : boundaryId_( org.boundaryId_ ),
71  boundary_( org.boundary_ ),
72  neighbor_( org.neighbor_ )
73  { }
74 
76  {
77  boundary_ = org.boundary_;
79  neighbor_ = org.neighbor_;
80  return *this;
81  }
82 
84  bool boundary_;
85  bool neighbor_;
86  };
87 
88  // write information for current intersection
90  {
91  if ( hostIterator()->neighbor() )
92  {
93  if ( filter().interiorIntersection( *hostIterator() ) )
94  {
95  nInfo_.boundary_ = false;
96  nInfo_.boundaryId_ = 0;
97  nInfo_.neighbor_ = true;
98  }
99  else
100  {
101  // otherwise get boundary information from filter
102  nInfo_.boundary_ = filter().intersectionBoundary( *hostIterator() );
103  nInfo_.boundaryId_ = filter().intersectionBoundaryId( *hostIterator() );
104  nInfo_.neighbor_ = filter().intersectionNeighbor( *hostIterator() );
105  }
106  }
107  else
108  {
109  // for real boundary get boundary from filter
110  nInfo_.boundary_ = true;
111  nInfo_.boundaryId_ = filter().intersectionBoundaryId( *hostIterator() );
112  nInfo_.neighbor_ = false;
113  }
114  }
115 
116 
117  public:
119  FilteredGridPartIntersectionIterator( const GridPartType & gridPart,
120  const Entity &en,
121  const HostIteratorType & hostIterator )
122  : gridPart_( gridPart ),
123  hostIterator_( hostIterator ),
124  endIterator_( gridPart.hostGridPart().iend( en ) ),
125  nInfo_()
126  {
127  if( !done() )
129  }
130 
132  FilteredGridPartIntersectionIterator( const ThisType & other )
133  : gridPart_( other.gridPart_ ),
134  hostIterator_( other.hostIterator_ ),
135  endIterator_( other.endIterator_ ),
136  nInfo_( other.nInfo_ )
137  { }
138 
141  {
142  gridPart_ = other.gridPart_;
143  hostIterator_ = other.hostIterator_;
144  nInfo_ = other.nInfo_;
145  return *this;
146  }
147 
150  {
151  assert( !done() );
152  ++hostIterator_;
153  if( !done() )
155  return *this;
156  }
157 
160  {
161  return hostIterator_.operator==( other.hostIterator_ );
162  }
163 
166  {
167  return !(*this == other);
168  }
169 
171  bool boundary () const
172  {
173  return nInfo_.boundary_;
174  }
175 
177  int boundaryId () const
178  {
179  return nInfo_.boundaryId_;
180  }
181 
183  bool neighbor () const
184  {
185  return nInfo_.neighbor_;
186  }
187 
189  Entity inside () const
190  {
191  return make_entity( hostIterator()->inside() );
192  }
193 
195  Entity outside () const
196  {
197  return make_entity( hostIterator()->outside() );
198  }
199 
201  bool conforming () const
202  {
203  return hostIterator()->conforming();
204  }
205 
207  LocalGeometry geometryInInside () const
208  {
209  return hostIterator()->geometryInInside();
210  }
211 
213  LocalGeometry geometryInOutside () const
214  {
215  return hostIterator()->geometryInOutside();
216  }
217 
219  Geometry geometry () const
220  {
221  return hostIterator()->geometry();
222  }
223 
225  GeometryType type () const
226  {
227  return hostIterator()->type();
228  }
229 
231  int indexInInside () const
232  {
233  return hostIterator()->indexInInside();
234  }
235 
237  int indexInOutside () const
238  {
239  return hostIterator()->indexInOutside();
240  }
241 
243  GlobalCoordinate outerNormal ( const LocalCoordinate & local ) const
244  {
245  return hostIterator()->outerNormal( local );
246  }
247 
249  GlobalCoordinate integrationOuterNormal ( const LocalCoordinate & local ) const
250  {
251  return hostIterator()->integrationOuterNormal( local );
252  }
253 
255  GlobalCoordinate unitOuterNormal( const LocalCoordinate & local ) const
256  {
257  return hostIterator()->unitOuterNormal( local );
258  }
259 
261  GlobalCoordinate centerUnitOuterNormal( ) const
262  {
263  return hostIterator()->centerUnitOuterNormal( );
264  }
265 
267  typedef ThisType Intersection;
268 
270  const Intersection& operator *() const { return *this; }
271 
273  const Intersection* operator ->() const { return this; }
274 
275  // impl method is needed for MetaTwistUtility
276  const Intersection& impl() const
277  {
278  return *this;
279  }
280 
281  // hostIntersection method is needed for MetaTwistUtility
282  HostIntersection hostIntersection() const
283  {
284  return *hostIterator();
285  }
286 
287  private:
288  const GridPartType & gridPart () const
289  {
290  return gridPart_;
291  }
292 
293  bool done () const
294  {
295  return hostIterator_.operator ==( endIterator_ );
296  }
297 
298  // return reference to base class
299  HostIteratorType & hostIterator ()
300  {
301  return hostIterator_;
302  }
303 
304  // return reference to base class
305  const HostIteratorType & hostIterator () const
306  {
307  return hostIterator_;
308  }
309 
310  const FilterType & filter () const
311  {
312  return gridPart().filter();
313  }
314 
315  const GridPartType & gridPart_;
316  HostIteratorType hostIterator_, endIterator_;
317  NeighborInfo nInfo_;
318 
319  };
320 
321  } // namespace Fem
322 
323 } // namespace Dune
324 
325 #endif // #ifndef DUNE_FEM_GRIDPART_FILTEREDGRIDPART_INTERSECTIONITERATOR_HH
NeighborInfo(const NeighborInfo &org)
Definition: filteredgridpart/intersectioniterator.hh:69
LocalGeometry geometryInInside() const
return inside entity
Definition: filteredgridpart/intersectioniterator.hh:207
const Intersection & operator*() const
dereference operator
Definition: filteredgridpart/intersectioniterator.hh:270
GlobalCoordinate outerNormal(const LocalCoordinate &local) const
return inside entity
Definition: filteredgridpart/intersectioniterator.hh:243
HostIntersection::EntityPointer EntityPointer
entity type
Definition: filteredgridpart/intersectioniterator.hh:45
Definition: filteredgridpart/intersectioniterator.hh:23
HostIntersection::Geometry Geometry
geometry type
Definition: filteredgridpart/intersectioniterator.hh:48
Entity inside() const
return inside entity
Definition: filteredgridpart/intersectioniterator.hh:189
bool operator!=(const FilteredGridPartIntersectionIterator &other) const
check for inequality
Definition: filteredgridpart/intersectioniterator.hh:165
static const int dimensionworld
world dimension
Definition: filteredgridpart/intersectioniterator.hh:35
GlobalCoordinate integrationOuterNormal(const LocalCoordinate &local) const
return inside entity
Definition: filteredgridpart/intersectioniterator.hh:249
const Intersection * operator->() const
de-pointer operator
Definition: filteredgridpart/intersectioniterator.hh:273
GlobalCoordinate unitOuterNormal(const LocalCoordinate &local) const
return inside entity
Definition: filteredgridpart/intersectioniterator.hh:255
int boundaryId() const
overloaded boundaryId method
Definition: filteredgridpart/intersectioniterator.hh:177
HostIntersection hostIntersection() const
Definition: filteredgridpart/intersectioniterator.hh:282
int indexInInside() const
return inside entity
Definition: filteredgridpart/intersectioniterator.hh:231
HostIntersection::GlobalCoordinate GlobalCoordinate
global coordinate type
Definition: filteredgridpart/intersectioniterator.hh:57
HostIntersection::LocalGeometry LocalGeometry
local geometry type
Definition: filteredgridpart/intersectioniterator.hh:51
int indexInOutside() const
return inside entity
Definition: filteredgridpart/intersectioniterator.hh:237
bool boundary() const
overloaded boundary method
Definition: filteredgridpart/intersectioniterator.hh:171
Dune::EntityPointer< Grid, Implementation >::Entity make_entity(const Dune::EntityPointer< Grid, Implementation > &entityPointer)
Definition: compatibility.hh:23
FilteredGridPartIntersectionIterator(const GridPartType &gridPart, const Entity &en, const HostIteratorType &hostIterator)
constructor
Definition: filteredgridpart/intersectioniterator.hh:119
int boundaryId_
Definition: filteredgridpart/intersectioniterator.hh:83
FilteredGridPartIntersectionIterator & operator++()
increment intersection iterator
Definition: filteredgridpart/intersectioniterator.hh:149
ThisType Intersection
type of Intersection
Definition: filteredgridpart/intersectioniterator.hh:267
Definition: coordinate.hh:4
HostIntersection::LocalCoordinate LocalCoordinate
local coordinate type
Definition: filteredgridpart/intersectioniterator.hh:54
static const int mydimension
Definition: filteredgridpart/intersectioniterator.hh:36
Definition: filteredgridpart/intersectioniterator.hh:60
bool operator==(const FilteredGridPartIntersectionIterator &other) const
check for equality
Definition: filteredgridpart/intersectioniterator.hh:159
bool boundary_
Definition: filteredgridpart/intersectioniterator.hh:84
const Intersection & impl() const
Definition: filteredgridpart/intersectioniterator.hh:276
static const int dimension
dimension
Definition: filteredgridpart/intersectioniterator.hh:33
bool neighbor() const
overloaded neighbor method
Definition: filteredgridpart/intersectioniterator.hh:183
Entity outside() const
return outside entity
Definition: filteredgridpart/intersectioniterator.hh:195
Geometry geometry() const
return inside entity
Definition: filteredgridpart/intersectioniterator.hh:219
HostIntersection::Entity Entity
entity type
Definition: filteredgridpart/intersectioniterator.hh:42
void writeNeighborInfo()
Definition: filteredgridpart/intersectioniterator.hh:89
GeometryType type() const
return inside entity
Definition: filteredgridpart/intersectioniterator.hh:225
FilteredGridPartIntersectionIterator(const ThisType &other)
copy constructor
Definition: filteredgridpart/intersectioniterator.hh:132
NeighborInfo()
Definition: filteredgridpart/intersectioniterator.hh:63
NeighborInfo & operator=(const NeighborInfo &org)
Definition: filteredgridpart/intersectioniterator.hh:75
LocalGeometry geometryInOutside() const
return inside entity
Definition: filteredgridpart/intersectioniterator.hh:213
GlobalCoordinate centerUnitOuterNormal() const
return inside entity
Definition: filteredgridpart/intersectioniterator.hh:261
HostIntersection::ctype ctype
single coordinate type
Definition: filteredgridpart/intersectioniterator.hh:39
bool conforming() const
Definition: filteredgridpart/intersectioniterator.hh:201
bool neighbor_
Definition: filteredgridpart/intersectioniterator.hh:85