DUNE PDELab (2.8)

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 entity_.impl().equals( other.entity_.impl() );
63 }
64
66 Entity &dereference () const
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
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:79
int level() const
ask for level of entities
Definition: hierarchiciterator.hh:72
void increment()
increment
Definition: hierarchiciterator.hh:140
bool equals(const This &other) const
equality
Definition: hierarchiciterator.hh:60
This & operator=(const This &other)
assignment operator
Definition: hierarchiciterator.hh:130
Wrapper class for entities.
Definition: entity.hh:64
provides a wrapper for ALBERTA's el_info structure
Dune namespace.
Definition: alignedallocator.hh:11
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 (Dec 22, 23:30, 2024)