dune-grid  2.5.0
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 >
21 
22  template< class GridImp >
24 
25 
26  template< class GridImp >
28  {
30 
32  typedef typename std::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  {
51 
52  typedef typename Grid::Traits::template Codim< cd >::Entity Entity;
53 
54  typedef typename Grid::template Codim< cd >::Geometry Geometry;
55  typedef typename Grid::template Codim< cd >::LocalGeometry
57 
59  template< PartitionIteratorType pit >
60  struct Partition
61  {
63  typedef typename Grid::template Codim< cd >::template Partition< pit >::LevelIterator
65  };
66  };
67 
69  };
70 
71 
72  template< class GridImp >
74  {
75  typedef AlbertaLevelGridView< GridImp > ThisType;
76 
77  public:
79 
81  typedef typename Traits::Grid Grid;
82 
84  typedef typename Traits::IndexSet IndexSet;
85 
88 
91 
94 
96  template< int cd >
97  struct Codim : public Traits::template Codim<cd> {};
98 
100 
101  private:
103 
105 
106  public:
107  AlbertaLevelGridView ( const Grid &grid, int level )
108  : grid_( &grid ),
109  indexSet_( &(grid.levelIndexSet( level )) ),
110  level_( level )
111  {}
112 
113  // use default implementation of copy constructor and assignment operator
114 #if 0
115  AlbertaLevelGridView ( const ThisType &other )
116  : grid_( other.grid_ ),
117  indexSet_( other.indexSet_ ),
118  level_( other.level_ )
119  {}
120 
122  ThisType &operator= ( const ThisType & other)
123  {
124  grid_ = other.grid_;
125  indexSet_ = other.indexSet_;
126  level_ = other.level_;
127  }
128 #endif
129 
131  const Grid &grid () const
132  {
133  return *grid_;
134  }
135 
137  const IndexSet &indexSet () const
138  {
139  return *indexSet_;
140  }
141 
143  int size ( int codim ) const
144  {
145  return grid().size( level_, codim );
146  }
147 
149  int size ( const GeometryType &type ) const
150  {
151  return grid().size( level_, type );
152  }
153 
155  template< int cd >
156  typename Codim< cd >::Iterator begin () const
157  {
158  return grid().template lbegin< cd, All_Partition >( level_ );
159  }
160 
162  template< int cd, PartitionIteratorType pit >
164  {
165  return grid().template lbegin< cd, pit >( level_ );
166  }
167 
169  template< int cd >
170  typename Codim< cd >::Iterator end () const
171  {
172  return grid().template lend< cd, All_Partition >( level_ );
173  }
174 
176  template< int cd, PartitionIteratorType pit >
178  {
179  return grid().template lend< cd, pit >( level_ );
180  }
181 
183  IntersectionIterator
184  ibegin ( const typename Codim< 0 >::Entity &entity ) const
185  {
186  if( grid().maxLevel() == 0)
187  {
188  typename IntersectionIteratorImpl::Begin begin;
189  return IntersectionIteratorImpl( Grid::getRealImplementation( entity ), begin );
190  }
191  else
192  {
193  DUNE_THROW( NotImplemented, "method ibegin not implemented on LevelGridView for AlbertaGrid." );
194  typename IntersectionIteratorImpl::End end;
195  return IntersectionIteratorImpl( Grid::getRealImplementation( entity ), end );
196  }
197  }
198 
200  IntersectionIterator
201  iend ( const typename Codim< 0 >::Entity &entity ) const
202  {
203  typename IntersectionIteratorImpl::End end;
204  return IntersectionIteratorImpl( Grid::getRealImplementation( entity ), end );
205  }
206 
208  const CollectiveCommunication &comm () const
209  {
210  return grid().comm();
211  }
212 
214  int overlapSize(int codim) const
215  {
216  return grid().overlapSize(level_, codim);
217  }
218 
220  int ghostSize(int codim) const
221  {
222  return grid().ghostSize(level_, codim);
223  }
224 
226  template< class DataHandleImp, class DataType >
228  InterfaceType iftype,
229  CommunicationDirection dir ) const
230  {}
231 
232  private:
233  const Grid *grid_;
234  const IndexSet *indexSet_;
235  int level_;
236  };
237 
238 
239  template< class GridImp >
241  {
243 
245  typedef typename std::remove_const<GridImp>::type Grid;
246 
248  typedef typename Grid::Traits::LeafIndexSet IndexSet;
249 
251  typedef typename Grid::Traits::LeafIntersection Intersection;
252 
254  typedef typename Grid::Traits::LeafIntersectionIterator
256 
258  typedef typename Grid::Traits::CollectiveCommunication CollectiveCommunication;
259 
260  template< int cd >
261  struct Codim
262  {
263  typedef typename Grid::Traits::template Codim< cd >::template Partition< All_Partition >::LeafIterator
265 
266  typedef typename Grid::Traits::template Codim< cd >::Entity Entity;
267 
268  typedef typename Grid::template Codim< cd >::Geometry Geometry;
269  typedef typename Grid::template Codim< cd >::LocalGeometry
271 
273  template <PartitionIteratorType pit >
274  struct Partition
275  {
277  typedef typename Grid::template Codim< cd >::template Partition< pit >::LeafIterator
279  };
280  };
281 
283  };
284 
285 
286  template< class GridImp >
287  class AlbertaLeafGridView
288  {
289  typedef AlbertaLeafGridView< GridImp > ThisType;
290 
291  public:
293 
295  typedef typename Traits::Grid Grid;
296 
298  typedef typename Traits::IndexSet IndexSet;
299 
302 
305 
308 
310  template< int cd >
311  struct Codim : public Traits::template Codim<cd> {};
312 
314 
315  private:
317 
319 
320  public:
321  AlbertaLeafGridView ( const Grid &grid )
322  : grid_( &grid ),
323  indexSet_( &(grid.leafIndexSet()) )
324  {}
325 
326  // use default implementation of copy constructor and assignment operator
327 #if 0
328  AlbertaLeafGridView ( const ThisType &other )
329  : grid_( other.grid_ ),
330  indexSet_( other.indexSet_ )
331  {}
332 
334  ThisType &operator= ( const ThisType & other)
335  {
336  grid_ = other.grid_;
337  indexSet_ = other.indexSet_;
338  }
339 #endif
340 
342  const Grid &grid () const
343  {
344  return *grid_;
345  }
346 
348  const IndexSet &indexSet () const
349  {
350  return *indexSet_;
351  }
352 
354  int size ( int codim ) const
355  {
356  return grid().size( codim );
357  }
358 
360  int size ( const GeometryType &type ) const
361  {
362  return grid().size( type );
363  }
364 
366  template< int cd >
367  typename Codim< cd >::Iterator begin () const
368  {
369  return grid().template leafbegin< cd, All_Partition >();
370  }
371 
373  template< int cd, PartitionIteratorType pit >
375  {
376  return grid().template leafbegin< cd, pit >();
377  }
378 
380  template< int cd >
381  typename Codim< cd >::Iterator end () const
382  {
383  return grid().template leafend< cd, All_Partition >();
384  }
385 
387  template< int cd, PartitionIteratorType pit >
389  {
390  return grid().template leafend< cd, pit >();
391  }
392 
394  IntersectionIterator
395  ibegin ( const typename Codim< 0 >::Entity &entity ) const
396  {
397  const ElementInfo elementInfo = Grid::getRealImplementation( entity ).elementInfo();
398  assert( !!elementInfo );
399 
400 #ifndef NDEBUG
401  for( int i = 0; i <= Grid::dimension; ++i )
402  {
403  if( elementInfo.elInfo().opp_vertex[ i ] == 127 )
404  DUNE_THROW( NotImplemented, "AlbertaGrid: Intersections on outside entities are not fully implemented, yet." );
405  }
406 #endif // #ifndef NDEBUG
407 
408  typename IntersectionIteratorImpl::Begin begin;
409  return IntersectionIteratorImpl( Grid::getRealImplementation( entity ), begin );
410  }
411 
413  IntersectionIterator
414  iend ( const typename Codim< 0 >::Entity &entity ) const
415  {
416  assert( !!Grid::getRealImplementation( entity ).elementInfo() );
417  typename IntersectionIteratorImpl::End end;
418  return IntersectionIteratorImpl( Grid::getRealImplementation( entity ), end );
419  }
420 
422  const CollectiveCommunication &comm () const
423  {
424  return grid().comm();
425  }
426 
428  int overlapSize(int codim) const
429  {
430  return grid().overlapSize(codim);
431  }
432 
434  int ghostSize(int codim) const
435  {
436  return grid().ghostSize(codim);
437  }
438 
440  template< class DataHandleImp, class DataType >
442  InterfaceType iftype,
443  CommunicationDirection dir ) const
444  {}
445 
446  private:
447  const Grid *grid_;
448  const IndexSet *indexSet_;
449  };
450 
451 }
452 
453 #endif // #if HAVE_ALBERTA
454 #endif // #ifndef DUNE_ALBERTAGRID_GRIDVIEW_HH
Traits::Grid Grid
type of the grid
Definition: albertagrid/gridview.hh:295
Grid::Traits::LeafIntersectionIterator IntersectionIterator
type of the intersection iterator
Definition: albertagrid/gridview.hh:255
Traits::Intersection Intersection
type of the intersection
Definition: albertagrid/gridview.hh:301
Traits::CollectiveCommunication CollectiveCommunication
type of the collective communication
Definition: albertagrid/gridview.hh:307
Codim< cd >::Iterator end() const
obtain end iterator for this view
Definition: albertagrid/gridview.hh:381
AlbertaLeafGridView(const Grid &grid)
Definition: albertagrid/gridview.hh:321
Grid::Traits::template Codim< cd >::template Partition< All_Partition >::LevelIterator Iterator
Definition: albertagrid/gridview.hh:50
Grid::Traits::LevelIndexSet IndexSet
type of the index set
Definition: albertagrid/gridview.hh:35
const IndexSet & indexSet() const
obtain the index set
Definition: albertagrid/gridview.hh:137
void communicate(CommDataHandleIF< DataHandleImp, DataType > &data, InterfaceType iftype, CommunicationDirection dir) const
Definition: albertagrid/gridview.hh:227
GeometryType
Type representing VTK&#39;s entity geometry types.
Definition: common.hh:178
int size(const GeometryType &type) const
obtain number of entities with a given geometry type
Definition: albertagrid/gridview.hh:149
Traits::IntersectionIterator IntersectionIterator
type of the intersection iterator
Definition: albertagrid/gridview.hh:304
Definition: albertagrid/intersectioniterator.hh:34
int overlapSize(int codim) const
Return size of the overlap region for a given codim on the grid view.
Definition: albertagrid/gridview.hh:428
Grid::Traits::CollectiveCommunication CollectiveCommunication
type of the collective communication
Definition: albertagrid/gridview.hh:45
CommunicationDirection
Define a type for communication direction parameter.
Definition: gridenums.hh:168
AlbertaLevelGridViewTraits< GridImp > Traits
Definition: albertagrid/gridview.hh:78
Grid::Traits::LeafIntersection Intersection
type of the intersection
Definition: albertagrid/gridview.hh:251
IntersectionIterator ibegin(const typename Codim< 0 >::Entity &entity) const
obtain begin intersection iterator with respect to this view
Definition: albertagrid/gridview.hh:395
int size(int codim) const
obtain number of entities in a given codimension
Definition: albertagrid/gridview.hh:143
Grid::template Codim< cd >::Geometry Geometry
Definition: albertagrid/gridview.hh:268
Grid::Traits::LeafIndexSet IndexSet
type of the index set
Definition: albertagrid/gridview.hh:248
Grid::Traits::CollectiveCommunication CollectiveCommunication
type of the collective communication
Definition: albertagrid/gridview.hh:258
int size(int codim) const
obtain number of entities in a given codimension
Definition: albertagrid/gridview.hh:354
AlbertaLevelGridView< GridImp > GridViewImp
Definition: albertagrid/gridview.hh:29
Definition: albertagrid/gridview.hh:48
Grid::Traits::template Codim< cd >::Entity Entity
Definition: albertagrid/gridview.hh:52
Output conforming data.
Definition: common.hh:70
Grid::template Codim< cd >::Geometry Geometry
Definition: albertagrid/gridview.hh:54
std::remove_const< GridImp >::type Grid
type of the grid
Definition: albertagrid/gridview.hh:32
Codim< cd >::template Partition< pit >::Iterator begin() const
obtain begin iterator for this view
Definition: albertagrid/gridview.hh:163
const IndexSet & indexSet() const
obtain the index set
Definition: albertagrid/gridview.hh:348
int overlapSize(int codim) const
Return size of the overlap region for a given codim on the grid view.
Definition: albertagrid/gridview.hh:214
Grid::Traits::template Codim< cd >::template Partition< All_Partition >::LeafIterator Iterator
Definition: albertagrid/gridview.hh:264
int ghostSize(int codim) const
Return size of the ghost region for a given codim on the grid view.
Definition: albertagrid/gridview.hh:220
Define types needed to iterate over entities of a given partition type.
Definition: albertagrid/gridview.hh:274
Grid::Traits::LevelIntersectionIterator IntersectionIterator
type of the intersection iterator
Definition: albertagrid/gridview.hh:42
Grid::template Codim< cd >::template Partition< pit >::LevelIterator Iterator
iterator over a given codim and partition type
Definition: albertagrid/gridview.hh:64
Definition: albertagrid/gridview.hh:20
Grid::Traits::LevelIntersection Intersection
type of the intersection
Definition: albertagrid/gridview.hh:38
AlbertaLeafGridView< GridImp > GridViewImp
Definition: albertagrid/gridview.hh:242
Grid::template Codim< cd >::template Partition< pit >::LeafIterator Iterator
iterator over a given codim and partition type
Definition: albertagrid/gridview.hh:278
Grid::template Codim< cd >::LocalGeometry LocalGeometry
Definition: albertagrid/gridview.hh:56
Traits::Grid Grid
type of the grid
Definition: albertagrid/gridview.hh:81
Traits::Intersection Intersection
type of the intersection
Definition: albertagrid/gridview.hh:87
std::remove_const< GridImp >::type Grid
type of the grid
Definition: albertagrid/gridview.hh:245
A set of traits classes to store static information about grid implementation.
IntersectionIterator ibegin(const typename Codim< 0 >::Entity &entity) const
obtain begin intersection iterator with respect to this view
Definition: albertagrid/gridview.hh:184
Codim Structure.
Definition: albertagrid/gridview.hh:97
Grid::template Codim< cd >::LocalGeometry LocalGeometry
Definition: albertagrid/gridview.hh:270
Traits::CollectiveCommunication CollectiveCommunication
type of the collective communication
Definition: albertagrid/gridview.hh:93
Include standard header files.
Definition: agrid.hh:59
Definition: albertagrid/entity.hh:33
Definition: albertagrid/gridview.hh:27
Codim< cd >::Iterator begin() const
obtain begin iterator for this view
Definition: albertagrid/gridview.hh:156
const Grid & grid() const
obtain a const reference to the underlying hierarchic grid
Definition: albertagrid/gridview.hh:131
Codim< cd >::template Partition< pit >::Iterator end() const
obtain end iterator for this view
Definition: albertagrid/gridview.hh:177
AlbertaLevelGridView(const Grid &grid, int level)
Definition: albertagrid/gridview.hh:107
CommDataHandleIF describes the features of a data handle for communication in parallel runs using the...
Definition: datahandleif.hh:72
void communicate(CommDataHandleIF< DataHandleImp, DataType > &data, InterfaceType iftype, CommunicationDirection dir) const
Definition: albertagrid/gridview.hh:441
IntersectionIterator iend(const typename Codim< 0 >::Entity &entity) const
obtain end intersection iterator with respect to this view
Definition: albertagrid/gridview.hh:414
Definition: albertagrid/gridview.hh:68
Codim< cd >::template Partition< pit >::Iterator end() const
obtain end iterator for this view
Definition: albertagrid/gridview.hh:388
Definition: albertagrid/gridview.hh:261
Specialize with &#39;true&#39; if implementation guarantees a conforming leaf grid. (default=false) ...
Definition: common/capabilities.hh:86
Codim< cd >::template Partition< pit >::Iterator begin() const
obtain begin iterator for this view
Definition: albertagrid/gridview.hh:374
Define types needed to iterate over entities of a given partition type.
Definition: albertagrid/gridview.hh:60
const CollectiveCommunication & comm() const
obtain collective communication object
Definition: albertagrid/gridview.hh:208
Definition: albertagrid/gridview.hh:23
Traits::IntersectionIterator IntersectionIterator
type of the intersection iterator
Definition: albertagrid/gridview.hh:90
IntersectionIterator iend(const typename Codim< 0 >::Entity &entity) const
obtain end intersection iterator with respect to this view
Definition: albertagrid/gridview.hh:201
Codim Structure.
Definition: albertagrid/gridview.hh:311
Definition: elementinfo.hh:40
AlbertaLeafGridViewTraits< GridImp > Traits
Definition: albertagrid/gridview.hh:292
Implementation of the IntersectionIterator for AlbertaGrid.
Traits::IndexSet IndexSet
type of the index set
Definition: albertagrid/gridview.hh:84
const Grid & grid() const
obtain a const reference to the underlying hierarchic grid
Definition: albertagrid/gridview.hh:342
Definition: albertagrid/gridview.hh:240
Specialize with &#39;true&#39; if implementation guarantees conforming level grids. (default=false) ...
Definition: common/capabilities.hh:77
Traits::IndexSet IndexSet
type of the index set
Definition: albertagrid/gridview.hh:298
The dimension of the grid.
Definition: common/grid.hh:387
Definition: albertagrid/intersectioniterator.hh:33
Codim< cd >::Iterator end() const
obtain end iterator for this view
Definition: albertagrid/gridview.hh:170
int ghostSize(int codim) const
Return size of the ghost region for a given codim on the grid view.
Definition: albertagrid/gridview.hh:434
Grid::Traits::template Codim< cd >::Entity Entity
Definition: albertagrid/gridview.hh:266
const CollectiveCommunication & comm() const
obtain collective communication object
Definition: albertagrid/gridview.hh:422
InterfaceType
Parameter to be used for the communication functions.
Definition: gridenums.hh:84
Codim< cd >::Iterator begin() const
obtain begin iterator for this view
Definition: albertagrid/gridview.hh:367
ALBERTA EL_INFO & elInfo() const
Definition: elementinfo.hh:742
int size(const GeometryType &type) const
obtain number of entities with a given geometry type
Definition: albertagrid/gridview.hh:360