Dune Core Modules (2.9.1)

gridview.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_ALBERTAGRID_GRIDVIEW_HH
6#define DUNE_ALBERTAGRID_GRIDVIEW_HH
7
8#if HAVE_ALBERTA
9
12
14#include <dune/grid/common/gridview.hh>
15
17
18namespace Dune
19{
20
21 template< class GridImp >
22 class AlbertaLevelGridView;
23
24 template< class GridImp >
25 class AlbertaLeafGridView;
26
27
28 template< class GridImp >
29 struct AlbertaLevelGridViewTraits
30 {
31 typedef AlbertaLevelGridView< GridImp > GridViewImp;
32
34 typedef typename std::remove_const<GridImp>::type Grid;
35
37 typedef typename Grid::Traits::LevelIndexSet IndexSet;
38
40 typedef typename Grid::Traits::LevelIntersection Intersection;
41
43 typedef typename Grid::Traits::LevelIntersectionIterator
44 IntersectionIterator;
45
47 typedef typename Grid::Traits::Communication Communication;
48
50 [[deprecated("Use Communication instead!")]]
51 typedef Communication CollectiveCommunication;
52
53 template< int cd >
54 struct Codim
55 {
56 typedef typename Grid::Traits::template Codim< cd >::template Partition< All_Partition >::LevelIterator Iterator;
57
58 typedef typename Grid::Traits::template Codim< cd >::Entity Entity;
59
60 typedef typename Grid::template Codim< cd >::Geometry Geometry;
61 typedef typename Grid::template Codim< cd >::LocalGeometry
62 LocalGeometry;
63
65 template< PartitionIteratorType pit >
66 struct Partition
67 {
69 typedef typename Grid::template Codim< cd >::template Partition< pit >::LevelIterator
71 };
72 };
73
74 constexpr static bool conforming = Capabilities::isLevelwiseConforming< Grid >::v;
75 };
76
77
78 template< class GridImp >
79 class AlbertaLevelGridView
80 {
81 typedef AlbertaLevelGridView< GridImp > ThisType;
82
83 public:
84 typedef AlbertaLevelGridViewTraits<GridImp> Traits;
85
87 typedef typename Traits::Grid Grid;
88
90 typedef typename Traits::IndexSet IndexSet;
91
93 typedef typename Traits::Intersection Intersection;
94
96 typedef typename Traits::IntersectionIterator IntersectionIterator;
97
99 typedef typename Traits::Communication Communication;
100
102 [[deprecated("Use Communication instead!")]]
104
106 template< int cd >
107 struct Codim : public Traits::template Codim<cd> {};
108
109 constexpr static bool conforming = Traits::conforming;
110
111 private:
112 typedef Alberta::ElementInfo< Grid::dimension > ElementInfo;
113
114 typedef Dune::AlbertaGridLeafIntersectionIterator< GridImp > IntersectionIteratorImpl;
115
116 public:
117 AlbertaLevelGridView ( const Grid &grid, int level )
118 : grid_( &grid ),
119 indexSet_( &(grid.levelIndexSet( level )) ),
120 level_( level )
121 {}
122
123 // use default implementation of copy constructor and assignment operator
124#if 0
125 AlbertaLevelGridView ( const ThisType &other )
126 : grid_( other.grid_ ),
127 indexSet_( other.indexSet_ ),
128 level_( other.level_ )
129 {}
130
132 ThisType &operator= ( const ThisType & other)
133 {
134 grid_ = other.grid_;
135 indexSet_ = other.indexSet_;
136 level_ = other.level_;
137 }
138#endif
139
141 const Grid &grid () const
142 {
143 return *grid_;
144 }
145
147 const IndexSet &indexSet () const
148 {
149 return *indexSet_;
150 }
151
153 bool isConforming() const { return bool(conforming); }
154
156 int size ( int codim ) const
157 {
158 return grid().size( level_, codim );
159 }
160
162 int size ( const GeometryType &type ) const
163 {
164 return grid().size( level_, type );
165 }
166
168 template< int cd >
169 typename Codim< cd >::Iterator begin () const
170 {
171 return grid().template lbegin< cd, All_Partition >( level_ );
172 }
173
175 template< int cd, PartitionIteratorType pit >
176 typename Codim< cd >::template Partition< pit >::Iterator begin () const
177 {
178 return grid().template lbegin< cd, pit >( level_ );
179 }
180
182 template< int cd >
183 typename Codim< cd >::Iterator end () const
184 {
185 return grid().template lend< cd, All_Partition >( level_ );
186 }
187
189 template< int cd, PartitionIteratorType pit >
190 typename Codim< cd >::template Partition< pit >::Iterator end () const
191 {
192 return grid().template lend< cd, pit >( level_ );
193 }
194
196 IntersectionIterator
197 ibegin ( const typename Codim< 0 >::Entity &entity ) const
198 {
199 if( grid().maxLevel() == 0)
200 {
201 typename IntersectionIteratorImpl::Begin begin;
202 return IntersectionIteratorImpl( entity.impl(), begin );
203 }
204 else
205 {
206 DUNE_THROW( NotImplemented, "method ibegin not implemented on LevelGridView for AlbertaGrid." );
207 typename IntersectionIteratorImpl::End end;
208 return IntersectionIteratorImpl( entity.impl(), end );
209 }
210 }
211
213 IntersectionIterator
214 iend ( const typename Codim< 0 >::Entity &entity ) const
215 {
216 typename IntersectionIteratorImpl::End end;
217 return IntersectionIteratorImpl( entity.impl(), end );
218 }
219
221 const Communication &comm () const
222 {
223 return grid().comm();
224 }
225
227 int overlapSize ( [[maybe_unused]] int codim ) const { return 0; }
228
230 int ghostSize ( [[maybe_unused]] int codim ) const { return 0; }
231
233 template< class DataHandleImp, class DataType >
234 void communicate ( [[maybe_unused]] CommDataHandleIF< DataHandleImp, DataType > &data,
235 [[maybe_unused]] InterfaceType iftype,
236 [[maybe_unused]] CommunicationDirection dir ) const
237 {}
238
239 private:
240 const Grid *grid_;
241 const IndexSet *indexSet_;
242 int level_;
243 };
244
245
246 template< class GridImp >
247 struct AlbertaLeafGridViewTraits
248 {
249 typedef AlbertaLeafGridView< GridImp > GridViewImp;
250
252 typedef typename std::remove_const<GridImp>::type Grid;
253
255 typedef typename Grid::Traits::LeafIndexSet IndexSet;
256
258 typedef typename Grid::Traits::LeafIntersection Intersection;
259
261 typedef typename Grid::Traits::LeafIntersectionIterator
262 IntersectionIterator;
263
265 typedef typename Grid::Traits::Communication Communication;
266
268 [[deprecated("Use Communication instead!")]]
269 typedef Communication CollectiveCommunication;
270
271 template< int cd >
272 struct Codim
273 {
274 typedef typename Grid::Traits::template Codim< cd >::template Partition< All_Partition >::LeafIterator
275 Iterator;
276
277 typedef typename Grid::Traits::template Codim< cd >::Entity Entity;
278
279 typedef typename Grid::template Codim< cd >::Geometry Geometry;
280 typedef typename Grid::template Codim< cd >::LocalGeometry
281 LocalGeometry;
282
284 template <PartitionIteratorType pit >
286 {
288 typedef typename Grid::template Codim< cd >::template Partition< pit >::LeafIterator
290 };
291 };
292
293 constexpr static bool conforming = Capabilities::isLeafwiseConforming< Grid >::v;
294 };
295
296
297 template< class GridImp >
298 class AlbertaLeafGridView
299 {
300 typedef AlbertaLeafGridView< GridImp > ThisType;
301
302 public:
303 typedef AlbertaLeafGridViewTraits<GridImp> Traits;
304
306 typedef typename Traits::Grid Grid;
307
309 typedef typename Traits::IndexSet IndexSet;
310
312 typedef typename Traits::Intersection Intersection;
313
315 typedef typename Traits::IntersectionIterator IntersectionIterator;
316
318 typedef typename Traits::Communication Communication;
319
321 [[deprecated("Use Communication instead!")]]
323
325 template< int cd >
326 struct Codim : public Traits::template Codim<cd> {};
327
328 constexpr static bool conforming = Traits::conforming;
329
330 private:
331 typedef Alberta::ElementInfo< Grid::dimension > ElementInfo;
332
333 typedef Dune::AlbertaGridLeafIntersectionIterator< GridImp > IntersectionIteratorImpl;
334
335 public:
336 AlbertaLeafGridView ( const Grid &grid )
337 : grid_( &grid ),
338 indexSet_( &(grid.leafIndexSet()) )
339 {}
340
341 // use default implementation of copy constructor and assignment operator
342#if 0
343 AlbertaLeafGridView ( const ThisType &other )
344 : grid_( other.grid_ ),
345 indexSet_( other.indexSet_ )
346 {}
347
349 ThisType &operator= ( const ThisType & other)
350 {
351 grid_ = other.grid_;
352 indexSet_ = other.indexSet_;
353 }
354#endif
355
357 const Grid &grid () const
358 {
359 return *grid_;
360 }
361
363 const IndexSet &indexSet () const
364 {
365 return *indexSet_;
366 }
367
369 bool isConforming() const { return bool(conforming); }
370
372 int size ( int codim ) const
373 {
374 return grid().size( codim );
375 }
376
378 int size ( const GeometryType &type ) const
379 {
380 return grid().size( type );
381 }
382
384 template< int cd >
385 typename Codim< cd >::Iterator begin () const
386 {
387 return grid().template leafbegin< cd, All_Partition >();
388 }
389
391 template< int cd, PartitionIteratorType pit >
392 typename Codim< cd >::template Partition< pit >::Iterator begin () const
393 {
394 return grid().template leafbegin< cd, pit >();
395 }
396
398 template< int cd >
399 typename Codim< cd >::Iterator end () const
400 {
401 return grid().template leafend< cd, All_Partition >();
402 }
403
405 template< int cd, PartitionIteratorType pit >
406 typename Codim< cd >::template Partition< pit >::Iterator end () const
407 {
408 return grid().template leafend< cd, pit >();
409 }
410
412 IntersectionIterator
413 ibegin ( const typename Codim< 0 >::Entity &entity ) const
414 {
415 const ElementInfo elementInfo = entity.impl().elementInfo();
416 assert( !!elementInfo );
417
418#ifndef NDEBUG
419 for( int i = 0; i <= Grid::dimension; ++i )
420 {
421 if( elementInfo.elInfo().opp_vertex[ i ] == 127 )
422 DUNE_THROW( NotImplemented, "AlbertaGrid: Intersections on outside entities are not fully implemented, yet." );
423 }
424#endif // #ifndef NDEBUG
425
426 typename IntersectionIteratorImpl::Begin begin;
427 return IntersectionIteratorImpl( entity.impl(), begin );
428 }
429
431 IntersectionIterator
432 iend ( const typename Codim< 0 >::Entity &entity ) const
433 {
434 assert( !!entity.impl().elementInfo() );
435 typename IntersectionIteratorImpl::End end;
436 return IntersectionIteratorImpl( entity.impl(), end );
437 }
438
440 const Communication &comm () const
441 {
442 return grid().comm();
443 }
444
446 int overlapSize ( [[maybe_unused]] int codim ) const { return 0; }
447
449 int ghostSize ( [[maybe_unused]] int codim ) const { return 0; }
450
452 template< class DataHandleImp, class DataType >
453 void communicate ( [[maybe_unused]] CommDataHandleIF< DataHandleImp, DataType > &data,
454 [[maybe_unused]] InterfaceType iftype,
455 [[maybe_unused]] CommunicationDirection dir ) const
456 {}
457
458 private:
459 const Grid *grid_;
460 const IndexSet *indexSet_;
461 };
462
463}
464
465#endif // #if HAVE_ALBERTA
466#endif // #ifndef DUNE_ALBERTAGRID_GRIDVIEW_HH
Implementation of the IntersectionIterator for AlbertaGrid.
Collective communication interface and sequential default implementation.
Definition: communication.hh:100
Grid abstract base class.
Definition: grid.hh:375
static constexpr int dimension
The dimension of the grid.
Definition: grid.hh:387
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.
#define DUNE_THROW(E, m)
Definition: exceptions.hh:218
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
Define types needed to iterate over entities of a given partition type.
Definition: gridview.hh:286
Grid::template Codim< cd >::template Partition< pit >::LeafIterator Iterator
iterator over a given codim and partition type
Definition: gridview.hh:289
Codim Structure.
Definition: gridview.hh:326
Define types needed to iterate over entities of a given partition type.
Definition: gridview.hh:67
Grid::template Codim< cd >::template Partition< pit >::LevelIterator Iterator
iterator over a given codim and partition type
Definition: gridview.hh:70
Codim Structure.
Definition: gridview.hh:107
Specialize with 'true' if implementation guarantees a conforming leaf grid. (default=false)
Definition: capabilities.hh:115
Specialize with 'true' if implementation guarantees conforming level grids. (default=false)
Definition: capabilities.hh:106
Traits for type conversions and type information.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 15, 22:36, 2024)