Dune Core Modules (2.4.2)

gridview.hh
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3#ifndef DUNE_ALBERTAGRID_GRIDVIEW_HH
4#define DUNE_ALBERTAGRID_GRIDVIEW_HH
5
6#if HAVE_ALBERTA
7
10
12#include <dune/grid/common/gridview.hh>
13
15
16namespace Dune
17{
18
19 template< class GridImp, PartitionIteratorType pitype >
20 class AlbertaLevelGridView;
21
22 template< class GridImp, PartitionIteratorType pitype >
23 class AlbertaLeafGridView;
24
25
26 template< class GridImp, PartitionIteratorType pitype >
27 struct AlbertaLevelGridViewTraits
28 {
29 typedef AlbertaLevelGridView< GridImp, pitype > GridViewImp;
30
32 typedef typename remove_const<GridImp>::type Grid;
33
35 typedef typename Grid::Traits::LevelIndexSet IndexSet;
36
38 typedef typename Grid::Traits::LevelIntersection Intersection;
39
41 typedef typename Grid::Traits::LevelIntersectionIterator
42 IntersectionIterator;
43
45 typedef typename Grid::Traits::CollectiveCommunication CollectiveCommunication;
46
47 template< int cd >
48 struct Codim
49 {
50 typedef typename Grid::Traits::template Codim< cd >::template Partition< pitype >::LevelIterator
51 Iterator;
52
53 typedef typename Grid::Traits::template Codim< cd >::Entity Entity;
54 typedef typename Grid::Traits::template Codim< cd >::EntityPointer
55 EntityPointer;
56
57 typedef typename Grid::template Codim< cd >::Geometry Geometry;
58 typedef typename Grid::template Codim< cd >::LocalGeometry
59 LocalGeometry;
60
62 template< PartitionIteratorType pit >
63 struct Partition
64 {
66 typedef typename Grid::template Codim< cd >::template Partition< pit >::LevelIterator
68 };
69 };
70
72 };
73
74
75 template< class GridImp, PartitionIteratorType pitype >
76 class AlbertaLevelGridView
77 {
78 typedef AlbertaLevelGridView< GridImp, pitype > ThisType;
79
80 public:
81 typedef AlbertaLevelGridViewTraits<GridImp,pitype> Traits;
82
84 typedef typename Traits::Grid Grid;
85
87 typedef typename Traits::IndexSet IndexSet;
88
90 typedef typename Traits::Intersection Intersection;
91
93 typedef typename Traits::IntersectionIterator IntersectionIterator;
94
96 typedef typename Traits::CollectiveCommunication CollectiveCommunication;
97
99 template< int cd >
100 struct Codim : public Traits::template Codim<cd> {};
101
102 enum { conforming = Traits::conforming };
103
104 private:
105 typedef Alberta::ElementInfo< Grid::dimension > ElementInfo;
106
107 typedef Dune::AlbertaGridLeafIntersectionIterator< GridImp > IntersectionIteratorImpl;
108
109 public:
110 AlbertaLevelGridView ( const Grid &grid, int level )
111 : grid_( &grid ),
112 indexSet_( &(grid.levelIndexSet( level )) ),
113 level_( level )
114 {}
115
116 // use default implementation of copy constructor and assignment operator
117#if 0
118 AlbertaLevelGridView ( const ThisType &other )
119 : grid_( other.grid_ ),
120 indexSet_( other.indexSet_ ),
121 level_( other.level_ )
122 {}
123
125 ThisType &operator= ( const ThisType & other)
126 {
127 grid_ = other.grid_;
128 indexSet_ = other.indexSet_;
129 level_ = other.level_;
130 }
131#endif
132
134 const Grid &grid () const
135 {
136 return *grid_;
137 }
138
140 const IndexSet &indexSet () const
141 {
142 return *indexSet_;
143 }
144
146 int size ( int codim ) const
147 {
148 return grid().size( level_, codim );
149 }
150
152 int size ( const GeometryType &type ) const
153 {
154 return grid().size( level_, type );
155 }
156
158 template< int cd >
159 typename Codim< cd >::Iterator begin () const
160 {
161 return grid().template lbegin< cd, pitype >( level_ );
162 }
163
165 template< int cd, PartitionIteratorType pit >
166 typename Codim< cd >::template Partition< pit >::Iterator begin () const
167 {
168 return grid().template lbegin< cd, pit >( level_ );
169 }
170
172 template< int cd >
173 typename Codim< cd >::Iterator end () const
174 {
175 return grid().template lend< cd, pitype >( level_ );
176 }
177
179 template< int cd, PartitionIteratorType pit >
180 typename Codim< cd >::template Partition< pit >::Iterator end () const
181 {
182 return grid().template lend< cd, pit >( level_ );
183 }
184
186 IntersectionIterator
187 ibegin ( const typename Codim< 0 >::Entity &entity ) const
188 {
189 if( grid().maxLevel() == 0)
190 {
191 typename IntersectionIteratorImpl::Begin begin;
192 return IntersectionIteratorImpl( Grid::getRealImplementation( entity ), begin );
193 }
194 else
195 {
196 DUNE_THROW( NotImplemented, "method ibegin not implemented on LevelGridView for AlbertaGrid." );
197 typename IntersectionIteratorImpl::End end;
198 return IntersectionIteratorImpl( Grid::getRealImplementation( entity ), end );
199 }
200 }
201
203 IntersectionIterator
204 iend ( const typename Codim< 0 >::Entity &entity ) const
205 {
206 typename IntersectionIteratorImpl::End end;
207 return IntersectionIteratorImpl( Grid::getRealImplementation( entity ), end );
208 }
209
211 const CollectiveCommunication &comm () const
212 {
213 return grid().comm();
214 }
215
217 int overlapSize(int codim) const
218 {
219 return grid().overlapSize(level_, codim);
220 }
221
223 int ghostSize(int codim) const
224 {
225 return grid().ghostSize(level_, codim);
226 }
227
229 template< class DataHandleImp, class DataType >
230 void communicate ( CommDataHandleIF< DataHandleImp, DataType > &data,
231 InterfaceType iftype,
232 CommunicationDirection dir ) const
233 {}
234
235 private:
236 const Grid *grid_;
237 const IndexSet *indexSet_;
238 int level_;
239 };
240
241
242 template< class GridImp, PartitionIteratorType pitype >
243 struct AlbertaLeafGridViewTraits
244 {
245 typedef AlbertaLeafGridView< GridImp, pitype > GridViewImp;
246
248 typedef typename remove_const<GridImp>::type Grid;
249
251 typedef typename Grid::Traits::LeafIndexSet IndexSet;
252
254 typedef typename Grid::Traits::LeafIntersection Intersection;
255
257 typedef typename Grid::Traits::LeafIntersectionIterator
258 IntersectionIterator;
259
261 typedef typename Grid::Traits::CollectiveCommunication CollectiveCommunication;
262
263 template< int cd >
264 struct Codim
265 {
266 typedef typename Grid::Traits::template Codim< cd >::template Partition< pitype >::LeafIterator
267 Iterator;
268
269 typedef typename Grid::Traits::template Codim< cd >::Entity Entity;
270 typedef typename Grid::Traits::template Codim< cd >::EntityPointer
271 EntityPointer;
272
273 typedef typename Grid::template Codim< cd >::Geometry Geometry;
274 typedef typename Grid::template Codim< cd >::LocalGeometry
275 LocalGeometry;
276
278 template <PartitionIteratorType pit >
280 {
282 typedef typename Grid::template Codim< cd >::template Partition< pit >::LeafIterator
284 };
285 };
286
288 };
289
290
291 template< class GridImp, PartitionIteratorType pitype >
292 class AlbertaLeafGridView
293 {
294 typedef AlbertaLeafGridView< GridImp, pitype > ThisType;
295
296 public:
297 typedef AlbertaLeafGridViewTraits<GridImp,pitype> Traits;
298
300 typedef typename Traits::Grid Grid;
301
303 typedef typename Traits::IndexSet IndexSet;
304
306 typedef typename Traits::Intersection Intersection;
307
309 typedef typename Traits::IntersectionIterator IntersectionIterator;
310
312 typedef typename Traits::CollectiveCommunication CollectiveCommunication;
313
315 template< int cd >
316 struct Codim : public Traits::template Codim<cd> {};
317
318 enum { conforming = Traits::conforming };
319
320 private:
321 typedef Alberta::ElementInfo< Grid::dimension > ElementInfo;
322
323 typedef Dune::AlbertaGridLeafIntersectionIterator< GridImp > IntersectionIteratorImpl;
324
325 public:
326 AlbertaLeafGridView ( const Grid &grid )
327 : grid_( &grid ),
328 indexSet_( &(grid.leafIndexSet()) )
329 {}
330
331 // use default implementation of copy constructor and assignment operator
332#if 0
333 AlbertaLeafGridView ( const ThisType &other )
334 : grid_( other.grid_ ),
335 indexSet_( other.indexSet_ )
336 {}
337
339 ThisType &operator= ( const ThisType & other)
340 {
341 grid_ = other.grid_;
342 indexSet_ = other.indexSet_;
343 }
344#endif
345
347 const Grid &grid () const
348 {
349 return *grid_;
350 }
351
353 const IndexSet &indexSet () const
354 {
355 return *indexSet_;
356 }
357
359 int size ( int codim ) const
360 {
361 return grid().size( codim );
362 }
363
365 int size ( const GeometryType &type ) const
366 {
367 return grid().size( type );
368 }
369
371 template< int cd >
372 typename Codim< cd >::Iterator begin () const
373 {
374 return grid().template leafbegin< cd, pitype >();
375 }
376
378 template< int cd, PartitionIteratorType pit >
379 typename Codim< cd >::template Partition< pit >::Iterator begin () const
380 {
381 return grid().template leafbegin< cd, pit >();
382 }
383
385 template< int cd >
386 typename Codim< cd >::Iterator end () const
387 {
388 return grid().template leafend< cd, pitype >();
389 }
390
392 template< int cd, PartitionIteratorType pit >
393 typename Codim< cd >::template Partition< pit >::Iterator end () const
394 {
395 return grid().template leafend< cd, pit >();
396 }
397
399 IntersectionIterator
400 ibegin ( const typename Codim< 0 >::Entity &entity ) const
401 {
402 const ElementInfo elementInfo = Grid::getRealImplementation( entity ).elementInfo();
403 assert( !!elementInfo );
404
405#ifndef NDEBUG
406 for( int i = 0; i <= Grid::dimension; ++i )
407 {
408 if( elementInfo.elInfo().opp_vertex[ i ] == 127 )
409 DUNE_THROW( NotImplemented, "AlbertaGrid: Intersections on outside entities are not fully implemented, yet." );
410 }
411#endif // #ifndef NDEBUG
412
413 typename IntersectionIteratorImpl::Begin begin;
414 return IntersectionIteratorImpl( Grid::getRealImplementation( entity ), begin );
415 }
416
418 IntersectionIterator
419 iend ( const typename Codim< 0 >::Entity &entity ) const
420 {
421 assert( !!Grid::getRealImplementation( entity ).elementInfo() );
422 typename IntersectionIteratorImpl::End end;
423 return IntersectionIteratorImpl( Grid::getRealImplementation( entity ), end );
424 }
425
427 const CollectiveCommunication &comm () const
428 {
429 return grid().comm();
430 }
431
433 int overlapSize(int codim) const
434 {
435 return grid().overlapSize(codim);
436 }
437
439 int ghostSize(int codim) const
440 {
441 return grid().ghostSize(codim);
442 }
443
445 template< class DataHandleImp, class DataType >
446 void communicate ( CommDataHandleIF< DataHandleImp, DataType > &data,
447 InterfaceType iftype,
448 CommunicationDirection dir ) const
449 {}
450
451 private:
452 const Grid *grid_;
453 const IndexSet *indexSet_;
454 };
455
456}
457
458#endif // #if HAVE_ALBERTA
459#endif // #ifndef DUNE_ALBERTAGRID_GRIDVIEW_HH
Implementation of the IntersectionIterator for AlbertaGrid.
Grid abstract base class.
Definition: grid.hh:388
@ dimension
The dimension of the grid.
Definition: grid.hh:402
A set of traits classes to store static information about grid implementation.
A few common exception classes.
#define DUNE_THROW(E, m)
Definition: exceptions.hh:243
CommunicationDirection
Define a type for communication direction parameter.
Definition: gridenums.hh:168
InterfaceType
Parameter to be used for the communication functions.
Definition: gridenums.hh:84
Dune namespace.
Definition: alignment.hh:10
Define types needed to iterate over entities of a given partition type.
Definition: gridview.hh:280
Grid::template Codim< cd >::template Partition< pit >::LeafIterator Iterator
iterator over a given codim and partition type
Definition: gridview.hh:283
Codim Structure.
Definition: gridview.hh:316
Define types needed to iterate over entities of a given partition type.
Definition: gridview.hh:64
Grid::template Codim< cd >::template Partition< pit >::LevelIterator Iterator
iterator over a given codim and partition type
Definition: gridview.hh:67
Codim Structure.
Definition: gridview.hh:100
Specialize with 'true' if implementation guarantees a conforming leaf grid. (default=false)
Definition: capabilities.hh:108
Specialize with 'true' if implementation guarantees conforming level grids. (default=false)
Definition: capabilities.hh:99
Traits for type conversions and type information.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 21, 23:30, 2024)