dune-grid  2.7.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 >
20  class AlbertaLevelGridView;
21 
22  template< class GridImp >
23  class AlbertaLeafGridView;
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  {
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:
102  typedef Alberta::ElementInfo< Grid::dimension > ElementInfo;
103 
104  typedef Dune::AlbertaGridLeafIntersectionIterator< GridImp > IntersectionIteratorImpl;
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 >
163  typename Codim< cd >::template Partition< pit >::Iterator begin () const
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 >
177  typename Codim< cd >::template Partition< pit >::Iterator end () const
178  {
179  return grid().template lend< cd, pit >( level_ );
180  }
181 
184  ibegin ( const typename Codim< 0 >::Entity &entity ) const
185  {
186  if( grid().maxLevel() == 0)
187  {
189  return IntersectionIteratorImpl( entity.impl(), begin );
190  }
191  else
192  {
193  DUNE_THROW( NotImplemented, "method ibegin not implemented on LevelGridView for AlbertaGrid." );
195  return IntersectionIteratorImpl( entity.impl(), end );
196  }
197  }
198 
201  iend ( const typename Codim< 0 >::Entity &entity ) const
202  {
204  return IntersectionIteratorImpl( entity.impl(), end );
205  }
206 
209  {
210  return grid().comm();
211  }
212 
214  int overlapSize ( int codim ) const { return 0; }
215 
217  int ghostSize ( int codim ) const { return 0; }
218 
220  template< class DataHandleImp, class DataType >
222  InterfaceType iftype,
223  CommunicationDirection dir ) const
224  {}
225 
226  private:
227  const Grid *grid_;
228  const IndexSet *indexSet_;
229  int level_;
230  };
231 
232 
233  template< class GridImp >
235  {
237 
239  typedef typename std::remove_const<GridImp>::type Grid;
240 
242  typedef typename Grid::Traits::LeafIndexSet IndexSet;
243 
245  typedef typename Grid::Traits::LeafIntersection Intersection;
246 
248  typedef typename Grid::Traits::LeafIntersectionIterator
250 
252  typedef typename Grid::Traits::CollectiveCommunication CollectiveCommunication;
253 
254  template< int cd >
255  struct Codim
256  {
257  typedef typename Grid::Traits::template Codim< cd >::template Partition< All_Partition >::LeafIterator
259 
260  typedef typename Grid::Traits::template Codim< cd >::Entity Entity;
261 
262  typedef typename Grid::template Codim< cd >::Geometry Geometry;
263  typedef typename Grid::template Codim< cd >::LocalGeometry
265 
267  template <PartitionIteratorType pit >
268  struct Partition
269  {
271  typedef typename Grid::template Codim< cd >::template Partition< pit >::LeafIterator
273  };
274  };
275 
277  };
278 
279 
280  template< class GridImp >
282  {
284 
285  public:
287 
289  typedef typename Traits::Grid Grid;
290 
292  typedef typename Traits::IndexSet IndexSet;
293 
296 
299 
302 
304  template< int cd >
305  struct Codim : public Traits::template Codim<cd> {};
306 
308 
309  private:
310  typedef Alberta::ElementInfo< Grid::dimension > ElementInfo;
311 
312  typedef Dune::AlbertaGridLeafIntersectionIterator< GridImp > IntersectionIteratorImpl;
313 
314  public:
316  : grid_( &grid ),
317  indexSet_( &(grid.leafIndexSet()) )
318  {}
319 
320  // use default implementation of copy constructor and assignment operator
321 #if 0
322  AlbertaLeafGridView ( const ThisType &other )
323  : grid_( other.grid_ ),
324  indexSet_( other.indexSet_ )
325  {}
326 
328  ThisType &operator= ( const ThisType & other)
329  {
330  grid_ = other.grid_;
331  indexSet_ = other.indexSet_;
332  }
333 #endif
334 
336  const Grid &grid () const
337  {
338  return *grid_;
339  }
340 
342  const IndexSet &indexSet () const
343  {
344  return *indexSet_;
345  }
346 
348  int size ( int codim ) const
349  {
350  return grid().size( codim );
351  }
352 
354  int size ( const GeometryType &type ) const
355  {
356  return grid().size( type );
357  }
358 
360  template< int cd >
361  typename Codim< cd >::Iterator begin () const
362  {
363  return grid().template leafbegin< cd, All_Partition >();
364  }
365 
367  template< int cd, PartitionIteratorType pit >
368  typename Codim< cd >::template Partition< pit >::Iterator begin () const
369  {
370  return grid().template leafbegin< cd, pit >();
371  }
372 
374  template< int cd >
375  typename Codim< cd >::Iterator end () const
376  {
377  return grid().template leafend< cd, All_Partition >();
378  }
379 
381  template< int cd, PartitionIteratorType pit >
382  typename Codim< cd >::template Partition< pit >::Iterator end () const
383  {
384  return grid().template leafend< cd, pit >();
385  }
386 
389  ibegin ( const typename Codim< 0 >::Entity &entity ) const
390  {
391  const ElementInfo elementInfo = entity.impl().elementInfo();
392  assert( !!elementInfo );
393 
394 #ifndef NDEBUG
395  for( int i = 0; i <= Grid::dimension; ++i )
396  {
397  if( elementInfo.elInfo().opp_vertex[ i ] == 127 )
398  DUNE_THROW( NotImplemented, "AlbertaGrid: Intersections on outside entities are not fully implemented, yet." );
399  }
400 #endif // #ifndef NDEBUG
401 
403  return IntersectionIteratorImpl( entity.impl(), begin );
404  }
405 
408  iend ( const typename Codim< 0 >::Entity &entity ) const
409  {
410  assert( !!entity.impl().elementInfo() );
412  return IntersectionIteratorImpl( entity.impl(), end );
413  }
414 
417  {
418  return grid().comm();
419  }
420 
422  int overlapSize ( int codim ) const { return 0; }
423 
425  int ghostSize ( int codim ) const { return 0; }
426 
428  template< class DataHandleImp, class DataType >
430  InterfaceType iftype,
431  CommunicationDirection dir ) const
432  {}
433 
434  private:
435  const Grid *grid_;
436  const IndexSet *indexSet_;
437  };
438 
439 }
440 
441 #endif // #if HAVE_ALBERTA
442 #endif // #ifndef DUNE_ALBERTAGRID_GRIDVIEW_HH
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
Include standard header files.
Definition: agrid.hh:59
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:180
Definition: elementinfo.hh:41
ALBERTA EL_INFO & elInfo() const
Definition: elementinfo.hh:742
Definition: albertagrid/intersectioniterator.hh:25
Definition: albertagrid/gridview.hh:74
Traits::Intersection Intersection
type of the intersection
Definition: albertagrid/gridview.hh:87
int size(const GeometryType &type) const
obtain number of entities with a given geometry type
Definition: albertagrid/gridview.hh:149
void communicate(CommDataHandleIF< DataHandleImp, DataType > &data, InterfaceType iftype, CommunicationDirection dir) const
Definition: albertagrid/gridview.hh:221
Traits::IndexSet IndexSet
type of the index set
Definition: albertagrid/gridview.hh:84
IntersectionIterator iend(const typename Codim< 0 >::Entity &entity) const
obtain end intersection iterator with respect to this view
Definition: albertagrid/gridview.hh:201
Codim< cd >::template Partition< pit >::Iterator begin() const
obtain begin iterator for this view
Definition: albertagrid/gridview.hh:163
AlbertaLevelGridView(const Grid &grid, int level)
Definition: albertagrid/gridview.hh:107
Traits::Grid Grid
type of the grid
Definition: albertagrid/gridview.hh:81
@ conforming
Definition: albertagrid/gridview.hh:99
int size(int codim) const
obtain number of entities in a given codimension
Definition: albertagrid/gridview.hh:143
AlbertaLevelGridViewTraits< GridImp > Traits
Definition: albertagrid/gridview.hh:78
const IndexSet & indexSet() const
obtain the index set
Definition: albertagrid/gridview.hh:137
int ghostSize(int codim) const
Return size of the ghost region for a given codim on the grid view.
Definition: albertagrid/gridview.hh:217
Traits::CollectiveCommunication CollectiveCommunication
type of the collective communication
Definition: albertagrid/gridview.hh:93
Codim< cd >::Iterator end() const
obtain end iterator for this view
Definition: albertagrid/gridview.hh:170
const CollectiveCommunication & comm() const
obtain collective communication object
Definition: albertagrid/gridview.hh:208
Codim< cd >::Iterator begin() const
obtain begin iterator for this view
Definition: albertagrid/gridview.hh:156
Traits::IntersectionIterator IntersectionIterator
type of the intersection iterator
Definition: albertagrid/gridview.hh:90
int overlapSize(int codim) const
Return size of the overlap region for a given codim on the grid view.
Definition: albertagrid/gridview.hh:214
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
IntersectionIterator ibegin(const typename Codim< 0 >::Entity &entity) const
obtain begin intersection iterator with respect to this view
Definition: albertagrid/gridview.hh:184
Definition: albertagrid/gridview.hh:282
const Grid & grid() const
obtain a const reference to the underlying hierarchic grid
Definition: albertagrid/gridview.hh:336
AlbertaLeafGridView(const Grid &grid)
Definition: albertagrid/gridview.hh:315
Traits::IndexSet IndexSet
type of the index set
Definition: albertagrid/gridview.hh:292
int ghostSize(int codim) const
Return size of the ghost region for a given codim on the grid view.
Definition: albertagrid/gridview.hh:425
Traits::CollectiveCommunication CollectiveCommunication
type of the collective communication
Definition: albertagrid/gridview.hh:301
int size(int codim) const
obtain number of entities in a given codimension
Definition: albertagrid/gridview.hh:348
AlbertaLeafGridViewTraits< GridImp > Traits
Definition: albertagrid/gridview.hh:286
Codim< cd >::Iterator begin() const
obtain begin iterator for this view
Definition: albertagrid/gridview.hh:361
Traits::Grid Grid
type of the grid
Definition: albertagrid/gridview.hh:289
Codim< cd >::template Partition< pit >::Iterator end() const
obtain end iterator for this view
Definition: albertagrid/gridview.hh:382
void communicate(CommDataHandleIF< DataHandleImp, DataType > &data, InterfaceType iftype, CommunicationDirection dir) const
Definition: albertagrid/gridview.hh:429
const CollectiveCommunication & comm() const
obtain collective communication object
Definition: albertagrid/gridview.hh:416
@ conforming
Definition: albertagrid/gridview.hh:307
IntersectionIterator ibegin(const typename Codim< 0 >::Entity &entity) const
obtain begin intersection iterator with respect to this view
Definition: albertagrid/gridview.hh:389
int size(const GeometryType &type) const
obtain number of entities with a given geometry type
Definition: albertagrid/gridview.hh:354
IntersectionIterator iend(const typename Codim< 0 >::Entity &entity) const
obtain end intersection iterator with respect to this view
Definition: albertagrid/gridview.hh:408
Traits::IntersectionIterator IntersectionIterator
type of the intersection iterator
Definition: albertagrid/gridview.hh:298
Traits::Intersection Intersection
type of the intersection
Definition: albertagrid/gridview.hh:295
const IndexSet & indexSet() const
obtain the index set
Definition: albertagrid/gridview.hh:342
Codim< cd >::Iterator end() const
obtain end iterator for this view
Definition: albertagrid/gridview.hh:375
int overlapSize(int codim) const
Return size of the overlap region for a given codim on the grid view.
Definition: albertagrid/gridview.hh:422
Codim< cd >::template Partition< pit >::Iterator begin() const
obtain begin iterator for this view
Definition: albertagrid/gridview.hh:368
Definition: albertagrid/gridview.hh:28
@ conforming
Definition: albertagrid/gridview.hh:68
Grid::Traits::LevelIntersection Intersection
type of the intersection
Definition: albertagrid/gridview.hh:38
Grid::Traits::CollectiveCommunication CollectiveCommunication
type of the collective communication
Definition: albertagrid/gridview.hh:45
std::remove_const< GridImp >::type Grid
type of the grid
Definition: albertagrid/gridview.hh:32
AlbertaLevelGridView< GridImp > GridViewImp
Definition: albertagrid/gridview.hh:29
Grid::Traits::LevelIntersectionIterator IntersectionIterator
type of the intersection iterator
Definition: albertagrid/gridview.hh:42
Grid::Traits::LevelIndexSet IndexSet
type of the index set
Definition: albertagrid/gridview.hh:35
Definition: albertagrid/gridview.hh:49
Grid::template Codim< cd >::Geometry Geometry
Definition: albertagrid/gridview.hh:54
Grid::template Codim< cd >::LocalGeometry LocalGeometry
Definition: albertagrid/gridview.hh:56
Grid::Traits::template Codim< cd >::template Partition< All_Partition >::LevelIterator Iterator
Definition: albertagrid/gridview.hh:50
Grid::Traits::template Codim< cd >::Entity Entity
Definition: albertagrid/gridview.hh:52
Define types needed to iterate over entities of a given partition type.
Definition: albertagrid/gridview.hh:61
Grid::template Codim< cd >::template Partition< pit >::LevelIterator Iterator
iterator over a given codim and partition type
Definition: albertagrid/gridview.hh:64
Codim Structure.
Definition: albertagrid/gridview.hh:97
Definition: albertagrid/gridview.hh:235
Grid::Traits::LeafIntersectionIterator IntersectionIterator
type of the intersection iterator
Definition: albertagrid/gridview.hh:249
std::remove_const< GridImp >::type Grid
type of the grid
Definition: albertagrid/gridview.hh:239
Grid::Traits::LeafIndexSet IndexSet
type of the index set
Definition: albertagrid/gridview.hh:242
Grid::Traits::CollectiveCommunication CollectiveCommunication
type of the collective communication
Definition: albertagrid/gridview.hh:252
AlbertaLeafGridView< GridImp > GridViewImp
Definition: albertagrid/gridview.hh:236
Grid::Traits::LeafIntersection Intersection
type of the intersection
Definition: albertagrid/gridview.hh:245
@ conforming
Definition: albertagrid/gridview.hh:276
Definition: albertagrid/gridview.hh:256
Grid::Traits::template Codim< cd >::template Partition< All_Partition >::LeafIterator Iterator
Definition: albertagrid/gridview.hh:258
Grid::Traits::template Codim< cd >::Entity Entity
Definition: albertagrid/gridview.hh:260
Grid::template Codim< cd >::LocalGeometry LocalGeometry
Definition: albertagrid/gridview.hh:264
Grid::template Codim< cd >::Geometry Geometry
Definition: albertagrid/gridview.hh:262
Define types needed to iterate over entities of a given partition type.
Definition: albertagrid/gridview.hh:269
Grid::template Codim< cd >::template Partition< pit >::LeafIterator Iterator
iterator over a given codim and partition type
Definition: albertagrid/gridview.hh:272
Codim Structure.
Definition: albertagrid/gridview.hh:305
Definition: albertagrid/intersectioniterator.hh:33
Definition: albertagrid/intersectioniterator.hh:34
Specialize with 'true' if implementation guarantees conforming level grids. (default=false)
Definition: common/capabilities.hh:104
Specialize with 'true' if implementation guarantees a conforming leaf grid. (default=false)
Definition: common/capabilities.hh:113
CommDataHandleIF describes the features of a data handle for communication in parallel runs using the...
Definition: datahandleif.hh:76
Mesh entities of codimension 0 ("elements") allow to visit all intersections with "neighboring" eleme...
Definition: common/intersectioniterator.hh:81
Index Set Interface base class.
Definition: indexidset.hh:76
Grid abstract base class.
Definition: common/grid.hh:373
@ dimension
The dimension of the grid.
Definition: common/grid.hh:387
A set of traits classes to store static information about grid implementation.
Implementation of the IntersectionIterator for AlbertaGrid.