dune-grid  2.4
albertagrid/gridview.hh
Go to the documentation of this file.
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 
8 #include <dune/common/typetraits.hh>
9 #include <dune/common/exceptions.hh>
10 
13 
15 
16 namespace Dune
17 {
18 
19  template< class GridImp, PartitionIteratorType pitype >
21 
22  template< class GridImp, PartitionIteratorType pitype >
24 
25 
26  template< class GridImp, PartitionIteratorType pitype >
28  {
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
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
52 
53  typedef typename Grid::Traits::template Codim< cd >::Entity Entity;
54  typedef typename Grid::Traits::template Codim< cd >::EntityPointer
56 
57  typedef typename Grid::template Codim< cd >::Geometry Geometry;
58  typedef typename Grid::template Codim< cd >::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:
82 
84  typedef typename Traits::Grid Grid;
85 
87  typedef typename Traits::IndexSet IndexSet;
88 
91 
94 
97 
99  template< int cd >
100  struct Codim : public Traits::template Codim<cd> {};
101 
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  {
192  return IntersectionIteratorImpl( Grid::getRealImplementation( entity ), begin );
193  }
194  else
195  {
196  DUNE_THROW( NotImplemented, "method ibegin not implemented on LevelGridView for AlbertaGrid." );
198  return IntersectionIteratorImpl( Grid::getRealImplementation( entity ), end );
199  }
200  }
201 
203  IntersectionIterator
204  iend ( const typename Codim< 0 >::Entity &entity ) const
205  {
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 >
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 >
244  {
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
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
268 
269  typedef typename Grid::Traits::template Codim< cd >::Entity Entity;
270  typedef typename Grid::Traits::template Codim< cd >::EntityPointer
272 
273  typedef typename Grid::template Codim< cd >::Geometry Geometry;
274  typedef typename Grid::template Codim< cd >::LocalGeometry
276 
278  template <PartitionIteratorType pit >
279  struct Partition
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:
298 
300  typedef typename Traits::Grid Grid;
301 
303  typedef typename Traits::IndexSet IndexSet;
304 
307 
310 
313 
315  template< int cd >
316  struct Codim : public Traits::template Codim<cd> {};
317 
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 
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() );
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 >
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
Codim< cd >::template Partition< pit >::Iterator begin() const
obtain begin iterator for this view
Definition: albertagrid/gridview.hh:166
Grid::template Codim< cd >::Geometry Geometry
Definition: albertagrid/gridview.hh:273
void communicate(CommDataHandleIF< DataHandleImp, DataType > &data, InterfaceType iftype, CommunicationDirection dir) const
Definition: albertagrid/gridview.hh:230
Grid::Traits::LevelIntersectionIterator IntersectionIterator
type of the intersection iterator
Definition: albertagrid/gridview.hh:42
Traits::Grid Grid
type of the grid
Definition: albertagrid/gridview.hh:84
Traits::IndexSet IndexSet
type of the index set
Definition: albertagrid/gridview.hh:303
Definition: albertagrid/gridview.hh:102
Definition: albertagrid/gridview.hh:264
Define types needed to iterate over entities of a given partition type.
Definition: albertagrid/gridview.hh:279
Grid::template Codim< cd >::template Partition< pit >::LeafIterator Iterator
iterator over a given codim and partition type
Definition: albertagrid/gridview.hh:283
const IndexSet & indexSet() const
obtain the index set
Definition: albertagrid/gridview.hh:353
Codim< cd >::template Partition< pit >::Iterator end() const
obtain end iterator for this view
Definition: albertagrid/gridview.hh:180
InterfaceType
Parameter to be used for the communication functions.
Definition: gridenums.hh:84
Definition: albertagrid/gridview.hh:20
AlbertaLevelGridView< GridImp, pitype > GridViewImp
Definition: albertagrid/gridview.hh:29
int ghostSize(int codim) const
Return size of the ghost region for a given codim on the grid view.
Definition: albertagrid/gridview.hh:439
Codim< cd >::Iterator end() const
obtain end iterator for this view
Definition: albertagrid/gridview.hh:173
Traits::Grid Grid
type of the grid
Definition: albertagrid/gridview.hh:300
AlbertaLevelGridView(const Grid &grid, int level)
Definition: albertagrid/gridview.hh:110
Definition: albertagrid/intersectioniterator.hh:34
Traits::CollectiveCommunication CollectiveCommunication
type of the collective communication
Definition: albertagrid/gridview.hh:96
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:178
Traits::Intersection Intersection
type of the intersection
Definition: albertagrid/gridview.hh:90
int size(int codim) const
obtain number of entities in a given codimension
Definition: albertagrid/gridview.hh:146
Traits::IndexSet IndexSet
type of the index set
Definition: albertagrid/gridview.hh:87
AlbertaLevelGridViewTraits< GridImp, pitype > Traits
Definition: albertagrid/gridview.hh:81
Include standard header files.
Definition: agrid.hh:59
int size(int codim) const
obtain number of entities in a given codimension
Definition: albertagrid/gridview.hh:359
int size(const GeometryType &type) const
obtain number of entities with a given geometry type
Definition: albertagrid/gridview.hh:365
Grid::Traits::template Codim< cd >::Entity Entity
Definition: albertagrid/gridview.hh:53
Definition: albertagrid/gridview.hh:27
Definition: albertagrid/gridview.hh:243
AlbertaLeafGridViewTraits< GridImp, pitype > Traits
Definition: albertagrid/gridview.hh:297
Grid::Traits::CollectiveCommunication CollectiveCommunication
type of the collective communication
Definition: albertagrid/gridview.hh:261
const IndexSet & indexSet() const
obtain the index set
Definition: albertagrid/gridview.hh:140
Grid::Traits::template Codim< cd >::template Partition< pitype >::LevelIterator Iterator
Definition: albertagrid/gridview.hh:51
Grid::Traits::template Codim< cd >::Entity Entity
Definition: albertagrid/gridview.hh:269
AlbertaLeafGridView< GridImp, pitype > GridViewImp
Definition: albertagrid/gridview.hh:245
Grid::Traits::template Codim< cd >::EntityPointer EntityPointer
Definition: albertagrid/gridview.hh:55
IntersectionIterator iend(const typename Codim< 0 >::Entity &entity) const
obtain end intersection iterator with respect to this view
Definition: albertagrid/gridview.hh:204
Codim Structure.
Definition: albertagrid/gridview.hh:100
remove_const< GridImp >::type Grid
type of the grid
Definition: albertagrid/gridview.hh:248
CommDataHandleIF describes the features of a data handle for communication in parallel runs using the...
Definition: datahandleif.hh:72
Codim< cd >::Iterator begin() const
obtain begin iterator for this view
Definition: albertagrid/gridview.hh:372
Grid::template Codim< cd >::LocalGeometry LocalGeometry
Definition: albertagrid/gridview.hh:59
Codim< cd >::Iterator end() const
obtain end iterator for this view
Definition: albertagrid/gridview.hh:386
Grid::Traits::LeafIntersection Intersection
type of the intersection
Definition: albertagrid/gridview.hh:254
const CollectiveCommunication & comm() const
obtain collective communication object
Definition: albertagrid/gridview.hh:427
void communicate(CommDataHandleIF< DataHandleImp, DataType > &data, InterfaceType iftype, CommunicationDirection dir) const
Definition: albertagrid/gridview.hh:446
int size(const GeometryType &type) const
obtain number of entities with a given geometry type
Definition: albertagrid/gridview.hh:152
Grid::template Codim< cd >::Geometry Geometry
Definition: albertagrid/gridview.hh:57
The dimension of the grid.
Definition: common/grid.hh:402
int overlapSize(int codim) const
Return size of the overlap region for a given codim on the grid view.
Definition: albertagrid/gridview.hh:433
const CollectiveCommunication & comm() const
obtain collective communication object
Definition: albertagrid/gridview.hh:211
Grid::Traits::CollectiveCommunication CollectiveCommunication
type of the collective communication
Definition: albertagrid/gridview.hh:45
Grid::Traits::LevelIntersection Intersection
type of the intersection
Definition: albertagrid/gridview.hh:38
Definition: albertagrid/gridview.hh:48
Specialize with 'true' if implementation guarantees conforming level grids. (default=false) ...
Definition: common/capabilities.hh:98
ALBERTA EL_INFO & elInfo() const
Definition: elementinfo.hh:742
Definition: albertagrid/gridview.hh:23
Codim Structure.
Definition: albertagrid/gridview.hh:316
Grid::Traits::LeafIndexSet IndexSet
type of the index set
Definition: albertagrid/gridview.hh:251
Definition: albertagrid/gridview.hh:71
Definition: albertagrid/intersectioniterator.hh:33
Specialize with 'true' if implementation guarantees a conforming leaf grid. (default=false) ...
Definition: common/capabilities.hh:107
Traits::CollectiveCommunication CollectiveCommunication
type of the collective communication
Definition: albertagrid/gridview.hh:312
Definition: elementinfo.hh:40
Traits::IntersectionIterator IntersectionIterator
type of the intersection iterator
Definition: albertagrid/gridview.hh:93
Grid::Traits::LeafIntersectionIterator IntersectionIterator
type of the intersection iterator
Definition: albertagrid/gridview.hh:258
Definition: albertagrid/entity.hh:33
int overlapSize(int codim) const
Return size of the overlap region for a given codim on the grid view.
Definition: albertagrid/gridview.hh:217
IntersectionIterator iend(const typename Codim< 0 >::Entity &entity) const
obtain end intersection iterator with respect to this view
Definition: albertagrid/gridview.hh:419
Implementation of the IntersectionIterator for AlbertaGrid.
Definition: albertagrid/gridview.hh:287
Traits::IntersectionIterator IntersectionIterator
type of the intersection iterator
Definition: albertagrid/gridview.hh:309
Grid::Traits::template Codim< cd >::template Partition< pitype >::LeafIterator Iterator
Definition: albertagrid/gridview.hh:267
Codim< cd >::template Partition< pit >::Iterator begin() const
obtain begin iterator for this view
Definition: albertagrid/gridview.hh:379
Grid::template Codim< cd >::template Partition< pit >::LevelIterator Iterator
iterator over a given codim and partition type
Definition: albertagrid/gridview.hh:67
CommunicationDirection
Define a type for communication direction parameter.
Definition: gridenums.hh:168
Grid::Traits::template Codim< cd >::EntityPointer EntityPointer
Definition: albertagrid/gridview.hh:271
Define types needed to iterate over entities of a given partition type.
Definition: albertagrid/gridview.hh:63
const Grid & grid() const
obtain a const reference to the underlying hierarchic grid
Definition: albertagrid/gridview.hh:347
int ghostSize(int codim) const
Return size of the ghost region for a given codim on the grid view.
Definition: albertagrid/gridview.hh:223
Traits::Intersection Intersection
type of the intersection
Definition: albertagrid/gridview.hh:306
remove_const< GridImp >::type Grid
type of the grid
Definition: albertagrid/gridview.hh:32
Definition: albertagrid/gridview.hh:318
Grid::Traits::LevelIndexSet IndexSet
type of the index set
Definition: albertagrid/gridview.hh:35
Codim< cd >::template Partition< pit >::Iterator end() const
obtain end iterator for this view
Definition: albertagrid/gridview.hh:393
AlbertaLeafGridView(const Grid &grid)
Definition: albertagrid/gridview.hh:326
IntersectionIterator ibegin(const typename Codim< 0 >::Entity &entity) const
obtain begin intersection iterator with respect to this view
Definition: albertagrid/gridview.hh:187
A set of traits classes to store static information about grid implementation.
Grid::template Codim< cd >::LocalGeometry LocalGeometry
Definition: albertagrid/gridview.hh:275
IntersectionIterator ibegin(const typename Codim< 0 >::Entity &entity) const
obtain begin intersection iterator with respect to this view
Definition: albertagrid/gridview.hh:400
Codim< cd >::Iterator begin() const
obtain begin iterator for this view
Definition: albertagrid/gridview.hh:159
const Grid & grid() const
obtain a const reference to the underlying hierarchic grid
Definition: albertagrid/gridview.hh:134