dune-grid 2.9.0
albertagrid/gridview.hh
Go to the documentation of this file.
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
10#include <dune/common/typetraits.hh>
11#include <dune/common/exceptions.hh>
12
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 >
30 {
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
45
47 typedef typename Grid::Traits::Communication Communication;
48
50 [[deprecated("Use Communication instead!")]]
52
53 template< int cd >
54 struct Codim
55 {
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
63
65 template< PartitionIteratorType pit >
66 struct Partition
67 {
69 typedef typename Grid::template Codim< cd >::template Partition< pit >::LevelIterator
71 };
72 };
73
75 };
76
77
78 template< class GridImp >
80 {
82
83 public:
85
87 typedef typename Traits::Grid Grid;
88
90 typedef typename Traits::IndexSet IndexSet;
91
94
97
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:
113
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
197 ibegin ( const typename Codim< 0 >::Entity &entity ) const
198 {
199 if( grid().maxLevel() == 0)
200 {
202 return IntersectionIteratorImpl( entity.impl(), begin );
203 }
204 else
205 {
206 DUNE_THROW( NotImplemented, "method ibegin not implemented on LevelGridView for AlbertaGrid." );
208 return IntersectionIteratorImpl( entity.impl(), end );
209 }
210 }
211
214 iend ( const typename Codim< 0 >::Entity &entity ) const
215 {
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 >
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 >
248 {
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
263
265 typedef typename Grid::Traits::Communication Communication;
266
268 [[deprecated("Use Communication instead!")]]
270
271 template< int cd >
272 struct Codim
273 {
274 typedef typename Grid::Traits::template Codim< cd >::template Partition< All_Partition >::LeafIterator
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
282
284 template <PartitionIteratorType pit >
286 {
288 typedef typename Grid::template Codim< cd >::template Partition< pit >::LeafIterator
290 };
291 };
292
294 };
295
296
297 template< class GridImp >
299 {
301
302 public:
304
306 typedef typename Traits::Grid Grid;
307
309 typedef typename Traits::IndexSet IndexSet;
310
313
316
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:
332
334
335 public:
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
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
427 return IntersectionIteratorImpl( entity.impl(), begin );
428 }
429
432 iend ( const typename Codim< 0 >::Entity &entity ) const
433 {
434 assert( !!entity.impl().elementInfo() );
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 >
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
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
Include standard header files.
Definition: agrid.hh:60
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:132
Definition: elementinfo.hh:43
ALBERTA EL_INFO & elInfo() const
Definition: elementinfo.hh:744
Definition: albertagrid/intersectioniterator.hh:27
Definition: albertagrid/gridview.hh:80
Traits::Intersection Intersection
type of the intersection
Definition: albertagrid/gridview.hh:93
int size(const GeometryType &type) const
obtain number of entities with a given geometry type
Definition: albertagrid/gridview.hh:162
void communicate(CommDataHandleIF< DataHandleImp, DataType > &data, InterfaceType iftype, CommunicationDirection dir) const
Definition: albertagrid/gridview.hh:234
const Communication & comm() const
obtain communication object
Definition: albertagrid/gridview.hh:221
Traits::Communication Communication
type of the communication
Definition: albertagrid/gridview.hh:99
Traits::IndexSet IndexSet
type of the index set
Definition: albertagrid/gridview.hh:90
IntersectionIterator iend(const typename Codim< 0 >::Entity &entity) const
obtain end intersection iterator with respect to this view
Definition: albertagrid/gridview.hh:214
Codim< cd >::template Partition< pit >::Iterator begin() const
obtain begin iterator for this view
Definition: albertagrid/gridview.hh:176
AlbertaLevelGridView(const Grid &grid, int level)
Definition: albertagrid/gridview.hh:117
Traits::Grid Grid
type of the grid
Definition: albertagrid/gridview.hh:87
const Grid & grid() const
obtain a const reference to the underlying hierarchic grid
Definition: albertagrid/gridview.hh:141
int size(int codim) const
obtain number of entities in a given codimension
Definition: albertagrid/gridview.hh:156
bool isConforming() const
return true if current state of grid view represents a conforming grid
Definition: albertagrid/gridview.hh:153
AlbertaLevelGridViewTraits< GridImp > Traits
Definition: albertagrid/gridview.hh:84
static constexpr bool conforming
Definition: albertagrid/gridview.hh:109
int ghostSize(int codim) const
Return size of the ghost region for a given codim on the grid view.
Definition: albertagrid/gridview.hh:230
Codim< cd >::Iterator end() const
obtain end iterator for this view
Definition: albertagrid/gridview.hh:183
Codim< cd >::Iterator begin() const
obtain begin iterator for this view
Definition: albertagrid/gridview.hh:169
const IndexSet & indexSet() const
obtain the index set
Definition: albertagrid/gridview.hh:147
Traits::IntersectionIterator IntersectionIterator
type of the intersection iterator
Definition: albertagrid/gridview.hh:96
int overlapSize(int codim) const
Return size of the overlap region for a given codim on the grid view.
Definition: albertagrid/gridview.hh:227
Codim< cd >::template Partition< pit >::Iterator end() const
obtain end iterator for this view
Definition: albertagrid/gridview.hh:190
Communication CollectiveCommunication
Definition: albertagrid/gridview.hh:103
IntersectionIterator ibegin(const typename Codim< 0 >::Entity &entity) const
obtain begin intersection iterator with respect to this view
Definition: albertagrid/gridview.hh:197
Definition: albertagrid/gridview.hh:299
AlbertaLeafGridView(const Grid &grid)
Definition: albertagrid/gridview.hh:336
Traits::Communication Communication
type of the communication
Definition: albertagrid/gridview.hh:318
Traits::IndexSet IndexSet
type of the index set
Definition: albertagrid/gridview.hh:309
int ghostSize(int codim) const
Return size of the ghost region for a given codim on the grid view.
Definition: albertagrid/gridview.hh:449
int size(int codim) const
obtain number of entities in a given codimension
Definition: albertagrid/gridview.hh:372
AlbertaLeafGridViewTraits< GridImp > Traits
Definition: albertagrid/gridview.hh:303
bool isConforming() const
return true if current state of grid view represents a conforming grid
Definition: albertagrid/gridview.hh:369
Codim< cd >::Iterator begin() const
obtain begin iterator for this view
Definition: albertagrid/gridview.hh:385
static constexpr bool conforming
Definition: albertagrid/gridview.hh:328
const Grid & grid() const
obtain a const reference to the underlying hierarchic grid
Definition: albertagrid/gridview.hh:357
Traits::Grid Grid
type of the grid
Definition: albertagrid/gridview.hh:306
Codim< cd >::template Partition< pit >::Iterator end() const
obtain end iterator for this view
Definition: albertagrid/gridview.hh:406
void communicate(CommDataHandleIF< DataHandleImp, DataType > &data, InterfaceType iftype, CommunicationDirection dir) const
Definition: albertagrid/gridview.hh:453
Communication CollectiveCommunication
Definition: albertagrid/gridview.hh:322
IntersectionIterator ibegin(const typename Codim< 0 >::Entity &entity) const
obtain begin intersection iterator with respect to this view
Definition: albertagrid/gridview.hh:413
int size(const GeometryType &type) const
obtain number of entities with a given geometry type
Definition: albertagrid/gridview.hh:378
IntersectionIterator iend(const typename Codim< 0 >::Entity &entity) const
obtain end intersection iterator with respect to this view
Definition: albertagrid/gridview.hh:432
Traits::IntersectionIterator IntersectionIterator
type of the intersection iterator
Definition: albertagrid/gridview.hh:315
const IndexSet & indexSet() const
obtain the index set
Definition: albertagrid/gridview.hh:363
Traits::Intersection Intersection
type of the intersection
Definition: albertagrid/gridview.hh:312
const Communication & comm() const
obtain communication object
Definition: albertagrid/gridview.hh:440
Codim< cd >::Iterator end() const
obtain end iterator for this view
Definition: albertagrid/gridview.hh:399
int overlapSize(int codim) const
Return size of the overlap region for a given codim on the grid view.
Definition: albertagrid/gridview.hh:446
Codim< cd >::template Partition< pit >::Iterator begin() const
obtain begin iterator for this view
Definition: albertagrid/gridview.hh:392
Definition: albertagrid/gridview.hh:30
Communication CollectiveCommunication
Definition: albertagrid/gridview.hh:51
Grid::Traits::Communication Communication
type of the communication
Definition: albertagrid/gridview.hh:47
Grid::Traits::LevelIntersection Intersection
type of the intersection
Definition: albertagrid/gridview.hh:40
std::remove_const< GridImp >::type Grid
type of the grid
Definition: albertagrid/gridview.hh:34
AlbertaLevelGridView< GridImp > GridViewImp
Definition: albertagrid/gridview.hh:31
static constexpr bool conforming
Definition: albertagrid/gridview.hh:74
Grid::Traits::LevelIntersectionIterator IntersectionIterator
type of the intersection iterator
Definition: albertagrid/gridview.hh:44
Grid::Traits::LevelIndexSet IndexSet
type of the index set
Definition: albertagrid/gridview.hh:37
Definition: albertagrid/gridview.hh:55
Grid::template Codim< cd >::LocalGeometry LocalGeometry
Definition: albertagrid/gridview.hh:62
Grid::Traits::template Codim< cd >::Entity Entity
Definition: albertagrid/gridview.hh:58
Grid::Traits::template Codim< cd >::template Partition< All_Partition >::LevelIterator Iterator
Definition: albertagrid/gridview.hh:56
Grid::template Codim< cd >::Geometry Geometry
Definition: albertagrid/gridview.hh:60
Define types needed to iterate over entities of a given partition type.
Definition: albertagrid/gridview.hh:67
Grid::template Codim< cd >::template Partition< pit >::LevelIterator Iterator
iterator over a given codim and partition type
Definition: albertagrid/gridview.hh:70
Codim Structure.
Definition: albertagrid/gridview.hh:107
Definition: albertagrid/gridview.hh:248
Grid::Traits::LeafIntersectionIterator IntersectionIterator
type of the intersection iterator
Definition: albertagrid/gridview.hh:262
std::remove_const< GridImp >::type Grid
type of the grid
Definition: albertagrid/gridview.hh:252
Grid::Traits::Communication Communication
type of the communication
Definition: albertagrid/gridview.hh:265
Grid::Traits::LeafIndexSet IndexSet
type of the index set
Definition: albertagrid/gridview.hh:255
Communication CollectiveCommunication
Definition: albertagrid/gridview.hh:269
AlbertaLeafGridView< GridImp > GridViewImp
Definition: albertagrid/gridview.hh:249
static constexpr bool conforming
Definition: albertagrid/gridview.hh:293
Grid::Traits::LeafIntersection Intersection
type of the intersection
Definition: albertagrid/gridview.hh:258
Definition: albertagrid/gridview.hh:273
Grid::template Codim< cd >::LocalGeometry LocalGeometry
Definition: albertagrid/gridview.hh:281
Grid::template Codim< cd >::Geometry Geometry
Definition: albertagrid/gridview.hh:279
Grid::Traits::template Codim< cd >::template Partition< All_Partition >::LeafIterator Iterator
Definition: albertagrid/gridview.hh:275
Grid::Traits::template Codim< cd >::Entity Entity
Definition: albertagrid/gridview.hh:277
Define types needed to iterate over entities of a given partition type.
Definition: albertagrid/gridview.hh:286
Grid::template Codim< cd >::template Partition< pit >::LeafIterator Iterator
iterator over a given codim and partition type
Definition: albertagrid/gridview.hh:289
Codim Structure.
Definition: albertagrid/gridview.hh:326
Definition: albertagrid/intersectioniterator.hh:35
Definition: albertagrid/intersectioniterator.hh:36
Specialize with 'true' if implementation guarantees conforming level grids. (default=false)
Definition: common/capabilities.hh:106
Specialize with 'true' if implementation guarantees a conforming leaf grid. (default=false)
Definition: common/capabilities.hh:115
CommDataHandleIF describes the features of a data handle for communication in parallel runs using the...
Definition: datahandleif.hh:78
Mesh entities of codimension 0 ("elements") allow to visit all intersections with "neighboring" eleme...
Definition: common/intersectioniterator.hh:83
Index Set Interface base class.
Definition: indexidset.hh:78
Grid abstract base class.
Definition: common/grid.hh:375
static constexpr int dimension
The dimension of the grid.
Definition: common/grid.hh:387
A set of traits classes to store static information about grid implementation.
Implementation of the IntersectionIterator for AlbertaGrid.