24#ifndef DUMUX_SCV_AND_SCVF_ITERATORS_HH
25#define DUMUX_SCV_AND_SCVF_ITERATORS_HH
27#include <dune/common/iteratorrange.hh>
28#include <dune/common/iteratorfacades.hh>
37template<
class SubControlVolume,
class Vector,
class FVElementGeometry>
38class ScvIterator :
public Dune::ForwardIteratorFacade<ScvIterator<SubControlVolume,
41 const SubControlVolume>
44 using Iterator =
typename Vector::const_iterator;
46 ScvIterator(
const Iterator& it,
const FVElementGeometry& fvGeometry)
47 : it_(it), fvGeometryPtr_(&fvGeometry) {}
54 return fvGeometryPtr_->scv(*it_);
59 return it_ == other.it_;
69 const FVElementGeometry* fvGeometryPtr_;
77template<
class SubControlVolumeFace,
class Vector,
class FVElementGeometry>
78class ScvfIterator :
public Dune::ForwardIteratorFacade<ScvfIterator<SubControlVolumeFace,
81 const SubControlVolumeFace>
84 using Iterator =
typename Vector::const_iterator;
86 ScvfIterator(
const Iterator& it,
const FVElementGeometry& fvGeometry)
87 : it_(it), fvGeometryPtr_(&fvGeometry) {}
94 return fvGeometryPtr_->scvf(*it_);
99 return it_ == other.it_;
109 const FVElementGeometry* fvGeometryPtr_;
117template<
class SubControlVolumeFace,
class Vector,
class FVElementGeometry>
121 const SubControlVolumeFace>
124 using Iterator =
typename Vector::const_iterator;
129 static ThisType makeBegin(
const Vector& vector,
const FVElementGeometry& fvGeometry,
const std::size_t scvIdx)
131 auto begin = vector.begin();
132 const auto end = vector.end();
134 while (begin != end && fvGeometry.scvf(*begin).insideScvIdx() != scvIdx)
140 static ThisType makeEnd(
const Vector& vector,
const FVElementGeometry& fvGeometry,
const std::size_t scvIdx)
148 return fvGeometryPtr_->scvf(*it_);
153 return it_ == other.it_;
159 while (it_ != itEnd_ &&
dereference().insideScvIdx() != scvIdx_)
165 SkippingScvfIterator(
const Iterator& itBegin,
const Iterator& itEnd,
const FVElementGeometry& fvGeometry,
const std::size_t scvIdx)
166 : it_(itBegin), fvGeometryPtr_(&fvGeometry), itEnd_(itEnd), scvIdx_(scvIdx) {}
169 const FVElementGeometry* fvGeometryPtr_;
170 const Iterator itEnd_;
Iterators over sub control volumes.
Definition: scvandscvfiterators.hh:42
bool equals(const ThisType &other) const
Definition: scvandscvfiterators.hh:57
ScvIterator(const Iterator &it, const FVElementGeometry &fvGeometry)
Definition: scvandscvfiterators.hh:46
const SubControlVolume & dereference() const
dereferencing yields a subcontrol volume
Definition: scvandscvfiterators.hh:52
void increment()
Definition: scvandscvfiterators.hh:62
ScvIterator()
Definition: scvandscvfiterators.hh:49
Iterators over sub control volume faces of an fv geometry.
Definition: scvandscvfiterators.hh:82
ScvfIterator()
Definition: scvandscvfiterators.hh:89
void increment()
Definition: scvandscvfiterators.hh:102
ScvfIterator(const Iterator &it, const FVElementGeometry &fvGeometry)
Definition: scvandscvfiterators.hh:86
const SubControlVolumeFace & dereference() const
dereferencing yields a subcontrol volume face
Definition: scvandscvfiterators.hh:92
bool equals(const ThisType &other) const
Definition: scvandscvfiterators.hh:97
Iterators over sub control volume faces of an fv geometry and a given sub control volume.
Definition: scvandscvfiterators.hh:122
bool equals(const ThisType &other) const
Definition: scvandscvfiterators.hh:151
const SubControlVolumeFace & dereference() const
dereferencing yields a subcontrol volume face
Definition: scvandscvfiterators.hh:146
SkippingScvfIterator()
Definition: scvandscvfiterators.hh:127
void increment()
Definition: scvandscvfiterators.hh:156
static ThisType makeEnd(const Vector &vector, const FVElementGeometry &fvGeometry, const std::size_t scvIdx)
Definition: scvandscvfiterators.hh:140
static ThisType makeBegin(const Vector &vector, const FVElementGeometry &fvGeometry, const std::size_t scvIdx)
Definition: scvandscvfiterators.hh:129