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 >
75  {
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 
176  IntersectionIterator
177  ibegin ( const typename Codim< 0 > :: Entity &entity ) const
178  {
179  return entity.impl().ilevelbegin();
180  }
181 
183  IntersectionIterator
184  iend ( const typename Codim< 0 > :: Entity &entity ) const
185  {
186  return entity.impl().ilevelend();
187  }
188 
190  const CollectiveCommunication &comm () const
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  {
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:
302  DefaultLeafGridView ( const Grid &grid )
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 
360  IntersectionIterator
361  ibegin ( const typename Codim< 0 > :: Entity &entity ) const
362  {
363  return entity.impl().ileafbegin();
364  }
365 
367  IntersectionIterator
368  iend ( const typename Codim< 0 > :: Entity &entity ) const
369  {
370  return entity.impl().ileafend();
371  }
372 
374  const CollectiveCommunication &comm () const
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
Codim< cd >::Iterator begin() const
obtain begin iterator for this view
Definition: defaultgridview.hh:333
int ghostSize(int codim) const
Return size of the ghost region for a given codim on the grid view.
Definition: defaultgridview.hh:202
Codim< cd >::template Partition< pit >::Iterator end() const
obtain end iterator for this view
Definition: defaultgridview.hh:170
Grid::Traits::template Codim< cd >::Entity Entity
Definition: defaultgridview.hh:249
Grid::Traits::LevelIntersectionIterator IntersectionIterator
type of the intersection iterator
Definition: defaultgridview.hh:38
IntersectionIterator iend(const typename Codim< 0 >::Entity &entity) const
obtain end intersection iterator with respect to this view
Definition: defaultgridview.hh:184
Specialize with &#39;true&#39; if implementation guarantees conforming level grids. (default=false) ...
Definition: common/capabilities.hh:98
Grid::Traits::CollectiveCommunication CollectiveCommunication
type of the collective communication
Definition: defaultgridview.hh:41
DefaultLevelGridViewTraits< GridImp, pitype > Traits
Definition: defaultgridview.hh:79
Codim Structure.
Definition: defaultgridview.hh:297
Grid::Traits::LevelIndexSet IndexSet
type of the index set
Definition: defaultgridview.hh:31
Grid::template Codim< cd >::Geometry Geometry
Definition: defaultgridview.hh:54
int size(int codim) const
obtain number of entities in a given codimension
Definition: defaultgridview.hh:136
int size(int codim) const
obtain number of entities in a given codimension
Definition: defaultgridview.hh:320
Grid::template Codim< cd >::template Partition< pit >::LevelIterator Iterator
iterator over a given codim and partition type
Definition: defaultgridview.hh:65
const Grid & grid() const
obtain a const reference to the underlying hierarchic grid
Definition: defaultgridview.hh:123
Grid::template Codim< cd >::LocalGeometry LocalGeometry
Definition: defaultgridview.hh:56
Specialize with &#39;true&#39; if implementation guarantees a conforming leaf grid. (default=false) ...
Definition: common/capabilities.hh:107
Grid::Traits::template Codim< cd >::template Partition< pitype >::LeafIterator Iterator
Definition: defaultgridview.hh:247
const IndexSet & indexSet() const
obtain the index set
Definition: defaultgridview.hh:130
Codim< cd >::template Partition< pit >::Iterator begin() const
obtain begin iterator for this view
Definition: defaultgridview.hh:340
IntersectionIterator ibegin(const typename Codim< 0 >::Entity &entity) const
obtain begin intersection iterator with respect to this view
Definition: defaultgridview.hh:361
GeometryType
Type representing VTK&#39;s entity geometry types.
Definition: common.hh:178
remove_const< GridImp >::type Grid
type of the grid
Definition: defaultgridview.hh:227
CommunicationDirection
Define a type for communication direction parameter.
Definition: gridenums.hh:168
IntersectionIterator iend(const typename Codim< 0 >::Entity &entity) const
obtain end intersection iterator with respect to this view
Definition: defaultgridview.hh:368
Definition: defaultgridview.hh:69
Traits::IntersectionIterator IntersectionIterator
type of the intersection iterator
Definition: defaultgridview.hh:290
DefaultLeafGridView< GridImp, pitype > GridViewImp
Definition: defaultgridview.hh:224
Grid::Traits::LevelIntersection Intersection
type of the intersection
Definition: defaultgridview.hh:34
Grid::Traits::LeafIntersection Intersection
type of the intersection
Definition: defaultgridview.hh:233
int overlapSize(int codim) const
Return size of the overlap region for a given codim on the grid view.
Definition: defaultgridview.hh:380
Grid::template Codim< cd >::template Partition< pit >::LeafIterator Iterator
iterator over a given codim and partition type
Definition: defaultgridview.hh:264
Define types needed to iterate over entities of a given partition type.
Definition: defaultgridview.hh:259
Codim< cd >::template Partition< pit >::Iterator end() const
obtain end iterator for this view
Definition: defaultgridview.hh:354
Codim< cd >::Iterator end() const
obtain end iterator for this view
Definition: defaultgridview.hh:347
Traits::CollectiveCommunication CollectiveCommunication
type of the collective communication
Definition: defaultgridview.hh:293
DefaultLeafGridViewTraits< GridImp, pitype > Traits
Definition: defaultgridview.hh:278
Traits::IndexSet IndexSet
type of the index set
Definition: defaultgridview.hh:85
CommDataHandleIF describes the features of a data handle for communication in parallel runs using the...
Definition: datahandleif.hh:72
int overlapSize(int codim) const
Return size of the overlap region for a given codim on the grid view.
Definition: defaultgridview.hh:196
IntersectionIterator ibegin(const typename Codim< 0 >::Entity &entity) const
obtain begin intersection iterator with respect to this view
Definition: defaultgridview.hh:177
Definition: alugrid/common/declaration.hh:20
const IndexSet & indexSet() const
obtain the index set
Definition: defaultgridview.hh:314
Codim Structure.
Definition: defaultgridview.hh:98
const Grid & grid() const
obtain a const reference to the underlying hierarchic grid
Definition: defaultgridview.hh:307
int ghostSize(int codim) const
Return size of the ghost region for a given codim on the grid view.
Definition: defaultgridview.hh:386
Traits::Intersection Intersection
type of the intersection
Definition: defaultgridview.hh:88
Definition: defaultgridview.hh:223
const CollectiveCommunication & comm() const
obtain collective communication object
Definition: defaultgridview.hh:374
Grid::template Codim< cd >::Geometry Geometry
Definition: defaultgridview.hh:253
Grid::Traits::template Codim< cd >::template Partition< pitype >::LevelIterator Iterator
Definition: defaultgridview.hh:48
Traits::IntersectionIterator IntersectionIterator
type of the intersection iterator
Definition: defaultgridview.hh:91
DefaultLevelGridView< GridImp, pitype > GridViewImp
Definition: defaultgridview.hh:25
Traits::Grid Grid
type of the grid
Definition: defaultgridview.hh:281
Grid::Traits::LeafIntersectionIterator IntersectionIterator
type of the intersection iterator
Definition: defaultgridview.hh:237
Grid::Traits::template Codim< cd >::Entity Entity
Definition: defaultgridview.hh:50
Traits::CollectiveCommunication CollectiveCommunication
type of the collective communication
Definition: defaultgridview.hh:94
Traits::Intersection Intersection
type of the intersection
Definition: defaultgridview.hh:287
Codim< cd >::Iterator begin() const
obtain begin iterator for this view
Definition: defaultgridview.hh:149
DefaultLevelGridView(const Grid &grid, int level)
Definition: defaultgridview.hh:102
Definition: defaultgridview.hh:44
Grid::Traits::LeafIndexSet IndexSet
type of the index set
Definition: defaultgridview.hh:230
Codim< cd >::template Partition< pit >::Iterator begin() const
obtain begin iterator for this view
Definition: defaultgridview.hh:156
DefaultLeafGridView(const Grid &grid)
Definition: defaultgridview.hh:302
Grid::template Codim< cd >::LocalGeometry LocalGeometry
Definition: defaultgridview.hh:255
Definition: defaultgridview.hh:23
InterfaceType
Parameter to be used for the communication functions.
Definition: gridenums.hh:84
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:163
Include standard header files.
Definition: agrid.hh:59
remove_const< GridImp >::type Grid
type of the grid
Definition: defaultgridview.hh:28
A set of traits classes to store static information about grid implementation.
Traits::IndexSet IndexSet
type of the index set
Definition: defaultgridview.hh:284
Define types needed to iterate over entities of a given partition type.
Definition: defaultgridview.hh:60
const CollectiveCommunication & comm() const
obtain collective communication object
Definition: defaultgridview.hh:190
Definition: defaultgridview.hh:19
int size(const GeometryType &type) const
obtain number of entities with a given geometry type
Definition: defaultgridview.hh:326
Grid::Traits::CollectiveCommunication CollectiveCommunication
type of the collective communication
Definition: defaultgridview.hh:240
void communicate(CommDataHandleIF< DataHandleImp, DataType > &data, InterfaceType iftype, CommunicationDirection dir) const
Definition: defaultgridview.hh:209
Definition: defaultgridview.hh:243
Definition: defaultgridview.hh:16
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:393
int size(const GeometryType &type) const
obtain number of entities with a given geometry type
Definition: defaultgridview.hh:142
Grid::Traits::template Codim< cd >::EntityPointer EntityPointer
Definition: defaultgridview.hh:52