dune-foamgrid  2.8-git
foamgridleveliterator.hh
Go to the documentation of this file.
1 #ifndef DUNE_FOAMGRID_LEVELITERATOR_HH
2 #define DUNE_FOAMGRID_LEVELITERATOR_HH
3 
8 namespace Dune {
9 
10 //**********************************************************************
11 //
12 // --FoamGridLevelIterator
16 template<int codim, PartitionIteratorType pitype, class GridImp>
18 {
19  enum {dimgrid = GridImp::dimension};
20  enum {dimworld = GridImp::dimensionworld};
21 
22  using EntityImp = FoamGridEntityImp<dimgrid-codim, dimgrid, dimworld, typename GridImp::ctype>;
23 
24 public:
25 
26  using Entity = typename GridImp::template Codim<codim>::Entity;
27  enum { codimension = codim };
28 
30  explicit FoamGridLevelIterator(const typename std::list<EntityImp>::const_iterator& it)
31  : levelIterator_(it)
32  {
33  virtualEntity_.impl().setToTarget(&(*levelIterator_));
34  }
35 
37  void increment() {
38  ++levelIterator_;
39  virtualEntity_.impl().setToTarget(&(*levelIterator_));
40  }
41 
43  const Entity& dereference() const { return virtualEntity_; }
44 
47  return virtualEntity_ == other.virtualEntity_;
48  }
49 
50 
51 private:
53  Entity virtualEntity_;
54 
55  // This iterator derives from FoamGridEntityPointer, and that base class stores the value
56  // of the iterator, i.e. the 'pointer' to the entity. However, that pointer can not be
57  // set to its successor in the level std::list, not even by magic. Therefore we keep the
58  // same information redundantly in this iterator, which can be incremented.
59  typename std::list<EntityImp>::const_iterator levelIterator_;
60 
61 };
62 
63 
64 } // namespace Dune
65 
66 #endif
Definition: dgffoam.cc:6
Iterator over all entities of a given codimension and level of a grid.
Definition: foamgridleveliterator.hh:18
@ codimension
Definition: foamgridleveliterator.hh:27
FoamGridLevelIterator(const typename std::list< EntityImp >::const_iterator &it)
Constructor.
Definition: foamgridleveliterator.hh:30
typename GridImp::template Codim< codim >::Entity Entity
Definition: foamgridleveliterator.hh:26
const Entity & dereference() const
dereferencing
Definition: foamgridleveliterator.hh:43
bool equals(const FoamGridLevelIterator< codim, pitype, GridImp > &other) const
equality
Definition: foamgridleveliterator.hh:46
void increment()
prefix increment
Definition: foamgridleveliterator.hh:37