Dune Core Modules (2.6.0)

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_GRID_COMMON_DEFAULTGRIDVIEW_HH
4#define DUNE_GRID_COMMON_DEFAULTGRIDVIEW_HH
5
8
10#include <dune/grid/common/gridview.hh>
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 >
23 struct DefaultLevelGridViewTraits
24 {
25 typedef DefaultLevelGridView< GridImp > GridViewImp;
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
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< All_Partition > :: LevelIterator
48 Iterator;
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
54 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 >
72 class DefaultLevelGridView
73 {
74 typedef DefaultLevelGridView< GridImp > ThisType;
75
76 public:
77 typedef DefaultLevelGridViewTraits<GridImp> Traits;
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
106 const Grid &grid () const
107 {
108 assert( grid_ );
109 return *grid_;
110 }
111
113 const IndexSet &indexSet () const
114 {
115 return grid().levelIndexSet( level_ );
116 }
117
119 int size ( int codim ) const
120 {
121 return grid().size( level_, codim );
122 }
123
125 int size ( const GeometryType &type ) const
126 {
127 return grid().size( level_, type );
128 }
129
131 template< int cd >
132 typename Codim< cd > :: Iterator begin () const
133 {
134 return grid().template lbegin< cd, All_Partition >( level_ );
135 }
136
138 template< int cd, PartitionIteratorType pit >
139 typename Codim< cd > :: template Partition< pit > :: Iterator begin () const
140 {
141 return grid().template lbegin< cd, pit >( level_ );
142 }
143
145 template< int cd >
146 typename Codim< cd > :: Iterator end () const
147 {
148 return grid().template lend< cd, All_Partition >( level_ );
149 }
150
152 template< int cd, PartitionIteratorType pit >
153 typename Codim< cd > :: template Partition< pit > :: Iterator end () const
154 {
155 return grid().template lend< cd, pit >( level_ );
156 }
157
159 IntersectionIterator
160 ibegin ( const typename Codim< 0 > :: Entity &entity ) const
161 {
162 return entity.impl().ilevelbegin();
163 }
164
166 IntersectionIterator
167 iend ( const typename Codim< 0 > :: Entity &entity ) const
168 {
169 return entity.impl().ilevelend();
170 }
171
173 const CollectiveCommunication &comm () const
174 {
175 return grid().comm();
176 }
177
179 int overlapSize(int codim) const
180 {
181 return grid().overlapSize(level_, codim);
182 }
183
185 int ghostSize(int codim) const
186 {
187 return grid().ghostSize(level_, codim);
188 }
189
191 template< class DataHandleImp, class DataType >
192 void communicate ( CommDataHandleIF< DataHandleImp, DataType > &data,
193 InterfaceType iftype,
194 CommunicationDirection dir ) const
195 {
196 return grid().communicate( data, iftype, dir, level_ );
197 }
198
199 private:
200 const Grid *grid_;
201 int level_;
202 };
203
204
205 template< class GridImp >
206 struct DefaultLeafGridViewTraits {
207 typedef DefaultLeafGridView< GridImp > GridViewImp;
208
210 typedef typename std::remove_const<GridImp>::type Grid;
211
213 typedef typename Grid :: Traits :: LeafIndexSet IndexSet;
214
216 typedef typename Grid :: Traits :: LeafIntersection Intersection;
217
219 typedef typename Grid :: Traits :: LeafIntersectionIterator
220 IntersectionIterator;
221
223 typedef typename Grid :: Traits :: CollectiveCommunication CollectiveCommunication;
224
225 template< int cd >
226 struct Codim
227 {
228 typedef typename Grid :: Traits
229 :: template Codim< cd > :: template Partition< All_Partition > :: LeafIterator
230 Iterator;
231
232 typedef typename Grid :: Traits :: template Codim< cd > :: Entity Entity;
233
234 typedef typename Grid :: template Codim< cd > :: Geometry Geometry;
235 typedef typename Grid :: template Codim< cd > :: LocalGeometry
236 LocalGeometry;
237
239 template <PartitionIteratorType pit >
241 {
243 typedef typename Grid :: template Codim< cd >
244 :: template Partition< pit > :: LeafIterator
246 };
247 };
248
249 enum { conforming = Capabilities :: isLeafwiseConforming< Grid > :: v };
250 };
251
252
253 template< class GridImp >
254 class DefaultLeafGridView
255 {
256 typedef DefaultLeafGridView< GridImp > ThisType;
257
258 public:
259 typedef DefaultLeafGridViewTraits<GridImp> Traits;
260
262 typedef typename Traits::Grid Grid;
263
265 typedef typename Traits :: IndexSet IndexSet;
266
268 typedef typename Traits :: Intersection Intersection;
269
271 typedef typename Traits :: IntersectionIterator IntersectionIterator;
272
274 typedef typename Traits :: CollectiveCommunication CollectiveCommunication;
275
277 template< int cd >
278 struct Codim : public Traits :: template Codim<cd> {};
279
280 enum { conforming = Traits :: conforming };
281
282 public:
283 DefaultLeafGridView ( const Grid &grid )
284 : grid_( &grid )
285 {}
286
288 const Grid &grid () const
289 {
290 assert( grid_ );
291 return *grid_;
292 }
293
295 const IndexSet &indexSet () const
296 {
297 return grid().leafIndexSet();
298 }
299
301 int size ( int codim ) const
302 {
303 return grid().size( codim );
304 }
305
307 int size ( const GeometryType &type ) const
308 {
309 return grid().size( type );
310 }
311
313 template< int cd >
314 typename Codim< cd > :: Iterator begin () const
315 {
316 return grid().template leafbegin< cd, All_Partition >();
317 }
318
320 template< int cd, PartitionIteratorType pit >
321 typename Codim< cd > :: template Partition< pit > :: Iterator begin () const
322 {
323 return grid().template leafbegin< cd, pit >();
324 }
325
327 template< int cd >
328 typename Codim< cd > :: Iterator end () const
329 {
330 return grid().template leafend< cd, All_Partition >();
331 }
332
334 template< int cd, PartitionIteratorType pit >
335 typename Codim< cd > :: template Partition< pit > :: Iterator end () const
336 {
337 return grid().template leafend< cd, pit >();
338 }
339
341 IntersectionIterator
342 ibegin ( const typename Codim< 0 > :: Entity &entity ) const
343 {
344 return entity.impl().ileafbegin();
345 }
346
348 IntersectionIterator
349 iend ( const typename Codim< 0 > :: Entity &entity ) const
350 {
351 return entity.impl().ileafend();
352 }
353
355 const CollectiveCommunication &comm () const
356 {
357 return grid().comm();
358 }
359
361 int overlapSize(int codim) const
362 {
363 return grid().overlapSize(codim);
364 }
365
367 int ghostSize(int codim) const
368 {
369 return grid().ghostSize(codim);
370 }
371
373 template< class DataHandleImp, class DataType >
374 void communicate ( CommDataHandleIF< DataHandleImp, DataType > &data,
375 InterfaceType iftype,
376 CommunicationDirection dir ) const
377 {
378 return grid().communicate( data, iftype, dir );
379 }
380
381 private:
382 const Grid *grid_;
383 };
384
385}
386
387#endif
Grid abstract base class.
Definition: grid.hh:373
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: alignedallocator.hh:10
Define types needed to iterate over entities of a given partition type.
Definition: defaultgridview.hh:241
Grid::template Codim< cd >::template Partition< pit >::LeafIterator Iterator
iterator over a given codim and partition type
Definition: defaultgridview.hh:245
Codim Structure.
Definition: defaultgridview.hh:278
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
Traits for type conversions and type information.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 27, 23:30, 2024)