dune-grid  2.3.1
common/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_GRIDVIEW_HH
4 #define DUNE_GRIDVIEW_HH
5 
6 #include <dune/geometry/type.hh>
7 
10 
11 namespace Dune
12 {
13 
14  template< int, int, class, class >
15  class GridDefaultImplementation;
16 
17 
18 
55  template< class ViewTraits >
56  class GridView
57  {
59 
60  public:
61  typedef typename ViewTraits :: GridViewImp GridViewImp;
62 
64  typedef ViewTraits Traits;
65 
67  typedef typename Traits :: Grid Grid;
68 
70  typedef typename Traits :: IndexSet IndexSet;
71 
73  typedef typename Traits :: Intersection Intersection;
74 
76  typedef typename Traits :: IntersectionIterator IntersectionIterator;
77 
79  typedef typename Traits :: CollectiveCommunication CollectiveCommunication;
80 
84  template< int cd >
85  struct Codim {
87  typedef typename Traits :: template Codim<cd> :: Iterator Iterator;
88 
90  typedef typename Traits :: template Codim<cd> :: EntityPointer EntityPointer;
91 
93  typedef typename Traits :: template Codim<cd> :: Entity Entity;
94 
96  typedef typename Traits :: template Codim<cd> :: Geometry Geometry;
97 
99  typedef typename Traits :: template Codim<cd> :: LocalGeometry LocalGeometry;
100 
102  template< PartitionIteratorType pit >
103  struct Partition
104  {
106  typedef typename Traits :: template Codim< cd >
108  };
109  }; //: public Traits :: template Codim<cd> {};
110 
111  enum {
114  };
115 
117  typedef typename Grid::ctype ctype;
118 
119  enum {
121  };
122 
123  enum {
125  };
126 
127  public:
129  GridView ( const GridViewImp &imp )
130  : impl_( imp )
131  {}
132 
134  GridView ( const ThisType &other )
135  : impl_( other.impl_ )
136  {}
137 
139  ThisType &operator= ( const ThisType &other )
140  {
141  impl_ = other.impl_;
142  return *this;
143  }
144 
145  public:
147  const Grid &grid () const
148  {
149  return impl().grid();
150  }
151 
158  const IndexSet &indexSet () const
159  {
160  return impl().indexSet();
161  }
162 
164  int size ( int codim ) const
165  {
166  return impl().size( codim );
167  }
168 
170  int size ( const GeometryType &type ) const
171  {
172  return impl().size( type );
173  }
174 
181  template<class EntityType>
182  bool contains (const EntityType& e) const
183  {
184  return impl().indexSet().contains(e);
185  }
186 
188  template< int cd >
189  typename Codim< cd > :: Iterator begin () const
190  {
191  return impl().template begin<cd>();
192  }
193 
195  template< int cd >
196  typename Codim< cd > :: Iterator end () const
197  {
198  return impl().template end<cd>();
199  }
200 
202  template< int cd , PartitionIteratorType pitype >
203  typename Codim< cd > :: template Partition< pitype > :: Iterator
204  begin () const
205  {
206  return impl().template begin<cd,pitype>();
207  }
208 
210  template< int cd, PartitionIteratorType pitype >
211  typename Codim< cd > :: template Partition< pitype > :: Iterator
212  end () const
213  {
214  return impl().template end<cd,pitype>();
215  }
216 
219  ibegin ( const typename Codim< 0 > :: Entity &entity ) const
220  {
221  return impl().ibegin(entity);
222  }
223 
226  iend ( const typename Codim< 0 > :: Entity &entity ) const
227  {
228  return impl().iend(entity);
229  }
230 
233  {
234  return impl().comm();
235  }
236 
238  int overlapSize(int codim) const
239  {
240  return impl().overlapSize(codim);
241  }
242 
244  int ghostSize(int codim) const
245  {
246  return impl().ghostSize(codim);
247  }
248 
250  template< class DataHandleImp, class DataType >
252  InterfaceType iftype,
253  CommunicationDirection dir ) const
254  {
255  impl().communicate(data,iftype,dir);
256  }
257 
258 #if DUNE_GRID_EXPERIMENTAL_GRID_EXTENSIONS
259  public:
260 #else
261  protected:
262  // give the GridDefaultImplementation class access to the realImp
263  friend class GridDefaultImplementation< Grid::dimension, Grid::dimensionworld, typename Grid::ctype, typename Grid::GridFamily >;
264 #endif
265  // type of underlying implementation, for internal use only
267 
269  Implementation &impl () { return impl_; }
271  const Implementation &impl () const { return impl_; }
272 
273  protected:
275 
281  DUNE_DEPRECATED_MSG("Use impl() instead.")
282  {
283  return impl_;
284  }
285 
290  const GridViewImp& asImp () const
291  DUNE_DEPRECATED_MSG("Use impl() instead.")
292  {
293  return impl_;
294  }
295  };
296 
297 } // namespace Dune
298 
299 #endif // #ifndef DUNE_GRIDVIEW_HH