GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: dumux/dumux/discretization/cellcentered/mpfa/fvgridgeometry.hh
Date: 2025-04-12 19:19:20
Exec Total Coverage
Lines: 247 250 98.8%
Functions: 47 47 100.0%
Branches: 442 661 66.9%

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-FileCopyrightText: 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 CCMpfaDiscretization
10 * \brief The finite volume geometry (scvs and scvfs) for cell-centered mpfa models on a grid view
11 * This builds up the sub control volumes and sub control volume faces
12 * for each element of the grid partition.
13 */
14 #ifndef DUMUX_DISCRETIZATION_CC_MPFA_FV_GRID_GEOMETRY_HH
15 #define DUMUX_DISCRETIZATION_CC_MPFA_FV_GRID_GEOMETRY_HH
16
17 #include <utility>
18
19 #include <dumux/common/parameters.hh>
20 #include <dumux/common/indextraits.hh>
21 #include <dumux/discretization/method.hh>
22 #include <dumux/discretization/extrusion.hh>
23 #include <dumux/discretization/basegridgeometry.hh>
24 #include <dumux/discretization/checkoverlapsize.hh>
25
26 namespace Dumux {
27
28 /*!
29 * \ingroup CCMpfaDiscretization
30 * \brief The finite volume geometry (scvs and scvfs) for cell-centered mpfa models on a grid view
31 * This builds up the sub control volumes and sub control volume faces
32 * \note This class is specialized for versions with and without caching the fv geometries on the grid view
33 *
34 * \tparam GridView the grid view
35 * \tparam GridIvIs the interaction volume index sets
36 * \tparam Traits traits class
37 * \tparam enableCache
38 */
39 template<class GridView, class Traits, bool enableCache>
40 class CCMpfaFVGridGeometry;
41
42 //! check the overlap size for parallel computations
43 template<class GridView>
44
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
48 void checkOverlapSizeCCMpfa(const GridView& gridView)
45 {
46 // Check if the overlap size is what we expect
47
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
48 if (!CheckOverlapSize<DiscretizationMethods::CCMpfa>::isValid(gridView))
48 DUNE_THROW(Dune::InvalidStateException, "The ccmpfa discretization method needs at least an overlap of 1 for parallel computations. "
49 << " Set the parameter \"Grid.Overlap\" in the input file.");
50 30 }
51
52 /*!
53 * \ingroup CCMpfaDiscretization
54 * \brief The finite volume geometry (scvs and scvfs) for cell-centered mpfa models on a grid view
55 * This builds up the sub control volumes and sub control volume faces
56 * \note For caching enabled we store the fv geometries for the whole grid view which is memory intensive but faster
57 */
58 template<class GV, class Traits>
59 class CCMpfaFVGridGeometry<GV, Traits, true>
60 : public BaseGridGeometry<GV, Traits>
61 {
62 using ThisType = CCMpfaFVGridGeometry<GV, Traits, true>;
63 using ParentType = BaseGridGeometry<GV, Traits>;
64
65 static constexpr int dim = GV::dimension;
66 static constexpr int dimWorld = GV::dimensionworld;
67
68 using Element = typename GV::template Codim<0>::Entity;
69 using Vertex = typename GV::template Codim<dim>::Entity;
70 using Intersection = typename GV::Intersection;
71 using GridIndexType = typename IndexTraits<GV>::GridIndex;
72 using CoordScalar = typename GV::ctype;
73
74 using ScvfOutsideGridIndexStorage = typename Traits::SubControlVolumeFace::Traits::OutsideGridIndexStorage;
75
76 public:
77 //! export the flip scvf index set type
78 using FlipScvfIndexSet = std::vector<ScvfOutsideGridIndexStorage>;
79 //! export the grid interaction volume index set type
80 using GridIVIndexSets = typename Traits::template GridIvIndexSets<ThisType>;
81 //! export the type to be used for indicators where to use the secondary ivs
82 using SecondaryIvIndicatorType = std::function<bool(const Element&, const Intersection&, bool)>;
83
84 //! export the type of the fv element geometry (the local view type)
85 using LocalView = typename Traits::template LocalView<ThisType, true>;
86 //! export the type of sub control volume
87 using SubControlVolume = typename Traits::SubControlVolume;
88 //! export the type of sub control volume
89 using SubControlVolumeFace = typename Traits::SubControlVolumeFace;
90 //! export the type of extrusion
91 using Extrusion = Extrusion_t<Traits>;
92 //! export the connectivity map type
93 using ConnectivityMap = typename Traits::template ConnectivityMap<ThisType>;
94 //! export dof mapper type
95 using DofMapper = typename Traits::ElementMapper;
96 //! export the grid view type
97 using GridView = GV;
98 //! export the mpfa helper type
99 using MpfaHelper = typename Traits::template MpfaHelper<ThisType>;
100
101 //! export the discretization method this geometry belongs to
102 using DiscretizationMethod = DiscretizationMethods::CCMpfa;
103 static constexpr DiscretizationMethod discMethod{};
104
105 //! The maximum admissible stencil size (used for static memory allocation during assembly)
106 static constexpr int maxElementStencilSize = Traits::maxElementStencilSize;
107
108 //! State if only a single type is used for interaction volumes
109 static constexpr bool hasSingleInteractionVolumeType = !MpfaHelper::considerSecondaryIVs();
110
111 //! Constructor without indicator function for secondary interaction volumes
112 //! Per default, we use the secondary IVs at branching points & boundaries
113 19 CCMpfaFVGridGeometry(const GridView& gridView)
114 : ParentType(gridView)
115
4/5
✓ Branch 0 taken 53682 times.
✓ Branch 1 taken 36836 times.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✓ Branch 2 taken 3 times.
121837 , secondaryIvIndicator_([] (const Element& e, const Intersection& is, bool isBranching)
116
4/6
✓ Branch 0 taken 1662 times.
✓ Branch 1 taken 62112 times.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
63793 { return is.boundary() || isBranching; } )
117 {
118
1/2
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
19 checkOverlapSizeCCMpfa(gridView);
119
1/2
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
19 update_();
120 19 }
121
122 //! Constructor with user-defined indicator function for secondary interaction volumes
123 CCMpfaFVGridGeometry(const GridView& gridView, const SecondaryIvIndicatorType& indicator)
124 : ParentType(gridView)
125 , secondaryIvIndicator_(indicator)
126 {
127 checkOverlapSizeCCMpfa(gridView);
128 update_();
129 }
130
131 //! the element mapper is the dofMapper
132 //! this is convenience to have better chance to have the same main files for box/tpfa/mpfa...
133 217136 const DofMapper& dofMapper() const
134
2/3
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
217136 { return this->elementMapper(); }
135
136 //! The total number of sub control volumes
137 7517121 std::size_t numScv() const
138
6/11
✓ Branch 1 taken 105 times.
✓ Branch 2 taken 1283454 times.
✓ Branch 4 taken 6215316 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1741 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 13214 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 186 times.
✗ Branch 14 not taken.
✗ Branch 3 not taken.
7517121 { return scvs_.size(); }
139
140 //! The total number of sub control volume faces
141 34 std::size_t numScvf() const
142 34 { return scvfs_.size(); }
143
144 //! The total number of boundary sub control volume faces
145 std::size_t numBoundaryScvf() const
146 { return numBoundaryScvf_; }
147
148 //! The total number of degrees of freedom
149 3141 std::size_t numDofs() const
150
9/13
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 15 taken 2 times.
✓ Branch 16 taken 2 times.
✓ Branch 18 taken 2 times.
✗ Branch 19 not taken.
✓ Branch 11 taken 9 times.
✓ Branch 12 taken 1 times.
✓ Branch 14 taken 9 times.
✓ Branch 13 taken 2 times.
✗ Branch 17 not taken.
3128 { return this->gridView().size(0); }
151
152 //! Returns true if secondary interaction volumes are used around a given vertex (index).
153 //! This specialization is enabled if the use of secondary interaction volumes is active.
154 template<bool useSecondary = !hasSingleInteractionVolumeType, std::enable_if_t<useSecondary, bool> = 0>
155 8114949 bool vertexUsesSecondaryInteractionVolume(GridIndexType vIdxGlobal) const
156
24/28
✓ Branch 0 taken 120080 times.
✓ Branch 1 taken 3532800 times.
✓ Branch 2 taken 312 times.
✓ Branch 3 taken 2760 times.
✓ Branch 4 taken 345 times.
✓ Branch 5 taken 80 times.
✓ Branch 6 taken 345 times.
✓ Branch 7 taken 80 times.
✓ Branch 8 taken 13416 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 10608 times.
✓ Branch 11 taken 93840 times.
✓ Branch 12 taken 10336 times.
✓ Branch 13 taken 30192 times.
✓ Branch 14 taken 105952 times.
✓ Branch 15 taken 1871408 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 935704 times.
✓ Branch 18 taken 52976 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 18072 times.
✓ Branch 21 taken 19048 times.
✓ Branch 22 taken 168376 times.
✓ Branch 23 taken 19048 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 116963 times.
✓ Branch 26 taken 56504 times.
✓ Branch 27 taken 935704 times.
8114949 { return secondaryInteractionVolumeVertices_[vIdxGlobal]; }
157
158 //! Returns true if secondary interaction volumes are used around a given vertex (index).
159 //! If the use of secondary interaction volumes is disabled, this can be evaluated at compile time.
160 template<bool useSecondary = !hasSingleInteractionVolumeType, std::enable_if_t<!useSecondary, bool> = 0>
161 constexpr bool vertexUsesSecondaryInteractionVolume(GridIndexType vIdxGlobal) const
162 { return false; }
163
164
165 //! update all fvElementGeometries (call this after grid adaption)
166 void update(const GridView& gridView)
167 {
168 ParentType::update(gridView);
169 update_();
170 }
171
172 //! update all fvElementGeometries (call this after grid adaption)
173 void update(GridView&& gridView)
174 {
175 ParentType::update(std::move(gridView));
176 update_();
177 }
178
179 //! Returns instance of the mpfa helper type
180 MpfaHelper mpfaHelper() const
181 { return MpfaHelper(); }
182
183 //! Get a sub control volume with a global scv index
184 834799776 const SubControlVolume& scv(GridIndexType scvIdx) const
185
14/21
✓ Branch 1 taken 769 times.
✗ Branch 2 not taken.
✗ Branch 0 not taken.
✓ Branch 14 taken 55760 times.
✗ Branch 15 not taken.
✓ Branch 12 taken 405304 times.
✗ Branch 13 not taken.
✓ Branch 21 taken 15139 times.
✓ Branch 22 taken 795400 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 764 times.
✓ Branch 6 taken 579386 times.
✓ Branch 7 taken 9984 times.
✓ Branch 19 taken 579725 times.
✓ Branch 20 taken 216014 times.
✗ Branch 23 not taken.
✓ Branch 24 taken 579386 times.
✓ Branch 26 taken 1166106 times.
✗ Branch 27 not taken.
✓ Branch 17 taken 60230 times.
✗ Branch 18 not taken.
927051344 { return scvs_[scvIdx]; }
186
187 //! Get a sub control volume face with a global scvf index
188 1519808559 const SubControlVolumeFace& scvf(GridIndexType scvfIdx) const
189
40/42
✓ Branch 1 taken 7472 times.
✓ Branch 2 taken 215600 times.
✓ Branch 8 taken 21502192 times.
✓ Branch 9 taken 3248768 times.
✓ Branch 10 taken 111589232 times.
✓ Branch 11 taken 5909616 times.
✓ Branch 18 taken 5355194 times.
✓ Branch 19 taken 87520 times.
✓ Branch 20 taken 6866844 times.
✓ Branch 21 taken 12988512 times.
✓ Branch 23 taken 989372 times.
✓ Branch 24 taken 5450720 times.
✓ Branch 26 taken 87395770 times.
✓ Branch 27 taken 1321426 times.
✓ Branch 4 taken 768 times.
✓ Branch 5 taken 28832 times.
✓ Branch 6 taken 504 times.
✓ Branch 7 taken 768 times.
✓ Branch 0 taken 8 times.
✓ Branch 3 taken 8 times.
✓ Branch 15 taken 14731376 times.
✓ Branch 16 taken 1597202 times.
✓ Branch 22 taken 6153320 times.
✓ Branch 25 taken 71831674 times.
✓ Branch 28 taken 15610091 times.
✓ Branch 30 taken 6966280 times.
✓ Branch 31 taken 1089852 times.
✓ Branch 29 taken 175904 times.
✓ Branch 32 taken 136472 times.
✓ Branch 13 taken 10608 times.
✓ Branch 14 taken 9359908 times.
✓ Branch 33 taken 4515568 times.
✓ Branch 34 taken 336280 times.
✓ Branch 35 taken 19048 times.
✗ Branch 36 not taken.
✓ Branch 37 taken 1380 times.
✗ Branch 38 not taken.
✓ Branch 39 taken 15776 times.
✓ Branch 41 taken 74520 times.
✓ Branch 42 taken 8424 times.
✓ Branch 17 taken 45476318 times.
✓ Branch 12 taken 13730200 times.
1518738254 { return scvfs_[scvfIdx]; }
190
191 //! Returns the connectivity map of which dofs
192 //! have derivatives with respect to a given dof.
193 2508750 const ConnectivityMap& connectivityMap() const
194 2508750 { return connectivityMap_; }
195
196 //! Returns the grid interaction volume index set class.
197 const GridIVIndexSets& gridInteractionVolumeIndexSets() const
198
9/10
✓ Branch 0 taken 522160836 times.
✓ Branch 1 taken 20483274 times.
✓ Branch 3 taken 34694150 times.
✓ Branch 4 taken 3390674 times.
✓ Branch 5 taken 151187294 times.
✓ Branch 6 taken 6515186 times.
✓ Branch 9 taken 31091712 times.
✓ Branch 10 taken 1899784 times.
✗ Branch 2 not taken.
✓ Branch 7 taken 935704 times.
796556438 { return ivIndexSets_; }
199
200 //! Get the sub control volume face indices of an scv by global index
201 46989688 const std::vector<GridIndexType>& scvfIndicesOfScv(GridIndexType scvIdx) const
202
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 27500 times.
✓ Branch 3 taken 27500 times.
✓ Branch 4 taken 1140160 times.
✓ Branch 5 taken 23418856 times.
✓ Branch 6 taken 17777380 times.
✗ Branch 2 not taken.
✓ Branch 7 taken 1738497 times.
90485195 { return scvfIndicesOfScv_[scvIdx]; }
203
204 //! Returns the flip scvf index set
205 29311 const FlipScvfIndexSet& flipScvfIndexSet() const
206
1/2
✓ Branch 1 taken 7741 times.
✗ Branch 2 not taken.
11079994 { return flipScvfIndices_; }
207
208 //! Get the scvf on the same face but from the other side
209 //! Note that e.g. the normals might be different in the case of surface grids
210 89652458 const SubControlVolumeFace& flipScvf(GridIndexType scvfIdx, unsigned int outsideScvfIdx = 0) const
211 89652458 { return scvfs_[flipScvfIndices_[scvfIdx][outsideScvfIdx]]; }
212
213 //! Returns whether one of the geometry's scvfs lies on a boundary
214 1303191 bool hasBoundaryScvf(GridIndexType eIdx) const
215
2/2
✓ Branch 0 taken 1012119 times.
✓ Branch 1 taken 291072 times.
1303191 { return hasBoundaryScvf_[eIdx]; }
216
217 private:
218
219 19 void update_()
220 {
221 // stop the time required for the update
222 19 Dune::Timer timer;
223
224 // clear scvfs container
225
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
19 scvfs_.clear();
226
227 // determine the number of geometric entities
228 19 const auto numVert = this->gridView().size(dim);
229 19 const auto numScvs = numDofs();
230 19 std::size_t numScvf = MpfaHelper::getGlobalNumScvf(this->gridView());
231
232 // resize containers
233 19 scvs_.resize(numScvs);
234 19 scvfs_.reserve(numScvf);
235 19 scvfIndicesOfScv_.resize(numScvs);
236 19 hasBoundaryScvf_.assign(numScvs, false);
237
238 // Some methods require to use a second type of interaction volume, e.g.
239 // around vertices on the boundary or branching points (surface grids)
240 19 secondaryInteractionVolumeVertices_.assign(numVert, false);
241
242 // find vertices on processor boundaries
243 19 const auto isGhostVertex = MpfaHelper::findGhostVertices(this->gridView(), this->vertexMapper());
244
245 // instantiate the dual grid index set (to be used for construction of interaction volumes)
246
1/2
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
19 typename GridIVIndexSets::DualGridIndexSet dualIdSet(this->gridView());
247
248 // Build the SCVs and SCV faces
249 19 GridIndexType scvfIdx = 0;
250 19 numBoundaryScvf_ = 0;
251
11/14
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 6981 times.
✓ Branch 5 taken 5 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 14511 times.
✓ Branch 9 taken 501 times.
✗ Branch 10 not taken.
✓ Branch 13 taken 7825 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 7825 times.
✓ Branch 16 taken 3 times.
✓ Branch 6 taken 17397 times.
✓ Branch 3 taken 491 times.
68293 for (const auto& element : elements(this->gridView()))
252 {
253
3/5
✓ Branch 1 taken 22336 times.
✓ Branch 2 taken 9863 times.
✓ Branch 4 taken 22336 times.
✗ Branch 5 not taken.
✗ Branch 3 not taken.
32199 const auto eIdx = this->elementMapper().index(element);
254
255 // the element geometry
256 32199 auto elementGeometry = element.geometry();
257
258 // The local scvf index set
259
1/2
✓ Branch 1 taken 25221 times.
✗ Branch 2 not taken.
32199 std::vector<GridIndexType> scvfIndexSet;
260
2/6
✓ Branch 1 taken 32199 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 32199 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
32199 scvfIndexSet.reserve(MpfaHelper::getNumLocalScvfs(elementGeometry.type()));
261
262 // for network grids there might be multiple intersection with the same geometryInInside
263 // we identify those by the indexInInside for now (assumes conforming grids at branching facets)
264
1/2
✓ Branch 1 taken 6978 times.
✗ Branch 2 not taken.
32199 std::vector<ScvfOutsideGridIndexStorage> outsideIndices;
265 if (dim < dimWorld)
266 {
267
1/2
✓ Branch 1 taken 6978 times.
✗ Branch 2 not taken.
6978 outsideIndices.resize(element.subEntities(1));
268
5/8
✓ Branch 1 taken 6978 times.
✗ Branch 2 not taken.
✓ Branch 6 taken 21500 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 28478 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 20866 times.
✓ Branch 11 taken 634 times.
84800 for (const auto& intersection : intersections(this->gridView(), element))
269 {
270
2/2
✓ Branch 0 taken 20866 times.
✓ Branch 1 taken 634 times.
21500 if (intersection.neighbor())
271 {
272
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 20866 times.
20866 const auto nIdx = this->elementMapper().index( intersection.outside() );
273
1/2
✓ Branch 1 taken 20866 times.
✗ Branch 2 not taken.
20866 outsideIndices[intersection.indexInInside()].push_back(nIdx);
274 }
275 }
276 }
277
278 // construct the sub control volume faces
279
11/14
✓ Branch 1 taken 32199 times.
✓ Branch 2 taken 11540 times.
✓ Branch 6 taken 52800 times.
✓ Branch 7 taken 14511 times.
✓ Branch 10 taken 89344 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 111680 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 26780 times.
✓ Branch 15 taken 52764 times.
✓ Branch 4 taken 25909 times.
✓ Branch 5 taken 142 times.
✓ Branch 8 taken 28478 times.
✗ Branch 9 not taken.
449410 for (const auto& is : intersections(this->gridView(), element))
280 {
281
2/2
✓ Branch 0 taken 17312 times.
✓ Branch 1 taken 73772 times.
122384 const auto indexInInside = is.indexInInside();
282
2/2
✓ Branch 0 taken 13514 times.
✓ Branch 1 taken 77570 times.
122384 const bool boundary = is.boundary();
283 122384 const bool neighbor = is.neighbor();
284
285
2/2
✓ Branch 0 taken 3144 times.
✓ Branch 1 taken 119240 times.
122384 if (boundary)
286 3144 hasBoundaryScvf_[eIdx] = true;
287
288 // for surface grids, skip the rest if handled already
289
4/4
✓ Branch 0 taken 20866 times.
✓ Branch 1 taken 634 times.
✓ Branch 2 taken 20300 times.
✓ Branch 3 taken 566 times.
21500 if (dim < dimWorld && neighbor && outsideIndices[indexInInside].empty())
290 566 continue;
291
292 // if outside level > inside level, use the outside element in the following
293
6/12
✓ Branch 0 taken 118674 times.
✓ Branch 1 taken 3144 times.
✓ Branch 3 taken 98374 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 30556 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 30556 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 2 taken 20300 times.
✗ Branch 5 not taken.
239492 const bool useNeighbor = neighbor && is.outside().level() > element.level();
294
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31300 times.
153118 const auto& e = useNeighbor ? is.outside() : element;
295
3/5
✗ Branch 0 not taken.
✓ Branch 1 taken 121818 times.
✓ Branch 3 taken 100884 times.
✓ Branch 4 taken 20934 times.
✗ Branch 5 not taken.
121818 const auto indexInElement = useNeighbor ? is.indexInOutside() : indexInInside;
296
1/2
✓ Branch 1 taken 121818 times.
✗ Branch 2 not taken.
121818 const auto eg = e.geometry();
297
1/2
✓ Branch 1 taken 110278 times.
✗ Branch 2 not taken.
121818 const auto refElement = referenceElement(eg);
298
299 // Set up a container with all relevant positions for scvf corner computation
300
1/2
✓ Branch 1 taken 56080 times.
✗ Branch 2 not taken.
121818 const auto numCorners = is.geometry().corners();
301
1/2
✓ Branch 1 taken 60008 times.
✗ Branch 2 not taken.
121818 const auto isPositions = MpfaHelper::computeScvfCornersOnIntersection(eg,
302 refElement,
303 indexInElement,
304 numCorners);
305
306 // evaluate if vertices on this intersection use primary/secondary IVs
307
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20934 times.
121818 const bool isBranchingPoint = dim < dimWorld ? outsideIndices[indexInInside].size() > 1 : false;
308
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 121818 times.
121818 const bool usesSecondaryIV = secondaryIvIndicator_(element, is, isBranchingPoint);
309
310 // make the scv faces belonging to each corner of the intersection
311
2/2
✓ Branch 0 taken 247564 times.
✓ Branch 1 taken 121818 times.
369382 for (int c = 0; c < numCorners; ++c)
312 {
313 // get the global vertex index the scv face is connected to
314 247564 const auto vIdxLocal = refElement.subEntity(indexInElement, 1, c, dim);
315
1/2
✓ Branch 1 taken 247564 times.
✗ Branch 2 not taken.
247564 const auto vIdxGlobal = this->vertexMapper().subIndex(e, vIdxLocal, dim);
316
317 // do not build scvfs connected to a processor boundary
318
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247564 times.
247564 if (isGhostVertex[vIdxGlobal])
319 continue;
320
321 // if this vertex is tagged to use the secondary IVs, store info
322
2/2
✓ Branch 0 taken 7364 times.
✓ Branch 1 taken 240200 times.
247564 if (usesSecondaryIV)
323 7364 secondaryInteractionVolumeVertices_[vIdxGlobal] = true;
324
325 // the quadrature point parameterizarion to be used on scvfs
326
4/6
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 247545 times.
✓ Branch 3 taken 19 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 19 times.
✗ Branch 7 not taken.
247564 static const auto q = getParam<CoordScalar>("MPFA.Q");
327
328 // make the scv face (for non-boundary scvfs on network grids, use precalculated outside indices)
329
1/2
✓ Branch 1 taken 41868 times.
✗ Branch 2 not taken.
658956 const auto& outsideScvIndices = [&] ()
330 {
331
2/2
✓ Branch 0 taken 240796 times.
✓ Branch 1 taken 6768 times.
247564 if (!boundary)
332 return dim == dimWorld ?
333
3/5
✓ Branch 1 taken 10344 times.
✓ Branch 2 taken 57664 times.
✓ Branch 4 taken 10344 times.
✗ Branch 5 not taken.
✗ Branch 3 not taken.
200196 ScvfOutsideGridIndexStorage({this->elementMapper().index(is.outside())}) :
334 240796 outsideIndices[indexInInside];
335 else
336 6768 return ScvfOutsideGridIndexStorage({GridIndexType(numScvs) + numBoundaryScvf_++});
337
1/2
✓ Branch 1 taken 182616 times.
✗ Branch 2 not taken.
205696 } ();
338
339
1/2
✓ Branch 1 taken 247564 times.
✗ Branch 2 not taken.
247564 scvfIndexSet.push_back(scvfIdx);
340 495128 typename SubControlVolumeFace::FacetInfo facetInfo{
341
1/2
✓ Branch 1 taken 182616 times.
✗ Branch 2 not taken.
247564 this->elementMapper().index(e),
342
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247564 times.
247564 useNeighbor ? is.indexInOutside() : is.indexInInside(),
343 c
344 };
345
1/2
✓ Branch 1 taken 53652 times.
✗ Branch 2 not taken.
441476 scvfs_.emplace_back(MpfaHelper(),
346
3/5
✓ Branch 0 taken 40876 times.
✓ Branch 1 taken 164820 times.
✓ Branch 3 taken 193912 times.
✗ Branch 4 not taken.
✗ Branch 2 not taken.
441476 MpfaHelper::getScvfCorners(isPositions, numCorners, c),
347 is,
348 std::move(facetInfo),
349 vIdxGlobal,
350 vIdxLocal,
351 scvfIdx,
352 eIdx,
353 outsideScvIndices,
354 q,
355 boundary);
356
357 // insert the scvf data into the dual grid index set
358
1/2
✓ Branch 1 taken 247564 times.
✗ Branch 2 not taken.
247564 dualIdSet[vIdxGlobal].insert(scvfs_.back());
359
360 // increment scvf counter
361 247564 scvfIdx++;
362 }
363
364 // for network grids, clear outside indices to not make a second scvf on that facet
365 if (dim < dimWorld)
366
2/2
✓ Branch 0 taken 20300 times.
✓ Branch 1 taken 634 times.
41234 outsideIndices[indexInInside].clear();
367 }
368
369 // create sub control volume for this element
370
3/7
✓ Branch 1 taken 28823 times.
✓ Branch 2 taken 3376 times.
✓ Branch 4 taken 21845 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 3 not taken.
32690 scvs_[eIdx] = SubControlVolume(std::move(elementGeometry), eIdx);
371
372 // Save the scvf indices belonging to this scv to build up fv element geometries fast
373
1/2
✓ Branch 1 taken 32199 times.
✗ Branch 2 not taken.
32199 scvfIndicesOfScv_[eIdx] = scvfIndexSet;
374 }
375
376 // Make the flip index set for network and surface grids
377
1/2
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
19 flipScvfIndices_.resize(scvfs_.size());
378
4/4
✓ Branch 0 taken 6768 times.
✓ Branch 1 taken 240796 times.
✓ Branch 2 taken 247564 times.
✓ Branch 3 taken 19 times.
247583 for (const auto& scvf : scvfs_)
379 {
380
2/2
✓ Branch 0 taken 6768 times.
✓ Branch 1 taken 240796 times.
247564 if (scvf.boundary())
381 6768 continue;
382
383
1/2
✓ Branch 1 taken 40600 times.
✗ Branch 2 not taken.
240796 const auto numOutsideScvs = scvf.numOutsideScvs();
384
1/2
✓ Branch 1 taken 40600 times.
✗ Branch 2 not taken.
240796 const auto vIdxGlobal = scvf.vertexIndex();
385 240796 const auto insideScvIdx = scvf.insideScvIdx();
386
387
1/2
✓ Branch 1 taken 40600 times.
✗ Branch 2 not taken.
240796 flipScvfIndices_[scvf.index()].resize(numOutsideScvs);
388
2/2
✓ Branch 0 taken 241928 times.
✓ Branch 1 taken 240796 times.
482724 for (std::size_t i = 0; i < numOutsideScvs; ++i)
389 {
390 241928 const auto outsideScvIdx = scvf.outsideScvIdx(i);
391
3/4
✓ Branch 0 taken 368501 times.
✓ Branch 1 taken 701804 times.
✓ Branch 2 taken 1070305 times.
✗ Branch 3 not taken.
1070305 for (auto outsideScvfIndex : scvfIndicesOfScv_[outsideScvIdx])
392 {
393
2/2
✓ Branch 0 taken 368501 times.
✓ Branch 1 taken 701804 times.
1070305 const auto& outsideScvf = this->scvf(outsideScvfIndex);
394
4/4
✓ Branch 0 taken 368501 times.
✓ Branch 1 taken 701804 times.
✓ Branch 2 taken 126573 times.
✓ Branch 3 taken 241928 times.
1070305 if (outsideScvf.vertexIndex() == vIdxGlobal &&
395
2/2
✓ Branch 0 taken 126573 times.
✓ Branch 1 taken 241928 times.
368501 MpfaHelper::vectorContainsValue(outsideScvf.outsideScvIndices(), insideScvIdx))
396 {
397 241928 flipScvfIndices_[scvf.index()][i] = outsideScvfIndex;
398 // there is always only one flip face in an outside element
399 241928 break;
400 }
401 }
402 }
403 }
404
405 // building the geometries has finished
406
3/6
✓ Branch 2 taken 19 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 19 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 19 times.
✗ Branch 9 not taken.
19 std::cout << "Initializing of the grid finite volume geometry took " << timer.elapsed() << " seconds." << std::endl;
407
408 // Initialize the grid interaction volume index sets
409 19 timer.reset();
410
1/2
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
19 ivIndexSets_.update(*this, std::move(dualIdSet));
411
3/6
✓ Branch 2 taken 19 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 19 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 19 times.
✗ Branch 9 not taken.
19 std::cout << "Initializing of the grid interaction volume index sets took " << timer.elapsed() << " seconds." << std::endl;
412
413 // build the connectivity map for an efficient assembly
414 19 timer.reset();
415
1/2
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
19 connectivityMap_.update(*this);
416
3/6
✓ Branch 2 taken 19 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 19 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 19 times.
✗ Branch 9 not taken.
19 std::cout << "Initializing of the connectivity map took " << timer.elapsed() << " seconds." << std::endl;
417 19 }
418
419 // connectivity map for efficient assembly
420 ConnectivityMap connectivityMap_;
421
422 // the finite volume grid geometries
423 std::vector<SubControlVolume> scvs_;
424 std::vector<SubControlVolumeFace> scvfs_;
425
426 // containers storing the global data
427 std::vector<std::vector<GridIndexType>> scvfIndicesOfScv_;
428 std::vector<bool> secondaryInteractionVolumeVertices_;
429 GridIndexType numBoundaryScvf_;
430 std::vector<bool> hasBoundaryScvf_;
431
432 // needed for embedded surface and network grids (dim < dimWorld)
433 FlipScvfIndexSet flipScvfIndices_;
434
435 // The grid interaction volume index set
436 GridIVIndexSets ivIndexSets_;
437
438 // Indicator function on where to use the secondary IVs
439 SecondaryIvIndicatorType secondaryIvIndicator_;
440 };
441
442 /*!
443 * \ingroup CCMpfaDiscretization
444 * \brief The finite volume geometry (scvs and scvfs) for cell-centered mpfa models on a grid view
445 * This builds up the sub control volumes and sub control volume faces
446 * \note For caching disabled we store only some essential index maps to build up local systems on-demand in
447 * the corresponding FVElementGeometry
448 */
449 template<class GV, class Traits>
450 class CCMpfaFVGridGeometry<GV, Traits, false>
451 : public BaseGridGeometry<GV, Traits>
452 {
453 using ThisType = CCMpfaFVGridGeometry<GV, Traits, false>;
454 using ParentType = BaseGridGeometry<GV, Traits>;
455
456 static constexpr int dim = GV::dimension;
457 static constexpr int dimWorld = GV::dimensionworld;
458
459 using Element = typename GV::template Codim<0>::Entity;
460 using Vertex = typename GV::template Codim<dim>::Entity;
461 using Intersection = typename GV::Intersection;
462 using GridIndexType = typename IndexTraits<GV>::GridIndex;
463 using CoordScalar = typename GV::ctype;
464
465 using ScvfOutsideGridIndexStorage = typename Traits::SubControlVolumeFace::Traits::OutsideGridIndexStorage;
466
467 public:
468 //! export the flip scvf index set type
469 using FlipScvfIndexSet = std::vector<ScvfOutsideGridIndexStorage>;
470 //! export the grid interaction volume index set type
471 using GridIVIndexSets = typename Traits::template GridIvIndexSets<ThisType>;
472 //! export the type to be used for indicators where to use the secondary ivs
473 using SecondaryIvIndicatorType = std::function<bool(const Element&, const Intersection&, bool)>;
474
475 //! export the type of the fv element geometry (the local view type)
476 using LocalView = typename Traits::template LocalView<ThisType, false>;
477 //! export the type of sub control volume
478 using SubControlVolume = typename Traits::SubControlVolume;
479 //! export the type of sub control volume
480 using SubControlVolumeFace = typename Traits::SubControlVolumeFace;
481 //! export the type of extrusion
482 using Extrusion = Extrusion_t<Traits>;
483 //! export the connectivity map type
484 using ConnectivityMap = typename Traits::template ConnectivityMap<ThisType>;
485 //! export dof mapper type
486 using DofMapper = typename Traits::ElementMapper;
487 //! export the grid view type
488 using GridView = GV;
489 //! export the mpfa helper type
490 using MpfaHelper = typename Traits::template MpfaHelper<ThisType>;
491
492 //! export the discretization method this geometry belongs to
493 using DiscretizationMethod = DiscretizationMethods::CCMpfa;
494 static constexpr DiscretizationMethod discMethod{};
495
496 //! The maximum admissible stencil size (used for static memory allocation during assembly)
497 static constexpr int maxElementStencilSize = Traits::maxElementStencilSize;
498
499 //! State if only a single type is used for interaction volumes
500 static constexpr bool hasSingleInteractionVolumeType = !MpfaHelper::considerSecondaryIVs();
501
502 //! Constructor without indicator function for secondary interaction volumes
503 //! Per default, we use the secondary IVs at branching points & boundaries
504 29 CCMpfaFVGridGeometry(const GridView& gridView)
505 : ParentType(gridView)
506
4/5
✓ Branch 0 taken 1074 times.
✓ Branch 1 taken 12930 times.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✓ Branch 2 taken 13 times.
191619 , secondaryIvIndicator_([] (const Element& e, const Intersection& is, bool isBranching)
507
4/5
✓ Branch 0 taken 4002 times.
✓ Branch 1 taken 185732 times.
✓ Branch 4 taken 24 times.
✗ Branch 5 not taken.
✓ Branch 2 taken 5 times.
189763 { return is.boundary() || isBranching; } )
508 {
509
1/2
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
29 checkOverlapSizeCCMpfa(gridView);
510
1/2
✓ Branch 1 taken 29 times.
✗ Branch 2 not taken.
29 update_();
511 29 }
512
513 //! Constructor with user-defined indicator function for secondary interaction volumes
514 CCMpfaFVGridGeometry(const GridView& gridView, const SecondaryIvIndicatorType& indicator)
515 : ParentType(gridView)
516 , secondaryIvIndicator_(indicator)
517 {
518 checkOverlapSizeCCMpfa(gridView);
519 update_();
520 }
521
522 //! the element mapper is the dofMapper
523 //! this is convenience to have better chance to have the same main files for box/tpfa/mpfa...
524 13 const DofMapper& dofMapper() const
525
1/4
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13 { return this->elementMapper(); }
526
527 //! Returns the total number of sub control volumes.
528 std::size_t numScv() const
529 { return numScvs_; }
530
531 //! Returns the total number of sub control volume faces.
532 58 std::size_t numScvf() const
533
1/2
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
58 { return numScvf_; }
534
535 //! Returns the number of scvfs on the domain boundary.
536 std::size_t numBoundaryScvf() const
537 { return numBoundaryScvf_; }
538
539 //! Returns the total number of degrees of freedom.
540 234 std::size_t numDofs() const
541
19/29
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
✓ Branch 8 taken 15 times.
✓ Branch 9 taken 4 times.
✓ Branch 12 taken 5 times.
✓ Branch 13 taken 1 times.
✓ Branch 18 taken 15 times.
✗ Branch 19 not taken.
✓ Branch 29 taken 1 times.
✗ Branch 30 not taken.
✓ Branch 32 taken 1 times.
✗ Branch 33 not taken.
✓ Branch 35 taken 1 times.
✗ Branch 36 not taken.
✓ Branch 38 taken 1 times.
✗ Branch 39 not taken.
✓ Branch 15 taken 14 times.
✓ Branch 16 taken 1 times.
✓ Branch 11 taken 7 times.
✓ Branch 14 taken 7 times.
✗ Branch 10 not taken.
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 17 taken 3 times.
✓ Branch 20 taken 3 times.
✗ Branch 21 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
205 { return this->gridView().size(0); }
542
543 //! Returns true if secondary interaction volumes are used around a given vertex (index).
544 //! This specialization is enabled if the use of secondary interaction volumes is active.
545 template<bool useSecondary = !hasSingleInteractionVolumeType, std::enable_if_t<useSecondary, bool> = 0>
546 3268386 bool vertexUsesSecondaryInteractionVolume(GridIndexType vIdxGlobal) const
547
16/18
✓ Branch 0 taken 105952 times.
✓ Branch 1 taken 1898880 times.
✓ Branch 2 taken 312 times.
✓ Branch 3 taken 2760 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 949440 times.
✓ Branch 6 taken 52976 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 345 times.
✓ Branch 9 taken 80 times.
✓ Branch 10 taken 345 times.
✓ Branch 11 taken 80 times.
✓ Branch 12 taken 10064 times.
✓ Branch 13 taken 10608 times.
✓ Branch 14 taken 93840 times.
✓ Branch 15 taken 10608 times.
✓ Branch 16 taken 13416 times.
✓ Branch 17 taken 118680 times.
3268386 { return secondaryInteractionVolumeVertices_[vIdxGlobal]; }
548
549 //! Returns true if secondary interaction volumes are used around a given vertex (index).
550 //! If the use of secondary interaction volumes is disabled, this can be evaluated at compile time.
551 template<bool useSecondary = !hasSingleInteractionVolumeType, std::enable_if_t<!useSecondary, bool> = 0>
552 constexpr bool vertexUsesSecondaryInteractionVolume(GridIndexType vIdxGlobal) const
553 { return false; }
554
555 //! Returns true if a given vertex lies on a processor boundary inside a ghost element.
556 bool isGhostVertex(const Vertex& v) const
557 { return isGhostVertex_[this->vertexMapper().index(v)]; }
558
559 //! Returns true if the vertex (index) lies on a processor boundary inside a ghost element.
560 112919098 bool isGhostVertex(GridIndexType vIdxGlobal) const
561
4/4
✓ Branch 0 taken 8832 times.
✓ Branch 1 taken 11888216 times.
✓ Branch 2 taken 22496 times.
✓ Branch 3 taken 100999554 times.
112919098 { return isGhostVertex_[vIdxGlobal]; }
562
563
564 //! update all fvElementGeometries (call this after grid adaption)
565 void update(const GridView& gridView)
566 {
567 ParentType::update(gridView);
568 update_();
569 }
570
571 //! update all fvElementGeometries (call this after grid adaption)
572 2 void update(GridView&& gridView)
573 {
574 2 ParentType::update(std::move(gridView));
575 2 update_();
576 }
577
578 //! Returns instance of the mpfa helper type
579 MpfaHelper mpfaHelper() const
580 { return MpfaHelper(); }
581
582 //! Returns the sub control volume face indices of an scv by global index.
583 17444279 const std::vector<GridIndexType>& scvfIndicesOfScv(GridIndexType scvIdx) const
584
4/4
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 1749084 times.
✓ Branch 2 taken 30 times.
✓ Branch 3 taken 15695136 times.
17444279 { return scvfIndicesOfScv_[scvIdx]; }
585
586 //! Returns the neighboring vol var indices for each scvf contained in an scv.
587 17444279 const std::vector<ScvfOutsideGridIndexStorage>& neighborVolVarIndices(GridIndexType scvIdx) const
588
4/4
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 1749084 times.
✓ Branch 2 taken 30 times.
✓ Branch 3 taken 15695136 times.
17444279 { return neighborVolVarIndices_[scvIdx]; }
589
590 //! Get the index scvf on the same face but from the other side
591 //! Note that e.g. the normals might be different in the case of surface grids
592 31879480 const GridIndexType flipScvfIdx(GridIndexType scvfIdx, unsigned int outsideScvfIdx = 0) const
593 31879480 { return flipScvfIndices_[scvfIdx][outsideScvfIdx]; }
594
595 //! Returns the flip scvf index set
596 49713 const FlipScvfIndexSet& flipScvfIndexSet() const
597
4/6
✓ Branch 2 taken 26970 times.
✓ Branch 3 taken 17938 times.
✓ Branch 6 taken 8996 times.
✗ Branch 7 not taken.
✗ Branch 4 not taken.
✓ Branch 1 taken 18380 times.
47249517 { return flipScvfIndices_; }
598
599 //! Returns the connectivity map of which dofs
600 //! have derivatives with respect to a given dof.
601 438769 const ConnectivityMap& connectivityMap() const
602 438875 { return connectivityMap_; }
603
604 //! Returns the grid interaction volume seeds class.
605 const GridIVIndexSets& gridInteractionVolumeIndexSets() const
606
2/3
✓ Branch 2 taken 1080 times.
✓ Branch 3 taken 400 times.
✗ Branch 4 not taken.
7094737 { return ivIndexSets_; }
607
608 private:
609
610 31 void update_()
611 {
612
613 // stop the time required for the update
614 31 Dune::Timer timer;
615
616 // resize containers
617 31 numScvs_ = numDofs();
618 31 scvfIndicesOfScv_.resize(numScvs_);
619 31 neighborVolVarIndices_.resize(numScvs_);
620
621 // Some methods require to use a second type of interaction volume, e.g.
622 // around vertices on the boundary or branching points (surface grids)
623 31 const auto numVert = this->gridView().size(dim);
624 31 secondaryInteractionVolumeVertices_.assign(numVert, false);
625
626 // find vertices on processor boundaries HERE!!
627 31 isGhostVertex_ = MpfaHelper::findGhostVertices(this->gridView(), this->vertexMapper());
628
629 // instantiate the dual grid index set (to be used for construction of interaction volumes)
630 31 typename GridIVIndexSets::DualGridIndexSet dualIdSet(this->gridView());
631
632 // keep track of boundary scvfs and scvf vertex indices in order to set up flip scvf index set
633 31 const auto maxNumScvfs = numScvs_*LocalView::maxNumElementScvfs;
634 31 std::vector<bool> scvfIsOnBoundary;
635 31 std::vector<GridIndexType> scvfVertexIndex;
636
1/2
✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
31 scvfIsOnBoundary.reserve(maxNumScvfs);
637
1/2
✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
31 scvfVertexIndex.reserve(maxNumScvfs);
638
639 // Build the SCVs and SCV faces
640 31 numScvf_ = 0;
641 31 numBoundaryScvf_ = 0;
642
9/13
✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 3527 times.
✗ Branch 8 not taken.
✓ Branch 14 taken 45030 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 45030 times.
✓ Branch 17 taken 15 times.
✓ Branch 3 taken 1 times.
✓ Branch 9 taken 464 times.
✓ Branch 10 taken 5 times.
100176 for (const auto& element : elements(this->gridView()))
643 {
644
3/5
✓ Branch 1 taken 45494 times.
✓ Branch 2 taken 3037 times.
✓ Branch 4 taken 45494 times.
✗ Branch 5 not taken.
✗ Branch 3 not taken.
48531 const auto eIdx = this->elementMapper().index(element);
645
646 // the element geometry
647
1/2
✓ Branch 1 taken 48531 times.
✗ Branch 2 not taken.
48531 auto elementGeometry = element.geometry();
648
649 // the element-wise index sets for finite volume geometry
650
1/2
✓ Branch 1 taken 48531 times.
✗ Branch 2 not taken.
48531 const auto numLocalFaces = MpfaHelper::getNumLocalScvfs(elementGeometry.type());
651 48531 std::vector<GridIndexType> scvfsIndexSet;
652 48531 std::vector<ScvfOutsideGridIndexStorage> neighborVolVarIndexSet;
653
1/2
✓ Branch 1 taken 48531 times.
✗ Branch 2 not taken.
48531 scvfsIndexSet.reserve(numLocalFaces);
654
1/2
✓ Branch 1 taken 48531 times.
✗ Branch 2 not taken.
48531 neighborVolVarIndexSet.reserve(numLocalFaces);
655
656 // for network grids there might be multiple intersections with the same geometryInInside
657 // we identify those by the indexInInside for now (assumes conforming grids at branching facets)
658
1/2
✓ Branch 1 taken 8610 times.
✗ Branch 2 not taken.
48531 std::vector<ScvfOutsideGridIndexStorage> outsideIndices;
659 if (dim < dimWorld)
660 {
661
1/2
✓ Branch 1 taken 8610 times.
✗ Branch 2 not taken.
8610 outsideIndices.resize(element.subEntities(1));
662
3/8
✓ Branch 1 taken 8610 times.
✗ Branch 2 not taken.
✓ Branch 7 taken 34440 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 43050 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
129150 for (const auto& intersection : intersections(this->gridView(), element))
663 {
664
2/2
✓ Branch 0 taken 33676 times.
✓ Branch 1 taken 764 times.
34440 if (intersection.neighbor())
665 {
666
3/6
✓ Branch 1 taken 33676 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 33676 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 33676 times.
✗ Branch 9 not taken.
33676 auto nIdx = this->elementMapper().index( intersection.outside() );
667
1/2
✓ Branch 1 taken 33676 times.
✗ Branch 2 not taken.
33676 outsideIndices[intersection.indexInInside()].push_back(nIdx);
668 }
669 }
670 }
671
672 // construct the sub control volume faces
673
10/13
✓ Branch 1 taken 48531 times.
✓ Branch 2 taken 12148 times.
✓ Branch 6 taken 177586 times.
✓ Branch 7 taken 464 times.
✓ Branch 10 taken 179442 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 224936 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1712 times.
✓ Branch 15 taken 144 times.
✓ Branch 4 taken 12131 times.
✓ Branch 5 taken 481 times.
✗ Branch 8 not taken.
690457 for (const auto& is : intersections(this->gridView(), element))
674 {
675
2/2
✓ Branch 0 taken 13379 times.
✓ Branch 1 taken 625 times.
191590 const auto indexInInside = is.indexInInside();
676
2/2
✓ Branch 0 taken 12721 times.
✓ Branch 1 taken 1283 times.
191590 const bool boundary = is.boundary();
677
1/2
✓ Branch 0 taken 11186 times.
✗ Branch 1 not taken.
190628 const bool neighbor = is.neighbor();
678
679 // for surface grids, skip the rest if handled already
680
3/4
✓ Branch 0 taken 33676 times.
✓ Branch 1 taken 764 times.
✓ Branch 2 taken 33676 times.
✗ Branch 3 not taken.
34440 if (dim < dimWorld && neighbor && outsideIndices[indexInInside].empty())
681 continue;
682
683 // if outside level > inside level, use the outside element in the following
684
6/12
✓ Branch 0 taken 186754 times.
✓ Branch 1 taken 3874 times.
✓ Branch 3 taken 175568 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 174514 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 676 times.
✓ Branch 9 taken 173838 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 2 not taken.
✗ Branch 5 not taken.
541672 const bool useNeighbor = neighbor && is.outside().level() > element.level();
685
2/2
✓ Branch 0 taken 676 times.
✓ Branch 1 taken 176910 times.
368500 const auto& e = useNeighbor ? is.outside() : element;
686
3/4
✓ Branch 0 taken 676 times.
✓ Branch 1 taken 190914 times.
✓ Branch 3 taken 191590 times.
✗ Branch 4 not taken.
192266 const auto indexInElement = useNeighbor ? is.indexInOutside() : indexInInside;
687
1/2
✓ Branch 1 taken 191590 times.
✗ Branch 2 not taken.
191590 const auto eg = e.geometry();
688 191590 const auto refElement = referenceElement(eg);
689
690 // evaluate if vertices on this intersection use primary/secondary IVs
691
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34440 times.
191590 const bool isBranchingPoint = dim < dimWorld ? outsideIndices[indexInInside].size() > 1 : false;
692
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 191590 times.
191590 const bool usesSecondaryIV = secondaryIvIndicator_(element, is, isBranchingPoint);
693
694 // make the scv faces belonging to each corner of the intersection
695
6/7
✓ Branch 1 taken 459302 times.
✓ Branch 2 taken 115468 times.
✓ Branch 4 taken 291092 times.
✓ Branch 5 taken 212538 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 37896 times.
✓ Branch 7 taken 1600 times.
648450 for (std::size_t c = 0; c < is.geometry().corners(); ++c)
696 {
697 // get the global vertex index the scv face is connected to
698 383180 const auto vIdxLocal = refElement.subEntity(indexInElement, 1, c, dim);
699
1/2
✓ Branch 1 taken 383180 times.
✗ Branch 2 not taken.
383180 const auto vIdxGlobal = this->vertexMapper().subIndex(e, vIdxLocal, dim);
700
701 // do not build scvfs connected to a processor boundary
702
2/2
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 383052 times.
383180 if (isGhostVertex_[vIdxGlobal])
703 128 continue;
704
705 // if this vertex is tagged to use the secondary IVs, store info
706
2/2
✓ Branch 0 taken 9604 times.
✓ Branch 1 taken 373448 times.
383052 if (usesSecondaryIV)
707 9604 secondaryInteractionVolumeVertices_[vIdxGlobal] = true;
708
709 // make the scv face (for non-boundary scvfs on network grids, use precalculated outside indices)
710
1/2
✓ Branch 1 taken 68880 times.
✗ Branch 2 not taken.
1011396 const auto& outsideScvIndices = [&] ()
711 {
712
2/2
✓ Branch 0 taken 373448 times.
✓ Branch 1 taken 9604 times.
383052 if (!boundary)
713 return dim == dimWorld ?
714
3/5
✓ Branch 1 taken 448 times.
✓ Branch 2 taken 281676 times.
✓ Branch 4 taken 448 times.
✗ Branch 5 not taken.
✗ Branch 3 not taken.
306096 ScvfOutsideGridIndexStorage({this->elementMapper().index(is.outside())}) :
715 373448 outsideIndices[indexInInside];
716 else
717 9604 return ScvfOutsideGridIndexStorage({GridIndexType(numScvs_) + numBoundaryScvf_++});
718
1/2
✓ Branch 1 taken 290004 times.
✗ Branch 2 not taken.
314172 } ();
719
720 // insert the scvf data into the dual grid index set
721
1/2
✓ Branch 1 taken 383052 times.
✗ Branch 2 not taken.
383052 dualIdSet[vIdxGlobal].insert(numScvf_, eIdx, boundary);
722
723 // store information on the scv face
724
1/2
✓ Branch 1 taken 383052 times.
✗ Branch 2 not taken.
383052 scvfsIndexSet.push_back(numScvf_++);
725
1/2
✓ Branch 1 taken 383052 times.
✗ Branch 2 not taken.
383052 scvfIsOnBoundary.push_back(boundary);
726
1/2
✓ Branch 1 taken 383052 times.
✗ Branch 2 not taken.
383052 scvfVertexIndex.push_back(vIdxGlobal);
727
1/2
✓ Branch 1 taken 383052 times.
✗ Branch 2 not taken.
383052 neighborVolVarIndexSet.emplace_back(std::move(outsideScvIndices));
728 }
729
730 // for network grids, clear outside indices to not make a second scvf on that facet
731 if (dim < dimWorld)
732
2/2
✓ Branch 0 taken 33676 times.
✓ Branch 1 taken 764 times.
68116 outsideIndices[indexInInside].clear();
733 }
734
735 // store the sets of indices in the data container
736
1/2
✓ Branch 1 taken 48531 times.
✗ Branch 2 not taken.
48531 scvfIndicesOfScv_[eIdx] = scvfsIndexSet;
737
1/2
✓ Branch 1 taken 48531 times.
✗ Branch 2 not taken.
48531 neighborVolVarIndices_[eIdx] = neighborVolVarIndexSet;
738 }
739
740 // Make the flip scvf index set
741
1/2
✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
31 flipScvfIndices_.resize(numScvf_);
742
2/2
✓ Branch 0 taken 48531 times.
✓ Branch 1 taken 31 times.
48562 for (std::size_t scvIdx = 0; scvIdx < numScvs_; ++scvIdx)
743 {
744 48531 const auto& scvfIndices = scvfIndicesOfScv_[scvIdx];
745
2/2
✓ Branch 0 taken 383052 times.
✓ Branch 1 taken 48531 times.
431583 for (unsigned int i = 0; i < scvfIndices.size(); ++i)
746 {
747 // boundary scvf have no flip scvfs
748
2/2
✓ Branch 0 taken 9604 times.
✓ Branch 1 taken 373448 times.
383052 if (scvfIsOnBoundary[ scvfIndices[i] ])
749 9604 continue;
750
751 373448 const auto scvfIdx = scvfIndices[i];
752
1/2
✓ Branch 1 taken 67352 times.
✗ Branch 2 not taken.
373448 const auto vIdxGlobal = scvfVertexIndex[scvfIdx];
753
1/2
✓ Branch 1 taken 67352 times.
✗ Branch 2 not taken.
373448 const auto numOutsideScvs = neighborVolVarIndices_[scvIdx][i].size();
754
755
1/2
✓ Branch 1 taken 67352 times.
✗ Branch 2 not taken.
373448 flipScvfIndices_[scvfIdx].resize(numOutsideScvs);
756
2/2
✓ Branch 0 taken 373448 times.
✓ Branch 1 taken 373448 times.
746896 for (unsigned int j = 0; j < numOutsideScvs; ++j)
757 {
758 373448 const auto outsideScvIdx = neighborVolVarIndices_[scvIdx][i][j];
759 373448 const auto& outsideScvfIndices = scvfIndicesOfScv_[outsideScvIdx];
760
1/2
✓ Branch 0 taken 1663752 times.
✗ Branch 1 not taken.
1663752 for (unsigned int k = 0; k < outsideScvfIndices.size(); ++k)
761 {
762
2/2
✓ Branch 0 taken 559395 times.
✓ Branch 1 taken 1104357 times.
1663752 const auto outsideScvfIndex = outsideScvfIndices[k];
763
2/2
✓ Branch 0 taken 559395 times.
✓ Branch 1 taken 1104357 times.
1663752 const auto outsideScvfVertexIndex = scvfVertexIndex[outsideScvfIndex];
764 1663752 const auto& outsideScvfNeighborIndices = neighborVolVarIndices_[outsideScvIdx][k];
765
2/2
✓ Branch 0 taken 559395 times.
✓ Branch 1 taken 1104357 times.
1663752 if (outsideScvfVertexIndex == vIdxGlobal &&
766
2/2
✓ Branch 0 taken 185947 times.
✓ Branch 1 taken 373448 times.
559395 MpfaHelper::vectorContainsValue(outsideScvfNeighborIndices, scvIdx))
767 {
768 373448 flipScvfIndices_[scvfIdx][j] = outsideScvfIndex;
769 // there is always only one flip face in an outside element
770 373448 break;
771 }
772 }
773 }
774 }
775 }
776
777 // building the geometries has finished
778
3/6
✓ Branch 2 taken 31 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 31 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 31 times.
✗ Branch 9 not taken.
31 std::cout << "Initializing of the grid finite volume geometry took " << timer.elapsed() << " seconds." << std::endl;
779
780 // Initialize the grid interaction volume index sets
781 31 timer.reset();
782
1/2
✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
31 ivIndexSets_.update(*this, std::move(dualIdSet));
783
3/6
✓ Branch 2 taken 31 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 31 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 31 times.
✗ Branch 9 not taken.
31 std::cout << "Initializing of the grid interaction volume index sets took " << timer.elapsed() << " seconds." << std::endl;
784
785 // build the connectivity map for an efficient assembly
786 31 timer.reset();
787
1/2
✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
31 connectivityMap_.update(*this);
788
3/6
✓ Branch 2 taken 31 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 31 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 31 times.
✗ Branch 9 not taken.
31 std::cout << "Initializing of the connectivity map took " << timer.elapsed() << " seconds." << std::endl;
789 31 }
790
791 // connectivity map for efficient assembly
792 ConnectivityMap connectivityMap_;
793
794 // containers storing the global data
795 std::vector<std::vector<GridIndexType>> scvfIndicesOfScv_;
796 std::vector<std::vector<ScvfOutsideGridIndexStorage>> neighborVolVarIndices_;
797 std::vector<bool> secondaryInteractionVolumeVertices_;
798 std::vector<bool> isGhostVertex_;
799 GridIndexType numScvs_;
800 GridIndexType numScvf_;
801 GridIndexType numBoundaryScvf_;
802
803 // needed for embedded surface and network grids (dim < dimWorld)
804 FlipScvfIndexSet flipScvfIndices_;
805
806 // The grid interaction volume index set
807 GridIVIndexSets ivIndexSets_;
808
809 // Indicator function on where to use the secondary IVs
810 SecondaryIvIndicatorType secondaryIvIndicator_;
811 };
812
813 } // end namespace Dumux
814
815 #endif
816