Line | Branch | Exec | Source |
---|---|---|---|
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 | // SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder | ||
5 | // SPDX-License-Identifier: GPL-3.0-or-later | ||
6 | // | ||
7 | /*! | ||
8 | * \file | ||
9 | * \ingroup Discretization | ||
10 | * \brief Class providing iterators over sub control volumes and sub control volume faces of an element. | ||
11 | */ | ||
12 | #ifndef DUMUX_SCV_AND_SCVF_ITERATORS_HH | ||
13 | #define DUMUX_SCV_AND_SCVF_ITERATORS_HH | ||
14 | |||
15 | #include <dune/common/iteratorrange.hh> | ||
16 | #include <dune/common/iteratorfacades.hh> | ||
17 | |||
18 | namespace Dumux { | ||
19 | |||
20 | /*! | ||
21 | * \ingroup Discretization | ||
22 | * \brief Iterators over sub control volumes | ||
23 | * \note usage: for(const auto& scv : scvs(fvGeometry)) | ||
24 | */ | ||
25 | template<class SubControlVolume, class Vector, class FVElementGeometry> | ||
26 | class ScvIterator : public Dune::ForwardIteratorFacade<ScvIterator<SubControlVolume, | ||
27 | Vector, | ||
28 | FVElementGeometry>, | ||
29 | const SubControlVolume> | ||
30 | { | ||
31 | using ThisType = ScvIterator<SubControlVolume, Vector, FVElementGeometry>; | ||
32 | using Iterator = typename Vector::const_iterator; | ||
33 | public: | ||
34 | ScvIterator(const Iterator& it, const FVElementGeometry& fvGeometry) | ||
35 | : it_(it), fvGeometryPtr_(&fvGeometry) {} | ||
36 | |||
37 | 4 | ScvIterator() : it_(Iterator()), fvGeometryPtr_(nullptr) {} | |
38 | |||
39 | //! dereferencing yields a subcontrol volume | ||
40 | ✗ | const SubControlVolume& dereference() const | |
41 | { | ||
42 |
36/44✓ Branch 1 taken 1 times.
✓ Branch 2 taken 50476768 times.
✓ Branch 3 taken 144396030 times.
✓ Branch 4 taken 50476777 times.
✓ Branch 5 taken 144397558 times.
✓ Branch 6 taken 1470 times.
✓ Branch 7 taken 1189244 times.
✓ Branch 8 taken 21430 times.
✓ Branch 9 taken 2176572 times.
✓ Branch 10 taken 3388944 times.
✓ Branch 11 taken 1090492 times.
✓ Branch 12 taken 3371586 times.
✓ Branch 13 taken 137272 times.
✓ Branch 14 taken 2099 times.
✓ Branch 15 taken 2847715 times.
✓ Branch 16 taken 10357 times.
✓ Branch 17 taken 3409303 times.
✓ Branch 18 taken 2390944 times.
✓ Branch 19 taken 2119012 times.
✓ Branch 20 taken 906804 times.
✓ Branch 21 taken 5313318 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 5274454 times.
✓ Branch 24 taken 8000 times.
✓ Branch 25 taken 18248 times.
✗ Branch 26 not taken.
✓ Branch 27 taken 17146 times.
✓ Branch 28 taken 596 times.
✓ Branch 29 taken 29312 times.
✗ Branch 30 not taken.
✓ Branch 31 taken 277120 times.
✓ Branch 32 taken 12166 times.
✗ Branch 33 not taken.
✓ Branch 34 taken 277120 times.
✓ Branch 35 taken 12381 times.
✗ Branch 36 not taken.
✓ Branch 37 taken 1774400 times.
✓ Branch 38 taken 12381 times.
✗ Branch 39 not taken.
✓ Branch 40 taken 1774400 times.
✓ Branch 41 taken 901500 times.
✗ Branch 42 not taken.
✓ Branch 44 taken 901500 times.
✗ Branch 45 not taken.
|
1025340742 | return fvGeometryPtr_->scv(*it_); |
43 | } | ||
44 | |||
45 | ✗ | bool equals(const ThisType& other) const | |
46 | { | ||
47 | ✗ | return it_ == other.it_; | |
48 | } | ||
49 | |||
50 | ✗ | void increment() | |
51 | { | ||
52 | 317670027 | ++it_; | |
53 | ✗ | } | |
54 | |||
55 | private: | ||
56 | Iterator it_; | ||
57 | const FVElementGeometry* fvGeometryPtr_; | ||
58 | }; | ||
59 | |||
60 | /*! | ||
61 | * \ingroup Discretization | ||
62 | * \brief Iterators over sub control volume faces of an fv geometry | ||
63 | * \note usage: for(const auto& scvf : scvfs(fvGeometry)) | ||
64 | */ | ||
65 | template<class SubControlVolumeFace, class Vector, class FVElementGeometry> | ||
66 | class ScvfIterator : public Dune::ForwardIteratorFacade<ScvfIterator<SubControlVolumeFace, | ||
67 | Vector, | ||
68 | FVElementGeometry>, | ||
69 | const SubControlVolumeFace> | ||
70 | { | ||
71 | using ThisType = ScvfIterator<SubControlVolumeFace, Vector, FVElementGeometry>; | ||
72 | using Iterator = typename Vector::const_iterator; | ||
73 | public: | ||
74 | ScvfIterator(const Iterator& it, const FVElementGeometry& fvGeometry) | ||
75 | : it_(it), fvGeometryPtr_(&fvGeometry) {} | ||
76 | |||
77 | 64 | ScvfIterator() : it_(Iterator()), fvGeometryPtr_(nullptr) {} | |
78 | |||
79 | //! dereferencing yields a subcontrol volume face | ||
80 | 47775700 | const SubControlVolumeFace& dereference() const | |
81 | { | ||
82 |
58/62✓ Branch 0 taken 8 times.
✓ Branch 1 taken 196638 times.
✓ Branch 2 taken 40706 times.
✓ Branch 3 taken 933058 times.
✓ Branch 4 taken 5138534 times.
✓ Branch 5 taken 1937866 times.
✓ Branch 6 taken 6919461 times.
✓ Branch 7 taken 26743988 times.
✓ Branch 8 taken 3142381 times.
✓ Branch 9 taken 2969508 times.
✓ Branch 10 taken 23352934 times.
✓ Branch 11 taken 10031028 times.
✓ Branch 12 taken 41453569 times.
✓ Branch 13 taken 24454343 times.
✓ Branch 14 taken 35241989 times.
✓ Branch 15 taken 10352267 times.
✓ Branch 16 taken 17395293 times.
✓ Branch 17 taken 6356049 times.
✓ Branch 18 taken 5066937 times.
✓ Branch 19 taken 7370117 times.
✓ Branch 20 taken 36944399 times.
✓ Branch 21 taken 11895133 times.
✓ Branch 22 taken 36119961 times.
✓ Branch 23 taken 9087387 times.
✓ Branch 24 taken 7064926 times.
✓ Branch 25 taken 2567670 times.
✓ Branch 26 taken 4737572 times.
✓ Branch 27 taken 217248 times.
✓ Branch 28 taken 1202742 times.
✓ Branch 29 taken 543754 times.
✓ Branch 30 taken 2178398 times.
✓ Branch 31 taken 639038 times.
✓ Branch 32 taken 1855662 times.
✓ Branch 33 taken 587390 times.
✓ Branch 34 taken 582948 times.
✓ Branch 35 taken 557852 times.
✓ Branch 36 taken 39386 times.
✓ Branch 37 taken 642900 times.
✓ Branch 38 taken 22742 times.
✓ Branch 39 taken 249912 times.
✓ Branch 40 taken 330078 times.
✓ Branch 41 taken 555696 times.
✓ Branch 42 taken 390998 times.
✓ Branch 43 taken 436616 times.
✓ Branch 44 taken 461031 times.
✓ Branch 45 taken 174617 times.
✓ Branch 46 taken 97431 times.
✓ Branch 47 taken 58393 times.
✓ Branch 48 taken 6400 times.
✓ Branch 49 taken 281294 times.
✓ Branch 50 taken 37220 times.
✓ Branch 51 taken 407626 times.
✓ Branch 52 taken 31636 times.
✓ Branch 53 taken 140940 times.
✓ Branch 54 taken 22120 times.
✓ Branch 55 taken 18328 times.
✓ Branch 56 taken 22120 times.
✓ Branch 57 taken 18328 times.
✗ Branch 58 not taken.
✗ Branch 59 not taken.
✗ Branch 60 not taken.
✗ Branch 61 not taken.
|
2561794142 | return fvGeometryPtr_->scvf(*it_); |
83 | } | ||
84 | |||
85 | bool equals(const ThisType& other) const | ||
86 | { | ||
87 |
90/90✓ Branch 0 taken 7387970 times.
✓ Branch 1 taken 1822606 times.
✓ Branch 2 taken 7387970 times.
✓ Branch 3 taken 1822606 times.
✓ Branch 4 taken 265316021 times.
✓ Branch 5 taken 66465202 times.
✓ Branch 6 taken 265316021 times.
✓ Branch 7 taken 66465202 times.
✓ Branch 8 taken 247060666 times.
✓ Branch 9 taken 61890288 times.
✓ Branch 10 taken 247060666 times.
✓ Branch 11 taken 61890288 times.
✓ Branch 12 taken 155041179 times.
✓ Branch 13 taken 29117013 times.
✓ Branch 14 taken 155041179 times.
✓ Branch 15 taken 29117013 times.
✓ Branch 16 taken 80671838 times.
✓ Branch 17 taken 16002681 times.
✓ Branch 18 taken 80671838 times.
✓ Branch 19 taken 16002681 times.
✓ Branch 20 taken 105567354 times.
✓ Branch 21 taken 16848462 times.
✓ Branch 22 taken 105567354 times.
✓ Branch 23 taken 16848462 times.
✓ Branch 24 taken 163065186 times.
✓ Branch 25 taken 32081333 times.
✓ Branch 26 taken 163065186 times.
✓ Branch 27 taken 32081333 times.
✓ Branch 28 taken 74120734 times.
✓ Branch 29 taken 9876069 times.
✓ Branch 30 taken 74120734 times.
✓ Branch 31 taken 9876069 times.
✓ Branch 32 taken 37505370 times.
✓ Branch 33 taken 7019388 times.
✓ Branch 34 taken 37505370 times.
✓ Branch 35 taken 7019388 times.
✓ Branch 36 taken 93278044 times.
✓ Branch 37 taken 12868592 times.
✓ Branch 38 taken 93278044 times.
✓ Branch 39 taken 12868592 times.
✓ Branch 40 taken 46654512 times.
✓ Branch 41 taken 6357399 times.
✓ Branch 42 taken 46654512 times.
✓ Branch 43 taken 6357399 times.
✓ Branch 44 taken 6481312 times.
✓ Branch 45 taken 759153 times.
✓ Branch 46 taken 6481312 times.
✓ Branch 47 taken 759153 times.
✓ Branch 48 taken 3334026 times.
✓ Branch 49 taken 755676 times.
✓ Branch 50 taken 3354026 times.
✓ Branch 51 taken 760676 times.
✓ Branch 52 taken 3315792 times.
✓ Branch 53 taken 496399 times.
✓ Branch 54 taken 4054780 times.
✓ Branch 55 taken 613239 times.
✓ Branch 56 taken 3019296 times.
✓ Branch 57 taken 599470 times.
✓ Branch 58 taken 3130016 times.
✓ Branch 59 taken 650862 times.
✓ Branch 60 taken 1579154 times.
✓ Branch 61 taken 322539 times.
✓ Branch 62 taken 1405606 times.
✓ Branch 63 taken 317235 times.
✓ Branch 64 taken 1512760 times.
✓ Branch 65 taken 377328 times.
✓ Branch 66 taken 1202000 times.
✓ Branch 67 taken 300494 times.
✓ Branch 68 taken 392400 times.
✓ Branch 69 taken 98094 times.
✓ Branch 70 taken 2270715 times.
✓ Branch 71 taken 296112 times.
✓ Branch 72 taken 2270715 times.
✓ Branch 73 taken 296112 times.
✓ Branch 74 taken 3575040 times.
✓ Branch 75 taken 893760 times.
✓ Branch 76 taken 3575040 times.
✓ Branch 77 taken 893760 times.
✓ Branch 78 taken 1993856 times.
✓ Branch 79 taken 498464 times.
✓ Branch 80 taken 1993856 times.
✓ Branch 81 taken 498464 times.
✓ Branch 82 taken 1647680 times.
✓ Branch 83 taken 411920 times.
✓ Branch 84 taken 1647680 times.
✓ Branch 85 taken 411920 times.
✓ Branch 86 taken 1024 times.
✓ Branch 87 taken 256 times.
✓ Branch 88 taken 1024 times.
✓ Branch 89 taken 256 times.
|
3142667548 | return it_ == other.it_; |
88 | } | ||
89 | |||
90 | void increment() | ||
91 | { | ||
92 | 1303780334 | it_++; | |
93 | } | ||
94 | |||
95 | private: | ||
96 | Iterator it_; | ||
97 | const FVElementGeometry* fvGeometryPtr_; | ||
98 | }; | ||
99 | |||
100 | /*! | ||
101 | * \ingroup Discretization | ||
102 | * \brief Iterators over sub control volume faces of an fv geometry and a given sub control volume | ||
103 | * \note usage: for(const auto& scvf : scvfs(fvGeometry, scv)) | ||
104 | */ | ||
105 | template<class SubControlVolumeFace, class Vector, class FVElementGeometry> | ||
106 | class SkippingScvfIterator : public Dune::ForwardIteratorFacade<SkippingScvfIterator<SubControlVolumeFace, | ||
107 | Vector, | ||
108 | FVElementGeometry>, | ||
109 | const SubControlVolumeFace> | ||
110 | { | ||
111 | using ThisType = SkippingScvfIterator<SubControlVolumeFace, Vector, FVElementGeometry>; | ||
112 | using Iterator = typename Vector::const_iterator; | ||
113 | public: | ||
114 | |||
115 | 12 | SkippingScvfIterator() : it_(Iterator()), fvGeometryPtr_(nullptr) {} | |
116 | |||
117 | 98623131 | static ThisType makeBegin(const Vector& vector, const FVElementGeometry& fvGeometry, const std::size_t scvIdx) | |
118 | { | ||
119 | 98623131 | auto begin = vector.begin(); | |
120 | 197246262 | const auto end = vector.end(); | |
121 | |||
122 |
7/10✓ Branch 0 taken 551728371 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 551728371 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 549256171 times.
✓ Branch 6 taken 443967968 times.
✓ Branch 7 taken 107760403 times.
✓ Branch 8 taken 443967968 times.
✓ Branch 9 taken 96150931 times.
|
1131620086 | while (begin != end && fvGeometry.scvf(*begin).insideScvIdx() != scvIdx) |
123 | 453105240 | ++begin; | |
124 | |||
125 | 197246262 | return SkippingScvfIterator(begin, end, fvGeometry, scvIdx); | |
126 | } | ||
127 | |||
128 | static ThisType makeEnd(const Vector& vector, const FVElementGeometry& fvGeometry, const std::size_t scvIdx) | ||
129 | { | ||
130 | 394492524 | return SkippingScvfIterator(vector.end(), vector.end(), fvGeometry, scvIdx); | |
131 | } | ||
132 | |||
133 | //! dereferencing yields a subcontrol volume face | ||
134 | 893697462 | const SubControlVolumeFace& dereference() const | |
135 | { | ||
136 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 870809680 times.
|
893697462 | return fvGeometryPtr_->scvf(*it_); |
137 | } | ||
138 | |||
139 | bool equals(const ThisType& other) const | ||
140 | { | ||
141 |
24/24✓ Branch 0 taken 20604526 times.
✓ Branch 1 taken 676 times.
✓ Branch 2 taken 20604526 times.
✓ Branch 3 taken 676 times.
✓ Branch 4 taken 71789623 times.
✓ Branch 5 taken 23713390 times.
✓ Branch 6 taken 71789623 times.
✓ Branch 7 taken 23713390 times.
✓ Branch 8 taken 181725660 times.
✓ Branch 9 taken 60093330 times.
✓ Branch 10 taken 181725660 times.
✓ Branch 11 taken 60093330 times.
✓ Branch 12 taken 178746 times.
✓ Branch 13 taken 59208 times.
✓ Branch 14 taken 178746 times.
✓ Branch 15 taken 59208 times.
✓ Branch 16 taken 794893 times.
✓ Branch 17 taken 263135 times.
✓ Branch 18 taken 794893 times.
✓ Branch 19 taken 263135 times.
✓ Branch 20 taken 87 times.
✓ Branch 21 taken 29 times.
✓ Branch 22 taken 87 times.
✓ Branch 23 taken 29 times.
|
718446626 | return it_ == other.it_; |
142 | } | ||
143 | |||
144 | 275091891 | void increment() | |
145 | { | ||
146 | 275091891 | ++it_; | |
147 |
8/8✓ Branch 0 taken 609426860 times.
✓ Branch 1 taken 84129766 times.
✓ Branch 2 taken 609426860 times.
✓ Branch 3 taken 84129766 times.
✓ Branch 5 taken 418464735 times.
✓ Branch 6 taken 190962125 times.
✓ Branch 7 taken 418464735 times.
✓ Branch 8 taken 190962125 times.
|
1387113252 | while (it_ != itEnd_ && dereference().insideScvIdx() != scvIdx_) |
148 | 418464735 | ++it_; | |
149 | 275091891 | } | |
150 | |||
151 | private: | ||
152 | |||
153 | 197246262 | SkippingScvfIterator(const Iterator& itBegin, const Iterator& itEnd, const FVElementGeometry& fvGeometry, const std::size_t scvIdx) | |
154 | 197246262 | : it_(itBegin), fvGeometryPtr_(&fvGeometry), itEnd_(itEnd), scvIdx_(scvIdx) {} | |
155 | |||
156 | Iterator it_; | ||
157 | const FVElementGeometry* fvGeometryPtr_; | ||
158 | const Iterator itEnd_; | ||
159 | std::size_t scvIdx_; | ||
160 | }; | ||
161 | |||
162 | } // end namespace Dumux | ||
163 | |||
164 | #endif | ||
165 |