dune-grid  2.3.1
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 
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 
204  iend ( const typename Codim< 0 >::Entity &entity ) const
205  {
207  return IntersectionIteratorImpl( Grid::getRealImplementation( entity ), end );
208  }
209 
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:
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 
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 
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 
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
Traits::Grid Grid
type of the grid
Definition: albertagrid/gridview.hh:84
IntersectionIterator ibegin(const typename Codim< 0 >::Entity &entity) const
obtain begin intersection iterator with respect to this view
Definition: albertagrid/gridview.hh:400
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: elementinfo.hh:39
Grid::template Codim< cd >::template Partition< pit >::LevelIterator Iterator
iterator over a given codim and partition type
Definition: albertagrid/gridview.hh:67
const CollectiveCommunication & comm() const
obtain collective communication object
Definition: albertagrid/gridview.hh:211
Definition: albertagrid/intersectioniterator.hh:33
void communicate(CommDataHandleIF< DataHandleImp, DataType > &data, InterfaceType iftype, CommunicationDirection dir) const
Definition: albertagrid/gridview.hh:230
Traits::IntersectionIterator IntersectionIterator
type of the intersection iterator
Definition: albertagrid/gridview.hh:93
Definition: albertagrid/gridview.hh:27
Grid::Traits::LeafIntersection Intersection
type of the intersection
Definition: albertagrid/gridview.hh:254
Traits::IndexSet IndexSet
type of the index set
Definition: albertagrid/gridview.hh:303
AlbertaLeafGridViewTraits< GridImp, pitype > Traits
Definition: albertagrid/gridview.hh:297
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:243
Codim Structure.
Definition: albertagrid/gridview.hh:100
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:178
Grid::template Codim< cd >::Geometry Geometry
Definition: albertagrid/gridview.hh:57
Grid::Traits::LevelIntersectionIterator IntersectionIterator
type of the intersection iterator
Definition: albertagrid/gridview.hh:42
Codim< cd >::template Partition< pit >::Iterator end() const
obtain end iterator for this view
Definition: albertagrid/gridview.hh:180
Index Set Interface base class.
Definition: common/grid.hh:359
Grid::Traits::template Codim< cd >::template Partition< pitype >::LeafIterator Iterator
Definition: albertagrid/gridview.hh:267
Definition: albertagrid/gridview.hh:287
Grid::Traits::template Codim< cd >::template Partition< pitype >::LevelIterator Iterator
Definition: albertagrid/gridview.hh:51
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::CollectiveCommunication CollectiveCommunication
type of the collective communication
Definition: albertagrid/gridview.hh:96
Codim< cd >::Iterator begin() const
obtain begin iterator for this view
Definition: albertagrid/gridview.hh:372
Grid::template Codim< cd >::template Partition< pit >::LeafIterator Iterator
iterator over a given codim and partition type
Definition: albertagrid/gridview.hh:283
CommunicationDirection
Define a type for communication direction parameter.
Definition: gridenums.hh:164
Definition: albertagrid/gridview.hh:318
Codim< cd >::Iterator end() const
obtain end iterator for this view
Definition: albertagrid/gridview.hh:386
const Grid & grid() const
obtain a const reference to the underlying hierarchic grid
Definition: albertagrid/gridview.hh:134
Definition: albertagrid/gridview.hh:20
const IndexSet & indexSet() const
obtain the index set
Definition: albertagrid/gridview.hh:353
Definition: albertagrid/gridview.hh:264
Specialize with 'true' if implementation guarantees conforming level grids. (default=false) ...
Definition: common/capabilities.hh:86
Definition: albertagrid/gridview.hh:23
Definition: albertagrid/intersectioniterator.hh:34
Definition: albertagrid/gridview.hh:48
Grid::Traits::template Codim< cd >::Entity Entity
Definition: albertagrid/gridview.hh:269
int ghostSize(int codim) const
Return size of the ghost region for a given codim on the grid view.
Definition: albertagrid/gridview.hh:439
Grid::Traits::LeafIntersectionIterator IntersectionIterator
type of the intersection iterator
Definition: albertagrid/gridview.hh:258
Traits::Grid Grid
type of the grid
Definition: albertagrid/gridview.hh:300
Grid::template Codim< cd >::Geometry Geometry
Definition: albertagrid/gridview.hh:273
The dimension of the grid.
Definition: common/grid.hh:400
CommDataHandleIF describes the features of a data handle for communication in parallel runs using the...
Definition: datahandleif.hh:74
IntersectionIterator ibegin(const typename Codim< 0 >::Entity &entity) const
obtain begin intersection iterator with respect to this view
Definition: albertagrid/gridview.hh:187
IntersectionIterator iend(const typename Codim< 0 >::Entity &entity) const
obtain end intersection iterator with respect to this view
Definition: albertagrid/gridview.hh:204
const CollectiveCommunication & comm() const
obtain collective communication object
Definition: albertagrid/gridview.hh:427
int overlapSize(int codim) const
Return size of the overlap region for a given codim on the grid view.
Definition: albertagrid/gridview.hh:217
Grid::Traits::CollectiveCommunication CollectiveCommunication
type of the collective communication
Definition: albertagrid/gridview.hh:45
Grid::Traits::CollectiveCommunication CollectiveCommunication
type of the collective communication
Definition: albertagrid/gridview.hh:261
Specialize with 'true' if implementation guarantees a conforming leaf grid. (default=false) ...
Definition: common/capabilities.hh:95
Definition: albertagrid/entity.hh:33
Grid abstract base classThis class is the base class for all grid implementations. Although no virtual functions are used we call it abstract since its methods do not contain an implementation but forward to the methods of the derived class via the Barton-Nackman trick.
Definition: common/grid.hh:386
AlbertaLevelGridView< GridImp, pitype > GridViewImp
Definition: albertagrid/gridview.hh:29
Grid::template Codim< cd >::LocalGeometry LocalGeometry
Definition: albertagrid/gridview.hh:275
Traits::IntersectionIterator IntersectionIterator
type of the intersection iterator
Definition: albertagrid/gridview.hh:309
Codim< cd >::template Partition< pit >::Iterator begin() const
obtain begin iterator for this view
Definition: albertagrid/gridview.hh:379
Mesh entities of codimension 0 ("elements") allow to visit all intersections with "neighboring" eleme...
Definition: common/grid.hh:358
Grid::Traits::template Codim< cd >::EntityPointer EntityPointer
Definition: albertagrid/gridview.hh:271
int overlapSize(int codim) const
Return size of the overlap region for a given codim on the grid view.
Definition: albertagrid/gridview.hh:433
Grid::template Codim< cd >::LocalGeometry LocalGeometry
Definition: albertagrid/gridview.hh:59
const Grid & grid() const
obtain a const reference to the underlying hierarchic grid
Definition: albertagrid/gridview.hh:347
Codim< cd >::Iterator end() const
obtain end iterator for this view
Definition: albertagrid/gridview.hh:173
Traits::Intersection Intersection
type of the intersection
Definition: albertagrid/gridview.hh:306
A set of traits classes to store static information about grid implementation.
remove_const< GridImp >::type Grid
type of the grid
Definition: albertagrid/gridview.hh:248
const IndexSet & indexSet() const
obtain the index set
Definition: albertagrid/gridview.hh:140
AlbertaLevelGridView(const Grid &grid, int level)
Definition: albertagrid/gridview.hh:110
Traits::Intersection Intersection
type of the intersection
Definition: albertagrid/gridview.hh:90
Traits::IndexSet IndexSet
type of the index set
Definition: albertagrid/gridview.hh:87
Codim< cd >::template Partition< pit >::Iterator end() const
obtain end iterator for this view
Definition: albertagrid/gridview.hh:393
Grid::Traits::LevelIndexSet IndexSet
type of the index set
Definition: albertagrid/gridview.hh:35
ALBERTA EL_INFO & elInfo() const
Definition: elementinfo.hh:804
void communicate(CommDataHandleIF< DataHandleImp, DataType > &data, InterfaceType iftype, CommunicationDirection dir) const
Definition: albertagrid/gridview.hh:446
Define types needed to iterate over entities of a given partition type.
Definition: albertagrid/gridview.hh:279
int size(const GeometryType &type) const
obtain number of entities with a given geometry type
Definition: albertagrid/gridview.hh:152
IntersectionIterator iend(const typename Codim< 0 >::Entity &entity) const
obtain end intersection iterator with respect to this view
Definition: albertagrid/gridview.hh:419
Traits::CollectiveCommunication CollectiveCommunication
type of the collective communication
Definition: albertagrid/gridview.hh:312
AlbertaLeafGridView< GridImp, pitype > GridViewImp
Definition: albertagrid/gridview.hh:245
remove_const< GridImp >::type Grid
type of the grid
Definition: albertagrid/gridview.hh:32
Grid::Traits::LevelIntersection Intersection
type of the intersection
Definition: albertagrid/gridview.hh:38
InterfaceType
Parameter to be used for the communication functions.
Definition: gridenums.hh:80
Define types needed to iterate over entities of a given partition type.
Definition: albertagrid/gridview.hh:63
Definition: albertagrid/gridview.hh:71
int size(int codim) const
obtain number of entities in a given codimension
Definition: albertagrid/gridview.hh:146
AlbertaLevelGridViewTraits< GridImp, pitype > Traits
Definition: albertagrid/gridview.hh:81
Grid::Traits::template Codim< cd >::EntityPointer EntityPointer
Definition: albertagrid/gridview.hh:55
Codim< cd >::Iterator begin() const
obtain begin iterator for this view
Definition: albertagrid/gridview.hh:159
Definition: albertagrid/gridview.hh:102
Implementation of the IntersectionIterator for AlbertaGrid.
Codim< cd >::template Partition< pit >::Iterator begin() const
obtain begin iterator for this view
Definition: albertagrid/gridview.hh:166
AlbertaLeafGridView(const Grid &grid)
Definition: albertagrid/gridview.hh:326