Dune Core Modules (2.4.2)

defaultgridview.hh
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
8
10#include <dune/grid/common/gridview.hh>
11
12namespace Dune
13{
14
15 template< class GridImp, PartitionIteratorType pitype >
16 class DefaultLevelGridView;
17
18 template< class GridImp, PartitionIteratorType pitype >
19 class DefaultLeafGridView;
20
21
22 template< class GridImp, PartitionIteratorType pitype >
23 struct DefaultLevelGridViewTraits
24 {
25 typedef DefaultLevelGridView< GridImp, pitype > GridViewImp;
26
28 typedef typename 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
38 IntersectionIterator;
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< pitype > :: LevelIterator
48 Iterator;
49
50 typedef typename Grid :: Traits :: template Codim< cd > :: Entity Entity;
51 typedef typename Grid :: Traits :: template Codim< cd > :: EntityPointer
52 EntityPointer;
53
54 typedef typename Grid :: template Codim< cd > :: Geometry Geometry;
55 typedef typename Grid :: template Codim< cd > :: LocalGeometry
56 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 enum { conforming = Capabilities :: isLevelwiseConforming< Grid > :: v };
70 };
71
72
73 template< class GridImp, PartitionIteratorType pitype >
74 class DefaultLevelGridView
75 {
76 typedef DefaultLevelGridView< GridImp, pitype > ThisType;
77
78 public:
79 typedef DefaultLevelGridViewTraits<GridImp,pitype> Traits;
80
82 typedef typename Traits::Grid Grid;
83
85 typedef typename Traits :: IndexSet IndexSet;
86
88 typedef typename Traits :: Intersection Intersection;
89
91 typedef typename Traits :: IntersectionIterator IntersectionIterator;
92
94 typedef typename Traits :: CollectiveCommunication CollectiveCommunication;
95
97 template< int cd >
98 struct Codim : public Traits :: template Codim<cd> {};
99
100 enum { conforming = Traits :: conforming };
101
102 DefaultLevelGridView ( const Grid &grid, int level )
103 : grid_( &grid ),
104 level_( level )
105 {}
106
107 // use default implementation of copy constructor and assignment operator
108#if 0
109 DefaultLevelGridView ( const ThisType &other )
110 : grid_( other.grid_ ),
111 level_( other.level_ )
112 {}
113
115 ThisType &operator= ( const ThisType & other)
116 {
117 grid_ = other.grid_;
118 level_ = other.level_;
119 }
120#endif
121
123 const Grid &grid () const
124 {
125 assert( grid_ );
126 return *grid_;
127 }
128
130 const IndexSet &indexSet () const
131 {
132 return grid().levelIndexSet( level_ );
133 }
134
136 int size ( int codim ) const
137 {
138 return grid().size( level_, codim );
139 }
140
142 int size ( const GeometryType &type ) const
143 {
144 return grid().size( level_, type );
145 }
146
148 template< int cd >
149 typename Codim< cd > :: Iterator begin () const
150 {
151 return grid().template lbegin< cd, pitype >( level_ );
152 }
153
155 template< int cd, PartitionIteratorType pit >
156 typename Codim< cd > :: template Partition< pit > :: Iterator begin () const
157 {
158 return grid().template lbegin< cd, pit >( level_ );
159 }
160
162 template< int cd >
163 typename Codim< cd > :: Iterator end () const
164 {
165 return grid().template lend< cd, pitype >( level_ );
166 }
167
169 template< int cd, PartitionIteratorType pit >
170 typename Codim< cd > :: template Partition< pit > :: Iterator end () const
171 {
172 return grid().template lend< cd, pit >( level_ );
173 }
174
176 IntersectionIterator
177 ibegin ( const typename Codim< 0 > :: Entity &entity ) const
178 {
179 return entity.impl().ilevelbegin();
180 }
181
183 IntersectionIterator
184 iend ( const typename Codim< 0 > :: Entity &entity ) const
185 {
186 return entity.impl().ilevelend();
187 }
188
190 const CollectiveCommunication &comm () const
191 {
192 return grid().comm();
193 }
194
196 int overlapSize(int codim) const
197 {
198 return grid().overlapSize(level_, codim);
199 }
200
202 int ghostSize(int codim) const
203 {
204 return grid().ghostSize(level_, codim);
205 }
206
208 template< class DataHandleImp, class DataType >
209 void communicate ( CommDataHandleIF< DataHandleImp, DataType > &data,
210 InterfaceType iftype,
211 CommunicationDirection dir ) const
212 {
213 return grid().communicate( data, iftype, dir, level_ );
214 }
215
216 private:
217 const Grid *grid_;
218 int level_;
219 };
220
221
222 template< class GridImp, PartitionIteratorType pitype >
223 struct DefaultLeafGridViewTraits {
224 typedef DefaultLeafGridView< GridImp, pitype > GridViewImp;
225
227 typedef typename remove_const<GridImp>::type Grid;
228
230 typedef typename Grid :: Traits :: LeafIndexSet IndexSet;
231
233 typedef typename Grid :: Traits :: LeafIntersection Intersection;
234
236 typedef typename Grid :: Traits :: LeafIntersectionIterator
237 IntersectionIterator;
238
240 typedef typename Grid :: Traits :: CollectiveCommunication CollectiveCommunication;
241
242 template< int cd >
243 struct Codim
244 {
245 typedef typename Grid :: Traits
246 :: template Codim< cd > :: template Partition< pitype > :: LeafIterator
247 Iterator;
248
249 typedef typename Grid :: Traits :: template Codim< cd > :: Entity Entity;
250 typedef typename Grid :: Traits :: template Codim< cd > :: EntityPointer
251 EntityPointer;
252
253 typedef typename Grid :: template Codim< cd > :: Geometry Geometry;
254 typedef typename Grid :: template Codim< cd > :: LocalGeometry
255 LocalGeometry;
256
258 template <PartitionIteratorType pit >
260 {
262 typedef typename Grid :: template Codim< cd >
263 :: template Partition< pit > :: LeafIterator
265 };
266 };
267
268 enum { conforming = Capabilities :: isLeafwiseConforming< Grid > :: v };
269 };
270
271
272 template< class GridImp, PartitionIteratorType pitype >
273 class DefaultLeafGridView
274 {
275 typedef DefaultLeafGridView< GridImp, pitype > ThisType;
276
277 public:
278 typedef DefaultLeafGridViewTraits<GridImp,pitype> Traits;
279
281 typedef typename Traits::Grid Grid;
282
284 typedef typename Traits :: IndexSet IndexSet;
285
287 typedef typename Traits :: Intersection Intersection;
288
290 typedef typename Traits :: IntersectionIterator IntersectionIterator;
291
293 typedef typename Traits :: CollectiveCommunication CollectiveCommunication;
294
296 template< int cd >
297 struct Codim : public Traits :: template Codim<cd> {};
298
299 enum { conforming = Traits :: conforming };
300
301 public:
302 DefaultLeafGridView ( const Grid &grid )
303 : grid_( &grid )
304 {}
305
307 const Grid &grid () const
308 {
309 assert( grid_ );
310 return *grid_;
311 }
312
314 const IndexSet &indexSet () const
315 {
316 return grid().leafIndexSet();
317 }
318
320 int size ( int codim ) const
321 {
322 return grid().size( codim );
323 }
324
326 int size ( const GeometryType &type ) const
327 {
328 return grid().size( type );
329 }
330
332 template< int cd >
333 typename Codim< cd > :: Iterator begin () const
334 {
335 return grid().template leafbegin< cd, pitype >();
336 }
337
339 template< int cd, PartitionIteratorType pit >
340 typename Codim< cd > :: template Partition< pit > :: Iterator begin () const
341 {
342 return grid().template leafbegin< cd, pit >();
343 }
344
346 template< int cd >
347 typename Codim< cd > :: Iterator end () const
348 {
349 return grid().template leafend< cd, pitype >();
350 }
351
353 template< int cd, PartitionIteratorType pit >
354 typename Codim< cd > :: template Partition< pit > :: Iterator end () const
355 {
356 return grid().template leafend< cd, pit >();
357 }
358
360 IntersectionIterator
361 ibegin ( const typename Codim< 0 > :: Entity &entity ) const
362 {
363 return entity.impl().ileafbegin();
364 }
365
367 IntersectionIterator
368 iend ( const typename Codim< 0 > :: Entity &entity ) const
369 {
370 return entity.impl().ileafend();
371 }
372
374 const CollectiveCommunication &comm () const
375 {
376 return grid().comm();
377 }
378
380 int overlapSize(int codim) const
381 {
382 return grid().overlapSize(codim);
383 }
384
386 int ghostSize(int codim) const
387 {
388 return grid().ghostSize(codim);
389 }
390
392 template< class DataHandleImp, class DataType >
393 void communicate ( CommDataHandleIF< DataHandleImp, DataType > &data,
394 InterfaceType iftype,
395 CommunicationDirection dir ) const
396 {
397 return grid().communicate( data, iftype, dir );
398 }
399
400 private:
401 const Grid *grid_;
402 };
403
404}
405
406#endif
Grid abstract base class.
Definition: grid.hh:388
A set of traits classes to store static information about grid implementation.
A few common exception classes.
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
Dune namespace.
Definition: alignment.hh:10
Define types needed to iterate over entities of a given partition type.
Definition: defaultgridview.hh:260
Grid::template Codim< cd >::template Partition< pit >::LeafIterator Iterator
iterator over a given codim and partition type
Definition: defaultgridview.hh:264
Codim Structure.
Definition: defaultgridview.hh:297
Define types needed to iterate over entities of a given partition type.
Definition: defaultgridview.hh:61
Grid::template Codim< cd >::template Partition< pit >::LevelIterator Iterator
iterator over a given codim and partition type
Definition: defaultgridview.hh:65
Codim Structure.
Definition: defaultgridview.hh:98
Traits for type conversions and type information.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 21, 23:30, 2024)