Dune Core Modules (2.6.0)

hierarchiciterator.hh
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3#ifndef DUNE_ALBERTA_HIERARCHICITERATOR_HH
4#define DUNE_ALBERTA_HIERARCHICITERATOR_HH
5
7#include <dune/grid/common/entityiterator.hh>
8
9#if HAVE_ALBERTA
10
11namespace Dune
12{
13
14 // AlbertaGridHierarchicIterator
15 // -----------------------------
16
25 template< class GridImp >
27 {
29
30 public:
31 typedef typename GridImp::template Codim<0>::Entity Entity;
32 typedef typename GridImp::ctype ctype;
33
35 typedef typename EntityObject::ImplementationType EntityImp;
36
37 typedef typename EntityImp::ElementInfo ElementInfo;
38
40 {}
41
43 AlbertaGridHierarchicIterator ( const GridImp &grid,
44 const ElementInfo &elementInfo,
45 int maxLevel );
46
48 AlbertaGridHierarchicIterator ( const GridImp &grid, int actLevel, int maxLevel );
49
51 AlbertaGridHierarchicIterator ( const This &other );
52
54 This &operator= ( const This &other );
55
57 void increment();
58
60 bool equals ( const This &other ) const
61 {
62 return entityImp().equals( other.entityImp() );
63 }
64
66 Entity &dereference () const
67 {
68 return entity_;
69 }
70
72 int level () const
73 {
74 return entityImp().level();
75 }
76
77 protected:
79 EntityImp &entityImp ()
80 {
81 return GridImp::getRealImplementation( entity_ );
82 }
83
85 const EntityImp &entityImp () const
86 {
87 return GridImp::getRealImplementation( entity_ );
88 }
89
91 const GridImp &grid () const
92 {
93 return entityImp().grid();
94 }
95
96 private:
97 void increment ( ElementInfo elementInfo );
98
99 mutable Entity entity_;
100
101 // level on which the iterator was started
102 int startLevel_;
103
104 // maximal level to go down to
105 int maxlevel_;
106 };
107
108
109 template< class GridImp >
110 inline AlbertaGridHierarchicIterator< GridImp >
111 ::AlbertaGridHierarchicIterator( const GridImp &grid, int actLevel, int maxLevel )
112 : entity_( EntityImp( grid ) ),
113 startLevel_( actLevel ),
114 maxlevel_( maxLevel )
115 {}
116
117
118 template< class GridImp >
121 const ElementInfo &elementInfo,
122 int maxLevel )
123 : entity_( EntityImp( grid ) ),
124 startLevel_( elementInfo.level() ),
125 maxlevel_( maxLevel )
126 {
127 increment( elementInfo );
128 }
129
130
131 template< class GridImp >
134 : entity_( other.entity_ ),
135 startLevel_( other.startLevel_ ),
136 maxlevel_( other.maxlevel_ )
137 {}
138
139
140 template< class GridImp >
143 {
144 entity_ = other.entity_;
145 startLevel_ = other.startLevel_;
146 maxlevel_ = other.maxlevel_;
147 return *this;
148 }
149
150
151 template< class GridImp >
153 {
154 increment( entityImp().elementInfo() );
155 }
156
157 template< class GridImp >
159 ::increment ( ElementInfo elementInfo )
160 {
161 assert( !elementInfo == false );
162 if( (elementInfo.level() >= maxlevel_) || elementInfo.isLeaf() )
163 {
164 while( (elementInfo.level() > startLevel_) && (elementInfo.indexInFather() == 1) )
165 elementInfo = elementInfo.father();
166 if( elementInfo.level() > startLevel_ )
167 entityImp().setElement( elementInfo.father().child( 1 ), 0 );
168 else
169 entityImp().clearElement();
170 }
171 else
172 entityImp().setElement( elementInfo.child( 0 ), 0 );
173 }
174
175}
176
177#endif // #if HAVE_ALBERTA
178
179#endif // #ifndef DUNE_ALBERTA_HIERARCHICITERATOR_HH
Definition: hierarchiciterator.hh:27
Entity & dereference() const
dereferencing
Definition: hierarchiciterator.hh:66
const GridImp & grid() const
obtain a reference to the grid
Definition: hierarchiciterator.hh:91
int level() const
ask for level of entities
Definition: hierarchiciterator.hh:72
const EntityImp & entityImp() const
obtain const reference to internal entity implementation
Definition: hierarchiciterator.hh:85
void increment()
increment
Definition: hierarchiciterator.hh:152
bool equals(const This &other) const
equality
Definition: hierarchiciterator.hh:60
This & operator=(const This &other)
assignment operator
Definition: hierarchiciterator.hh:142
EntityImp & entityImp()
obtain reference to internal entity implementation
Definition: hierarchiciterator.hh:79
Wrapper class for entities.
Definition: entity.hh:64
provides a wrapper for ALBERTA's el_info structure
Dune namespace.
Definition: alignedallocator.hh:10
Static tag representing a codimension.
Definition: dimension.hh:22
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 15, 22:36, 2024)