dune-grid  2.3beta2
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 >
16  class DefaultLevelGridView;
17 
18  template< class GridImp, PartitionIteratorType pitype >
19  class DefaultLeafGridView;
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 >
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 
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 >
265  };
266  };
267 
269  };
270 
271 
272  template< class GridImp, PartitionIteratorType pitype >
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:
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