dune-grid  2.2.0
common/gridview.hh
Go to the documentation of this file.
1 #ifndef DUNE_GRIDVIEW_HH
2 #define DUNE_GRIDVIEW_HH
3 
4 #include <dune/geometry/type.hh>
5 
8 
9 namespace Dune
10 {
11 
12  template< int, int, class, class >
13  class GridDefaultImplementation;
14 
15 
16 
53  template< class ViewTraits >
54  class GridView
55  {
57 
58  public:
59  typedef typename ViewTraits :: GridViewImp GridViewImp;
60 
62  typedef ViewTraits Traits;
63 
65  typedef typename Traits :: Grid Grid;
66 
68  typedef typename Traits :: IndexSet IndexSet;
69 
71  typedef typename Traits :: Intersection Intersection;
72 
74  typedef typename Traits :: IntersectionIterator IntersectionIterator;
75 
77  typedef typename Traits :: CollectiveCommunication CollectiveCommunication;
78 
82  template< int cd >
83  struct Codim {
85  typedef typename Traits :: template Codim<cd> :: Iterator Iterator;
86 
88  typedef typename Traits :: template Codim<cd> :: EntityPointer EntityPointer;
89 
91  typedef typename Traits :: template Codim<cd> :: Entity Entity;
92 
94  typedef typename Traits :: template Codim<cd> :: Geometry Geometry;
95 
97  typedef typename Traits :: template Codim<cd> :: LocalGeometry LocalGeometry;
98 
100  template< PartitionIteratorType pit >
101  struct Partition
102  {
104  typedef typename Traits :: template Codim< cd >
106  };
107  }; //: public Traits :: template Codim<cd> {};
108 
109  enum {
112 
114  typedef typename Grid::ctype ctype;
115 
116  enum {
118 
119  enum {
121 
122  public:
124  GridView ( const GridViewImp &imp )
125  : impl_( imp )
126  {}
127 
129  GridView ( const ThisType &other )
130  : impl_( other.impl_ )
131  {}
132 
134  ThisType &operator= ( const ThisType &other )
135  {
136  impl_ = other.impl_;
137  return *this;
138  }
139 
140  public:
142  const Grid &grid () const
143  {
144  return asImp().grid();
145  }
146 
148  const IndexSet &indexSet () const
149  {
150  return asImp().indexSet();
151  }
152 
154  int size ( int codim ) const
155  {
156  return asImp().size( codim );
157  }
158 
160  int size ( const GeometryType &type ) const
161  {
162  return asImp().size( type );
163  }
164 
171  template<class EntityType>
172  bool contains (const EntityType& e) const
173  {
174  return asImp().indexSet().contains(e);
175  }
176 
178  template< int cd >
179  typename Codim< cd > :: Iterator begin () const
180  {
181  return asImp().template begin<cd>();
182  }
183 
185  template< int cd >
186  typename Codim< cd > :: Iterator end () const
187  {
188  return asImp().template end<cd>();
189  }
190 
192  template< int cd , PartitionIteratorType pitype >
193  typename Codim< cd > :: template Partition< pitype > :: Iterator
194  begin () const
195  {
196  return asImp().template begin<cd,pitype>();
197  }
198 
200  template< int cd, PartitionIteratorType pitype >
201  typename Codim< cd > :: template Partition< pitype > :: Iterator
202  end () const
203  {
204  return asImp().template end<cd,pitype>();
205  }
206 
209  ibegin ( const typename Codim< 0 > :: Entity &entity ) const
210  {
211  return asImp().ibegin(entity);
212  }
213 
216  iend ( const typename Codim< 0 > :: Entity &entity ) const
217  {
218  return asImp().iend(entity);
219  }
220 
223  {
224  return asImp().comm();
225  }
226 
228  int overlapSize(int codim) const
229  {
230  return asImp().overlapSize(codim);
231  }
232 
234  int ghostSize(int codim) const
235  {
236  return asImp().ghostSize(codim);
237  }
238 
240  template< class DataHandleImp, class DataType >
242  InterfaceType iftype,
243  CommunicationDirection dir ) const
244  {
245  asImp().communicate(data,iftype,dir);
246  }
247 
248 #if DUNE_GRID_EXPERIMENTAL_GRID_EXTENSIONS
249  public:
250 #else
251  protected:
252  // give the GridDefaultImplementation class access to the realImp
253  friend class GridDefaultImplementation< Grid::dimension, Grid::dimensionworld, typename Grid::ctype, typename Grid::GridFamily >;
254 #endif
255  // type of underlying implementation, for internal use only
257 
259  Implementation &impl () { return impl_; }
261  const Implementation &impl () const { return impl_; }
262 
263  protected:
265 
267  {
268  return impl_;
269  }
270 
271  const GridViewImp& asImp () const
272  {
273  return impl_;
274  }
275  };
276 
277 }
278 
279 #endif