DUNE PDELab (git)

defaultgridview.hh
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
10
12#include <dune/grid/common/gridview.hh>
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 >
25 struct DefaultLevelGridViewTraits
26 {
27 typedef DefaultLevelGridView< GridImp > GridViewImp;
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
40 IntersectionIterator;
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
50 Iterator;
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
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 constexpr static bool conforming = Capabilities :: isLevelwiseConforming< Grid > :: v;
70 };
71
72
73 template< class GridImp >
74 class DefaultLevelGridView
75 {
76 typedef DefaultLevelGridView< GridImp > ThisType;
77
78 public:
79 typedef DefaultLevelGridViewTraits<GridImp> 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 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
164 IntersectionIterator
165 ibegin ( const typename Codim< 0 > :: Entity &entity ) const
166 {
167 return grid().ilevelbegin(entity);
168 }
169
171 IntersectionIterator
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 >
197 void communicate ( CommDataHandleIF< DataHandleImp, DataType > &data,
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 >
211 struct DefaultLeafGridViewTraits {
212 typedef DefaultLeafGridView< GridImp > GridViewImp;
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
225 IntersectionIterator;
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
235 Iterator;
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
241 LocalGeometry;
242
244 template <PartitionIteratorType pit >
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:
264 typedef DefaultLeafGridViewTraits<GridImp> Traits;
265
267 typedef typename Traits::Grid Grid;
268
270 typedef typename Traits :: IndexSet IndexSet;
271
273 typedef typename Traits :: Intersection Intersection;
274
276 typedef typename Traits :: IntersectionIterator IntersectionIterator;
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:
288 DefaultLeafGridView ( const Grid &grid )
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
349 IntersectionIterator
350 ibegin ( const typename Codim< 0 > :: Entity &entity ) const
351 {
352 return grid().ileafbegin(entity);
353 }
354
356 IntersectionIterator
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 >
382 void communicate ( CommDataHandleIF< DataHandleImp, DataType > &data,
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
Collective communication interface and sequential default implementation.
Definition: communication.hh:100
Grid abstract base class.
Definition: grid.hh:375
Index Set Interface base class.
Definition: indexidset.hh:78
Mesh entities of codimension 0 ("elements") allow to visit all intersections with "neighboring" eleme...
Definition: intersectioniterator.hh:83
Intersection of a mesh entity of codimension 0 ("element") with a "neighboring" element or with the d...
Definition: intersection.hh:164
A set of traits classes to store static information about grid implementation.
A few common exception classes.
Traits for type conversions and type information.
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
Dune namespace.
Definition: alignedallocator.hh:13
constexpr std::integral_constant< std::size_t, sizeof...(II)> size(std::integer_sequence< T, II... >)
Return the size of the sequence.
Definition: integersequence.hh:75
Define types needed to iterate over entities of a given partition type.
Definition: defaultgridview.hh:246
Grid::template Codim< cd >::template Partition< pit >::LeafIterator Iterator
iterator over a given codim and partition type
Definition: defaultgridview.hh:250
Codim Structure.
Definition: defaultgridview.hh:283
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
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 24, 23:30, 2024)