dune-alugrid  2.6-git
gridview.hh
Go to the documentation of this file.
1 #ifndef DUNE_ALUGRID_3D_GRIDVIEW_HH
2 #define DUNE_ALUGRID_3D_GRIDVIEW_HH
3 
4 #include <type_traits>
5 
6 #include <dune/common/version.hh>
7 #include <dune/common/exceptions.hh>
8 
9 #include <dune/grid/common/capabilities.hh>
10 #include <dune/grid/common/gridview.hh>
11 
12 namespace Dune
13 {
14 
15  template< class GridImp, PartitionIteratorType pitype >
16  class ALU3dLevelGridView;
17 
18  template< class GridImp, PartitionIteratorType pitype >
19  class ALU3dLeafGridView;
20 
21 
22  template< class GridImp, PartitionIteratorType pitype >
24  {
26 
28  typedef typename std::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::template Codim< cd >::Twists Twists;
47  typedef typename Twists::Twist Twist;
48 
49  typedef typename Grid :: Traits
50  :: template Codim< cd > :: template Partition< pitype > :: LevelIterator
52 
53  typedef typename Grid :: Traits :: template Codim< cd > :: Entity Entity;
54 #if ! DUNE_VERSION_NEWER(DUNE_GRID,2,5)
55  typedef typename Grid :: Traits :: template Codim< cd > :: EntityPointer
57 #endif
58 
59  typedef typename Grid :: template Codim< cd > :: Geometry Geometry;
60  typedef typename Grid :: template Codim< cd > :: LocalGeometry
62 
64  template< PartitionIteratorType pit >
65  struct Partition
66  {
68  typedef typename Grid :: template Codim< cd >
69  :: template Partition< pit > :: LevelIterator
71  };
72  };
73 
74  enum { conforming = Capabilities :: isLevelwiseConforming< Grid > :: v };
75  };
76 
77 
78  template< class GridImp, PartitionIteratorType pitype >
80  {
82 
83  public:
85 
87  typedef typename Traits::Grid Grid;
88 
90  typedef typename Traits :: IndexSet IndexSet;
91 
94 
97 
100 
102  template< int cd >
103  struct Codim : public Traits :: template Codim<cd> {};
104 
106 
107  ALU3dLevelGridView ( const Grid &grid, int level )
108  : grid_( &grid ),
109  level_( level )
110  {}
111 
113  const Grid &grid () const
114  {
115  assert( grid_ );
116  return *grid_;
117  }
118 
120  const IndexSet &indexSet () const
121  {
122  return grid().levelIndexSet( level_ );
123  }
124 
126  int size ( int codim ) const
127  {
128  return grid().size( level_, codim );
129  }
130 
132  int size ( const GeometryType &type ) const
133  {
134  return grid().size( level_, type );
135  }
136 
138  template< int cd >
139  typename Codim< cd > :: Iterator begin () const
140  {
141  return grid().template lbegin< cd, pitype >( level_ );
142  }
143 
145  template< int cd, PartitionIteratorType pit >
146  typename Codim< cd > :: template Partition< pit > :: Iterator begin () const
147  {
148  return grid().template lbegin< cd, pit >( level_ );
149  }
150 
152  template< int cd >
153  typename Codim< cd > :: Iterator end () const
154  {
155  return grid().template lend< cd, pitype >( level_ );
156  }
157 
159  template< int cd, PartitionIteratorType pit >
160  typename Codim< cd > :: template Partition< pit > :: Iterator end () const
161  {
162  return grid().template lend< cd, pit >( level_ );
163  }
164 
167  ibegin ( const typename Codim< 0 > :: Entity &entity ) const
168  {
169  return grid().ilevelbegin( entity );
170  }
171 
174  iend ( const typename Codim< 0 > :: Entity &entity ) const
175  {
176  return grid().ilevelend( entity );
177  }
178 
181  {
182  return grid().comm();
183  }
184 
186  int overlapSize(int codim) const
187  {
188  return grid().overlapSize(level_, codim);
189  }
190 
192  int ghostSize(int codim) const
193  {
194  return grid().ghostSize(level_, codim);
195  }
196 
198  template< class DataHandle, class Data >
199  typename Grid::LevelCommunication communicate ( CommDataHandleIF< DataHandle, Data > &data,
200  InterfaceType iftype,
201  CommunicationDirection dir ) const
202  {
203  return grid().communicate( data, iftype, dir, level_ );
204  }
205 
206  template< int cd >
207  typename Codim< cd >::Twists twists ( GeometryType type ) const
208  {
209  return grid().template twists< cd >( type );
210  }
211 
212  private:
213  const Grid *grid_;
214  int level_;
215  };
216 
217 
218  template< class GridImp, PartitionIteratorType pitype >
221 
223  typedef typename std::remove_const<GridImp>::type Grid;
224 
226  typedef typename Grid :: Traits :: LeafIndexSet IndexSet;
227 
229  typedef typename Grid :: Traits :: LeafIntersection Intersection;
230 
232  typedef typename Grid :: Traits :: LeafIntersectionIterator
234 
236  typedef typename Grid :: Traits :: CollectiveCommunication CollectiveCommunication;
237 
238  template< int cd >
239  struct Codim
240  {
241  typedef typename Grid::Traits::template Codim< cd >::Twists Twists;
242  typedef typename Twists::Twist Twist;
243 
244  typedef typename Grid :: Traits
245  :: template Codim< cd > :: template Partition< pitype > :: LeafIterator
247 
248  typedef typename Grid :: Traits :: template Codim< cd > :: Entity Entity;
249 #if ! DUNE_VERSION_NEWER(DUNE_GRID,2,5)
250  typedef typename Grid :: Traits :: template Codim< cd > :: EntityPointer
252 #endif
253 
254  typedef typename Grid :: template Codim< cd > :: Geometry Geometry;
255  typedef typename Grid :: template Codim< cd > :: LocalGeometry
257 
259  template <PartitionIteratorType pit >
260  struct Partition
261  {
263  typedef typename Grid :: template Codim< cd >
264  :: template Partition< pit > :: LeafIterator
266  };
267  };
268 
269  enum { conforming = Capabilities :: isLeafwiseConforming< Grid > :: v };
270  };
271 
272 
273  template< class GridImp, PartitionIteratorType pitype >
275  {
277 
278  public:
280 
282  typedef typename Traits::Grid Grid;
283 
285  typedef typename Traits :: IndexSet IndexSet;
286 
289 
292 
295 
297  template< int cd >
298  struct Codim : public Traits :: template Codim<cd> {};
299 
301 
302  public:
304  : grid_( &grid )
305  {}
306 
308  const Grid &grid () const
309  {
310  assert( grid_ );
311  return *grid_;
312  }
313 
315  const IndexSet &indexSet () const
316  {
317  return grid().leafIndexSet();
318  }
319 
321  int size ( int codim ) const
322  {
323  return grid().size( codim );
324  }
325 
327  int size ( const GeometryType &type ) const
328  {
329  return grid().size( type );
330  }
331 
333  template< int cd >
334  typename Codim< cd > :: Iterator begin () const
335  {
336  return grid().template leafbegin< cd, pitype >();
337  }
338 
340  template< int cd, PartitionIteratorType pit >
341  typename Codim< cd > :: template Partition< pit > :: Iterator begin () const
342  {
343  return grid().template leafbegin< cd, pit >();
344  }
345 
347  template< int cd >
348  typename Codim< cd > :: Iterator end () const
349  {
350  return grid().template leafend< cd, pitype >();
351  }
352 
354  template< int cd, PartitionIteratorType pit >
355  typename Codim< cd > :: template Partition< pit > :: Iterator end () const
356  {
357  return grid().template leafend< cd, pit >();
358  }
359 
362  ibegin ( const typename Codim< 0 > :: Entity &entity ) const
363  {
364  return grid().ileafbegin( entity );
365  }
366 
369  iend ( const typename Codim< 0 > :: Entity &entity ) const
370  {
371  return grid().ileafend( entity );
372  }
373 
376  {
377  return grid().comm();
378  }
379 
381  int overlapSize(int codim) const
382  {
383  return grid().overlapSize(codim);
384  }
385 
387  int ghostSize(int codim) const
388  {
389  return grid().ghostSize(codim);
390  }
391 
393  template< class DataHandle, class Data >
394  typename Grid::LeafCommunication communicate ( CommDataHandleIF< DataHandle, Data > &data,
395  InterfaceType iftype,
396  CommunicationDirection dir ) const
397  {
398  return grid().communicate( data, iftype, dir );
399  }
400 
401  template< int cd >
402  typename Codim< cd >::Twists twists ( GeometryType type ) const
403  {
404  return grid().template twists< cd >( type );
405  }
406 
407  private:
408  const Grid *grid_;
409  };
410 
411 } // namespace Dune
412 
413 #endif // #ifndef DUNE_ALUGRID_3D_GRIDVIEW_HH
Definition: alu3dinclude.hh:80
Definition: gridview.hh:80
Codim< cd >::Iterator begin() const
obtain begin iterator for this view
Definition: gridview.hh:139
int size(int codim) const
obtain number of entities in a given codimension
Definition: gridview.hh:126
Traits::Grid Grid
type of the grid
Definition: gridview.hh:87
int overlapSize(int codim) const
Return size of the overlap region for a given codim on the grid view.
Definition: gridview.hh:186
Traits ::CollectiveCommunication CollectiveCommunication
type of the collective communication
Definition: gridview.hh:99
int ghostSize(int codim) const
Return size of the ghost region for a given codim on the grid view.
Definition: gridview.hh:192
IntersectionIterator iend(const typename Codim< 0 > ::Entity &entity) const
obtain end intersection iterator with respect to this view
Definition: gridview.hh:174
Traits ::Intersection Intersection
type of the intersection
Definition: gridview.hh:93
ALU3dLevelGridView(const Grid &grid, int level)
Definition: gridview.hh:107
const CollectiveCommunication & comm() const
obtain collective communication object
Definition: gridview.hh:180
Codim< cd >::template Partition< pit >::Iterator begin() const
obtain begin iterator for this view
Definition: gridview.hh:146
@ conforming
Definition: gridview.hh:105
Codim< cd >::template Partition< pit >::Iterator end() const
obtain end iterator for this view
Definition: gridview.hh:160
ALU3dLevelGridViewTraits< GridImp, pitype > Traits
Definition: gridview.hh:84
Codim< cd >::Iterator end() const
obtain end iterator for this view
Definition: gridview.hh:153
const IndexSet & indexSet() const
obtain the index set
Definition: gridview.hh:120
int size(const GeometryType &type) const
obtain number of entities with a given geometry type
Definition: gridview.hh:132
Codim< cd >::Twists twists(GeometryType type) const
Definition: gridview.hh:207
Traits ::IndexSet IndexSet
type of the index set
Definition: gridview.hh:90
IntersectionIterator ibegin(const typename Codim< 0 > ::Entity &entity) const
obtain begin intersection iterator with respect to this view
Definition: gridview.hh:167
Traits ::IntersectionIterator IntersectionIterator
type of the intersection iterator
Definition: gridview.hh:96
const Grid & grid() const
obtain a const reference to the underlying hierarchic grid
Definition: gridview.hh:113
Grid::LevelCommunication communicate(CommDataHandleIF< DataHandle, Data > &data, InterfaceType iftype, CommunicationDirection dir) const
Definition: gridview.hh:199
Definition: gridview.hh:275
Codim< cd >::template Partition< pit >::Iterator begin() const
obtain begin iterator for this view
Definition: gridview.hh:341
IntersectionIterator ibegin(const typename Codim< 0 > ::Entity &entity) const
obtain begin intersection iterator with respect to this view
Definition: gridview.hh:362
Codim< cd >::Twists twists(GeometryType type) const
Definition: gridview.hh:402
Grid::LeafCommunication communicate(CommDataHandleIF< DataHandle, Data > &data, InterfaceType iftype, CommunicationDirection dir) const
Definition: gridview.hh:394
Traits ::Intersection Intersection
type of the intersection
Definition: gridview.hh:288
Traits::Grid Grid
type of the grid
Definition: gridview.hh:282
Codim< cd >::Iterator end() const
obtain end iterator for this view
Definition: gridview.hh:348
Traits ::IntersectionIterator IntersectionIterator
type of the intersection iterator
Definition: gridview.hh:291
ALU3dLeafGridViewTraits< GridImp, pitype > Traits
Definition: gridview.hh:279
int size(int codim) const
obtain number of entities in a given codimension
Definition: gridview.hh:321
int overlapSize(int codim) const
Return size of the overlap region for a given codim on the grid view.
Definition: gridview.hh:381
Traits ::IndexSet IndexSet
type of the index set
Definition: gridview.hh:285
ALU3dLeafGridView(const Grid &grid)
Definition: gridview.hh:303
IntersectionIterator iend(const typename Codim< 0 > ::Entity &entity) const
obtain end intersection iterator with respect to this view
Definition: gridview.hh:369
int size(const GeometryType &type) const
obtain number of entities with a given geometry type
Definition: gridview.hh:327
const CollectiveCommunication & comm() const
obtain collective communication object
Definition: gridview.hh:375
Codim< cd >::Iterator begin() const
obtain begin iterator for this view
Definition: gridview.hh:334
Traits ::CollectiveCommunication CollectiveCommunication
type of the collective communication
Definition: gridview.hh:294
int ghostSize(int codim) const
Return size of the ghost region for a given codim on the grid view.
Definition: gridview.hh:387
const Grid & grid() const
obtain a const reference to the underlying hierarchic grid
Definition: gridview.hh:308
const IndexSet & indexSet() const
obtain the index set
Definition: gridview.hh:315
@ conforming
Definition: gridview.hh:300
Codim< cd >::template Partition< pit >::Iterator end() const
obtain end iterator for this view
Definition: gridview.hh:355
Definition: gridview.hh:24
Grid ::Traits ::LevelIntersection Intersection
type of the intersection
Definition: gridview.hh:34
std::remove_const< GridImp >::type Grid
type of the grid
Definition: gridview.hh:28
ALU3dLevelGridView< GridImp, pitype > GridViewImp
Definition: gridview.hh:25
Grid ::Traits ::LevelIndexSet IndexSet
type of the index set
Definition: gridview.hh:31
Grid ::Traits ::CollectiveCommunication CollectiveCommunication
type of the collective communication
Definition: gridview.hh:41
Grid ::Traits ::LevelIntersectionIterator IntersectionIterator
type of the intersection iterator
Definition: gridview.hh:38
@ conforming
Definition: gridview.hh:74
Definition: gridview.hh:45
Grid ::Traits ::template Codim< cd >::template Partition< pitype >::LevelIterator Iterator
Definition: gridview.hh:51
Grid ::template Codim< cd >::LocalGeometry LocalGeometry
Definition: gridview.hh:61
Grid ::Traits ::template Codim< cd >::EntityPointer EntityPointer
Definition: gridview.hh:56
Grid::Traits::template Codim< cd >::Twists Twists
Definition: gridview.hh:46
Grid ::Traits ::template Codim< cd >::Entity Entity
Definition: gridview.hh:53
Grid ::template Codim< cd >::Geometry Geometry
Definition: gridview.hh:59
Twists::Twist Twist
Definition: gridview.hh:47
Define types needed to iterate over entities of a given partition type.
Definition: gridview.hh:66
Grid ::template Codim< cd >::template Partition< pit >::LevelIterator Iterator
iterator over a given codim and partition type
Definition: gridview.hh:70
Codim Structure.
Definition: gridview.hh:103
Definition: gridview.hh:219
std::remove_const< GridImp >::type Grid
type of the grid
Definition: gridview.hh:223
Grid ::Traits ::LeafIntersectionIterator IntersectionIterator
type of the intersection iterator
Definition: gridview.hh:233
Grid ::Traits ::CollectiveCommunication CollectiveCommunication
type of the collective communication
Definition: gridview.hh:236
ALU3dLeafGridView< GridImp, pitype > GridViewImp
Definition: gridview.hh:220
Grid ::Traits ::LeafIndexSet IndexSet
type of the index set
Definition: gridview.hh:226
@ conforming
Definition: gridview.hh:269
Grid ::Traits ::LeafIntersection Intersection
type of the intersection
Definition: gridview.hh:229
Definition: gridview.hh:240
Grid ::Traits ::template Codim< cd >::EntityPointer EntityPointer
Definition: gridview.hh:251
Grid::Traits::template Codim< cd >::Twists Twists
Definition: gridview.hh:241
Grid ::Traits ::template Codim< cd >::template Partition< pitype >::LeafIterator Iterator
Definition: gridview.hh:246
Grid ::Traits ::template Codim< cd >::Entity Entity
Definition: gridview.hh:248
Twists::Twist Twist
Definition: gridview.hh:242
Grid ::template Codim< cd >::LocalGeometry LocalGeometry
Definition: gridview.hh:256
Grid ::template Codim< cd >::Geometry Geometry
Definition: gridview.hh:254
Define types needed to iterate over entities of a given partition type.
Definition: gridview.hh:261
Grid ::template Codim< cd >::template Partition< pit >::LeafIterator Iterator
iterator over a given codim and partition type
Definition: gridview.hh:265
Codim Structure.
Definition: gridview.hh:298