DUNE-FEM (unstable)

hierarchiciterator.hh
1// SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file LICENSE.md in module root
2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
3// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
4// vi: set et ts=4 sw=2 sts=2:
5#ifndef DUNE_ALBERTA_HIERARCHICITERATOR_HH
6#define DUNE_ALBERTA_HIERARCHICITERATOR_HH
7
9#include <dune/grid/common/entityiterator.hh>
10
11#if HAVE_ALBERTA
12
13namespace Dune
14{
15
16 // AlbertaGridHierarchicIterator
17 // -----------------------------
18
27 template< class GridImp >
29 {
31
32 public:
33 typedef typename GridImp::template Codim<0>::Entity Entity;
34 typedef typename GridImp::ctype ctype;
35
37 typedef typename EntityObject::ImplementationType EntityImp;
38
39 typedef typename EntityImp::ElementInfo ElementInfo;
40
42 {}
43
45 AlbertaGridHierarchicIterator ( const GridImp &grid,
46 const ElementInfo &elementInfo,
47 int maxLevel );
48
50 AlbertaGridHierarchicIterator ( const GridImp &grid, int actLevel, int maxLevel );
51
53 AlbertaGridHierarchicIterator ( const This &other );
54
56 This &operator= ( const This &other );
57
59 void increment();
60
62 bool equals ( const This &other ) const
63 {
64 return entity_.impl().equals( other.entity_.impl() );
65 }
66
68 Entity &dereference () const
69 {
70 return entity_;
71 }
72
74 int level () const
75 {
76 return entity_.impl().level();
77 }
78
79 protected:
81 const GridImp &grid () const
82 {
83 return entity_.impl().grid();
84 }
85
86 private:
87 void increment ( ElementInfo elementInfo );
88
89 mutable Entity entity_;
90
91 // level on which the iterator was started
92 int startLevel_;
93
94 // maximal level to go down to
95 int maxlevel_;
96 };
97
98
99 template< class GridImp >
100 inline AlbertaGridHierarchicIterator< GridImp >
101 ::AlbertaGridHierarchicIterator( const GridImp &grid, int actLevel, int maxLevel )
102 : entity_( EntityImp( grid ) ),
103 startLevel_( actLevel ),
104 maxlevel_( maxLevel )
105 {}
106
107
108 template< class GridImp >
111 const ElementInfo &elementInfo,
112 int maxLevel )
113 : entity_( EntityImp( grid ) ),
114 startLevel_( elementInfo.level() ),
115 maxlevel_( maxLevel )
116 {
117 increment( elementInfo );
118 }
119
120
121 template< class GridImp >
124 : entity_( other.entity_ ),
125 startLevel_( other.startLevel_ ),
126 maxlevel_( other.maxlevel_ )
127 {}
128
129
130 template< class GridImp >
133 {
134 entity_ = other.entity_;
135 startLevel_ = other.startLevel_;
136 maxlevel_ = other.maxlevel_;
137 return *this;
138 }
139
140
141 template< class GridImp >
143 {
144 increment( entity_.impl().elementInfo() );
145 }
146
147 template< class GridImp >
149 ::increment ( ElementInfo elementInfo )
150 {
151 assert( !elementInfo == false );
152 if( (elementInfo.level() >= maxlevel_) || elementInfo.isLeaf() )
153 {
154 while( (elementInfo.level() > startLevel_) && (elementInfo.indexInFather() == 1) )
155 elementInfo = elementInfo.father();
156 if( elementInfo.level() > startLevel_ )
157 entity_.impl().setElement( elementInfo.father().child( 1 ), 0 );
158 else
159 entity_.impl().clearElement();
160 }
161 else
162 entity_.impl().setElement( elementInfo.child( 0 ), 0 );
163 }
164
165}
166
167#endif // #if HAVE_ALBERTA
168
169#endif // #ifndef DUNE_ALBERTA_HIERARCHICITERATOR_HH
Definition: hierarchiciterator.hh:29
Entity & dereference() const
dereferencing
Definition: hierarchiciterator.hh:68
const GridImp & grid() const
obtain a reference to the grid
Definition: hierarchiciterator.hh:81
int level() const
ask for level of entities
Definition: hierarchiciterator.hh:74
void increment()
increment
Definition: hierarchiciterator.hh:142
bool equals(const This &other) const
equality
Definition: hierarchiciterator.hh:62
This & operator=(const This &other)
assignment operator
Definition: hierarchiciterator.hh:132
Wrapper class for entities.
Definition: entity.hh:66
provides a wrapper for ALBERTA's el_info structure
Dune namespace.
Definition: alignedallocator.hh:13
Static tag representing a codimension.
Definition: dimension.hh:24
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 21, 23:30, 2024)