dune-grid 2.8.0
Loading...
Searching...
No Matches
hierarchiciterator.hh
Go to the documentation of this file.
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
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
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 entity_.impl().equals( other.entity_.impl() );
63 }
64
67 {
68 return entity_;
69 }
70
72 int level () const
73 {
74 return entity_.impl().level();
75 }
76
77 protected:
79 const GridImp &grid () const
80 {
81 return entity_.impl().grid();
82 }
83
84 private:
85 void increment ( ElementInfo elementInfo );
86
87 mutable Entity entity_;
88
89 // level on which the iterator was started
90 int startLevel_;
91
92 // maximal level to go down to
93 int maxlevel_;
94 };
95
96
97 template< class GridImp >
98 inline AlbertaGridHierarchicIterator< GridImp >
99 ::AlbertaGridHierarchicIterator( const GridImp &grid, int actLevel, int maxLevel )
100 : entity_( EntityImp( grid ) ),
101 startLevel_( actLevel ),
102 maxlevel_( maxLevel )
103 {}
104
105
106 template< class GridImp >
109 const ElementInfo &elementInfo,
110 int maxLevel )
111 : entity_( EntityImp( grid ) ),
112 startLevel_( elementInfo.level() ),
113 maxlevel_( maxLevel )
114 {
115 increment( elementInfo );
116 }
117
118
119 template< class GridImp >
122 : entity_( other.entity_ ),
123 startLevel_( other.startLevel_ ),
124 maxlevel_( other.maxlevel_ )
125 {}
126
127
128 template< class GridImp >
131 {
132 entity_ = other.entity_;
133 startLevel_ = other.startLevel_;
134 maxlevel_ = other.maxlevel_;
135 return *this;
136 }
137
138
139 template< class GridImp >
141 {
142 increment( entity_.impl().elementInfo() );
143 }
144
145 template< class GridImp >
147 ::increment ( ElementInfo elementInfo )
148 {
149 assert( !elementInfo == false );
150 if( (elementInfo.level() >= maxlevel_) || elementInfo.isLeaf() )
151 {
152 while( (elementInfo.level() > startLevel_) && (elementInfo.indexInFather() == 1) )
153 elementInfo = elementInfo.father();
154 if( elementInfo.level() > startLevel_ )
155 entity_.impl().setElement( elementInfo.father().child( 1 ), 0 );
156 else
157 entity_.impl().clearElement();
158 }
159 else
160 entity_.impl().setElement( elementInfo.child( 0 ), 0 );
161 }
162
163}
164
165#endif // #if HAVE_ALBERTA
166
167#endif // #ifndef DUNE_ALBERTA_HIERARCHICITERATOR_HH
provides a wrapper for ALBERTA's el_info structure
Include standard header files.
Definition: agrid.hh:58
Definition: hierarchiciterator.hh:27
Entity & dereference() const
dereferencing
Definition: hierarchiciterator.hh:66
GridImp::template Codim< 0 >::Entity Entity
Definition: hierarchiciterator.hh:31
const GridImp & grid() const
obtain a reference to the grid
Definition: hierarchiciterator.hh:79
EntityImp::ElementInfo ElementInfo
Definition: hierarchiciterator.hh:37
int level() const
ask for level of entities
Definition: hierarchiciterator.hh:72
AlbertaGridHierarchicIterator()
Definition: hierarchiciterator.hh:39
void increment()
increment
Definition: hierarchiciterator.hh:140
GridImp::ctype ctype
Definition: hierarchiciterator.hh:32
EntityObject::ImplementationType EntityImp
Definition: hierarchiciterator.hh:35
bool equals(const This &other) const
equality
Definition: hierarchiciterator.hh:60
This & operator=(const This &other)
assignment operator
Definition: hierarchiciterator.hh:130
MakeableInterfaceObject< Entity > EntityObject
Definition: hierarchiciterator.hh:34
Wrapper class for entities.
Definition: common/entity.hh:64
InterfaceType::Implementation ImplementationType
Definition: common/grid.hh:1093