36 #ifndef OPM_ITERATORS_HEADER 37 #define OPM_ITERATORS_HEADER 39 #include <dune/grid/common/gridenums.hh> 40 #include "PartitionIteratorRule.hpp" 41 #include <opm/grid/utility/ErrorMacros.hpp> 42 #include "CpGridData.hpp" 58 template<
int cd, PartitionIteratorType pitype>
59 class Iterator :
public Entity<cd>
62 using Reference =
const Entity<cd>&;
79 if(rule_.fullSet || rule_.emptySet)
81 while(this->
index()<noEntities_ && rule_.isInvalid(*
this))
126 : virtualEntity_(grid,
EntityRep<0>::InvalidIndex, true )
134 : virtualEntity_(target), maxLevel_(maxLevel)
137 stackChildren_(target);
145 explicit HierarchicIterator(
int maxLevel)
146 : maxLevel_(maxLevel)
154 return virtualEntity_ == other.virtualEntity_;
168 if (elemStack_.empty()){
172 auto target = elemStack_.top();
176 stackChildren_(target);
187 if (elemStack_.empty()){
192 auto target = elemStack_.top();
196 stackChildren_(target);
205 assert(
this -> virtualEntity_.
isValid());
206 return &virtualEntity_;
212 assert(this-> virtualEntity_.
isValid());
213 return virtualEntity_;
217 void stackChildren_(
const Entity<0>& target);
227 std::stack<Entity<0>> elemStack_;
236 template<
int codim, Dune::PartitionIteratorType pitype >
237 struct iterator_traits<
Dune::cpgrid::Iterator< codim, pitype > >
240 typedef ptrdiff_t difference_type;
241 typedef typename Iterator::Entity value_type;
242 typedef value_type* pointer;
243 typedef value_type& reference;
244 typedef forward_iterator_tag iterator_category;
248 struct iterator_traits<
Dune::cpgrid::HierarchicIterator >
250 typedef ptrdiff_t difference_type;
254 typedef forward_iterator_tag iterator_category;
260 #include <opm/grid/cpgrid/CpGridData.hpp> 261 #include "Entity.hpp" 266 template<
int cd, PartitionIteratorType pitype>
272 noEntities_(grid.size(cd))
274 if(rule_.fullSet || rule_.emptySet)
277 while(this->
index()<noEntities_ && rule_.isInvalid(*
this))
283 #endif // OPM_ITERATORS_HEADER
int index() const
The (positive) index of an entity.
Definition: EntityRep.hpp:125
HierarchicIterator operator++(int)
Definition: Iterators.hpp:185
bool orientation() const
Returns true if the entity has positive orientation.
Definition: EntityRep.hpp:139
HierarchicIterator(const CpGridData &grid)
Definition: Iterators.hpp:125
const Entity< cd > * operator->() const
Const member by pointer operator.
Definition: Iterators.hpp:94
The namespace Dune is the main namespace for all Dune code.
Definition: CartesianIndexMapper.hpp:9
Definition: Intersection.hpp:329
const Entity< 0 > & operator*() const
Const dereferencing operator.
Definition: Iterators.hpp:210
HierarchicIterator & operator++()
Definition: Iterators.hpp:166
bool operator==(const HierarchicIterator &other) const
Equality.
Definition: Iterators.hpp:152
Struct that hods all the data needed to represent a Cpgrid.
Definition: CpGridData.hpp:117
Iterator intended to be used as LeafIterator and LevelIterator (no difference due to no adaptivity) f...
Definition: Entity.hpp:96
bool operator!=(const HierarchicIterator &other) const
Inequality.
Definition: Iterators.hpp:158
const Entity< cd > & operator*() const
Const dereferencing operator.
Definition: Iterators.hpp:101
Iterator & operator++()
Increment operator.
Definition: Iterators.hpp:76
bool isValid() const
isValid method for EntitySeed
Definition: Entity.hpp:465
const Entity< 0 > * operator->() const
Const member by pointer operator.
Definition: Iterators.hpp:203
Only needs to provide interface for doing nothing.
Definition: Iterators.hpp:117
Iterator(const CpGridData &grid, int index, bool orientation)
Definition: Iterators.hpp:267
A rule at what entities to stop.
Definition: PartitionIteratorRule.hpp:41
Represents an entity of a given codim, with positive or negative orientation.
Definition: CpGridData.hpp:96
void increment()
Increments the entityrep's index() by one.
Definition: EntityRep.hpp:152