dune-grid 3.0-git
defaultgridview.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_DEFAULTGRIDVIEW_HH
4#define DUNE_DEFAULTGRIDVIEW_HH
5
6#include <dune/common/typetraits.hh>
7#include <dune/common/exceptions.hh>
8
11
12namespace Dune
13{
14
15 template< class GridImp >
16 class DefaultLevelGridView;
17
18 template< class GridImp >
19 class DefaultLeafGridView;
20
21
22 template< class GridImp >
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
47 :: template Codim< cd > :: template Partition< All_Partition > :: LevelIterator
49
50 typedef typename Grid :: Traits :: template Codim< cd > :: Entity Entity;
51
52 typedef typename Grid :: template Codim< cd > :: Geometry Geometry;
53 typedef typename Grid :: template Codim< cd > :: LocalGeometry
55
57 template< PartitionIteratorType pit >
58 struct Partition
59 {
61 typedef typename Grid :: template Codim< cd >
62 :: template Partition< pit > :: LevelIterator
64 };
65 };
66
67 enum { conforming = Capabilities :: isLevelwiseConforming< Grid > :: v };
68 };
69
70
71 template< class GridImp >
73 {
75
76 public:
78
80 typedef typename Traits::Grid Grid;
81
83 typedef typename Traits :: IndexSet IndexSet;
84
86 typedef typename Traits :: Intersection Intersection;
87
89 typedef typename Traits :: IntersectionIterator IntersectionIterator;
90
92 typedef typename Traits :: CollectiveCommunication CollectiveCommunication;
93
95 template< int cd >
96 struct Codim : public Traits :: template Codim<cd> {};
97
98 enum { conforming = Traits :: conforming };
99
100 DefaultLevelGridView ( const Grid &grid, int level )
101 : grid_( &grid ),
102 level_( level )
103 {}
104
105 // use default implementation of copy constructor and assignment operator
106#if 0
107 DefaultLevelGridView ( const ThisType &other )
108 : grid_( other.grid_ ),
109 level_( other.level_ )
110 {}
111
113 ThisType &operator= ( const ThisType & other)
114 {
115 grid_ = other.grid_;
116 level_ = other.level_;
117 }
118#endif
119
121 const Grid &grid () const
122 {
123 assert( grid_ );
124 return *grid_;
125 }
126
128 const IndexSet &indexSet () const
129 {
130 return grid().levelIndexSet( level_ );
131 }
132
134 int size ( int codim ) const
135 {
136 return grid().size( level_, codim );
137 }
138
140 int size ( const GeometryType &type ) const
141 {
142 return grid().size( level_, type );
143 }
144
146 template< int cd >
147 typename Codim< cd > :: Iterator begin () const
148 {
149 return grid().template lbegin< cd, All_Partition >( level_ );
150 }
151
153 template< int cd, PartitionIteratorType pit >
154 typename Codim< cd > :: template Partition< pit > :: Iterator begin () const
155 {
156 return grid().template lbegin< cd, pit >( level_ );
157 }
158
160 template< int cd >
161 typename Codim< cd > :: Iterator end () const
162 {
163 return grid().template lend< cd, All_Partition >( level_ );
164 }
165
167 template< int cd, PartitionIteratorType pit >
168 typename Codim< cd > :: template Partition< pit > :: Iterator end () const
169 {
170 return grid().template lend< cd, pit >( level_ );
171 }
172
175 ibegin ( const typename Codim< 0 > :: Entity &entity ) const
176 {
177 return entity.impl().ilevelbegin();
178 }
179
182 iend ( const typename Codim< 0 > :: Entity &entity ) const
183 {
184 return entity.impl().ilevelend();
185 }
186
189 {
190 return grid().comm();
191 }
192
194 int overlapSize(int codim) const
195 {
196 return grid().overlapSize(level_, codim);
197 }
198
200 int ghostSize(int codim) const
201 {
202 return grid().ghostSize(level_, codim);
203 }
204
206 template< class DataHandleImp, class DataType >
208 InterfaceType iftype,
209 CommunicationDirection dir ) const
210 {
211 return grid().communicate( data, iftype, dir, level_ );
212 }
213
214 private:
215 const Grid *grid_;
216 int level_;
217 };
218
219
220 template< class GridImp >
223
225 typedef typename std::remove_const<GridImp>::type Grid;
226
228 typedef typename Grid :: Traits :: LeafIndexSet IndexSet;
229
231 typedef typename Grid :: Traits :: LeafIntersection Intersection;
232
234 typedef typename Grid :: Traits :: LeafIntersectionIterator
236
238 typedef typename Grid :: Traits :: CollectiveCommunication CollectiveCommunication;
239
240 template< int cd >
241 struct Codim
242 {
243 typedef typename Grid :: Traits
244 :: template Codim< cd > :: template Partition< All_Partition > :: LeafIterator
246
247 typedef typename Grid :: Traits :: template Codim< cd > :: Entity Entity;
248
249 typedef typename Grid :: template Codim< cd > :: Geometry Geometry;
250 typedef typename Grid :: template Codim< cd > :: LocalGeometry
252
254 template <PartitionIteratorType pit >
256 {
258 typedef typename Grid :: template Codim< cd >
259 :: template Partition< pit > :: LeafIterator
261 };
262 };
263
264 enum { conforming = Capabilities :: isLeafwiseConforming< Grid > :: v };
265 };
266
267
268 template< class GridImp >
270 {
272
273 public:
275
277 typedef typename Traits::Grid Grid;
278
280 typedef typename Traits :: IndexSet IndexSet;
281
283 typedef typename Traits :: Intersection Intersection;
284
286 typedef typename Traits :: IntersectionIterator IntersectionIterator;
287
289 typedef typename Traits :: CollectiveCommunication CollectiveCommunication;
290
292 template< int cd >
293 struct Codim : public Traits :: template Codim<cd> {};
294
295 enum { conforming = Traits :: conforming };
296
297 public:
299 : grid_( &grid )
300 {}
301
303 const Grid &grid () const
304 {
305 assert( grid_ );
306 return *grid_;
307 }
308
310 const IndexSet &indexSet () const
311 {
312 return grid().leafIndexSet();
313 }
314
316 int size ( int codim ) const
317 {
318 return grid().size( codim );
319 }
320
322 int size ( const GeometryType &type ) const
323 {
324 return grid().size( type );
325 }
326
328 template< int cd >
329 typename Codim< cd > :: Iterator begin () const
330 {
331 return grid().template leafbegin< cd, All_Partition >();
332 }
333
335 template< int cd, PartitionIteratorType pit >
336 typename Codim< cd > :: template Partition< pit > :: Iterator begin () const
337 {
338 return grid().template leafbegin< cd, pit >();
339 }
340
342 template< int cd >
343 typename Codim< cd > :: Iterator end () const
344 {
345 return grid().template leafend< cd, All_Partition >();
346 }
347
349 template< int cd, PartitionIteratorType pit >
350 typename Codim< cd > :: template Partition< pit > :: Iterator end () const
351 {
352 return grid().template leafend< cd, pit >();
353 }
354
357 ibegin ( const typename Codim< 0 > :: Entity &entity ) const
358 {
359 return entity.impl().ileafbegin();
360 }
361
364 iend ( const typename Codim< 0 > :: Entity &entity ) const
365 {
366 return entity.impl().ileafend();
367 }
368
371 {
372 return grid().comm();
373 }
374
376 int overlapSize(int codim) const
377 {
378 return grid().overlapSize(codim);
379 }
380
382 int ghostSize(int codim) const
383 {
384 return grid().ghostSize(codim);
385 }
386
388 template< class DataHandleImp, class DataType >
390 InterfaceType iftype,
391 CommunicationDirection dir ) const
392 {
393 return grid().communicate( data, iftype, dir );
394 }
395
396 private:
397 const Grid *grid_;
398 };
399
400}
401
402#endif
CommunicationDirection
Define a type for communication direction parameter.
Definition gridenums.hh:168
InterfaceType
Parameter to be used for the communication functions.
Definition gridenums.hh:84
Include standard header files.
Definition agrid.hh:60
CommDataHandleIF describes the features of a data handle for communication in parallel runs using the...
Definition datahandleif.hh:73
Definition defaultgridview.hh:73
Traits::CollectiveCommunication CollectiveCommunication
type of the collective communication
Definition defaultgridview.hh:92
Codim< cd >::template Partition< pit >::Iterator begin() const
obtain begin iterator for this view
Definition defaultgridview.hh:154
int size(const GeometryType &type) const
obtain number of entities with a given geometry type
Definition defaultgridview.hh:140
Codim< cd >::Iterator begin() const
obtain begin iterator for this view
Definition defaultgridview.hh:147
IntersectionIterator iend(const typename Codim< 0 > ::Entity &entity) const
obtain end intersection iterator with respect to this view
Definition defaultgridview.hh:182
Codim< cd >::template Partition< pit >::Iterator end() const
obtain end iterator for this view
Definition defaultgridview.hh:168
DefaultLevelGridViewTraits< GridImp > Traits
Definition defaultgridview.hh:77
const IndexSet & indexSet() const
obtain the index set
Definition defaultgridview.hh:128
Traits::IndexSet IndexSet
type of the index set
Definition defaultgridview.hh:83
void communicate(CommDataHandleIF< DataHandleImp, DataType > &data, InterfaceType iftype, CommunicationDirection dir) const
Definition defaultgridview.hh:207
@ conforming
Definition defaultgridview.hh:98
const CollectiveCommunication & comm() const
obtain collective communication object
Definition defaultgridview.hh:188
Traits::IntersectionIterator IntersectionIterator
type of the intersection iterator
Definition defaultgridview.hh:89
int size(int codim) const
obtain number of entities in a given codimension
Definition defaultgridview.hh:134
int overlapSize(int codim) const
Return size of the overlap region for a given codim on the grid view.
Definition defaultgridview.hh:194
Codim< cd >::Iterator end() const
obtain end iterator for this view
Definition defaultgridview.hh:161
IntersectionIterator ibegin(const typename Codim< 0 > ::Entity &entity) const
obtain begin intersection iterator with respect to this view
Definition defaultgridview.hh:175
DefaultLevelGridView(const Grid &grid, int level)
Definition defaultgridview.hh:100
Traits::Intersection Intersection
type of the intersection
Definition defaultgridview.hh:86
int ghostSize(int codim) const
Return size of the ghost region for a given codim on the grid view.
Definition defaultgridview.hh:200
Traits::Grid Grid
type of the grid
Definition defaultgridview.hh:80
const Grid & grid() const
obtain a const reference to the underlying hierarchic grid
Definition defaultgridview.hh:121
Definition defaultgridview.hh:270
void communicate(CommDataHandleIF< DataHandleImp, DataType > &data, InterfaceType iftype, CommunicationDirection dir) const
Definition defaultgridview.hh:389
DefaultLeafGridViewTraits< GridImp > Traits
Definition defaultgridview.hh:274
@ conforming
Definition defaultgridview.hh:295
Codim< cd >::template Partition< pit >::Iterator end() const
obtain end iterator for this view
Definition defaultgridview.hh:350
const Grid & grid() const
obtain a const reference to the underlying hierarchic grid
Definition defaultgridview.hh:303
Codim< cd >::template Partition< pit >::Iterator begin() const
obtain begin iterator for this view
Definition defaultgridview.hh:336
IntersectionIterator ibegin(const typename Codim< 0 > ::Entity &entity) const
obtain begin intersection iterator with respect to this view
Definition defaultgridview.hh:357
Traits::Intersection Intersection
type of the intersection
Definition defaultgridview.hh:283
IntersectionIterator iend(const typename Codim< 0 > ::Entity &entity) const
obtain end intersection iterator with respect to this view
Definition defaultgridview.hh:364
Codim< cd >::Iterator end() const
obtain end iterator for this view
Definition defaultgridview.hh:343
Traits::CollectiveCommunication CollectiveCommunication
type of the collective communication
Definition defaultgridview.hh:289
Traits::Grid Grid
type of the grid
Definition defaultgridview.hh:277
int size(const GeometryType &type) const
obtain number of entities with a given geometry type
Definition defaultgridview.hh:322
Traits::IndexSet IndexSet
type of the index set
Definition defaultgridview.hh:280
const CollectiveCommunication & comm() const
obtain collective communication object
Definition defaultgridview.hh:370
DefaultLeafGridView(const Grid &grid)
Definition defaultgridview.hh:298
int overlapSize(int codim) const
Return size of the overlap region for a given codim on the grid view.
Definition defaultgridview.hh:376
Codim< cd >::Iterator begin() const
obtain begin iterator for this view
Definition defaultgridview.hh:329
int ghostSize(int codim) const
Return size of the ghost region for a given codim on the grid view.
Definition defaultgridview.hh:382
int size(int codim) const
obtain number of entities in a given codimension
Definition defaultgridview.hh:316
const IndexSet & indexSet() const
obtain the index set
Definition defaultgridview.hh:310
Traits::IntersectionIterator IntersectionIterator
type of the intersection iterator
Definition defaultgridview.hh:286
Definition defaultgridview.hh:24
Grid::Traits::CollectiveCommunication CollectiveCommunication
type of the collective communication
Definition defaultgridview.hh:41
Grid::Traits::LevelIntersection Intersection
type of the intersection
Definition defaultgridview.hh:34
Grid::Traits::LevelIntersectionIterator IntersectionIterator
type of the intersection iterator
Definition defaultgridview.hh:38
@ conforming
Definition defaultgridview.hh:67
Grid::Traits::LevelIndexSet IndexSet
type of the index set
Definition defaultgridview.hh:31
std::remove_const< GridImp >::type Grid
type of the grid
Definition defaultgridview.hh:28
DefaultLevelGridView< GridImp > GridViewImp
Definition defaultgridview.hh:25
Definition defaultgridview.hh:45
Grid::Traits::template Codim< cd >::template Partition< All_Partition >::LevelIterator Iterator
Definition defaultgridview.hh:48
Grid::Traits::template Codim< cd >::Entity Entity
Definition defaultgridview.hh:50
Grid::template Codim< cd >::Geometry Geometry
Definition defaultgridview.hh:52
Grid::template Codim< cd >::LocalGeometry LocalGeometry
Definition defaultgridview.hh:54
Define types needed to iterate over entities of a given partition type.
Definition defaultgridview.hh:59
Grid::template Codim< cd >::template Partition< pit >::LevelIterator Iterator
iterator over a given codim and partition type
Definition defaultgridview.hh:63
Codim Structure.
Definition defaultgridview.hh:96
Definition defaultgridview.hh:221
std::remove_const< GridImp >::type Grid
type of the grid
Definition defaultgridview.hh:225
@ conforming
Definition defaultgridview.hh:264
DefaultLeafGridView< GridImp > GridViewImp
Definition defaultgridview.hh:222
Grid::Traits::LeafIntersectionIterator IntersectionIterator
type of the intersection iterator
Definition defaultgridview.hh:235
Grid::Traits::LeafIntersection Intersection
type of the intersection
Definition defaultgridview.hh:231
Grid::Traits::LeafIndexSet IndexSet
type of the index set
Definition defaultgridview.hh:228
Grid::Traits::CollectiveCommunication CollectiveCommunication
type of the collective communication
Definition defaultgridview.hh:238
Definition defaultgridview.hh:242
Grid::Traits::template Codim< cd >::template Partition< All_Partition >::LeafIterator Iterator
Definition defaultgridview.hh:245
Grid::Traits::template Codim< cd >::Entity Entity
Definition defaultgridview.hh:247
Grid::template Codim< cd >::Geometry Geometry
Definition defaultgridview.hh:249
Grid::template Codim< cd >::LocalGeometry LocalGeometry
Definition defaultgridview.hh:251
Define types needed to iterate over entities of a given partition type.
Definition defaultgridview.hh:256
Grid::template Codim< cd >::template Partition< pit >::LeafIterator Iterator
iterator over a given codim and partition type
Definition defaultgridview.hh:260
Codim Structure.
Definition defaultgridview.hh:293
Mesh entities of codimension 0 ("elements") allow to visit all intersections with "neighboring" eleme...
Definition common/intersectioniterator.hh:81
Grid abstract base class.
Definition common/grid.hh:373
A set of traits classes to store static information about grid implementation.