Dune Core Modules (2.3.1)

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
6#include <dune/grid/common/entityiterator.hh>
7
8#include <dune/grid/albertagrid/entitypointer.hh>
9
10#if HAVE_ALBERTA
11
12namespace Dune
13{
14
15 // AlbertaGridHierarchicIterator
16 // -----------------------------
17
26 template< class GridImp >
28 : public AlbertaGridEntityPointer< 0, GridImp >
29 {
32
33 public:
34 typedef typename GridImp::template Codim<0>::Entity Entity;
35 typedef typename GridImp::ctype ctype;
36
38 typedef typename EntityObject::ImplementationType EntityImp;
39
40 typedef typename Base::ElementInfo ElementInfo;
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
59 using Base::level;
60
61 protected:
62 using Base::entityImp;
63
64 private:
65 void increment ( ElementInfo elementInfo );
66
67 // level on which the iterator was started
68 int startLevel_;
69
70 // maximal level to go down to
71 int maxlevel_;
72 };
73
74
75 template< class GridImp >
77 ::AlbertaGridHierarchicIterator( const GridImp &grid, int actLevel, int maxLevel )
78 : Base( grid ),
79 startLevel_( actLevel ),
80 maxlevel_( maxLevel )
81 {}
82
83
84 template< class GridImp >
87 const ElementInfo &elementInfo,
88 int maxLevel )
89 : Base( grid ),
90 startLevel_( elementInfo.level() ),
91 maxlevel_( maxLevel )
92 {
93 increment( elementInfo );
94 }
95
96
97 template< class GridImp >
100 : Base( other ),
101 startLevel_( other.startLevel_ ),
102 maxlevel_( other.maxlevel_ )
103 {}
104
105
106 template< class GridImp >
109 {
110 Base::operator=( other );
111
112 startLevel_ = other.startLevel_;
113 maxlevel_ = other.maxlevel_;
114 return *this;
115 }
116
117
118 template< class GridImp >
120 {
121 increment( entityImp().elementInfo() );
122 }
123
124 template< class GridImp >
126 ::increment ( ElementInfo elementInfo )
127 {
128 assert( !elementInfo == false );
129 if( (elementInfo.level() >= maxlevel_) || elementInfo.isLeaf() )
130 {
131 while( (elementInfo.level() > startLevel_) && (elementInfo.indexInFather() == 1) )
132 elementInfo = elementInfo.father();
133 if( elementInfo.level() > startLevel_ )
134 entityImp().setElement( elementInfo.father().child( 1 ), 0 );
135 else
136 entityImp().clearElement();
137 }
138 else
139 entityImp().setElement( elementInfo.child( 0 ), 0 );
140 }
141
142}
143
144#endif // #if HAVE_ALBERTA
145
146#endif // #ifndef DUNE_ALBERTA_HIERARCHICITERATOR_HH
EntityPointer implementation for AlbertaGrid.
Definition: entitypointer.hh:29
const GridImp & grid() const
obtain a reference to the grid
Definition: entitypointer.hh:192
EntityImp & entityImp()
obtain reference to internal entity implementation
Definition: entitypointer.hh:177
int level() const
ask for level of entities
Definition: entitypointer.hh:169
Definition: hierarchiciterator.hh:29
AlbertaGridHierarchicIterator(const GridImp &grid, const ElementInfo &elementInfo, int maxLevel)
the normal Constructor
Definition: hierarchiciterator.hh:86
void increment()
increment
Definition: hierarchiciterator.hh:119
This & operator=(const This &other)
assignment operator
Definition: hierarchiciterator.hh:108
Dune namespace.
Definition: alignment.hh:14
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 15, 22:36, 2024)