3#ifndef DUNE_GRID_YASPGRIDHIERARCHICITERATOR_HH
4#define DUNE_GRID_YASPGRIDHIERARCHICITERATOR_HH
16 template<
class Gr
idImp>
19 enum { dim=GridImp::dimension };
21 typedef YaspEntity<0,GridImp::dimension,GridImp> YaspEntityImp;
25 typedef typename GridImp::YGridLevelIterator YGLI;
26 typedef typename GridImp::YGrid::Iterator I;
31 _entity(YaspEntity<0, dim, GridImp>(g,it))
34 YaspEntityImp& entity = entityImplementation();
36 StackElem se(entity._g);
37 std::copy(entity._it.coord().begin(), entity._it.coord().end(), se.coord.begin());
41 _maxlevel = std::min(maxlevel,entity._g->mg->maxLevel());
44 if (entity._g->level()<_maxlevel)
57 _maxlevel(it._maxlevel), stack(it.stack)
64 if (stack.empty())
return;
67 if (entityImplementation()._g->level()<_maxlevel)
77 return (_entity == rhs._entity);
86 void print (std::ostream& s)
const
89 YaspEntityImp& entity = entityImplementation();
90 s <<
"HIER: " <<
"level=" << entity._g.level()
91 <<
" position=" << entity._it.coord()
92 <<
" superindex=" << entity._it.superindex()
93 <<
" maxlevel=" << entity._maxlevel
94 <<
" stacksize=" << stack.size()
105 std::array<int,dim> coord;
106 StackElem(YGLI gg) : g(gg) {}
108 std::stack<StackElem> stack;
114 YaspEntityImp& entity = entityImplementation();
117 YGLI finer = entity._g;
120 for (
int i=0; i<(1<<dim); i++)
122 for (
int k=0; k<dim; k++)
124 se.coord[k] = entity._it.coord(k)*2+1;
126 se.coord[k] = entity._it.coord(k)*2;
129 for (
int k=0; k<dim; k++)
130 if ((se.coord[k] < finer->overlap[0].dataBegin()->origin(k)) || (se.coord[k] >= finer->overlap[0].dataBegin()->origin(k)+finer->overlap[0].dataBegin()->size(k)))
137 YaspEntityImp& entityImplementation()
139 return GridImp::getRealImplementation(this->_entity);
145 StackElem se = stack.top();
147 entityImplementation()._g = se.g;
148 entityImplementation()._it.reinit(entityImplementation()._g->overlap[0],se.coord);
YaspHierarchicIterator enables iteration over son entities of codim 0.
Definition: yaspgridhierarchiciterator.hh:18
YaspHierarchicIterator(const YaspHierarchicIterator &it)
constructor
Definition: yaspgridhierarchiciterator.hh:55
const Entity & dereference() const
dereferencing
Definition: yaspgridhierarchiciterator.hh:81
void increment()
increment
Definition: yaspgridhierarchiciterator.hh:61
bool equals(const YaspHierarchicIterator &rhs) const
equality
Definition: yaspgridhierarchiciterator.hh:75
YaspHierarchicIterator(const YGLI &g, const I &it, int maxlevel)
constructor
Definition: yaspgridhierarchiciterator.hh:30
Dune namespace.
Definition: alignedallocator.hh:10
Static tag representing a codimension.
Definition: dimension.hh:22