dune-grid  2.11
albertagrid/gridview.hh
Go to the documentation of this file.
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_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 
18 namespace Dune
19 {
20 
21  template< class GridImp >
23 
24  template< class GridImp >
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 
49  template< int cd >
50  struct Codim
51  {
53 
54  typedef typename Grid::Traits::template Codim< cd >::Entity Entity;
55 
56  typedef typename Grid::template Codim< cd >::Geometry Geometry;
57  typedef typename Grid::template Codim< cd >::LocalGeometry
59 
61  template< PartitionIteratorType pit >
62  struct Partition
63  {
65  typedef typename Grid::template Codim< cd >::template Partition< pit >::LevelIterator
67  };
68  };
69 
71  };
72 
73 
74  template< class GridImp >
76  {
77  typedef AlbertaLevelGridView< GridImp > ThisType;
78 
79  public:
81 
83  typedef typename Traits::Grid Grid;
84 
86  typedef typename Traits::IndexSet IndexSet;
87 
90 
93 
96 
98  template< int cd >
99  struct Codim : public Traits::template Codim<cd> {};
100 
101  constexpr static bool conforming = Traits::conforming;
102 
103  private:
105 
107 
108  public:
109  AlbertaLevelGridView ( const Grid &grid, int level )
110  : grid_( &grid ),
111  indexSet_( &(grid.levelIndexSet( level )) ),
112  level_( level )
113  {}
114 
115  // use default implementation of copy constructor and assignment operator
116 #if 0
117  AlbertaLevelGridView ( const ThisType &other )
118  : grid_( other.grid_ ),
119  indexSet_( other.indexSet_ ),
120  level_( other.level_ )
121  {}
122 
124  ThisType &operator= ( const ThisType & other)
125  {
126  grid_ = other.grid_;
127  indexSet_ = other.indexSet_;
128  level_ = other.level_;
129  }
130 #endif
131 
133  const Grid &grid () const
134  {
135  return *grid_;
136  }
137 
139  const IndexSet &indexSet () const
140  {
141  return *indexSet_;
142  }
143 
145  bool isConforming() const { return bool(conforming); }
146 
148  int size ( int codim ) const
149  {
150  return grid().size( level_, codim );
151  }
152 
154  int size ( const GeometryType &type ) const
155  {
156  return grid().size( level_, type );
157  }
158 
160  template< int cd >
161  typename Codim< cd >::Iterator begin () const
162  {
163  return grid().template lbegin< cd, All_Partition >( level_ );
164  }
165 
167  template< int cd, PartitionIteratorType pit >
168  typename Codim< cd >::template Partition< pit >::Iterator begin () const
169  {
170  return grid().template lbegin< cd, pit >( level_ );
171  }
172 
174  template< int cd >
175  typename Codim< cd >::Iterator end () const
176  {
177  return grid().template lend< cd, All_Partition >( level_ );
178  }
179 
181  template< int cd, PartitionIteratorType pit >
182  typename Codim< cd >::template Partition< pit >::Iterator end () const
183  {
184  return grid().template lend< cd, pit >( level_ );
185  }
186 
189  ibegin ( const typename Codim< 0 >::Entity &entity ) const
190  {
191  if( grid().maxLevel() == 0)
192  {
194  return IntersectionIteratorImpl( entity.impl(), begin );
195  }
196  else
197  {
198  DUNE_THROW( NotImplemented, "method ibegin not implemented on LevelGridView for AlbertaGrid." );
200  return IntersectionIteratorImpl( entity.impl(), end );
201  }
202  }
203 
206  iend ( const typename Codim< 0 >::Entity &entity ) const
207  {
209  return IntersectionIteratorImpl( entity.impl(), end );
210  }
211 
213  const Communication &comm () const
214  {
215  return grid().comm();
216  }
217 
219  int overlapSize ( [[maybe_unused]] int codim ) const { return 0; }
220 
222  int ghostSize ( [[maybe_unused]] int codim ) const { return 0; }
223 
225  template< class DataHandleImp, class DataType >
227  [[maybe_unused]] InterfaceType iftype,
228  [[maybe_unused]] CommunicationDirection dir ) const
229  {}
230 
231  private:
232  const Grid *grid_;
233  const IndexSet *indexSet_;
234  int level_;
235  };
236 
237 
238  template< class GridImp >
240  {
242 
244  typedef typename std::remove_const<GridImp>::type Grid;
245 
247  typedef typename Grid::Traits::LeafIndexSet IndexSet;
248 
250  typedef typename Grid::Traits::LeafIntersection Intersection;
251 
253  typedef typename Grid::Traits::LeafIntersectionIterator
255 
257  typedef typename Grid::Traits::Communication Communication;
258 
259  template< int cd >
260  struct Codim
261  {
262  typedef typename Grid::Traits::template Codim< cd >::template Partition< All_Partition >::LeafIterator
264 
265  typedef typename Grid::Traits::template Codim< cd >::Entity Entity;
266 
267  typedef typename Grid::template Codim< cd >::Geometry Geometry;
268  typedef typename Grid::template Codim< cd >::LocalGeometry
270 
272  template <PartitionIteratorType pit >
273  struct Partition
274  {
276  typedef typename Grid::template Codim< cd >::template Partition< pit >::LeafIterator
278  };
279  };
280 
282  };
283 
284 
285  template< class GridImp >
286  class AlbertaLeafGridView
287  {
288  typedef AlbertaLeafGridView< GridImp > ThisType;
289 
290  public:
292 
294  typedef typename Traits::Grid Grid;
295 
297  typedef typename Traits::IndexSet IndexSet;
298 
301 
304 
307 
309  template< int cd >
310  struct Codim : public Traits::template Codim<cd> {};
311 
312  constexpr static bool conforming = Traits::conforming;
313 
314  private:
316 
318 
319  public:
321  : grid_( &grid ),
322  indexSet_( &(grid.leafIndexSet()) )
323  {}
324 
325  // use default implementation of copy constructor and assignment operator
326 #if 0
327  AlbertaLeafGridView ( const ThisType &other )
328  : grid_( other.grid_ ),
329  indexSet_( other.indexSet_ )
330  {}
331 
333  ThisType &operator= ( const ThisType & other)
334  {
335  grid_ = other.grid_;
336  indexSet_ = other.indexSet_;
337  }
338 #endif
339 
341  const Grid &grid () const
342  {
343  return *grid_;
344  }
345 
347  const IndexSet &indexSet () const
348  {
349  return *indexSet_;
350  }
351 
353  bool isConforming() const { return bool(conforming); }
354 
356  int size ( int codim ) const
357  {
358  return grid().size( codim );
359  }
360 
362  int size ( const GeometryType &type ) const
363  {
364  return grid().size( type );
365  }
366 
368  template< int cd >
369  typename Codim< cd >::Iterator begin () const
370  {
371  return grid().template leafbegin< cd, All_Partition >();
372  }
373 
375  template< int cd, PartitionIteratorType pit >
376  typename Codim< cd >::template Partition< pit >::Iterator begin () const
377  {
378  return grid().template leafbegin< cd, pit >();
379  }
380 
382  template< int cd >
383  typename Codim< cd >::Iterator end () const
384  {
385  return grid().template leafend< cd, All_Partition >();
386  }
387 
389  template< int cd, PartitionIteratorType pit >
390  typename Codim< cd >::template Partition< pit >::Iterator end () const
391  {
392  return grid().template leafend< cd, pit >();
393  }
394 
397  ibegin ( const typename Codim< 0 >::Entity &entity ) const
398  {
399  const ElementInfo elementInfo = entity.impl().elementInfo();
400  assert( !!elementInfo );
401 
402 #ifndef NDEBUG
403  for( int i = 0; i <= Grid::dimension; ++i )
404  {
405  if( elementInfo.elInfo().opp_vertex[ i ] == 127 )
406  DUNE_THROW( NotImplemented, "AlbertaGrid: Intersections on outside entities are not fully implemented, yet." );
407  }
408 #endif // #ifndef NDEBUG
409 
411  return IntersectionIteratorImpl( entity.impl(), begin );
412  }
413 
416  iend ( const typename Codim< 0 >::Entity &entity ) const
417  {
418  assert( !!entity.impl().elementInfo() );
420  return IntersectionIteratorImpl( entity.impl(), end );
421  }
422 
424  const Communication &comm () const
425  {
426  return grid().comm();
427  }
428 
430  int overlapSize ( [[maybe_unused]] int codim ) const { return 0; }
431 
433  int ghostSize ( [[maybe_unused]] int codim ) const { return 0; }
434 
436  template< class DataHandleImp, class DataType >
438  [[maybe_unused]] InterfaceType iftype,
439  [[maybe_unused]] CommunicationDirection dir ) const
440  {}
441 
442  private:
443  const Grid *grid_;
444  const IndexSet *indexSet_;
445  };
446 
447 }
448 
449 #endif // #if HAVE_ALBERTA
450 #endif // #ifndef DUNE_ALBERTAGRID_GRIDVIEW_HH
Grid::Traits::LeafIntersectionIterator IntersectionIterator
type of the intersection iterator
Definition: albertagrid/gridview.hh:254
IntersectionIterator ibegin(const typename Codim< 0 >::Entity &entity) const
obtain begin intersection iterator with respect to this view
Definition: albertagrid/gridview.hh:397
const IndexSet & indexSet() const
obtain the index set
Definition: albertagrid/gridview.hh:347
Definition: elementinfo.hh:42
Codim Structure.
Definition: albertagrid/gridview.hh:310
Codim< cd >::Iterator end() const
obtain end iterator for this view
Definition: albertagrid/gridview.hh:383
Definition: albertagrid/gridview.hh:239
Codim< cd >::Iterator begin() const
obtain begin iterator for this view
Definition: albertagrid/gridview.hh:161
Traits::IntersectionIterator IntersectionIterator
type of the intersection iterator
Definition: albertagrid/gridview.hh:92
Index Set Interface base class.
Definition: common/grid.hh:348
Definition: albertagrid/gridview.hh:50
std::remove_const< GridImp >::type Grid
type of the grid
Definition: albertagrid/gridview.hh:244
Traits::Intersection Intersection
type of the intersection
Definition: albertagrid/gridview.hh:89
ALBERTA EL_INFO & elInfo() const
Definition: elementinfo.hh:744
bool isConforming() const
return true if current state of grid view represents a conforming grid
Definition: albertagrid/gridview.hh:353
static constexpr bool conforming
Definition: albertagrid/gridview.hh:312
Codim< cd >::Iterator end() const
obtain end iterator for this view
Definition: albertagrid/gridview.hh:175
IntersectionIterator iend(const typename Codim< 0 >::Entity &entity) const
obtain end intersection iterator with respect to this view
Definition: albertagrid/gridview.hh:416
Define types needed to iterate over entities of a given partition type.
Definition: albertagrid/gridview.hh:273
Grid abstract base classThis class is the base class for all grid implementations. Although no virtual functions are used we call it abstract since its methods do not contain an implementation but forward to the methods of the derived class via the Barton-Nackman trick.
Definition: common/grid.hh:375
static constexpr bool conforming
Definition: albertagrid/gridview.hh:281
int size(const GeometryType &type) const
obtain number of entities with a given geometry type
Definition: albertagrid/gridview.hh:154
Traits::IndexSet IndexSet
type of the index set
Definition: albertagrid/gridview.hh:297
static constexpr bool conforming
Definition: albertagrid/gridview.hh:70
int ghostSize([[maybe_unused]] int codim) const
Return size of the ghost region for a given codim on the grid view.
Definition: albertagrid/gridview.hh:433
Codim< cd >::template Partition< pit >::Iterator end() const
obtain end iterator for this view
Definition: albertagrid/gridview.hh:182
AlbertaLeafGridView< GridImp > GridViewImp
Definition: albertagrid/gridview.hh:241
bool isConforming() const
return true if current state of grid view represents a conforming grid
Definition: albertagrid/gridview.hh:145
Grid::Traits::LevelIntersection Intersection
type of the intersection
Definition: albertagrid/gridview.hh:40
int size(int codim) const
obtain number of entities in a given codimension
Definition: albertagrid/gridview.hh:356
const Grid & grid() const
obtain a const reference to the underlying hierarchic grid
Definition: albertagrid/gridview.hh:133
Grid::template Codim< cd >::template Partition< pit >::LeafIterator Iterator
iterator over a given codim and partition type
Definition: albertagrid/gridview.hh:277
int size(const GeometryType &type) const
obtain number of entities with a given geometry type
Definition: albertagrid/gridview.hh:362
Specialize with &#39;true&#39; if implementation guarantees a conforming leaf grid. (default=false) ...
Definition: common/capabilities.hh:114
int overlapSize([[maybe_unused]] int codim) const
Return size of the overlap region for a given codim on the grid view.
Definition: albertagrid/gridview.hh:219
Codim< cd >::Iterator begin() const
obtain begin iterator for this view
Definition: albertagrid/gridview.hh:369
int size(int codim) const
obtain number of entities in a given codimension
Definition: albertagrid/gridview.hh:148
Traits::Communication Communication
type of the communication
Definition: albertagrid/gridview.hh:306
const IndexSet & indexSet() const
obtain the index set
Definition: albertagrid/gridview.hh:139
Grid::Traits::LevelIndexSet IndexSet
type of the index set
Definition: albertagrid/gridview.hh:37
Definition: albertagrid/intersectioniterator.hh:35
Grid::Traits::LeafIndexSet IndexSet
type of the index set
Definition: albertagrid/gridview.hh:247
CommunicationDirection
Define a type for communication direction parameter.
Definition: gridenums.hh:170
const Communication & comm() const
obtain communication object
Definition: albertagrid/gridview.hh:424
Grid::Traits::LeafIntersection Intersection
type of the intersection
Definition: albertagrid/gridview.hh:250
AlbertaLevelGridViewTraits< GridImp > Traits
Definition: albertagrid/gridview.hh:80
Grid::Traits::template Codim< cd >::Entity Entity
Definition: albertagrid/gridview.hh:54
void communicate([[maybe_unused]] CommDataHandleIF< DataHandleImp, DataType > &data, [[maybe_unused]] InterfaceType iftype, [[maybe_unused]] CommunicationDirection dir) const
Definition: albertagrid/gridview.hh:437
const Grid & grid() const
obtain a const reference to the underlying hierarchic grid
Definition: albertagrid/gridview.hh:341
int ghostSize([[maybe_unused]] int codim) const
Return size of the ghost region for a given codim on the grid view.
Definition: albertagrid/gridview.hh:222
IntersectionIterator ibegin(const typename Codim< 0 >::Entity &entity) const
obtain begin intersection iterator with respect to this view
Definition: albertagrid/gridview.hh:189
AlbertaLeafGridView(const Grid &grid)
Definition: albertagrid/gridview.hh:320
Grid::Traits::LevelIntersectionIterator IntersectionIterator
type of the intersection iterator
Definition: albertagrid/gridview.hh:44
Definition: albertagrid/gridview.hh:22
Traits::Intersection Intersection
type of the intersection
Definition: albertagrid/gridview.hh:300
Traits::Grid Grid
type of the grid
Definition: albertagrid/gridview.hh:294
Grid::template Codim< cd >::LocalGeometry LocalGeometry
Definition: albertagrid/gridview.hh:58
Include standard header files.
Definition: agrid.hh:59
AlbertaLeafGridViewTraits< GridImp > Traits
Definition: albertagrid/gridview.hh:291
Definition: albertagrid/entity.hh:32
Codim Structure.
Definition: albertagrid/gridview.hh:99
IntersectionIterator iend(const typename Codim< 0 >::Entity &entity) const
obtain end intersection iterator with respect to this view
Definition: albertagrid/gridview.hh:206
CommDataHandleIF describes the features of a data handle for communication in parallel runs using the...
Definition: datahandleif.hh:77
InterfaceType
Parameter to be used for the communication functions.
Definition: gridenums.hh:86
Specialize with &#39;true&#39; if implementation guarantees conforming level grids. (default=false) ...
Definition: common/capabilities.hh:105
Mesh entities of codimension 0 ("elements") allow to visit all intersections with "neighboring" eleme...
Definition: common/grid.hh:347
Grid::Traits::Communication Communication
type of the communication
Definition: albertagrid/gridview.hh:257
std::remove_const< GridImp >::type Grid
type of the grid
Definition: albertagrid/gridview.hh:34
Implementation of the IntersectionIterator for AlbertaGrid.
static constexpr int dimension
The dimension of the grid.
Definition: common/grid.hh:387
Grid::Traits::template Codim< cd >::Entity Entity
Definition: albertagrid/gridview.hh:265
static constexpr bool conforming
Definition: albertagrid/gridview.hh:101
void communicate([[maybe_unused]] CommDataHandleIF< DataHandleImp, DataType > &data, [[maybe_unused]] InterfaceType iftype, [[maybe_unused]] CommunicationDirection dir) const
Definition: albertagrid/gridview.hh:226
Grid::Traits::template Codim< cd >::template Partition< All_Partition >::LevelIterator Iterator
Definition: albertagrid/gridview.hh:52
Traits::Grid Grid
type of the grid
Definition: albertagrid/gridview.hh:83
Grid::template Codim< cd >::Geometry Geometry
Definition: albertagrid/gridview.hh:56
AlbertaLevelGridView< GridImp > GridViewImp
Definition: albertagrid/gridview.hh:31
Definition: albertagrid/gridview.hh:29
AlbertaLevelGridView(const Grid &grid, int level)
Definition: albertagrid/gridview.hh:109
Codim< cd >::template Partition< pit >::Iterator begin() const
obtain begin iterator for this view
Definition: albertagrid/gridview.hh:168
GeometryType
Type representing VTK&#39;s entity geometry types.
Definition: common.hh:132
Traits::Communication Communication
type of the communication
Definition: albertagrid/gridview.hh:95
Grid::Traits::template Codim< cd >::template Partition< All_Partition >::LeafIterator Iterator
Definition: albertagrid/gridview.hh:263
int overlapSize([[maybe_unused]] int codim) const
Return size of the overlap region for a given codim on the grid view.
Definition: albertagrid/gridview.hh:430
Definition: albertagrid/intersectioniterator.hh:36
Traits::IndexSet IndexSet
type of the index set
Definition: albertagrid/gridview.hh:86
Grid::template Codim< cd >::Geometry Geometry
Definition: albertagrid/gridview.hh:267
A set of traits classes to store static information about grid implementation.
Codim< cd >::template Partition< pit >::Iterator begin() const
obtain begin iterator for this view
Definition: albertagrid/gridview.hh:376
Traits::IntersectionIterator IntersectionIterator
type of the intersection iterator
Definition: albertagrid/gridview.hh:303
Grid::template Codim< cd >::LocalGeometry LocalGeometry
Definition: albertagrid/gridview.hh:269
Definition: albertagrid/gridview.hh:260
const Communication & comm() const
obtain communication object
Definition: albertagrid/gridview.hh:213
Define types needed to iterate over entities of a given partition type.
Definition: albertagrid/gridview.hh:62
Grid::Traits::Communication Communication
type of the communication
Definition: albertagrid/gridview.hh:47
Codim< cd >::template Partition< pit >::Iterator end() const
obtain end iterator for this view
Definition: albertagrid/gridview.hh:390
Definition: albertagrid/gridview.hh:25
Grid::template Codim< cd >::template Partition< pit >::LevelIterator Iterator
iterator over a given codim and partition type
Definition: albertagrid/gridview.hh:66