dune-grid  2.11
defaultgridview.hh
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file LICENSE.md in module root
2 // SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
3 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
4 // vi: set et ts=4 sw=2 sts=2:
5 #ifndef DUNE_GRID_COMMON_DEFAULTGRIDVIEW_HH
6 #define DUNE_GRID_COMMON_DEFAULTGRIDVIEW_HH
7 
8 #include <dune/common/typetraits.hh>
9 #include <dune/common/exceptions.hh>
10 
13 
14 namespace Dune
15 {
16 
17  template< class GridImp >
19 
20  template< class GridImp >
22 
23 
24  template< class GridImp >
26  {
28 
30  typedef typename std::remove_const<GridImp>::type Grid;
31 
33  typedef typename Grid :: Traits :: LevelIndexSet IndexSet;
34 
36  typedef typename Grid :: Traits :: LevelIntersection Intersection;
37 
39  typedef typename Grid :: Traits :: LevelIntersectionIterator
41 
43  typedef typename Grid :: Traits :: Communication Communication;
44 
45  template< int cd >
46  struct Codim
47  {
48  typedef typename Grid :: Traits
49  :: template Codim< cd > :: template Partition< All_Partition > :: LevelIterator
51 
52  typedef typename Grid :: Traits :: template Codim< cd > :: Entity Entity;
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 
69  constexpr static bool conforming = Capabilities :: isLevelwiseConforming< Grid > :: v;
70  };
71 
72 
73  template< class GridImp >
75  {
76  typedef DefaultLevelGridView< GridImp > ThisType;
77 
78  public:
80 
82  typedef typename Traits::Grid Grid;
83 
85  typedef typename Traits :: IndexSet IndexSet;
86 
89 
92 
94  typedef typename Grid :: Traits :: Communication Communication;
95 
97  template< int cd >
98  struct Codim : public Traits :: template Codim<cd> {};
99 
100  constexpr static bool conforming = Traits :: conforming;
101 
102  DefaultLevelGridView ( const Grid &grid, int level )
103  : grid_( &grid ),
104  level_( level )
105  {}
106 
108  const Grid &grid () const
109  {
110  assert( grid_ );
111  return *grid_;
112  }
113 
115  const IndexSet &indexSet () const
116  {
117  return grid().levelIndexSet( level_ );
118  }
119 
121  bool isConforming() const { return bool(Traits::conforming); }
122 
124  int size ( int codim ) const
125  {
126  return grid().size( level_, codim );
127  }
128 
130  int size ( const GeometryType &type ) const
131  {
132  return grid().size( level_, type );
133  }
134 
136  template< int cd >
137  typename Codim< cd > :: Iterator begin () const
138  {
139  return grid().template lbegin< cd, All_Partition >( level_ );
140  }
141 
143  template< int cd, PartitionIteratorType pit >
144  typename Codim< cd > :: template Partition< pit > :: Iterator begin () const
145  {
146  return grid().template lbegin< cd, pit >( level_ );
147  }
148 
150  template< int cd >
151  typename Codim< cd > :: Iterator end () const
152  {
153  return grid().template lend< cd, All_Partition >( level_ );
154  }
155 
157  template< int cd, PartitionIteratorType pit >
158  typename Codim< cd > :: template Partition< pit > :: Iterator end () const
159  {
160  return grid().template lend< cd, pit >( level_ );
161  }
162 
165  ibegin ( const typename Codim< 0 > :: Entity &entity ) const
166  {
167  return grid().ilevelbegin(entity);
168  }
169 
172  iend ( const typename Codim< 0 > :: Entity &entity ) const
173  {
174  return grid().ilevelend(entity);
175  }
176 
178  const Communication &comm () const
179  {
180  return grid().comm();
181  }
182 
184  int overlapSize(int codim) const
185  {
186  return grid().overlapSize(level_, codim);
187  }
188 
190  int ghostSize(int codim) const
191  {
192  return grid().ghostSize(level_, codim);
193  }
194 
196  template< class DataHandleImp, class DataType >
198  InterfaceType iftype,
199  CommunicationDirection dir ) const
200  {
201  return grid().communicate( data, iftype, dir, level_ );
202  }
203 
204  private:
205  const Grid *grid_;
206  int level_;
207  };
208 
209 
210  template< class GridImp >
213 
215  typedef typename std::remove_const<GridImp>::type Grid;
216 
218  typedef typename Grid :: Traits :: LeafIndexSet IndexSet;
219 
221  typedef typename Grid :: Traits :: LeafIntersection Intersection;
222 
224  typedef typename Grid :: Traits :: LeafIntersectionIterator
226 
228  typedef typename Grid :: Traits :: Communication Communication;
229 
230  template< int cd >
231  struct Codim
232  {
233  typedef typename Grid :: Traits
234  :: template Codim< cd > :: template Partition< All_Partition > :: LeafIterator
236 
237  typedef typename Grid :: Traits :: template Codim< cd > :: Entity Entity;
238 
239  typedef typename Grid :: template Codim< cd > :: Geometry Geometry;
240  typedef typename Grid :: template Codim< cd > :: LocalGeometry
242 
244  template <PartitionIteratorType pit >
245  struct Partition
246  {
248  typedef typename Grid :: template Codim< cd >
249  :: template Partition< pit > :: LeafIterator
251  };
252  };
253 
254  constexpr static bool conforming = Capabilities :: isLeafwiseConforming< Grid > :: v;
255  };
256 
257 
258  template< class GridImp >
259  class DefaultLeafGridView
260  {
261  typedef DefaultLeafGridView< GridImp > ThisType;
262 
263  public:
265 
267  typedef typename Traits::Grid Grid;
268 
270  typedef typename Traits :: IndexSet IndexSet;
271 
274 
277 
279  typedef typename Grid :: Traits :: Communication Communication;
280 
282  template< int cd >
283  struct Codim : public Traits :: template Codim<cd> {};
284 
285  constexpr static bool conforming = Traits :: conforming;
286 
287  public:
289  : grid_( &grid )
290  {}
291 
293  const Grid &grid () const
294  {
295  assert( grid_ );
296  return *grid_;
297  }
298 
300  const IndexSet &indexSet () const
301  {
302  return grid().leafIndexSet();
303  }
304 
306  bool isConforming() const { return bool(Traits::conforming); }
307 
309  int size ( int codim ) const
310  {
311  return grid().size( codim );
312  }
313 
315  int size ( const GeometryType &type ) const
316  {
317  return grid().size( type );
318  }
319 
321  template< int cd >
322  typename Codim< cd > :: Iterator begin () const
323  {
324  return grid().template leafbegin< cd, All_Partition >();
325  }
326 
328  template< int cd, PartitionIteratorType pit >
329  typename Codim< cd > :: template Partition< pit > :: Iterator begin () const
330  {
331  return grid().template leafbegin< cd, pit >();
332  }
333 
335  template< int cd >
336  typename Codim< cd > :: Iterator end () const
337  {
338  return grid().template leafend< cd, All_Partition >();
339  }
340 
342  template< int cd, PartitionIteratorType pit >
343  typename Codim< cd > :: template Partition< pit > :: Iterator end () const
344  {
345  return grid().template leafend< cd, pit >();
346  }
347 
350  ibegin ( const typename Codim< 0 > :: Entity &entity ) const
351  {
352  return grid().ileafbegin(entity);
353  }
354 
357  iend ( const typename Codim< 0 > :: Entity &entity ) const
358  {
359  return grid().ileafend(entity);
360  }
361 
363  const Communication &comm () const
364  {
365  return grid().comm();
366  }
367 
369  int overlapSize(int codim) const
370  {
371  return grid().overlapSize(codim);
372  }
373 
375  int ghostSize(int codim) const
376  {
377  return grid().ghostSize(codim);
378  }
379 
381  template< class DataHandleImp, class DataType >
383  InterfaceType iftype,
384  CommunicationDirection dir ) const
385  {
386  return grid().communicate( data, iftype, dir );
387  }
388 
389  private:
390  const Grid *grid_;
391  };
392 
393 }
394 
395 #endif
Codim< cd >::Iterator begin() const
obtain begin iterator for this view
Definition: defaultgridview.hh:322
Traits ::IntersectionIterator IntersectionIterator
type of the intersection iterator
Definition: defaultgridview.hh:91
Definition: defaultgridview.hh:46
Traits::Grid Grid
type of the grid
Definition: defaultgridview.hh:82
static constexpr bool conforming
Definition: defaultgridview.hh:285
Definition: defaultgridview.hh:18
int size(const GeometryType &type) const
obtain number of entities with a given geometry type
Definition: defaultgridview.hh:315
void communicate(CommDataHandleIF< DataHandleImp, DataType > &data, InterfaceType iftype, CommunicationDirection dir) const
Definition: defaultgridview.hh:197
Grid ::template Codim< cd >::LocalGeometry LocalGeometry
Definition: defaultgridview.hh:241
Grid ::template Codim< cd >::LocalGeometry LocalGeometry
Definition: defaultgridview.hh:56
Codim< cd >::Iterator end() const
obtain end iterator for this view
Definition: defaultgridview.hh:151
IntersectionIterator ibegin(const typename Codim< 0 > ::Entity &entity) const
obtain begin intersection iterator with respect to this view
Definition: defaultgridview.hh:350
int ghostSize(int codim) const
Return size of the ghost region for a given codim on the grid view.
Definition: defaultgridview.hh:375
Grid ::Traits ::template Codim< cd >::template Partition< All_Partition >::LeafIterator Iterator
Definition: defaultgridview.hh:235
std::remove_const< GridImp >::type Grid
type of the grid
Definition: defaultgridview.hh:30
DefaultLevelGridView< GridImp > GridViewImp
Definition: defaultgridview.hh:27
const Grid & grid() const
obtain a const reference to the underlying hierarchic grid
Definition: defaultgridview.hh:293
static constexpr bool conforming
Definition: defaultgridview.hh:100
Codim< cd >::template Partition< pit >::Iterator begin() const
obtain begin iterator for this view
Definition: defaultgridview.hh:144
Definition: defaultgridview.hh:25
Grid ::Traits ::LevelIntersectionIterator IntersectionIterator
type of the intersection iterator
Definition: defaultgridview.hh:40
Traits ::Intersection Intersection
type of the intersection
Definition: defaultgridview.hh:273
Grid abstract base classThis class is the base class for all grid implementations. Although no virtual functions are used we call it abstract since its methods do not contain an implementation but forward to the methods of the derived class via the Barton-Nackman trick.
Definition: common/grid.hh:375
Grid ::Traits ::Communication Communication
type of the communication
Definition: defaultgridview.hh:279
Traits ::IndexSet IndexSet
type of the index set
Definition: defaultgridview.hh:85
void communicate(CommDataHandleIF< DataHandleImp, DataType > &data, InterfaceType iftype, CommunicationDirection dir) const
Definition: defaultgridview.hh:382
Codim< cd >::template Partition< pit >::Iterator end() const
obtain end iterator for this view
Definition: defaultgridview.hh:158
std::remove_const< GridImp >::type Grid
type of the grid
Definition: defaultgridview.hh:215
Codim< cd >::template Partition< pit >::Iterator end() const
obtain end iterator for this view
Definition: defaultgridview.hh:343
Grid ::template Codim< cd >::template Partition< pit >::LevelIterator Iterator
iterator over a given codim and partition type
Definition: defaultgridview.hh:65
Define types needed to iterate over entities of a given partition type.
Definition: defaultgridview.hh:60
Grid ::Traits ::LevelIndexSet IndexSet
type of the index set
Definition: defaultgridview.hh:33
Traits ::Intersection Intersection
type of the intersection
Definition: defaultgridview.hh:88
IntersectionIterator iend(const typename Codim< 0 > ::Entity &entity) const
obtain end intersection iterator with respect to this view
Definition: defaultgridview.hh:357
static constexpr bool conforming
Definition: defaultgridview.hh:69
int size(int codim) const
obtain number of entities in a given codimension
Definition: defaultgridview.hh:124
const IndexSet & indexSet() const
obtain the index set
Definition: defaultgridview.hh:300
Codim Structure.
Definition: defaultgridview.hh:283
const Grid & grid() const
obtain a const reference to the underlying hierarchic grid
Definition: defaultgridview.hh:108
Codim< cd >::Iterator begin() const
obtain begin iterator for this view
Definition: defaultgridview.hh:137
Traits::Grid Grid
type of the grid
Definition: defaultgridview.hh:267
Grid ::Traits ::template Codim< cd >::template Partition< All_Partition >::LevelIterator Iterator
Definition: defaultgridview.hh:50
Grid ::Traits ::template Codim< cd >::Entity Entity
Definition: defaultgridview.hh:237
Grid ::template Codim< cd >::template Partition< pit >::LeafIterator Iterator
iterator over a given codim and partition type
Definition: defaultgridview.hh:250
Grid ::Traits ::LeafIntersectionIterator IntersectionIterator
type of the intersection iterator
Definition: defaultgridview.hh:225
CommunicationDirection
Define a type for communication direction parameter.
Definition: gridenums.hh:170
Grid ::Traits ::LeafIntersection Intersection
type of the intersection
Definition: defaultgridview.hh:221
bool isConforming() const
return true if current state of grid view represents a conforming grid
Definition: defaultgridview.hh:306
int size(int codim) const
obtain number of entities in a given codimension
Definition: defaultgridview.hh:309
Definition: defaultgridview.hh:211
const IndexSet & indexSet() const
obtain the index set
Definition: defaultgridview.hh:115
Include standard header files.
Definition: agrid.hh:59
CommDataHandleIF describes the features of a data handle for communication in parallel runs using the...
Definition: datahandleif.hh:77
InterfaceType
Parameter to be used for the communication functions.
Definition: gridenums.hh:86
DefaultLeafGridView(const Grid &grid)
Definition: defaultgridview.hh:288
Mesh entities of codimension 0 ("elements") allow to visit all intersections with "neighboring" eleme...
Definition: common/grid.hh:347
Traits ::IndexSet IndexSet
type of the index set
Definition: defaultgridview.hh:270
Define types needed to iterate over entities of a given partition type.
Definition: defaultgridview.hh:245
Codim Structure.
Definition: defaultgridview.hh:98
int overlapSize(int codim) const
Return size of the overlap region for a given codim on the grid view.
Definition: defaultgridview.hh:184
bool isConforming() const
return true if current state of grid view represents a conforming grid
Definition: defaultgridview.hh:121
Grid ::Traits ::LeafIndexSet IndexSet
type of the index set
Definition: defaultgridview.hh:218
int size(const GeometryType &type) const
obtain number of entities with a given geometry type
Definition: defaultgridview.hh:130
Grid ::Traits ::Communication Communication
type of the communication
Definition: defaultgridview.hh:43
int ghostSize(int codim) const
Return size of the ghost region for a given codim on the grid view.
Definition: defaultgridview.hh:190
const Communication & comm() const
obtain communication object
Definition: defaultgridview.hh:178
Codim< cd >::Iterator end() const
obtain end iterator for this view
Definition: defaultgridview.hh:336
IntersectionIterator iend(const typename Codim< 0 > ::Entity &entity) const
obtain end intersection iterator with respect to this view
Definition: defaultgridview.hh:172
Grid ::Traits ::template Codim< cd >::Entity Entity
Definition: defaultgridview.hh:52
Definition: defaultgridview.hh:231
Grid ::template Codim< cd >::Geometry Geometry
Definition: defaultgridview.hh:239
GeometryType
Type representing VTK&#39;s entity geometry types.
Definition: common.hh:132
DefaultLevelGridViewTraits< GridImp > Traits
Definition: defaultgridview.hh:79
DefaultLevelGridView(const Grid &grid, int level)
Definition: defaultgridview.hh:102
DefaultLeafGridViewTraits< GridImp > Traits
Definition: defaultgridview.hh:264
IntersectionIterator ibegin(const typename Codim< 0 > ::Entity &entity) const
obtain begin intersection iterator with respect to this view
Definition: defaultgridview.hh:165
A set of traits classes to store static information about grid implementation.
Traits ::IntersectionIterator IntersectionIterator
type of the intersection iterator
Definition: defaultgridview.hh:276
const Communication & comm() const
obtain communication object
Definition: defaultgridview.hh:363
Grid ::Traits ::LevelIntersection Intersection
type of the intersection
Definition: defaultgridview.hh:36
int overlapSize(int codim) const
Return size of the overlap region for a given codim on the grid view.
Definition: defaultgridview.hh:369
Grid ::Traits ::Communication Communication
type of the communication
Definition: defaultgridview.hh:94
Grid ::Traits ::Communication Communication
type of the communication
Definition: defaultgridview.hh:228
Definition: defaultgridview.hh:21
Codim< cd >::template Partition< pit >::Iterator begin() const
obtain begin iterator for this view
Definition: defaultgridview.hh:329
static constexpr bool conforming
Definition: defaultgridview.hh:254
DefaultLeafGridView< GridImp > GridViewImp
Definition: defaultgridview.hh:212
Grid ::template Codim< cd >::Geometry Geometry
Definition: defaultgridview.hh:54