Dune Core Modules (2.5.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
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 {}
44
46 AlbertaGridHierarchicIterator ( const GridImp &grid,
47 const ElementInfo &elementInfo,
48 int maxLevel );
49
51 AlbertaGridHierarchicIterator ( const GridImp &grid, int actLevel, int maxLevel );
52
54 AlbertaGridHierarchicIterator ( const This &other );
55
57 This &operator= ( const This &other );
58
60 void increment();
61
62 using Base::level;
63
64 protected:
65 using Base::entityImp;
66
67 private:
68 void increment ( ElementInfo elementInfo );
69
70 // level on which the iterator was started
71 int startLevel_;
72
73 // maximal level to go down to
74 int maxlevel_;
75 };
76
77
78 template< class GridImp >
80 ::AlbertaGridHierarchicIterator( const GridImp &grid, int actLevel, int maxLevel )
81 : Base( grid ),
82 startLevel_( actLevel ),
83 maxlevel_( maxLevel )
84 {}
85
86
87 template< class GridImp >
90 const ElementInfo &elementInfo,
91 int maxLevel )
92 : Base( grid ),
93 startLevel_( elementInfo.level() ),
94 maxlevel_( maxLevel )
95 {
96 increment( elementInfo );
97 }
98
99
100 template< class GridImp >
103 : Base( other ),
104 startLevel_( other.startLevel_ ),
105 maxlevel_( other.maxlevel_ )
106 {}
107
108
109 template< class GridImp >
112 {
113 Base::operator=( other );
114
115 startLevel_ = other.startLevel_;
116 maxlevel_ = other.maxlevel_;
117 return *this;
118 }
119
120
121 template< class GridImp >
123 {
124 increment( entityImp().elementInfo() );
125 }
126
127 template< class GridImp >
129 ::increment ( ElementInfo elementInfo )
130 {
131 assert( !elementInfo == false );
132 if( (elementInfo.level() >= maxlevel_) || elementInfo.isLeaf() )
133 {
134 while( (elementInfo.level() > startLevel_) && (elementInfo.indexInFather() == 1) )
135 elementInfo = elementInfo.father();
136 if( elementInfo.level() > startLevel_ )
137 entityImp().setElement( elementInfo.father().child( 1 ), 0 );
138 else
139 entityImp().clearElement();
140 }
141 else
142 entityImp().setElement( elementInfo.child( 0 ), 0 );
143 }
144
145}
146
147#endif // #if HAVE_ALBERTA
148
149#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:170
EntityImp & entityImp()
obtain reference to internal entity implementation
Definition: entitypointer.hh:155
int level() const
ask for level of entities
Definition: entitypointer.hh:147
Definition: hierarchiciterator.hh:29
void increment()
increment
Definition: hierarchiciterator.hh:122
This & operator=(const This &other)
assignment operator
Definition: hierarchiciterator.hh:111
Dune namespace.
Definition: alignment.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 (Jul 15, 22:36, 2024)