Dune Core Modules (2.9.0)

defaultgridview.hh
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
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
46 [[deprecated("Use Communication instead!")]]
47 typedef Communication CollectiveCommunication;
48
49 template< int cd >
50 struct Codim
51 {
52 typedef typename Grid :: Traits
53 :: template Codim< cd > :: template Partition< All_Partition > :: LevelIterator
54 Iterator;
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
60 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 >
78 class DefaultLevelGridView
79 {
80 typedef DefaultLevelGridView< GridImp > ThisType;
81
82 public:
83 typedef DefaultLevelGridViewTraits<GridImp> Traits;
84
86 typedef typename Traits::Grid Grid;
87
89 typedef typename Traits :: IndexSet IndexSet;
90
92 typedef typename Traits :: Intersection Intersection;
93
95 typedef typename Traits :: IntersectionIterator IntersectionIterator;
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
172 IntersectionIterator
173 ibegin ( const typename Codim< 0 > :: Entity &entity ) const
174 {
175 return entity.impl().ilevelbegin();
176 }
177
179 IntersectionIterator
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 >
205 void communicate ( CommDataHandleIF< DataHandleImp, DataType > &data,
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 >
219 struct DefaultLeafGridViewTraits {
220 typedef DefaultLeafGridView< GridImp > GridViewImp;
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
233 IntersectionIterator;
234
236 typedef typename Grid :: Traits :: Communication Communication;
237
239 [[deprecated("Use Communication instead!")]]
240 typedef Communication CollectiveCommunication;
241
242 template< int cd >
243 struct Codim
244 {
245 typedef typename Grid :: Traits
246 :: template Codim< cd > :: template Partition< All_Partition > :: LeafIterator
247 Iterator;
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
253 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 >
271 class DefaultLeafGridView
272 {
273 typedef DefaultLeafGridView< GridImp > ThisType;
274
275 public:
276 typedef DefaultLeafGridViewTraits<GridImp> Traits;
277
279 typedef typename Traits::Grid Grid;
280
282 typedef typename Traits :: IndexSet IndexSet;
283
285 typedef typename Traits :: Intersection Intersection;
286
288 typedef typename Traits :: IntersectionIterator IntersectionIterator;
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:
304 DefaultLeafGridView ( const Grid &grid )
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
365 IntersectionIterator
366 ibegin ( const typename Codim< 0 > :: Entity &entity ) const
367 {
368 return entity.impl().ileafbegin();
369 }
370
372 IntersectionIterator
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 >
398 void communicate ( CommDataHandleIF< DataHandleImp, DataType > &data,
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
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 few common exception classes.
Traits for type conversions and type information.
A set of traits classes to store static information about grid implementation.
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
Communication< T > CollectiveCommunication
Definition: communication.hh:541
@ conforming
use only conforming bisection refinement
Definition: declaration.hh:25
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
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
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 21, 23:30, 2024)