dune-grid 2.9.0
defaultgridview.hh
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (C) 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
14namespace Dune
15{
16
17 template< class GridImp >
18 class DefaultLevelGridView;
19
20 template< class GridImp >
21 class DefaultLeafGridView;
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
46 [[deprecated("Use Communication instead!")]]
48
49 template< int cd >
50 struct Codim
51 {
52 typedef typename Grid :: Traits
53 :: template Codim< cd > :: template Partition< All_Partition > :: LevelIterator
55
56 typedef typename Grid :: Traits :: template Codim< cd > :: Entity Entity;
57
58 typedef typename Grid :: template Codim< cd > :: Geometry Geometry;
59 typedef typename Grid :: template Codim< cd > :: LocalGeometry
61
63 template< PartitionIteratorType pit >
64 struct Partition
65 {
67 typedef typename Grid :: template Codim< cd >
68 :: template Partition< pit > :: LevelIterator
70 };
71 };
72
73 constexpr static bool conforming = Capabilities :: isLevelwiseConforming< Grid > :: v;
74 };
75
76
77 template< class GridImp >
79 {
81
82 public:
84
86 typedef typename Traits::Grid Grid;
87
89 typedef typename Traits :: IndexSet IndexSet;
90
93
96
98 typedef typename Grid :: Traits :: Communication Communication;
99
101 [[deprecated("Use Communication instead!")]]
103
105 template< int cd >
106 struct Codim : public Traits :: template Codim<cd> {};
107
108 constexpr static bool conforming = Traits :: conforming;
109
110 DefaultLevelGridView ( const Grid &grid, int level )
111 : grid_( &grid ),
112 level_( level )
113 {}
114
116 const Grid &grid () const
117 {
118 assert( grid_ );
119 return *grid_;
120 }
121
123 const IndexSet &indexSet () const
124 {
125 return grid().levelIndexSet( level_ );
126 }
127
129 bool isConforming() const { return bool(Traits::conforming); }
130
132 int size ( int codim ) const
133 {
134 return grid().size( level_, codim );
135 }
136
138 int size ( const GeometryType &type ) const
139 {
140 return grid().size( level_, type );
141 }
142
144 template< int cd >
145 typename Codim< cd > :: Iterator begin () const
146 {
147 return grid().template lbegin< cd, All_Partition >( level_ );
148 }
149
151 template< int cd, PartitionIteratorType pit >
152 typename Codim< cd > :: template Partition< pit > :: Iterator begin () const
153 {
154 return grid().template lbegin< cd, pit >( level_ );
155 }
156
158 template< int cd >
159 typename Codim< cd > :: Iterator end () const
160 {
161 return grid().template lend< cd, All_Partition >( level_ );
162 }
163
165 template< int cd, PartitionIteratorType pit >
166 typename Codim< cd > :: template Partition< pit > :: Iterator end () const
167 {
168 return grid().template lend< cd, pit >( level_ );
169 }
170
173 ibegin ( const typename Codim< 0 > :: Entity &entity ) const
174 {
175 return entity.impl().ilevelbegin();
176 }
177
180 iend ( const typename Codim< 0 > :: Entity &entity ) const
181 {
182 return entity.impl().ilevelend();
183 }
184
186 const Communication &comm () const
187 {
188 return grid().comm();
189 }
190
192 int overlapSize(int codim) const
193 {
194 return grid().overlapSize(level_, codim);
195 }
196
198 int ghostSize(int codim) const
199 {
200 return grid().ghostSize(level_, codim);
201 }
202
204 template< class DataHandleImp, class DataType >
206 InterfaceType iftype,
207 CommunicationDirection dir ) const
208 {
209 return grid().communicate( data, iftype, dir, level_ );
210 }
211
212 private:
213 const Grid *grid_;
214 int level_;
215 };
216
217
218 template< class GridImp >
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 :: Communication Communication;
237
239 [[deprecated("Use Communication instead!")]]
241
242 template< int cd >
243 struct Codim
244 {
245 typedef typename Grid :: Traits
246 :: template Codim< cd > :: template Partition< All_Partition > :: LeafIterator
248
249 typedef typename Grid :: Traits :: template Codim< cd > :: Entity Entity;
250
251 typedef typename Grid :: template Codim< cd > :: Geometry Geometry;
252 typedef typename Grid :: template Codim< cd > :: LocalGeometry
254
256 template <PartitionIteratorType pit >
258 {
260 typedef typename Grid :: template Codim< cd >
261 :: template Partition< pit > :: LeafIterator
263 };
264 };
265
266 constexpr static bool conforming = Capabilities :: isLeafwiseConforming< Grid > :: v;
267 };
268
269
270 template< class GridImp >
272 {
274
275 public:
277
279 typedef typename Traits::Grid Grid;
280
282 typedef typename Traits :: IndexSet IndexSet;
283
286
289
291 typedef typename Grid :: Traits :: Communication Communication;
292
294 [[deprecated("Use Communication instead!")]]
296
298 template< int cd >
299 struct Codim : public Traits :: template Codim<cd> {};
300
301 constexpr static bool conforming = Traits :: conforming;
302
303 public:
305 : grid_( &grid )
306 {}
307
309 const Grid &grid () const
310 {
311 assert( grid_ );
312 return *grid_;
313 }
314
316 const IndexSet &indexSet () const
317 {
318 return grid().leafIndexSet();
319 }
320
322 bool isConforming() const { return bool(Traits::conforming); }
323
325 int size ( int codim ) const
326 {
327 return grid().size( codim );
328 }
329
331 int size ( const GeometryType &type ) const
332 {
333 return grid().size( type );
334 }
335
337 template< int cd >
338 typename Codim< cd > :: Iterator begin () const
339 {
340 return grid().template leafbegin< cd, All_Partition >();
341 }
342
344 template< int cd, PartitionIteratorType pit >
345 typename Codim< cd > :: template Partition< pit > :: Iterator begin () const
346 {
347 return grid().template leafbegin< cd, pit >();
348 }
349
351 template< int cd >
352 typename Codim< cd > :: Iterator end () const
353 {
354 return grid().template leafend< cd, All_Partition >();
355 }
356
358 template< int cd, PartitionIteratorType pit >
359 typename Codim< cd > :: template Partition< pit > :: Iterator end () const
360 {
361 return grid().template leafend< cd, pit >();
362 }
363
366 ibegin ( const typename Codim< 0 > :: Entity &entity ) const
367 {
368 return entity.impl().ileafbegin();
369 }
370
373 iend ( const typename Codim< 0 > :: Entity &entity ) const
374 {
375 return entity.impl().ileafend();
376 }
377
379 const Communication &comm () const
380 {
381 return grid().comm();
382 }
383
385 int overlapSize(int codim) const
386 {
387 return grid().overlapSize(codim);
388 }
389
391 int ghostSize(int codim) const
392 {
393 return grid().ghostSize(codim);
394 }
395
397 template< class DataHandleImp, class DataType >
399 InterfaceType iftype,
400 CommunicationDirection dir ) const
401 {
402 return grid().communicate( data, iftype, dir );
403 }
404
405 private:
406 const Grid *grid_;
407 };
408
409}
410
411#endif
CommunicationDirection
Define a type for communication direction parameter.
Definition: gridenums.hh:170
InterfaceType
Parameter to be used for the communication functions.
Definition: gridenums.hh:86
Include standard header files.
Definition: agrid.hh:60
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:132
CommDataHandleIF describes the features of a data handle for communication in parallel runs using the...
Definition: datahandleif.hh:78
Definition: defaultgridview.hh:79
Codim< cd >::template Partition< pit >::Iterator begin() const
obtain begin iterator for this view
Definition: defaultgridview.hh:152
int size(const GeometryType &type) const
obtain number of entities with a given geometry type
Definition: defaultgridview.hh:138
Codim< cd >::Iterator begin() const
obtain begin iterator for this view
Definition: defaultgridview.hh:145
Communication CollectiveCommunication
Definition: defaultgridview.hh:102
IntersectionIterator iend(const typename Codim< 0 > ::Entity &entity) const
obtain end intersection iterator with respect to this view
Definition: defaultgridview.hh:180
Codim< cd >::template Partition< pit >::Iterator end() const
obtain end iterator for this view
Definition: defaultgridview.hh:166
DefaultLevelGridViewTraits< GridImp > Traits
Definition: defaultgridview.hh:83
const IndexSet & indexSet() const
obtain the index set
Definition: defaultgridview.hh:123
const Communication & comm() const
obtain communication object
Definition: defaultgridview.hh:186
static constexpr bool conforming
Definition: defaultgridview.hh:108
Traits::IndexSet IndexSet
type of the index set
Definition: defaultgridview.hh:89
void communicate(CommDataHandleIF< DataHandleImp, DataType > &data, InterfaceType iftype, CommunicationDirection dir) const
Definition: defaultgridview.hh:205
Traits::IntersectionIterator IntersectionIterator
type of the intersection iterator
Definition: defaultgridview.hh:95
int size(int codim) const
obtain number of entities in a given codimension
Definition: defaultgridview.hh:132
int overlapSize(int codim) const
Return size of the overlap region for a given codim on the grid view.
Definition: defaultgridview.hh:192
Codim< cd >::Iterator end() const
obtain end iterator for this view
Definition: defaultgridview.hh:159
IntersectionIterator ibegin(const typename Codim< 0 > ::Entity &entity) const
obtain begin intersection iterator with respect to this view
Definition: defaultgridview.hh:173
DefaultLevelGridView(const Grid &grid, int level)
Definition: defaultgridview.hh:110
Traits::Intersection Intersection
type of the intersection
Definition: defaultgridview.hh:92
Grid::Traits::Communication Communication
type of the communication
Definition: defaultgridview.hh:98
bool isConforming() const
return true if current state of grid view represents a conforming grid
Definition: defaultgridview.hh:129
int ghostSize(int codim) const
Return size of the ghost region for a given codim on the grid view.
Definition: defaultgridview.hh:198
Traits::Grid Grid
type of the grid
Definition: defaultgridview.hh:86
const Grid & grid() const
obtain a const reference to the underlying hierarchic grid
Definition: defaultgridview.hh:116
Definition: defaultgridview.hh:272
void communicate(CommDataHandleIF< DataHandleImp, DataType > &data, InterfaceType iftype, CommunicationDirection dir) const
Definition: defaultgridview.hh:398
DefaultLeafGridViewTraits< GridImp > Traits
Definition: defaultgridview.hh:276
Communication CollectiveCommunication
Definition: defaultgridview.hh:295
Codim< cd >::template Partition< pit >::Iterator end() const
obtain end iterator for this view
Definition: defaultgridview.hh:359
const Grid & grid() const
obtain a const reference to the underlying hierarchic grid
Definition: defaultgridview.hh:309
Codim< cd >::template Partition< pit >::Iterator begin() const
obtain begin iterator for this view
Definition: defaultgridview.hh:345
IntersectionIterator ibegin(const typename Codim< 0 > ::Entity &entity) const
obtain begin intersection iterator with respect to this view
Definition: defaultgridview.hh:366
Traits::Intersection Intersection
type of the intersection
Definition: defaultgridview.hh:285
IntersectionIterator iend(const typename Codim< 0 > ::Entity &entity) const
obtain end intersection iterator with respect to this view
Definition: defaultgridview.hh:373
Codim< cd >::Iterator end() const
obtain end iterator for this view
Definition: defaultgridview.hh:352
Traits::Grid Grid
type of the grid
Definition: defaultgridview.hh:279
int size(const GeometryType &type) const
obtain number of entities with a given geometry type
Definition: defaultgridview.hh:331
bool isConforming() const
return true if current state of grid view represents a conforming grid
Definition: defaultgridview.hh:322
Traits::IndexSet IndexSet
type of the index set
Definition: defaultgridview.hh:282
const Communication & comm() const
obtain communication object
Definition: defaultgridview.hh:379
Grid::Traits::Communication Communication
type of the communication
Definition: defaultgridview.hh:291
DefaultLeafGridView(const Grid &grid)
Definition: defaultgridview.hh:304
int overlapSize(int codim) const
Return size of the overlap region for a given codim on the grid view.
Definition: defaultgridview.hh:385
Codim< cd >::Iterator begin() const
obtain begin iterator for this view
Definition: defaultgridview.hh:338
int ghostSize(int codim) const
Return size of the ghost region for a given codim on the grid view.
Definition: defaultgridview.hh:391
int size(int codim) const
obtain number of entities in a given codimension
Definition: defaultgridview.hh:325
const IndexSet & indexSet() const
obtain the index set
Definition: defaultgridview.hh:316
Traits::IntersectionIterator IntersectionIterator
type of the intersection iterator
Definition: defaultgridview.hh:288
static constexpr bool conforming
Definition: defaultgridview.hh:301
Definition: defaultgridview.hh:26
Grid::Traits::Communication Communication
type of the communication
Definition: defaultgridview.hh:43
static constexpr bool conforming
Definition: defaultgridview.hh:73
Grid::Traits::LevelIntersection Intersection
type of the intersection
Definition: defaultgridview.hh:36
Grid::Traits::LevelIntersectionIterator IntersectionIterator
type of the intersection iterator
Definition: defaultgridview.hh:40
Grid::Traits::LevelIndexSet IndexSet
type of the index set
Definition: defaultgridview.hh:33
Communication CollectiveCommunication
Definition: defaultgridview.hh:47
std::remove_const< GridImp >::type Grid
type of the grid
Definition: defaultgridview.hh:30
DefaultLevelGridView< GridImp > GridViewImp
Definition: defaultgridview.hh:27
Definition: defaultgridview.hh:51
Grid::Traits::template Codim< cd >::template Partition< All_Partition >::LevelIterator Iterator
Definition: defaultgridview.hh:54
Grid::Traits::template Codim< cd >::Entity Entity
Definition: defaultgridview.hh:56
Grid::template Codim< cd >::Geometry Geometry
Definition: defaultgridview.hh:58
Grid::template Codim< cd >::LocalGeometry LocalGeometry
Definition: defaultgridview.hh:60
Define types needed to iterate over entities of a given partition type.
Definition: defaultgridview.hh:65
Grid::template Codim< cd >::template Partition< pit >::LevelIterator Iterator
iterator over a given codim and partition type
Definition: defaultgridview.hh:69
Codim Structure.
Definition: defaultgridview.hh:106
Definition: defaultgridview.hh:219
std::remove_const< GridImp >::type Grid
type of the grid
Definition: defaultgridview.hh:223
DefaultLeafGridView< GridImp > GridViewImp
Definition: defaultgridview.hh:220
static constexpr bool conforming
Definition: defaultgridview.hh:266
Communication CollectiveCommunication
Definition: defaultgridview.hh:240
Grid::Traits::LeafIntersectionIterator IntersectionIterator
type of the intersection iterator
Definition: defaultgridview.hh:233
Grid::Traits::LeafIntersection Intersection
type of the intersection
Definition: defaultgridview.hh:229
Grid::Traits::LeafIndexSet IndexSet
type of the index set
Definition: defaultgridview.hh:226
Grid::Traits::Communication Communication
type of the communication
Definition: defaultgridview.hh:236
Definition: defaultgridview.hh:244
Grid::Traits::template Codim< cd >::template Partition< All_Partition >::LeafIterator Iterator
Definition: defaultgridview.hh:247
Grid::Traits::template Codim< cd >::Entity Entity
Definition: defaultgridview.hh:249
Grid::template Codim< cd >::Geometry Geometry
Definition: defaultgridview.hh:251
Grid::template Codim< cd >::LocalGeometry LocalGeometry
Definition: defaultgridview.hh:253
Define types needed to iterate over entities of a given partition type.
Definition: defaultgridview.hh:258
Grid::template Codim< cd >::template Partition< pit >::LeafIterator Iterator
iterator over a given codim and partition type
Definition: defaultgridview.hh:262
Codim Structure.
Definition: defaultgridview.hh:299
Mesh entities of codimension 0 ("elements") allow to visit all intersections with "neighboring" eleme...
Definition: common/intersectioniterator.hh:83
Grid abstract base class.
Definition: common/grid.hh:375
A set of traits classes to store static information about grid implementation.