Dune Core Modules (2.9.0)

hierarchiciterator.hh
1#ifndef DUNE_SPGRID_HITERATOR_HH
2#define DUNE_SPGRID_HITERATOR_HH
3
4#include <type_traits>
5
6#include <dune/grid/common/entityiterator.hh>
7
8#include <dune/grid/spgrid/entity.hh>
9
10namespace Dune
11{
12
13 // SPHierarchicIterator
14 // --------------------
15
16 template< class Grid, int codim >
17 class SPHierarchicIterator
18 {
19 typedef SPHierarchicIterator< Grid, codim > This;
20
21 public:
22 typedef typename std::remove_const< Grid >::type::Traits Traits;
23
24 static const int dimension = Traits::ReferenceCube::dimension;
25 static const int codimension = 0;
26 static const int mydimension = dimension - codimension;
27
28 typedef typename Traits::template Codim< codimension >::Entity Entity;
29
30 private:
31 typedef SPEntity< codimension, dimension, Grid > EntityImpl;
32
33 public:
34 typedef typename EntityImpl::EntityInfo EntityInfo;
35 typedef typename EntityImpl::GridLevel GridLevel;
36
37 SPHierarchicIterator () = default;
38
39 SPHierarchicIterator ( const EntityInfo &entityInfo, int maxLevel )
40 : entityInfo_( entityInfo ),
41 minLevel_( entityInfo.gridLevel().level() ),
42 maxLevel_( std::min( maxLevel, entityInfo.gridLevel().grid().maxLevel() ) )
43 {
44 increment();
45 }
46
47 Entity dereference () const { return EntityImpl( entityInfo() ); }
48
49 bool equals ( const This &other ) const { return entityInfo().equals( other.entityInfo() ); }
50
51 void increment ()
52 {
53 if( gridLevel().level() >= maxLevel_ )
54 {
55 while( (gridLevel().level() > minLevel_) && !entityInfo().nextChild() )
56 entityInfo().up();
57 }
58 else
59 entityInfo().down();
60 entityInfo().update();
61 }
62
63 const EntityInfo &entityInfo () const { return entityInfo_; }
64 EntityInfo &entityInfo () { return entityInfo_; }
65
66 const GridLevel &gridLevel () const { return entityInfo().gridLevel(); }
67
68 private:
69 EntityInfo entityInfo_;
70 int minLevel_, maxLevel_;
71 };
72
73} // namespace Dune
74
75#endif // #ifndef DUNE_SPGRID_HITERATOR_HH
constexpr auto equals(T1 &&t1, T2 &&t2)
Equality comparison.
Definition: hybridutilities.hh:402
auto min(ADLTag< 0 >, const V &v1, const V &v2)
implements binary Simd::min()
Definition: defaults.hh:89
Dune namespace.
Definition: alignedallocator.hh:13
STL namespace.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 15, 22:36, 2024)