3.4
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
scvandscvfiterators.hh
Go to the documentation of this file.
1// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2// vi: set et ts=4 sw=4 sts=4:
3/*****************************************************************************
4 * See the file COPYING for full copying permissions. *
5 * *
6 * This program is free software: you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation, either version 3 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
18 *****************************************************************************/
24#ifndef DUMUX_SCV_AND_SCVF_ITERATORS_HH
25#define DUMUX_SCV_AND_SCVF_ITERATORS_HH
26
27#include <dune/common/iteratorrange.hh>
28#include <dune/common/iteratorfacades.hh>
29
30namespace Dumux {
31
37template<class SubControlVolume, class Vector, class FVElementGeometry>
38class ScvIterator : public Dune::ForwardIteratorFacade<ScvIterator<SubControlVolume,
39 Vector,
40 FVElementGeometry>,
41 const SubControlVolume>
42{
44 using Iterator = typename Vector::const_iterator;
45public:
46 ScvIterator(const Iterator& it, const FVElementGeometry& fvGeometry)
47 : it_(it), fvGeometryPtr_(&fvGeometry) {}
48
49 ScvIterator() : it_(Iterator()), fvGeometryPtr_(nullptr) {}
50
52 const SubControlVolume& dereference() const
53 {
54 return fvGeometryPtr_->scv(*it_);
55 }
56
57 bool equals(const ThisType& other) const
58 {
59 return it_ == other.it_;
60 }
61
62 void increment()
63 {
64 ++it_;
65 }
66
67private:
68 Iterator it_;
69 const FVElementGeometry* fvGeometryPtr_;
70};
71
77template<class SubControlVolumeFace, class Vector, class FVElementGeometry>
78class ScvfIterator : public Dune::ForwardIteratorFacade<ScvfIterator<SubControlVolumeFace,
79 Vector,
80 FVElementGeometry>,
81 const SubControlVolumeFace>
82{
84 using Iterator = typename Vector::const_iterator;
85public:
86 ScvfIterator(const Iterator& it, const FVElementGeometry& fvGeometry)
87 : it_(it), fvGeometryPtr_(&fvGeometry) {}
88
89 ScvfIterator() : it_(Iterator()), fvGeometryPtr_(nullptr) {}
90
92 const SubControlVolumeFace& dereference() const
93 {
94 return fvGeometryPtr_->scvf(*it_);
95 }
96
97 bool equals(const ThisType& other) const
98 {
99 return it_ == other.it_;
100 }
101
103 {
104 it_++;
105 }
106
107private:
108 Iterator it_;
109 const FVElementGeometry* fvGeometryPtr_;
110};
111
112} // end namespace Dumux
113
114#endif
Definition: adapt.hh:29
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