GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/multidomain/facet/box/fvelementgeometry.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 68 72 94.4%
Functions: 12 19 63.2%
Branches: 267 447 59.7%

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 FacetCoupling
10 * \brief \copydoc Dumux::BoxFacetCouplingFVElementGeometry
11 */
12 #ifndef DUMUX_FACETCOUPLING_BOX_FV_ELEMENT_GEOMETRY_HH
13 #define DUMUX_FACETCOUPLING_BOX_FV_ELEMENT_GEOMETRY_HH
14
15 #include <algorithm>
16 #include <optional>
17
18 #include <dune/geometry/type.hh>
19
20 #include <dumux/common/indextraits.hh>
21 #include <dumux/discretization/scvandscvfiterators.hh>
22 #include <dumux/discretization/box/boxgeometryhelper.hh>
23
24 namespace Dumux {
25
26 /*!
27 * \ingroup FacetCoupling
28 * \brief Base class for the element-local finite volume geometry for box models
29 * in the context of models considering coupling of different domains across the
30 * bulk grid facets. This builds up the sub control volumes and sub control volume
31 * faces for an element.
32 * \tparam GG the finite volume grid geometry type
33 * \tparam enableGridGeometryCache if the grid geometry is cached or not
34 */
35 template<class GG, bool enableGridGeometryCache>
36 class BoxFacetCouplingFVElementGeometry;
37
38 //! specialization in case the FVElementGeometries are stored
39 template<class GG>
40
4/14
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 64 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
136 class BoxFacetCouplingFVElementGeometry<GG, true>
41 {
42 using GridView = typename GG::GridView;
43 static constexpr int dim = GridView::dimension;
44 static constexpr int dimWorld = GridView::dimensionworld;
45 using GridIndexType = typename IndexTraits<GridView>::GridIndex;
46 using LocalIndexType = typename IndexTraits<GridView>::LocalIndex;
47 using CoordScalar = typename GridView::ctype;
48 using FeLocalBasis = typename GG::FeCache::FiniteElementType::Traits::LocalBasisType;
49 public:
50 //! export type of the element
51 using Element = typename GridView::template Codim<0>::Entity;
52 //! export type of subcontrol volume
53 using SubControlVolume = typename GG::SubControlVolume;
54 //! export type of subcontrol volume face
55 using SubControlVolumeFace = typename GG::SubControlVolumeFace;
56 //! export type of finite volume grid geometry
57 using GridGeometry = GG;
58 //! the maximum number of scvs per element (2^dim for cubes)
59 static constexpr std::size_t maxNumElementScvs = (1<<dim);
60
61 //! Constructor
62 BoxFacetCouplingFVElementGeometry(const GridGeometry& gridGeometry)
63 272 : gridGeometryPtr_(&gridGeometry)
64 {}
65
66 //! Get a sub control volume with a local scv index
67 const SubControlVolume& scv(LocalIndexType scvIdx) const
68
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 768 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 768 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 768 times.
2304 { return gridGeometry().scvs(eIdx_)[scvIdx]; }
69
70 //! Get a sub control volume face with a local scvf index
71 const SubControlVolumeFace& scvf(LocalIndexType scvfIdx) const
72
11/22
✓ Branch 1 taken 768 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 768 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 768 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 768 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 768 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 768 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 768 times.
✗ Branch 20 not taken.
✓ Branch 21 taken 768 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 768 times.
✓ Branch 25 taken 768 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 768 times.
✗ Branch 29 not taken.
6912 { return gridGeometry().scvfs(eIdx_)[scvfIdx]; }
73
74 //! iterator range for sub control volumes. Iterates over
75 //! all scvs of the bound element.
76 //! This is a free function found by means of ADL
77 //! To iterate over all sub control volumes of this FVElementGeometry use
78 //! for (auto&& scv : scvs(fvGeometry))
79 friend inline Dune::IteratorRange<typename std::vector<SubControlVolume>::const_iterator>
80 scvs(const BoxFacetCouplingFVElementGeometry& fvGeometry)
81 {
82 const auto& g = fvGeometry.gridGeometry();
83 using Iter = typename std::vector<SubControlVolume>::const_iterator;
84 return Dune::IteratorRange<Iter>(g.scvs(fvGeometry.eIdx_).begin(), g.scvs(fvGeometry.eIdx_).end());
85 }
86
87 //! iterator range for sub control volumes faces. Iterates over
88 //! all scvfs of the bound element.
89 //! This is a free function found by means of ADL
90 //! To iterate over all sub control volume faces of this FVElementGeometry use
91 //! for (auto&& scvf : scvfs(fvGeometry))
92 friend inline Dune::IteratorRange<typename std::vector<SubControlVolumeFace>::const_iterator>
93 scvfs(const BoxFacetCouplingFVElementGeometry& fvGeometry)
94 {
95 256 const auto& g = fvGeometry.gridGeometry();
96 using Iter = typename std::vector<SubControlVolumeFace>::const_iterator;
97 1280 return Dune::IteratorRange<Iter>(g.scvfs(fvGeometry.eIdx_).begin(), g.scvfs(fvGeometry.eIdx_).end());
98 }
99
100 //! Get a local finite element basis
101 const FeLocalBasis& feLocalBasis() const
102 { return gridGeometry().feCache().get(element_->type()).localBasis(); }
103
104 //! The total number of sub control volumes
105 std::size_t numScv() const
106 { return gridGeometry().scvs(eIdx_).size(); }
107
108 //! The total number of sub control volume faces
109 std::size_t numScvf() const
110 { return gridGeometry().scvfs(eIdx_).size(); }
111
112 /*!
113 * \brief bind the local view (r-value overload)
114 * This overload is called when an instance of this class is a temporary in the usage context
115 * This allows a usage like this: `const auto view = localView(...).bind(element);`
116 */
117 BoxFacetCouplingFVElementGeometry bind(const Element& element) &&
118 {
119 this->bindElement(element);
120 return std::move(*this);
121 }
122
123 //! this function is for compatibility reasons with cc methods
124 //! The box stencil is always element-local so bind and bindElement
125 //! are identical.
126 void bind(const Element& element) &
127
2/4
✓ Branch 1 taken 224 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 256 times.
✗ Branch 5 not taken.
480 { this->bindElement(element); }
128
129 /*!
130 * \brief bind the local view (r-value overload)
131 * This overload is called when an instance of this class is a temporary in the usage context
132 * This allows a usage like this: `const auto view = localView(...).bindElement(element);`
133 */
134 BoxFacetCouplingFVElementGeometry bindElement(const Element& element) &&
135 {
136 this->bindElement(element);
137 return std::move(*this);
138 }
139
140 //! Binding of an element, has to be called before using the fvgeometries
141 //! Prepares all the volume variables within the element
142 //! For compatibility reasons with the FVGeometry cache being disabled
143 736 void bindElement(const Element& element) &
144 {
145
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 68 times.
736 element_ = element;
146 1472 eIdx_ = gridGeometry().elementMapper().index(element);
147 736 }
148
149 //! The global finite volume geometry we are a restriction of
150 const GridGeometry& gridGeometry() const
151 { return *gridGeometryPtr_; }
152
153 //! Returns true if bind/bindElement has already been called
154 bool isBound() const
155 { return static_cast<bool>(element_); }
156
157 //! The bound element
158 const Element& element() const
159 { return *element_; }
160
161 // suppress warnings due to current implementation
162 // these interfaces should be used!
163 #pragma GCC diagnostic push
164 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
165
166 //! Create the geometry of a given sub control volume
167 typename SubControlVolume::Traits::Geometry geometry(const SubControlVolume& scv) const
168 { return scv.geometry(); }
169
170 //! Create the geometry of a given sub control volume face
171 typename SubControlVolumeFace::Traits::Geometry geometry(const SubControlVolumeFace& scvf) const
172 { return scvf.geometry(); }
173
174 #pragma GCC diagnostic pop
175
176 private:
177 const GridGeometry* gridGeometryPtr_;
178
179 GridIndexType eIdx_;
180 std::optional<Element> element_;
181 };
182
183 //! specialization in case the geometries are not stored grid-wide
184 template<class GG>
185 class BoxFacetCouplingFVElementGeometry<GG, false>
186 {
187 using GridView = typename GG::GridView;
188 static constexpr int dim = GridView::dimension;
189 static constexpr int dimWorld = GridView::dimensionworld;
190
191 using GridIndexType = typename IndexTraits<GridView>::GridIndex;
192 using LocalIndexType = typename IndexTraits<GridView>::LocalIndex;
193
194 using CoordScalar = typename GridView::ctype;
195 using FeLocalBasis = typename GG::FeCache::FiniteElementType::Traits::LocalBasisType;
196
197 using GeometryHelper = typename GG::GeometryHelper;
198 public:
199 //! export type of the element
200 using Element = typename GridView::template Codim<0>::Entity;
201 //! export type of subcontrol volume
202 using SubControlVolume = typename GG::SubControlVolume;
203 //! export type of subcontrol volume face
204 using SubControlVolumeFace = typename GG::SubControlVolumeFace;
205 //! export type of finite volume grid geometry
206 using GridGeometry = GG;
207 //! the maximum number of scvs per element (2^dim for cubes)
208 static constexpr std::size_t maxNumElementScvs = (1<<dim);
209
210 //! Constructor
211 BoxFacetCouplingFVElementGeometry(const GridGeometry& gridGeometry)
212
92/148
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 9 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 9 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 12 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 12 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 12 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 12 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 4477 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 4477 times.
✗ Branch 29 not taken.
✓ Branch 31 taken 4477 times.
✗ Branch 32 not taken.
✓ Branch 33 taken 352 times.
✓ Branch 34 taken 4477 times.
✗ Branch 35 not taken.
✓ Branch 36 taken 352 times.
✓ Branch 37 taken 19 times.
✗ Branch 38 not taken.
✓ Branch 39 taken 352 times.
✓ Branch 40 taken 19 times.
✗ Branch 41 not taken.
✓ Branch 42 taken 352 times.
✓ Branch 43 taken 19 times.
✗ Branch 44 not taken.
✓ Branch 45 taken 16 times.
✓ Branch 46 taken 19 times.
✗ Branch 47 not taken.
✓ Branch 48 taken 16 times.
✓ Branch 49 taken 419 times.
✗ Branch 50 not taken.
✓ Branch 51 taken 16 times.
✓ Branch 52 taken 419 times.
✗ Branch 53 not taken.
✓ Branch 54 taken 16 times.
✓ Branch 55 taken 419 times.
✗ Branch 56 not taken.
✓ Branch 57 taken 64 times.
✓ Branch 58 taken 419 times.
✗ Branch 59 not taken.
✓ Branch 60 taken 64 times.
✓ Branch 61 taken 8789 times.
✗ Branch 62 not taken.
✓ Branch 63 taken 64 times.
✓ Branch 64 taken 8789 times.
✗ Branch 65 not taken.
✓ Branch 66 taken 64 times.
✓ Branch 67 taken 8789 times.
✗ Branch 68 not taken.
✓ Branch 70 taken 8789 times.
✗ Branch 71 not taken.
✓ Branch 73 taken 260097 times.
✗ Branch 74 not taken.
✓ Branch 76 taken 260097 times.
✗ Branch 77 not taken.
✓ Branch 79 taken 260097 times.
✗ Branch 80 not taken.
✓ Branch 81 taken 1 times.
✓ Branch 82 taken 260097 times.
✗ Branch 83 not taken.
✓ Branch 84 taken 1 times.
✓ Branch 85 taken 788 times.
✗ Branch 86 not taken.
✓ Branch 87 taken 1 times.
✓ Branch 88 taken 788 times.
✗ Branch 89 not taken.
✓ Branch 90 taken 1 times.
✓ Branch 91 taken 788 times.
✗ Branch 92 not taken.
✓ Branch 93 taken 1 times.
✓ Branch 94 taken 788 times.
✗ Branch 95 not taken.
✓ Branch 96 taken 1 times.
✓ Branch 97 taken 50000 times.
✗ Branch 98 not taken.
✓ Branch 99 taken 1 times.
✓ Branch 100 taken 50000 times.
✗ Branch 101 not taken.
✓ Branch 102 taken 1 times.
✓ Branch 103 taken 50000 times.
✗ Branch 104 not taken.
✓ Branch 105 taken 1 times.
✓ Branch 106 taken 50000 times.
✗ Branch 107 not taken.
✓ Branch 108 taken 1 times.
✓ Branch 109 taken 98500 times.
✗ Branch 110 not taken.
✓ Branch 111 taken 1 times.
✓ Branch 112 taken 98500 times.
✗ Branch 113 not taken.
✓ Branch 114 taken 1 times.
✓ Branch 115 taken 98500 times.
✗ Branch 116 not taken.
✓ Branch 117 taken 640 times.
✓ Branch 118 taken 98500 times.
✗ Branch 119 not taken.
✓ Branch 120 taken 640 times.
✓ Branch 121 taken 7712 times.
✗ Branch 122 not taken.
✓ Branch 123 taken 640 times.
✓ Branch 124 taken 7712 times.
✗ Branch 125 not taken.
✓ Branch 126 taken 640 times.
✓ Branch 127 taken 7712 times.
✗ Branch 128 not taken.
✓ Branch 129 taken 352 times.
✓ Branch 130 taken 7712 times.
✗ Branch 131 not taken.
✓ Branch 132 taken 352 times.
✓ Branch 133 taken 964000 times.
✗ Branch 134 not taken.
✓ Branch 135 taken 352 times.
✓ Branch 136 taken 964000 times.
✗ Branch 137 not taken.
✓ Branch 138 taken 352 times.
✓ Branch 139 taken 964000 times.
✗ Branch 140 not taken.
✓ Branch 141 taken 7708 times.
✓ Branch 142 taken 964000 times.
✗ Branch 143 not taken.
✓ Branch 144 taken 7708 times.
✓ Branch 145 taken 297 times.
✗ Branch 146 not taken.
✓ Branch 147 taken 7708 times.
✓ Branch 148 taken 297 times.
✗ Branch 149 not taken.
✓ Branch 150 taken 7708 times.
✓ Branch 151 taken 297 times.
✗ Branch 152 not taken.
✓ Branch 154 taken 297 times.
✗ Branch 155 not taken.
✓ Branch 157 taken 1 times.
✗ Branch 158 not taken.
✓ Branch 160 taken 1 times.
✗ Branch 161 not taken.
✓ Branch 163 taken 1 times.
✗ Branch 164 not taken.
✓ Branch 166 taken 1 times.
✗ Branch 167 not taken.
5845880 : gridGeometryPtr_(&gridGeometry)
213 {}
214
215 //! Get a sub control volume with a local scv index
216 const SubControlVolume& scv(LocalIndexType scvIdx) const
217
44/48
✓ Branch 0 taken 36640 times.
✓ Branch 1 taken 92544 times.
✓ Branch 2 taken 9013792 times.
✓ Branch 3 taken 92544 times.
✓ Branch 4 taken 9024228 times.
✓ Branch 5 taken 45468 times.
✓ Branch 6 taken 1105972 times.
✓ Branch 7 taken 11979900 times.
✓ Branch 8 taken 1690136 times.
✓ Branch 9 taken 14826432 times.
✓ Branch 10 taken 7308192 times.
✓ Branch 11 taken 8149480 times.
✓ Branch 12 taken 8137932 times.
✓ Branch 13 taken 6697204 times.
✓ Branch 14 taken 1460994 times.
✓ Branch 15 taken 1574430 times.
✓ Branch 16 taken 4242044 times.
✓ Branch 17 taken 136772 times.
✓ Branch 18 taken 4242030 times.
✓ Branch 19 taken 2066 times.
✓ Branch 20 taken 745473 times.
✓ Branch 21 taken 8484223 times.
✓ Branch 22 taken 745473 times.
✓ Branch 23 taken 8484223 times.
✓ Branch 24 taken 4761904 times.
✓ Branch 25 taken 4010136 times.
✓ Branch 26 taken 4761904 times.
✓ Branch 27 taken 4010136 times.
✓ Branch 28 taken 214047 times.
✓ Branch 29 taken 115521 times.
✓ Branch 30 taken 214047 times.
✓ Branch 31 taken 115521 times.
✓ Branch 32 taken 401 times.
✓ Branch 33 taken 66839 times.
✓ Branch 34 taken 401 times.
✓ Branch 35 taken 66839 times.
✓ Branch 36 taken 2913 times.
✓ Branch 37 taken 2871 times.
✓ Branch 38 taken 2913 times.
✓ Branch 39 taken 2871 times.
✓ Branch 40 taken 1 times.
✓ Branch 41 taken 37039 times.
✓ Branch 42 taken 1 times.
✓ Branch 43 taken 37039 times.
✗ Branch 48 not taken.
✗ Branch 49 not taken.
✗ Branch 50 not taken.
✗ Branch 51 not taken.
158316660 { return scvs_[scvIdx]; }
218
219 //! Get a sub control volume face with a local scvf index
220 const SubControlVolumeFace& scvf(LocalIndexType scvfIdx) const
221
14/28
✗ Branch 0 not taken.
✓ Branch 1 taken 715792 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 715792 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 169712 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 169712 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 6912 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 252684 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 258444 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 316672 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 304000 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 12640 times.
✗ Branch 20 not taken.
✓ Branch 21 taken 13440 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 800 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 22368 times.
✗ Branch 26 not taken.
✓ Branch 27 taken 22368 times.
3236600 { return scvfs_[scvfIdx]; }
222
223 //! iterator range for sub control volumes. Iterates over
224 //! all scvs of the bound element.
225 //! This is a free function found by means of ADL
226 //! To iterate over all sub control volumes of this FVElementGeometry use
227 //! for (auto&& scv : scvs(fvGeometry))
228 friend inline Dune::IteratorRange<typename std::vector<SubControlVolume>::const_iterator>
229 scvs(const BoxFacetCouplingFVElementGeometry& fvGeometry)
230 {
231 using Iter = typename std::vector<SubControlVolume>::const_iterator;
232 163084713 return Dune::IteratorRange<Iter>(fvGeometry.scvs_.begin(), fvGeometry.scvs_.end());
233 }
234
235 //! iterator range for sub control volumes faces. Iterates over
236 //! all scvfs of the bound element.
237 //! This is a free function found by means of ADL
238 //! To iterate over all sub control volume faces of this FVElementGeometry use
239 //! for (auto&& scvf : scvfs(fvGeometry))
240 friend inline Dune::IteratorRange<typename std::vector<SubControlVolumeFace>::const_iterator>
241 scvfs(const BoxFacetCouplingFVElementGeometry& fvGeometry)
242 {
243 using Iter = typename std::vector<SubControlVolumeFace>::const_iterator;
244 13972236 return Dune::IteratorRange<Iter>(fvGeometry.scvfs_.begin(), fvGeometry.scvfs_.end());
245 }
246
247 //! Get a local finite element basis
248 const FeLocalBasis& feLocalBasis() const
249
10/19
✓ Branch 1 taken 4820256 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 4820256 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 4884264 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 4884264 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 64008 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 36690 times.
✓ Branch 16 taken 64008 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 36690 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 36690 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 36690 times.
✗ Branch 25 not taken.
19690856 { return gridGeometry().feCache().get(element_->type()).localBasis(); }
250
251 //! The total number of sub control volumes
252 std::size_t numScv() const
253
11/14
✓ Branch 1 taken 4820256 times.
✓ Branch 2 taken 64008 times.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 31467 times.
✓ Branch 5 taken 416 times.
✓ Branch 6 taken 36690 times.
✓ Branch 7 taken 67104 times.
✓ Branch 8 taken 22368 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 times.
✓ Branch 12 taken 2111 times.
✓ Branch 19 taken 704 times.
✗ Branch 20 not taken.
20350060 { return scvs_.size(); }
254
255 //! The total number of sub control volume faces
256 std::size_t numScvf() const
257
1/2
✓ Branch 3 taken 1928 times.
✗ Branch 4 not taken.
1354280 { return scvfs_.size(); }
258
259 /*!
260 * \brief bind the local view (r-value overload)
261 * This overload is called when an instance of this class is a temporary in the usage context
262 * This allows a usage like this: `const auto view = localView(...).bind(element);`
263 */
264 BoxFacetCouplingFVElementGeometry bind(const Element& element) &&
265 {
266 this->bindElement(element);
267 return std::move(*this);
268 }
269
270 //! this function is for compatibility reasons with cc methods
271 //! The box stencil is always element-local so bind and bindElement
272 //! are identical.
273 void bind(const Element& element) &
274
6/17
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 7 taken 8788 times.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 13 taken 1504 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 64 times.
✓ Branch 17 taken 100000 times.
✗ Branch 18 not taken.
✓ Branch 21 taken 200 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 1928 times.
✗ Branch 25 not taken.
1352352 { this->bindElement(element); }
275
276 /*!
277 * \brief bind the local view (r-value overload)
278 * This overload is called when an instance of this class is a temporary in the usage context
279 * This allows a usage like this: `const auto view = localView(...).bindElement(element);`
280 */
281 BoxFacetCouplingFVElementGeometry bindElement(const Element& element) &&
282 {
283
5/10
✓ Branch 1 taken 5218 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 9592 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 50064 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 99140 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 297 times.
✗ Branch 14 not taken.
164311 this->bindElement(element);
284 164311 return std::move(*this);
285 }
286
287 //! Binding of an element, has to be called before using the fvgeometries
288 //! Prepares all the volume variables within the element
289 //! For compatibility reasons with the FVGeometry cache being disabled
290 1695153 void bindElement(const Element& element) &
291 {
292
2/2
✓ Branch 0 taken 623 times.
✓ Branch 1 taken 1449 times.
1695153 element_ = element;
293 3390306 eIdx_ = gridGeometry().elementMapper().index(element);
294 1695153 makeElementGeometries_();
295 1695153 }
296
297 //! The global finite volume geometry we are a restriction of
298 const GridGeometry& gridGeometry() const
299 { return *gridGeometryPtr_; }
300
301 //! Returns true if bind/bindElement has already been called
302 bool isBound() const
303 { return static_cast<bool>(element_); }
304
305 //! The bound element
306 const Element& element() const
307 4114912 { return *element_; }
308
309 // suppress warnings due to current implementation
310 // these interfaces should be used!
311 #pragma GCC diagnostic push
312 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
313
314 //! Create the geometry of a given sub control volume
315 typename SubControlVolume::Traits::Geometry geometry(const SubControlVolume& scv) const
316 { return scv.geometry(); }
317
318 //! Create the geometry of a given sub control volume face
319 typename SubControlVolumeFace::Traits::Geometry geometry(const SubControlVolumeFace& scvf) const
320 { return scvf.geometry(); }
321
322 #pragma GCC diagnostic pop
323
324 private:
325
326 1695153 void makeElementGeometries_()
327 {
328 // get the element geometry
329 1695153 const auto& element = *element_;
330 1695153 const auto elementGeometry = element.geometry();
331
1/2
✓ Branch 1 taken 1671794 times.
✗ Branch 2 not taken.
1695153 const auto refElement = referenceElement(elementGeometry);
332
333 // get the sub control volume geometries of this element
334
2/2
✓ Branch 0 taken 157046 times.
✓ Branch 1 taken 1516820 times.
1695153 GeometryHelper geometryHelper(elementGeometry);
335
336 // construct the sub control volumes
337
2/2
✓ Branch 0 taken 157046 times.
✓ Branch 1 taken 1516820 times.
1695153 scvs_.clear();
338
2/4
✓ Branch 1 taken 1671794 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1671794 times.
✗ Branch 5 not taken.
3390306 scvs_.reserve(elementGeometry.corners());
339 using LocalIndexType = typename SubControlVolumeFace::Traits::LocalIndexType;
340
4/4
✓ Branch 0 taken 5395663 times.
✓ Branch 1 taken 1673866 times.
✓ Branch 2 taken 5395663 times.
✓ Branch 3 taken 1673866 times.
12652631 for (LocalIndexType scvLocalIdx = 0; scvLocalIdx < elementGeometry.corners(); ++scvLocalIdx)
341
1/2
✓ Branch 1 taken 5389447 times.
✗ Branch 2 not taken.
5478739 scvs_.emplace_back(geometryHelper.getScvCorners(scvLocalIdx),
342 scvLocalIdx,
343
1/2
✓ Branch 1 taken 5389447 times.
✗ Branch 2 not taken.
5478739 eIdx_,
344
2/4
✓ Branch 1 taken 5389447 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5389447 times.
✗ Branch 5 not taken.
10957478 gridGeometry().vertexMapper().subIndex(element, scvLocalIdx, dim));
345
346 // construct the sub control volume faces
347
1/2
✓ Branch 1 taken 1671794 times.
✗ Branch 2 not taken.
1695153 const auto numInnerScvf = (dim==1) ? 1 : element.subEntities(dim-1);
348 1695153 scvfs_.clear();
349
1/2
✓ Branch 1 taken 1671794 times.
✗ Branch 2 not taken.
1695153 scvfs_.reserve(numInnerScvf);
350
351 1695153 unsigned int scvfLocalIdx = 0;
352
2/2
✓ Branch 0 taken 5434093 times.
✓ Branch 1 taken 1673866 times.
7250752 for (; scvfLocalIdx < numInnerScvf; ++scvfLocalIdx)
353 {
354 // find the local scv indices this scvf is connected to
355
2/6
✓ Branch 3 taken 5434093 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 5434093 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
16666797 std::vector<LocalIndexType> localScvIndices({static_cast<LocalIndexType>(refElement.subEntity(scvfLocalIdx, dim-1, 0, dim)),
356
1/2
✓ Branch 2 taken 5427877 times.
✗ Branch 3 not taken.
5555599 static_cast<LocalIndexType>(refElement.subEntity(scvfLocalIdx, dim-1, 1, dim))});
357
358 // create the sub-control volume face
359 11111198 scvfs_.emplace_back(geometryHelper,
360 element,
361 elementGeometry,
362 scvfLocalIdx,
363
1/2
✓ Branch 1 taken 5434093 times.
✗ Branch 2 not taken.
5555599 std::move(localScvIndices));
364 }
365
366 // construct the sub control volume faces on the domain/interior boundaries
367 // skip handled facets (necessary for e.g. Dune::FoamGrid)
368
1/5
✓ Branch 1 taken 1673866 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3386162 std::vector<unsigned int> handledFacets;
369
7/17
✓ Branch 1 taken 1673866 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1673866 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 7070649 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 13 taken 5391519 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 5396783 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 7336 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 1671794 times.
✗ Branch 22 not taken.
17750858 for (const auto& intersection : intersections(gridGeometry().gridView(), element))
370 {
371
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 5396783 times.
✓ Branch 2 taken 1120 times.
✓ Branch 3 taken 6216 times.
✓ Branch 4 taken 5389447 times.
10961958 if (std::count(handledFacets.begin(), handledFacets.end(), intersection.indexInInside()))
372 2240 continue;
373
374
2/4
✓ Branch 1 taken 5395663 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5395663 times.
✗ Branch 5 not taken.
5491171 handledFacets.push_back(intersection.indexInInside());
375
376 // determine if all corners live on the facet grid
377
1/2
✓ Branch 1 taken 5395663 times.
✗ Branch 2 not taken.
10945046 const auto isGeometry = intersection.geometry();
378
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 5395663 times.
✗ Branch 2 not taken.
5478739 const auto numFaceCorners = isGeometry.corners();
379
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 5395663 times.
✗ Branch 2 not taken.
5478739 const auto idxInInside = intersection.indexInInside();
380
1/2
✓ Branch 1 taken 6216 times.
✗ Branch 2 not taken.
5478739 const auto boundary = intersection.boundary();
381
382
3/6
✓ Branch 1 taken 5395663 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5395663 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5395663 times.
✗ Branch 7 not taken.
21914956 std::vector<LocalIndexType> vIndicesLocal(numFaceCorners);
383
2/2
✓ Branch 0 taken 10868186 times.
✓ Branch 1 taken 5395663 times.
16589937 for (int i = 0; i < numFaceCorners; ++i)
384 11111198 vIndicesLocal[i] = static_cast<LocalIndexType>(refElement.subEntity(idxInInside, 1, i, dim));
385
386 // if all vertices are living on the facet grid, this is an interiour boundary
387
1/2
✓ Branch 1 taken 5395663 times.
✗ Branch 2 not taken.
5478739 const bool isOnFacet = gridGeometry().isOnInteriorBoundary(element, intersection);
388
389
4/4
✓ Branch 0 taken 4994493 times.
✓ Branch 1 taken 401170 times.
✓ Branch 2 taken 85227 times.
✓ Branch 3 taken 4909266 times.
5478739 if (isOnFacet || boundary)
390 {
391
4/4
✓ Branch 0 taken 983234 times.
✓ Branch 1 taken 486397 times.
✓ Branch 2 taken 983234 times.
✓ Branch 3 taken 486397 times.
2532105 for (unsigned int isScvfLocalIdx = 0; isScvfLocalIdx < isGeometry.corners(); ++isScvfLocalIdx)
392 {
393 // find the inside scv this scvf is belonging to (localIdx = element local vertex index)
394
3/10
✓ Branch 1 taken 983234 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 983234 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 983234 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
4068072 std::vector<LocalIndexType> localScvIndices = {vIndicesLocal[isScvfLocalIdx], vIndicesLocal[isScvfLocalIdx]};
395
396 // create the sub-control volume face
397 2034036 scvfs_.emplace_back(geometryHelper,
398 intersection,
399 isGeometry,
400 isScvfLocalIdx,
401 scvfLocalIdx,
402
1/2
✓ Branch 1 taken 983234 times.
✗ Branch 2 not taken.
1017018 std::move(localScvIndices),
403 boundary,
404 isOnFacet);
405
406 // increment local counter
407
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 983234 times.
1017018 scvfLocalIdx++;
408 }
409 }
410 }
411 1695153 }
412
413 //! The global geometry this is a restriction of
414 const GridGeometry* gridGeometryPtr_;
415
416 //! The bound element
417 GridIndexType eIdx_;
418 std::optional<Element> element_;
419
420 //! vectors to store the geometries locally after binding an element
421 std::vector<SubControlVolume> scvs_;
422 std::vector<SubControlVolumeFace> scvfs_;
423 };
424
425 } // end namespace Dumux
426
427 #endif
428