dune-grid  2.4.1
defaultgridview.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_DEFAULTGRIDVIEW_HH
4 #define DUNE_DEFAULTGRIDVIEW_HH
5 
6 #include <dune/common/typetraits.hh>
7 #include <dune/common/exceptions.hh>
8 
11 
12 namespace Dune
13 {
14 
15  template< class GridImp, PartitionIteratorType pitype >
17 
18  template< class GridImp, PartitionIteratorType pitype >
20 
21 
22  template< class GridImp, PartitionIteratorType pitype >
24  {
26 
28  typedef typename remove_const<GridImp>::type Grid;
29 
31  typedef typename Grid :: Traits :: LevelIndexSet IndexSet;
32 
34  typedef typename Grid :: Traits :: LevelIntersection Intersection;
35 
37  typedef typename Grid :: Traits :: LevelIntersectionIterator
39 
41  typedef typename Grid :: Traits :: CollectiveCommunication CollectiveCommunication;
42 
43  template< int cd >
44  struct Codim
45  {
46  typedef typename Grid :: Traits
47  :: template Codim< cd > :: template Partition< pitype > :: LevelIterator
49 
50  typedef typename Grid :: Traits :: template Codim< cd > :: Entity Entity;
51  typedef typename Grid :: Traits :: template Codim< cd > :: EntityPointer
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 >
64  :: template Partition< pit > :: LevelIterator
66  };
67  };
68 
70  };
71 
72 
73  template< class GridImp, PartitionIteratorType pitype >
74  class DefaultLevelGridView
75  {
76  typedef DefaultLevelGridView< GridImp, pitype > ThisType;
77 
78  public:
80 
82  typedef typename Traits::Grid Grid;
83 
85  typedef typename Traits :: IndexSet IndexSet;
86 
89 
92 
95 
97  template< int cd >
98  struct Codim : public Traits :: template Codim<cd> {};
99 
101 
102  DefaultLevelGridView ( const Grid &grid, int level )
103  : grid_( &grid ),
104  level_( level )
105  {}
106 
107  // use default implementation of copy constructor and assignment operator
108 #if 0
109  DefaultLevelGridView ( const ThisType &other )
110  : grid_( other.grid_ ),
111  level_( other.level_ )
112  {}
113 
115  ThisType &operator= ( const ThisType & other)
116  {
117  grid_ = other.grid_;
118  level_ = other.level_;
119  }
120 #endif
121 
123  const Grid &grid () const
124  {
125  assert( grid_ );
126  return *grid_;
127  }
128 
130  const IndexSet &indexSet () const
131  {
132  return grid().levelIndexSet( level_ );
133  }
134 
136  int size ( int codim ) const
137  {
138  return grid().size( level_, codim );
139  }
140 
142  int size ( const GeometryType &type ) const
143  {
144  return grid().size( level_, type );
145  }
146 
148  template< int cd >
149  typename Codim< cd > :: Iterator begin () const
150  {
151  return grid().template lbegin< cd, pitype >( level_ );
152  }
153 
155  template< int cd, PartitionIteratorType pit >
156  typename Codim< cd > :: template Partition< pit > :: Iterator begin () const
157  {
158  return grid().template lbegin< cd, pit >( level_ );
159  }
160 
162  template< int cd >
163  typename Codim< cd > :: Iterator end () const
164  {
165  return grid().template lend< cd, pitype >( level_ );
166  }
167 
169  template< int cd, PartitionIteratorType pit >
170  typename Codim< cd > :: template Partition< pit > :: Iterator end () const
171  {
172  return grid().template lend< cd, pit >( level_ );
173  }
174 
177  ibegin ( const typename Codim< 0 > :: Entity &entity ) const
178  {
179  return entity.impl().ilevelbegin();
180  }
181 
184  iend ( const typename Codim< 0 > :: Entity &entity ) const
185  {
186  return entity.impl().ilevelend();
187  }
188 
191  {
192  return grid().comm();
193  }
194 
196  int overlapSize(int codim) const
197  {
198  return grid().overlapSize(level_, codim);
199  }
200 
202  int ghostSize(int codim) const
203  {
204  return grid().ghostSize(level_, codim);
205  }
206 
208  template< class DataHandleImp, class DataType >
210  InterfaceType iftype,
211  CommunicationDirection dir ) const
212  {
213  return grid().communicate( data, iftype, dir, level_ );
214  }
215 
216  private:
217  const Grid *grid_;
218  int level_;
219  };
220 
221 
222  template< class GridImp, PartitionIteratorType pitype >
225 
227  typedef typename remove_const<GridImp>::type Grid;
228 
230  typedef typename Grid :: Traits :: LeafIndexSet IndexSet;
231 
233  typedef typename Grid :: Traits :: LeafIntersection Intersection;
234 
236  typedef typename Grid :: Traits :: LeafIntersectionIterator
238 
240  typedef typename Grid :: Traits :: CollectiveCommunication CollectiveCommunication;
241 
242  template< int cd >
243  struct Codim
244  {
245  typedef typename Grid :: Traits
246  :: template Codim< cd > :: template Partition< pitype > :: LeafIterator
248 
249  typedef typename Grid :: Traits :: template Codim< cd > :: Entity Entity;
250  typedef typename Grid :: Traits :: template Codim< cd > :: EntityPointer
252 
253  typedef typename Grid :: template Codim< cd > :: Geometry Geometry;
254  typedef typename Grid :: template Codim< cd > :: LocalGeometry
256 
258  template <PartitionIteratorType pit >
259  struct Partition
260  {
262  typedef typename Grid :: template Codim< cd >
263  :: template Partition< pit > :: LeafIterator
265  };
266  };
267 
269  };
270 
271 
272  template< class GridImp, PartitionIteratorType pitype >
273  class DefaultLeafGridView
274  {
275  typedef DefaultLeafGridView< GridImp, pitype > ThisType;
276 
277  public:
279 
281  typedef typename Traits::Grid Grid;
282 
284  typedef typename Traits :: IndexSet IndexSet;
285 
288 
291 
294 
296  template< int cd >
297  struct Codim : public Traits :: template Codim<cd> {};
298 
300 
301  public:
303  : grid_( &grid )
304  {}
305 
307  const Grid &grid () const
308  {
309  assert( grid_ );
310  return *grid_;
311  }
312 
314  const IndexSet &indexSet () const
315  {
316  return grid().leafIndexSet();
317  }
318 
320  int size ( int codim ) const
321  {
322  return grid().size( codim );
323  }
324 
326  int size ( const GeometryType &type ) const
327  {
328  return grid().size( type );
329  }
330 
332  template< int cd >
333  typename Codim< cd > :: Iterator begin () const
334  {
335  return grid().template leafbegin< cd, pitype >();
336  }
337 
339  template< int cd, PartitionIteratorType pit >
340  typename Codim< cd > :: template Partition< pit > :: Iterator begin () const
341  {
342  return grid().template leafbegin< cd, pit >();
343  }
344 
346  template< int cd >
347  typename Codim< cd > :: Iterator end () const
348  {
349  return grid().template leafend< cd, pitype >();
350  }
351 
353  template< int cd, PartitionIteratorType pit >
354  typename Codim< cd > :: template Partition< pit > :: Iterator end () const
355  {
356  return grid().template leafend< cd, pit >();
357  }
358 
361  ibegin ( const typename Codim< 0 > :: Entity &entity ) const
362  {
363  return entity.impl().ileafbegin();
364  }
365 
368  iend ( const typename Codim< 0 > :: Entity &entity ) const
369  {
370  return entity.impl().ileafend();
371  }
372 
375  {
376  return grid().comm();
377  }
378 
380  int overlapSize(int codim) const
381  {
382  return grid().overlapSize(codim);
383  }
384 
386  int ghostSize(int codim) const
387  {
388  return grid().ghostSize(codim);
389  }
390 
392  template< class DataHandleImp, class DataType >
394  InterfaceType iftype,
395  CommunicationDirection dir ) const
396  {
397  return grid().communicate( data, iftype, dir );
398  }
399 
400  private:
401  const Grid *grid_;
402  };
403 
404 }
405 
406 #endif
int ghostSize(int codim) const
Return size of the ghost region for a given codim on the grid view.
Definition: defaultgridview.hh:202
Grid::Traits::template Codim< cd >::EntityPointer EntityPointer
Definition: defaultgridview.hh:251
void communicate(CommDataHandleIF< DataHandleImp, DataType > &data, InterfaceType iftype, CommunicationDirection dir) const
Definition: defaultgridview.hh:209
Grid::Traits::template Codim< cd >::template Partition< pitype >::LevelIterator Iterator
Definition: defaultgridview.hh:48
Grid::Traits::template Codim< cd >::EntityPointer EntityPointer
Definition: defaultgridview.hh:52
Definition: defaultgridview.hh:44
IntersectionIterator ibegin(const typename Codim< 0 >::Entity &entity) const
obtain begin intersection iterator with respect to this view
Definition: defaultgridview.hh:361
Codim< cd >::Iterator begin() const
obtain begin iterator for this view
Definition: defaultgridview.hh:149
Definition: defaultgridview.hh:19
Grid::Traits::template Codim< cd >::template Partition< pitype >::LeafIterator Iterator
Definition: defaultgridview.hh:247
Define types needed to iterate over entities of a given partition type.
Definition: defaultgridview.hh:259
Specialize with 'true' if implementation guarantees a conforming leaf grid. (default=false) ...
Definition: common/capabilities.hh:107
IntersectionIterator iend(const typename Codim< 0 >::Entity &entity) const
obtain end intersection iterator with respect to this view
Definition: defaultgridview.hh:368
int size(int codim) const
obtain number of entities in a given codimension
Definition: defaultgridview.hh:320
DefaultLevelGridViewTraits< GridImp, pitype > Traits
Definition: defaultgridview.hh:79
int overlapSize(int codim) const
Return size of the overlap region for a given codim on the grid view.
Definition: defaultgridview.hh:196
Mesh entities of codimension 0 ("elements") allow to visit all intersections with "neighboring" eleme...
Definition: common/grid.hh:360
Codim< cd >::Iterator begin() const
obtain begin iterator for this view
Definition: defaultgridview.hh:333
DefaultLeafGridViewTraits< GridImp, pitype > Traits
Definition: defaultgridview.hh:278
Grid::template Codim< cd >::Geometry Geometry
Definition: defaultgridview.hh:54
Traits::Intersection Intersection
type of the intersection
Definition: defaultgridview.hh:88
int overlapSize(int codim) const
Return size of the overlap region for a given codim on the grid view.
Definition: defaultgridview.hh:380
Codim< cd >::template Partition< pit >::Iterator begin() const
obtain begin iterator for this view
Definition: defaultgridview.hh:340
Codim< cd >::template Partition< pit >::Iterator end() const
obtain end iterator for this view
Definition: defaultgridview.hh:170
const CollectiveCommunication & comm() const
obtain collective communication object
Definition: defaultgridview.hh:374
Definition: defaultgridview.hh:100
Grid::template Codim< cd >::template Partition< pit >::LevelIterator Iterator
iterator over a given codim and partition type
Definition: defaultgridview.hh:65
Traits::IntersectionIterator IntersectionIterator
type of the intersection iterator
Definition: defaultgridview.hh:290
const CollectiveCommunication & comm() const
obtain collective communication object
Definition: defaultgridview.hh:190
const IndexSet & indexSet() const
obtain the index set
Definition: defaultgridview.hh:130
Grid::Traits::CollectiveCommunication CollectiveCommunication
type of the collective communication
Definition: defaultgridview.hh:240
remove_const< GridImp >::type Grid
type of the grid
Definition: defaultgridview.hh:227
Grid::Traits::LeafIndexSet IndexSet
type of the index set
Definition: defaultgridview.hh:230
remove_const< GridImp >::type Grid
type of the grid
Definition: defaultgridview.hh:28
IntersectionIterator iend(const typename Codim< 0 >::Entity &entity) const
obtain end intersection iterator with respect to this view
Definition: defaultgridview.hh:184
Codim< cd >::template Partition< pit >::Iterator end() const
obtain end iterator for this view
Definition: defaultgridview.hh:354
Grid::Traits::LeafIntersectionIterator IntersectionIterator
type of the intersection iterator
Definition: defaultgridview.hh:237
const IndexSet & indexSet() const
obtain the index set
Definition: defaultgridview.hh:314
Define types needed to iterate over entities of a given partition type.
Definition: defaultgridview.hh:60
Grid::template Codim< cd >::Geometry Geometry
Definition: defaultgridview.hh:253
Grid::Traits::template Codim< cd >::Entity Entity
Definition: defaultgridview.hh:249
Grid::template Codim< cd >::template Partition< pit >::LeafIterator Iterator
iterator over a given codim and partition type
Definition: defaultgridview.hh:264
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:178
const Grid & grid() const
obtain a const reference to the underlying hierarchic grid
Definition: defaultgridview.hh:307
Definition: defaultgridview.hh:299
Traits::Grid Grid
type of the grid
Definition: defaultgridview.hh:281
Grid::Traits::LevelIntersectionIterator IntersectionIterator
type of the intersection iterator
Definition: defaultgridview.hh:38
Definition: defaultgridview.hh:243
Definition: defaultgridview.hh:23
Traits::Grid Grid
type of the grid
Definition: defaultgridview.hh:82
Codim< cd >::Iterator end() const
obtain end iterator for this view
Definition: defaultgridview.hh:347
Grid::Traits::CollectiveCommunication CollectiveCommunication
type of the collective communication
Definition: defaultgridview.hh:41
Traits::Intersection Intersection
type of the intersection
Definition: defaultgridview.hh:287
Traits::CollectiveCommunication CollectiveCommunication
type of the collective communication
Definition: defaultgridview.hh:293
DefaultLeafGridView< GridImp, pitype > GridViewImp
Definition: defaultgridview.hh:224
Grid::Traits::template Codim< cd >::Entity Entity
Definition: defaultgridview.hh:50
int ghostSize(int codim) const
Return size of the ghost region for a given codim on the grid view.
Definition: defaultgridview.hh:386
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:388
DefaultLeafGridView(const Grid &grid)
Definition: defaultgridview.hh:302
const Grid & grid() const
obtain a const reference to the underlying hierarchic grid
Definition: defaultgridview.hh:123
Traits::IntersectionIterator IntersectionIterator
type of the intersection iterator
Definition: defaultgridview.hh:91
int size(const GeometryType &type) const
obtain number of entities with a given geometry type
Definition: defaultgridview.hh:142
Grid::Traits::LevelIntersection Intersection
type of the intersection
Definition: defaultgridview.hh:34
Codim Structure.
Definition: defaultgridview.hh:297
CommunicationDirection
Define a type for communication direction parameter.
Definition: gridenums.hh:168
Definition: defaultgridview.hh:69
Codim Structure.
Definition: defaultgridview.hh:98
Grid::Traits::LevelIndexSet IndexSet
type of the index set
Definition: defaultgridview.hh:31
void communicate(CommDataHandleIF< DataHandleImp, DataType > &data, InterfaceType iftype, CommunicationDirection dir) const
Definition: defaultgridview.hh:393
A set of traits classes to store static information about grid implementation.
Codim< cd >::template Partition< pit >::Iterator begin() const
obtain begin iterator for this view
Definition: defaultgridview.hh:156
IntersectionIterator ibegin(const typename Codim< 0 >::Entity &entity) const
obtain begin intersection iterator with respect to this view
Definition: defaultgridview.hh:177
Codim< cd >::Iterator end() const
obtain end iterator for this view
Definition: defaultgridview.hh:163
Grid::template Codim< cd >::LocalGeometry LocalGeometry
Definition: defaultgridview.hh:255
CommDataHandleIF describes the features of a data handle for communication in parallel runs using the...
Definition: datahandleif.hh:72
DefaultLevelGridView(const Grid &grid, int level)
Definition: defaultgridview.hh:102
Traits::CollectiveCommunication CollectiveCommunication
type of the collective communication
Definition: defaultgridview.hh:94
Definition: defaultgridview.hh:268
Definition: defaultgridview.hh:16
Grid::template Codim< cd >::LocalGeometry LocalGeometry
Definition: defaultgridview.hh:56
Specialize with 'true' if implementation guarantees conforming level grids. (default=false) ...
Definition: common/capabilities.hh:98
Definition: defaultgridview.hh:223
InterfaceType
Parameter to be used for the communication functions.
Definition: gridenums.hh:84
Traits::IndexSet IndexSet
type of the index set
Definition: defaultgridview.hh:85
int size(int codim) const
obtain number of entities in a given codimension
Definition: defaultgridview.hh:136
Grid::Traits::LeafIntersection Intersection
type of the intersection
Definition: defaultgridview.hh:233
Traits::IndexSet IndexSet
type of the index set
Definition: defaultgridview.hh:284
DefaultLevelGridView< GridImp, pitype > GridViewImp
Definition: defaultgridview.hh:25
int size(const GeometryType &type) const
obtain number of entities with a given geometry type
Definition: defaultgridview.hh:326