GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/discretization/cellcentered/tpfa/fvgridgeometry.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 142 151 94.0%
Functions: 135 165 81.8%
Branches: 623 942 66.1%

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 CCTpfaDiscretization
10 * \brief The finite volume geometry (scvs and scvfs) for cell-centered TPFA 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_CCTPFA_FV_GRID_GEOMETRY_HH
15 #define DUMUX_DISCRETIZATION_CCTPFA_FV_GRID_GEOMETRY_HH
16
17 #include <utility>
18 #include <algorithm>
19
20 #include <dumux/common/indextraits.hh>
21 #include <dumux/common/defaultmappertraits.hh>
22
23 #include <dumux/discretization/method.hh>
24 #include <dumux/discretization/basegridgeometry.hh>
25 #include <dumux/discretization/checkoverlapsize.hh>
26 #include <dumux/discretization/cellcentered/subcontrolvolume.hh>
27 #include <dumux/discretization/cellcentered/connectivitymap.hh>
28 #include <dumux/discretization/cellcentered/tpfa/fvelementgeometry.hh>
29 #include <dumux/discretization/cellcentered/tpfa/subcontrolvolumeface.hh>
30 #include <dumux/discretization/extrusion.hh>
31
32 namespace Dumux {
33
34 /*!
35 * \ingroup CCTpfaDiscretization
36 * \brief The default traits for the tpfa finite volume grid geometry
37 * Defines the scv and scvf types and the mapper types
38 * \tparam the grid view type
39 */
40 template<class GridView, class MapperTraits = DefaultMapperTraits<GridView>>
41 struct CCTpfaDefaultGridGeometryTraits
42 : public MapperTraits
43 {
44 using SubControlVolume = CCSubControlVolume<GridView>;
45 using SubControlVolumeFace = CCTpfaSubControlVolumeFace<GridView>;
46
47 template<class GridGeometry>
48 using ConnectivityMap = CCSimpleConnectivityMap<GridGeometry>;
49
50 template<class GridGeometry, bool enableCache>
51 using LocalView = CCTpfaFVElementGeometry<GridGeometry, enableCache>;
52
53 //! State the maximum admissible number of neighbors per scvf
54 //! Per default, we allow for 8 branches on network/surface grids, where
55 //! conformity is assumed. For normal grids, we allow a maximum of one
56 //! hanging node per scvf. Use different traits if you need more.
57 static constexpr int maxNumScvfNeighbors = int(GridView::dimension)<int(GridView::dimensionworld) ? 8 : 1<<(GridView::dimension-1);
58 };
59
60 /*!
61 * \ingroup CCTpfaDiscretization
62 * \brief The finite volume geometry (scvs and scvfs) for cell-centered TPFA models on a grid view
63 * This builds up the sub control volumes and sub control volume faces
64 * \note This class is specialized for versions with and without caching the fv geometries on the grid view
65 */
66 template<class GridView,
67 bool enableGridGeometryCache = false,
68 class Traits = CCTpfaDefaultGridGeometryTraits<GridView> >
69 class CCTpfaFVGridGeometry;
70
71 /*!
72 * \ingroup CCTpfaDiscretization
73 * \brief The finite volume geometry (scvs and scvfs) for cell-centered TPFA models on a grid view
74 * This builds up the sub control volumes and sub control volume faces
75 * \note For caching enabled we store the fv geometries for the whole grid view which is memory intensive but faster
76 */
77 template<class GV, class Traits>
78 class CCTpfaFVGridGeometry<GV, true, Traits>
79 : public BaseGridGeometry<GV, Traits>
80 {
81 using ThisType = CCTpfaFVGridGeometry<GV, true, Traits>;
82 using ParentType = BaseGridGeometry<GV, Traits>;
83 using ConnectivityMap = typename Traits::template ConnectivityMap<ThisType>;
84 using GridIndexType = typename IndexTraits<GV>::GridIndex;
85 using Element = typename GV::template Codim<0>::Entity;
86
87 static const int dim = GV::dimension;
88 static const int dimWorld = GV::dimensionworld;
89
90 public:
91 //! export basic grid geometry type for the alternative constructor
92 using BasicGridGeometry = BasicGridGeometry_t<GV, Traits>;
93 //! export the type of the fv element geometry (the local view type)
94 using LocalView = typename Traits::template LocalView<ThisType, true>;
95 //! export the type of sub control volume
96 using SubControlVolume = typename Traits::SubControlVolume;
97 //! export the type of sub control volume
98 using SubControlVolumeFace = typename Traits::SubControlVolumeFace;
99 //! export the type of extrusion
100 using Extrusion = Extrusion_t<Traits>;
101 //! export dof mapper type
102 using DofMapper = typename Traits::ElementMapper;
103
104 //! export the discretization method this geometry belongs to
105 using DiscretizationMethod = DiscretizationMethods::CCTpfa;
106 static constexpr DiscretizationMethod discMethod{};
107
108 //! The maximum admissible stencil size (used for static memory allocation during assembly)
109 static constexpr int maxElementStencilSize = LocalView::maxNumElementScvfs*Traits::maxNumScvfNeighbors + 1;
110
111 //! export the grid view type
112 using GridView = GV;
113
114 //! Constructor with basic grid geometry used to share state with another grid geometry on the same grid view
115 240 CCTpfaFVGridGeometry(std::shared_ptr<BasicGridGeometry> gg)
116
9/26
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 62 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 62 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 62 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 62 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 62 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 62 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 62 times.
✗ Branch 18 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
2160 : ParentType(std::move(gg))
117 {
118 // Check if the overlap size is what we expect
119
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 171 times.
480 if (!CheckOverlapSize<DiscretizationMethod>::isValid(this->gridView()))
120 DUNE_THROW(Dune::InvalidStateException, "The cctpfa discretization method needs at least an overlap of 1 for parallel computations. "
121 << " Set the parameter \"Grid.Overlap\" in the input file.");
122
123
1/2
✓ Branch 1 taken 171 times.
✗ Branch 2 not taken.
240 update_();
124 240 }
125
126 //! Constructor from gridView
127 237 CCTpfaFVGridGeometry(const GridView& gridView)
128
2/6
✓ Branch 2 taken 168 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 168 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
237 : CCTpfaFVGridGeometry(std::make_shared<BasicGridGeometry>(gridView))
129 237 {}
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 const DofMapper& dofMapper() const
134
6/10
✓ Branch 1 taken 28 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 28 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
75330 { return this->elementMapper(); }
135
136 //! The total number of sub control volumes
137 std::size_t numScv() const
138 {
139
25/33
✗ Branch 0 not taken.
✓ Branch 1 taken 180488 times.
✓ Branch 2 taken 1233890 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9258851 times.
✓ Branch 5 taken 4140413 times.
✓ Branch 6 taken 3470 times.
✓ Branch 7 taken 9697543 times.
✓ Branch 8 taken 2926319 times.
✓ Branch 9 taken 3470 times.
✓ Branch 10 taken 5266650 times.
✓ Branch 11 taken 19443991 times.
✓ Branch 12 taken 173500 times.
✓ Branch 13 taken 735759 times.
✓ Branch 14 taken 19446391 times.
✓ Branch 15 taken 173500 times.
✓ Branch 16 taken 317728 times.
✓ Branch 17 taken 9217 times.
✓ Branch 18 taken 800000 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 5000 times.
✓ Branch 21 taken 1737786 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 1735 times.
✓ Branch 25 taken 15642 times.
✓ Branch 26 taken 9 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 1735 times.
✗ Branch 29 not taken.
✓ Branch 32 taken 8000 times.
✗ Branch 33 not taken.
✓ Branch 37 taken 101 times.
✗ Branch 38 not taken.
81059882 return scvs_.size();
140 }
141
142 //! The total number of sub control volume faces
143 std::size_t numScvf() const
144 {
145
2/5
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
2640 return scvfs_.size();
146 }
147
148 //! The total number of boundary sub control volume faces
149 std::size_t numBoundaryScvf() const
150 {
151 return numBoundaryScvf_;
152 }
153
154 //! The total number of degrees of freedom
155 std::size_t numDofs() const
156
65/80
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 29 times.
✓ Branch 5 taken 12 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 51 times.
✓ Branch 8 taken 12 times.
✓ Branch 9 taken 5 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 15 times.
✓ Branch 12 taken 2 times.
✓ Branch 13 taken 5 times.
✓ Branch 14 taken 14 times.
✓ Branch 15 taken 14 times.
✓ Branch 16 taken 807473 times.
✓ Branch 17 taken 11 times.
✓ Branch 18 taken 5841 times.
✓ Branch 19 taken 807479 times.
✓ Branch 20 taken 5 times.
✓ Branch 21 taken 4 times.
✓ Branch 22 taken 807478 times.
✓ Branch 23 taken 429 times.
✓ Branch 24 taken 540802 times.
✓ Branch 25 taken 403 times.
✓ Branch 26 taken 22 times.
✓ Branch 27 taken 541208 times.
✓ Branch 28 taken 3 times.
✓ Branch 29 taken 17 times.
✓ Branch 30 taken 542433 times.
✓ Branch 31 taken 14 times.
✓ Branch 32 taken 25 times.
✓ Branch 33 taken 1632 times.
✓ Branch 34 taken 6 times.
✓ Branch 35 taken 8 times.
✓ Branch 36 taken 1636 times.
✓ Branch 37 taken 23 times.
✓ Branch 38 taken 17 times.
✓ Branch 39 taken 4 times.
✓ Branch 40 taken 10 times.
✓ Branch 41 taken 15 times.
✗ Branch 42 not taken.
✓ Branch 43 taken 20 times.
✓ Branch 44 taken 18 times.
✓ Branch 45 taken 16 times.
✓ Branch 46 taken 19 times.
✓ Branch 47 taken 6 times.
✗ Branch 48 not taken.
✓ Branch 49 taken 19 times.
✓ Branch 50 taken 9 times.
✗ Branch 51 not taken.
✓ Branch 52 taken 17 times.
✓ Branch 53 taken 25 times.
✓ Branch 54 taken 2 times.
✓ Branch 55 taken 15 times.
✓ Branch 56 taken 7 times.
✓ Branch 57 taken 2 times.
✓ Branch 58 taken 28 times.
✗ Branch 59 not taken.
✓ Branch 60 taken 2 times.
✓ Branch 61 taken 12 times.
✗ Branch 62 not taken.
✓ Branch 63 taken 3 times.
✓ Branch 64 taken 12 times.
✓ Branch 65 taken 3 times.
✓ Branch 66 taken 3 times.
✓ Branch 67 taken 12 times.
✗ Branch 68 not taken.
✓ Branch 69 taken 3 times.
✓ Branch 70 taken 1 times.
✗ Branch 71 not taken.
✓ Branch 74 taken 3 times.
✗ Branch 75 not taken.
✓ Branch 77 taken 16 times.
✗ Branch 78 not taken.
✓ Branch 80 taken 16 times.
✗ Branch 81 not taken.
✓ Branch 83 taken 16 times.
✗ Branch 84 not taken.
✓ Branch 88 taken 16 times.
✗ Branch 89 not taken.
2721824 { return this->gridView().size(0); }
157
158
159 //! update all fvElementGeometries (call this after grid adaption)
160 void update(const GridView& gridView)
161 {
162
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 ParentType::update(gridView);
163
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 update_();
164 }
165
166 //! update all fvElementGeometries (call this after grid adaption)
167 void update(GridView&& gridView)
168 {
169 ParentType::update(std::move(gridView));
170 update_();
171 }
172
173 //! Get a sub control volume with a global scv index
174 const SubControlVolume& scv(GridIndexType scvIdx) const
175 {
176
74/80
✗ Branch 0 not taken.
✓ Branch 1 taken 256 times.
✓ Branch 2 taken 2508832 times.
✓ Branch 3 taken 220420588 times.
✓ Branch 4 taken 2519136 times.
✓ Branch 5 taken 239111276 times.
✓ Branch 6 taken 10304 times.
✓ Branch 7 taken 18690944 times.
✓ Branch 8 taken 198498 times.
✓ Branch 9 taken 104673224 times.
✓ Branch 10 taken 198498 times.
✓ Branch 11 taken 363906409 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 314590625 times.
✓ Branch 14 taken 78880 times.
✓ Branch 15 taken 192235630 times.
✓ Branch 16 taken 78884 times.
✓ Branch 17 taken 137075834 times.
✓ Branch 18 taken 4 times.
✓ Branch 19 taken 15788972 times.
✓ Branch 20 taken 49687064 times.
✓ Branch 21 taken 142058296 times.
✓ Branch 22 taken 49695064 times.
✓ Branch 23 taken 126419936 times.
✓ Branch 24 taken 1162760 times.
✓ Branch 25 taken 1900608 times.
✓ Branch 26 taken 787440 times.
✓ Branch 27 taken 1603168 times.
✓ Branch 28 taken 5440 times.
✓ Branch 29 taken 1205428 times.
✓ Branch 30 taken 28288 times.
✓ Branch 31 taken 20506 times.
✓ Branch 32 taken 1205498 times.
✓ Branch 33 taken 37114 times.
✓ Branch 34 taken 20970 times.
✓ Branch 35 taken 1440814 times.
✓ Branch 36 taken 3111574 times.
✓ Branch 37 taken 1676108 times.
✓ Branch 38 taken 5217596 times.
✓ Branch 39 taken 1768742 times.
✓ Branch 40 taken 3998034 times.
✓ Branch 41 taken 5238228 times.
✓ Branch 42 taken 2800798 times.
✓ Branch 43 taken 6189492 times.
✓ Branch 44 taken 719258 times.
✓ Branch 45 taken 10005244 times.
✓ Branch 46 taken 2043014 times.
✓ Branch 47 taken 9665334 times.
✓ Branch 48 taken 125248 times.
✓ Branch 49 taken 160 times.
✓ Branch 50 taken 2049 times.
✓ Branch 51 taken 444243 times.
✓ Branch 52 taken 2049 times.
✓ Branch 53 taken 438651 times.
✓ Branch 54 taken 13632 times.
✓ Branch 55 taken 17652 times.
✗ Branch 56 not taken.
✓ Branch 57 taken 21448 times.
✗ Branch 58 not taken.
✓ Branch 59 taken 17146 times.
✓ Branch 60 taken 634 times.
✓ Branch 61 taken 21410 times.
✓ Branch 62 taken 38 times.
✓ Branch 63 taken 11498 times.
✓ Branch 64 taken 12166 times.
✓ Branch 65 taken 5324 times.
✓ Branch 66 taken 8000 times.
✓ Branch 67 taken 539766 times.
✓ Branch 68 taken 5324 times.
✓ Branch 69 taken 285 times.
✓ Branch 70 taken 539766 times.
✓ Branch 71 taken 8000 times.
✓ Branch 72 taken 285 times.
✓ Branch 73 taken 3463680 times.
✓ Branch 74 taken 8000 times.
✓ Branch 75 taken 901500 times.
✓ Branch 76 taken 3463680 times.
✗ Branch 77 not taken.
✓ Branch 78 taken 901500 times.
✗ Branch 79 not taken.
6043858598 return scvs_[scvIdx];
177 }
178
179 //! Get a sub control volume face with a global scvf index
180 const SubControlVolumeFace& scvf(GridIndexType scvfIdx) const
181 {
182
52/58
✓ Branch 2 taken 13634 times.
✓ Branch 3 taken 649454 times.
✓ Branch 4 taken 2561052 times.
✓ Branch 5 taken 1523044 times.
✓ Branch 6 taken 2672786 times.
✓ Branch 7 taken 875210 times.
✓ Branch 8 taken 291888 times.
✓ Branch 9 taken 86258 times.
✓ Branch 10 taken 1305518 times.
✓ Branch 11 taken 488702 times.
✓ Branch 12 taken 1784826 times.
✓ Branch 13 taken 594032 times.
✓ Branch 14 taken 1547619 times.
✓ Branch 15 taken 531338 times.
✓ Branch 16 taken 980101 times.
✓ Branch 17 taken 409372 times.
✓ Branch 18 taken 2310780 times.
✓ Branch 19 taken 1407510 times.
✓ Branch 20 taken 29079873 times.
✓ Branch 21 taken 12403083 times.
✓ Branch 22 taken 36312875 times.
✓ Branch 23 taken 20369527 times.
✓ Branch 24 taken 9474436 times.
✓ Branch 25 taken 10294422 times.
✓ Branch 26 taken 24342 times.
✓ Branch 27 taken 5652500 times.
✓ Branch 28 taken 5522389 times.
✓ Branch 29 taken 36415 times.
✓ Branch 30 taken 10165579 times.
✓ Branch 31 taken 40809 times.
✓ Branch 32 taken 105086 times.
✓ Branch 33 taken 22526 times.
✓ Branch 34 taken 104918 times.
✓ Branch 35 taken 12726 times.
✓ Branch 36 taken 1071408 times.
✓ Branch 37 taken 242432 times.
✓ Branch 38 taken 1071408 times.
✓ Branch 39 taken 242400 times.
✓ Branch 40 taken 536 times.
✓ Branch 41 taken 504 times.
✓ Branch 42 taken 536 times.
✓ Branch 43 taken 504 times.
✓ Branch 44 taken 3470 times.
✗ Branch 45 not taken.
✓ Branch 46 taken 3470 times.
✗ Branch 47 not taken.
✓ Branch 48 taken 3470 times.
✗ Branch 49 not taken.
✓ Branch 50 taken 3470 times.
✗ Branch 51 not taken.
✓ Branch 52 taken 48000 times.
✗ Branch 53 not taken.
✓ Branch 54 taken 48000 times.
✗ Branch 55 not taken.
✓ Branch 56 taken 3344 times.
✓ Branch 57 taken 126 times.
✓ Branch 58 taken 3344 times.
✓ Branch 59 taken 126 times.
1705819500 return scvfs_[scvfIdx];
183 }
184
185 //! Get the scvf on the same face but from the other side
186 //! Note that e.g. the normals might be different in the case of surface grids
187 const SubControlVolumeFace& flipScvf(GridIndexType scvfIdx, unsigned int outsideScvfIdx = 0) const
188 {
189 165289756 return scvfs_[flipScvfIndices_[scvfIdx][outsideScvfIdx]];
190 }
191
192 //! Get the sub control volume face indices of an scv by global index
193 const std::vector<GridIndexType>& scvfIndicesOfScv(GridIndexType scvIdx) const
194 {
195
3/12
✗ Branch 0 not taken.
✓ Branch 1 taken 165000 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 165000 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 165000 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
379799381 return scvfIndicesOfScv_[scvIdx];
196 }
197
198 /*!
199 * \brief Returns the connectivity map of which dofs have derivatives with respect
200 * to a given dof.
201 */
202 const ConnectivityMap &connectivityMap() const
203 39574457 { return connectivityMap_; }
204
205 //! Returns whether one of the geometry's scvfs lies on a boundary
206 bool hasBoundaryScvf(GridIndexType eIdx) const
207
24/24
✓ Branch 0 taken 2672452 times.
✓ Branch 1 taken 30745519 times.
✓ Branch 2 taken 2672452 times.
✓ Branch 3 taken 30745519 times.
✓ Branch 4 taken 5723173 times.
✓ Branch 5 taken 15612070 times.
✓ Branch 6 taken 5723173 times.
✓ Branch 7 taken 15612070 times.
✓ Branch 8 taken 2308 times.
✓ Branch 9 taken 13214 times.
✓ Branch 10 taken 2308 times.
✓ Branch 11 taken 13214 times.
✓ Branch 12 taken 28 times.
✓ Branch 13 taken 36 times.
✓ Branch 14 taken 28 times.
✓ Branch 15 taken 36 times.
✓ Branch 16 taken 592 times.
✓ Branch 17 taken 432 times.
✓ Branch 18 taken 592 times.
✓ Branch 19 taken 432 times.
✓ Branch 20 taken 1804 times.
✓ Branch 21 taken 6778 times.
✓ Branch 22 taken 1804 times.
✓ Branch 23 taken 6778 times.
109556812 { return hasBoundaryScvf_[eIdx]; }
208
209 private:
210
211 242 void update_()
212 {
213 // clear containers (necessary after grid refinement)
214
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 171 times.
242 scvs_.clear();
215
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 128 times.
242 scvfs_.clear();
216 242 scvfIndicesOfScv_.clear();
217 242 flipScvfIndices_.clear();
218
219 // determine size of containers
220 242 std::size_t numScvs = numDofs();
221 242 std::size_t numScvf = 0;
222
10/12
✓ Branch 2 taken 1595263 times.
✓ Branch 3 taken 70 times.
✓ Branch 4 taken 100439 times.
✓ Branch 5 taken 61 times.
✓ Branch 6 taken 11 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 19184 times.
✓ Branch 9 taken 11 times.
✓ Branch 10 taken 19184 times.
✓ Branch 11 taken 11 times.
✓ Branch 13 taken 19184 times.
✗ Branch 14 not taken.
2698158 for (const auto& element : elements(this->gridView()))
223
2/4
✓ Branch 1 taken 19184 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 19184 times.
✗ Branch 5 not taken.
5045277 numScvf += element.subEntities(1);
224
225 // reserve memory
226 242 scvs_.resize(numScvs);
227 242 scvfs_.reserve(numScvf);
228 242 scvfIndicesOfScv_.resize(numScvs);
229 242 hasBoundaryScvf_.assign(numScvs, false);
230
231 // Build the scvs and scv faces
232 242 GridIndexType scvfIdx = 0;
233 242 numBoundaryScvf_ = 0;
234
10/12
✓ Branch 2 taken 1595263 times.
✓ Branch 3 taken 70 times.
✓ Branch 4 taken 100439 times.
✓ Branch 5 taken 61 times.
✓ Branch 6 taken 11 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 19184 times.
✓ Branch 9 taken 11 times.
✓ Branch 10 taken 19184 times.
✓ Branch 11 taken 11 times.
✓ Branch 13 taken 19184 times.
✗ Branch 14 not taken.
5161792 for (const auto& element : elements(this->gridView()))
235 {
236
2/4
✓ Branch 1 taken 19184 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 19184 times.
✗ Branch 5 not taken.
5161302 const auto eIdx = this->elementMapper().index(element);
237
5/6
✓ Branch 1 taken 19184 times.
✓ Branch 2 taken 970140 times.
✓ Branch 3 taken 624912 times.
✓ Branch 4 taken 9352 times.
✓ Branch 5 taken 32 times.
✗ Branch 6 not taken.
5712748 scvs_[eIdx] = SubControlVolume(element.geometry(), eIdx);
238
239 // the element-wise index sets for finite volume geometry
240
2/6
✓ Branch 1 taken 1614236 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 19184 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
5161302 std::vector<GridIndexType> scvfsIndexSet;
241
3/5
✓ Branch 1 taken 1614236 times.
✓ Branch 2 taken 109 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1614236 times.
✗ Branch 5 not taken.
5045277 scvfsIndexSet.reserve(element.subEntities(1));
242
243 // for network grids there might be multiple intersection with the same geometryInInside
244 // we identify those by the indexInInside for now (assumes conforming grids at branching facets)
245 using ScvfGridIndexStorage = typename SubControlVolumeFace::Traits::GridIndexStorage;
246
4/6
✓ Branch 1 taken 1614345 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1596905 times.
✓ Branch 4 taken 17440 times.
✓ Branch 5 taken 103066 times.
✗ Branch 6 not taken.
7715853 std::vector<ScvfGridIndexStorage> outsideIndices;
247 if (dim < dimWorld)
248 {
249 //! first, push inside index in all neighbor sets
250
2/4
✓ Branch 1 taken 17440 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 17440 times.
✗ Branch 5 not taken.
52200 outsideIndices.resize(element.subEntities(1));
251
1/2
✓ Branch 1 taken 42646 times.
✗ Branch 2 not taken.
139054 std::for_each(outsideIndices.begin(), outsideIndices.end(), [eIdx] (auto& nIndices) { nIndices.push_back(eIdx); });
252
253 // second, insert neighbors
254
6/10
✓ Branch 1 taken 17440 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 17440 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 62282 times.
✗ Branch 9 not taken.
✓ Branch 13 taken 43352 times.
✓ Branch 14 taken 1490 times.
✓ Branch 16 taken 44842 times.
✗ Branch 17 not taken.
256932 for (const auto& intersection : intersections(this->gridView(), element))
255 {
256
4/4
✓ Branch 0 taken 43352 times.
✓ Branch 1 taken 1490 times.
✓ Branch 2 taken 43352 times.
✓ Branch 3 taken 1490 times.
128712 if (intersection.neighbor())
257 {
258
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3674 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3674 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3674 times.
186228 const auto nIdx = this->elementMapper().index( intersection.outside() );
259
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 43352 times.
✓ Branch 3 taken 43352 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 43352 times.
✗ Branch 7 not taken.
62076 outsideIndices[intersection.indexInInside()].push_back(nIdx);
260 }
261 }
262 }
263
264
17/21
✓ Branch 1 taken 120506 times.
✓ Branch 2 taken 1493839 times.
✓ Branch 3 taken 7878772 times.
✓ Branch 4 taken 121005 times.
✓ Branch 5 taken 110 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 84318 times.
✓ Branch 8 taken 157572 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 83882 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 382846 times.
✓ Branch 13 taken 44344 times.
✓ Branch 14 taken 83428 times.
✓ Branch 15 taken 992 times.
✓ Branch 16 taken 50674 times.
✓ Branch 17 taken 284900 times.
✓ Branch 18 taken 9224 times.
✓ Branch 19 taken 5832 times.
✓ Branch 20 taken 294124 times.
✗ Branch 21 not taken.
19904409 for (const auto& intersection : intersections(this->gridView(), element))
265 {
266 // inner sub control volume faces (includes periodic boundaries)
267
4/4
✓ Branch 0 taken 8138869 times.
✓ Branch 1 taken 157541 times.
✓ Branch 2 taken 331518 times.
✓ Branch 3 taken 10714 times.
14433626 if (intersection.neighbor())
268 {
269 // update the grid geometry if we have periodic boundaries
270
4/4
✓ Branch 0 taken 7765205 times.
✓ Branch 1 taken 298987 times.
✓ Branch 2 taken 73244 times.
✓ Branch 3 taken 43352 times.
13818242 if (intersection.boundary())
271 32 this->setPeriodic();
272
273 if (dim == dimWorld)
274 {
275
3/6
✓ Branch 1 taken 362434 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 362434 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 362434 times.
✗ Branch 8 not taken.
40658190 const auto nIdx = this->elementMapper().index(intersection.outside());
276
4/9
✓ Branch 1 taken 357760 times.
✓ Branch 2 taken 7736324 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 357760 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 284900 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
13694090 scvfs_.emplace_back(intersection,
277 intersection.geometry(),
278 scvfIdx,
279 ScvfGridIndexStorage({eIdx, nIdx}),
280 13694090 false);
281
1/2
✓ Branch 1 taken 8094084 times.
✗ Branch 2 not taken.
13694090 scvfsIndexSet.push_back(scvfIdx++);
282 }
283 // this is for network grids
284 // (will be optimized away of dim == dimWorld)
285 else
286 {
287
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43352 times.
62076 auto indexInInside = intersection.indexInInside();
288 // check if we already handled this facet
289
6/6
✓ Branch 0 taken 41156 times.
✓ Branch 1 taken 2196 times.
✓ Branch 2 taken 41156 times.
✓ Branch 3 taken 2196 times.
✓ Branch 4 taken 41156 times.
✓ Branch 5 taken 2196 times.
186228 if (outsideIndices[indexInInside].empty())
290 continue;
291 else
292 {
293
1/2
✓ Branch 1 taken 41156 times.
✗ Branch 2 not taken.
58474 scvfs_.emplace_back(intersection,
294 intersection.geometry(),
295 scvfIdx,
296 58474 outsideIndices[indexInInside],
297
1/2
✓ Branch 1 taken 41156 times.
✗ Branch 2 not taken.
58474 false);
298
1/2
✓ Branch 1 taken 41156 times.
✗ Branch 2 not taken.
58474 scvfsIndexSet.push_back(scvfIdx++);
299
2/4
✓ Branch 0 taken 41156 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 41156 times.
✗ Branch 3 not taken.
116948 outsideIndices[indexInInside].clear();
300 }
301 }
302 }
303 // boundary sub control volume faces
304
3/4
✓ Branch 0 taken 157798 times.
✓ Branch 1 taken 3284 times.
✓ Branch 2 taken 1490 times.
✗ Branch 3 not taken.
292836 else if (intersection.boundary())
305 {
306
5/12
✓ Branch 1 taken 13940 times.
✓ Branch 2 taken 147982 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13940 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 10694 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1490 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
292390 scvfs_.emplace_back(intersection,
307 intersection.geometry(),
308 scvfIdx,
309
2/4
✓ Branch 1 taken 150050 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1490 times.
✗ Branch 4 not taken.
292410 ScvfGridIndexStorage({eIdx, static_cast<GridIndexType>(this->gridView().size(0) + numBoundaryScvf_++)}),
310
1/2
✓ Branch 1 taken 150050 times.
✗ Branch 2 not taken.
290110 true);
311
1/4
✓ Branch 1 taken 161922 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
290110 scvfsIndexSet.push_back(scvfIdx++);
312
313 870330 hasBoundaryScvf_[eIdx] = true;
314 }
315 }
316
317 // Save the scvf indices belonging to this scv to build up fv element geometries fast
318
2/4
✓ Branch 1 taken 1614345 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1614345 times.
✗ Branch 5 not taken.
5161302 scvfIndicesOfScv_[eIdx] = scvfsIndexSet;
319 }
320
321 // Make the flip index set for network, surface, and periodic grids
322
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 127 times.
162 if (dim < dimWorld || this->isPeriodic())
323 {
324 164 flipScvfIndices_.resize(scvfs_.size());
325
4/4
✓ Branch 0 taken 43082 times.
✓ Branch 1 taken 45 times.
✓ Branch 2 taken 43082 times.
✓ Branch 3 taken 45 times.
61436 for (auto&& scvf : scvfs_)
326 {
327
2/2
✓ Branch 0 taken 41572 times.
✓ Branch 1 taken 1510 times.
61190 if (scvf.boundary())
328 continue;
329
330 176670 flipScvfIndices_[scvf.index()].resize(scvf.numOutsideScvs());
331 58890 const auto insideScvIdx = scvf.insideScvIdx();
332 // check which outside scvf has the insideScvIdx index in its outsideScvIndices
333
4/4
✓ Branch 0 taken 43768 times.
✓ Branch 1 taken 41572 times.
✓ Branch 2 taken 43768 times.
✓ Branch 3 taken 41572 times.
183874 for (unsigned int i = 0; i < scvf.numOutsideScvs(); ++i)
334 124984 flipScvfIndices_[scvf.index()][i] = findFlippedScvfIndex_(insideScvIdx, scvf.outsideScvIdx(i));
335 }
336 }
337
338 // build the connectivity map for an efficient assembly
339 242 connectivityMap_.update(*this);
340 242 }
341
342 // find the scvf that has insideScvIdx in its outsideScvIdx list and outsideScvIdx as its insideScvIdx
343 43768 GridIndexType findFlippedScvfIndex_(GridIndexType insideScvIdx, GridIndexType outsideScvIdx)
344 {
345 // go over all potential scvfs of the outside scv
346
2/4
✓ Branch 0 taken 48553 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48553 times.
✗ Branch 3 not taken.
208923 for (auto outsideScvfIndex : scvfIndicesOfScv_[outsideScvIdx])
347 {
348 77619 const auto& outsideScvf = this->scvf(outsideScvfIndex);
349
4/4
✓ Branch 0 taken 50753 times.
✓ Branch 1 taken 23509 times.
✓ Branch 2 taken 50753 times.
✓ Branch 3 taken 23509 times.
116870 for (unsigned int j = 0; j < outsideScvf.numOutsideScvs(); ++j)
350
4/4
✓ Branch 0 taken 25044 times.
✓ Branch 1 taken 25709 times.
✓ Branch 2 taken 25044 times.
✓ Branch 3 taken 25709 times.
166038 if (outsideScvf.outsideScvIdx(j) == insideScvIdx)
351 43768 return outsideScvf.index();
352 }
353
354 DUNE_THROW(Dune::InvalidStateException, "No flipped version of this scvf found!");
355 }
356
357 //! connectivity map for efficient assembly
358 ConnectivityMap connectivityMap_;
359
360 //! containers storing the global data
361 std::vector<SubControlVolume> scvs_;
362 std::vector<SubControlVolumeFace> scvfs_;
363 std::vector<std::vector<GridIndexType>> scvfIndicesOfScv_;
364 std::size_t numBoundaryScvf_;
365 std::vector<bool> hasBoundaryScvf_;
366
367 //! needed for embedded surface and network grids (dim < dimWorld)
368 std::vector<std::vector<GridIndexType>> flipScvfIndices_;
369 };
370
371 /*!
372 * \ingroup CCTpfaDiscretization
373 * \brief The finite volume geometry (scvs and scvfs) for cell-centered TPFA models on a grid view
374 * This builds up the sub control volumes and sub control volume faces
375 * \note For caching disabled we store only some essential index maps to build up local systems on-demand in
376 * the corresponding FVElementGeometry
377 */
378 template<class GV, class Traits>
379 class CCTpfaFVGridGeometry<GV, false, Traits>
380 : public BaseGridGeometry<GV, Traits>
381 {
382 using ThisType = CCTpfaFVGridGeometry<GV, false, Traits>;
383 using ParentType = BaseGridGeometry<GV, Traits>;
384 using ConnectivityMap = typename Traits::template ConnectivityMap<ThisType>;
385
386 using GridIndexType = typename IndexTraits<GV>::GridIndex;
387 using Element = typename GV::template Codim<0>::Entity;
388
389 static const int dim = GV::dimension;
390 static const int dimWorld = GV::dimensionworld;
391
392 using ScvfGridIndexStorage = typename Traits::SubControlVolumeFace::Traits::GridIndexStorage;
393 using NeighborVolVarIndices = typename std::conditional_t< (dim<dimWorld),
394 ScvfGridIndexStorage,
395 Dune::ReservedVector<GridIndexType, 1> >;
396
397 public:
398 //! export basic grid geometry type for the alternative constructor
399 using BasicGridGeometry = BasicGridGeometry_t<GV, Traits>;
400 //! export the type of the fv element geometry (the local view type)
401 using LocalView = typename Traits::template LocalView<ThisType, false>;
402 //! export the type of sub control volume
403 using SubControlVolume = typename Traits::SubControlVolume;
404 //! export the type of sub control volume
405 using SubControlVolumeFace = typename Traits::SubControlVolumeFace;
406 //! export the type of extrusion
407 using Extrusion = Extrusion_t<Traits>;
408 //! export dof mapper type
409 using DofMapper = typename Traits::ElementMapper;
410
411 //! Export the discretization method this geometry belongs to
412 using DiscretizationMethod = DiscretizationMethods::CCTpfa;
413 static constexpr DiscretizationMethod discMethod{};
414
415 //! The maximum admissible stencil size (used for static memory allocation during assembly)
416 static constexpr int maxElementStencilSize = LocalView::maxNumElementScvfs*Traits::maxNumScvfNeighbors + 1;
417
418 //! Export the type of the grid view
419 using GridView = GV;
420
421 //! Constructor with basic grid geometry used to share state with another grid geometry on the same grid view
422 275 CCTpfaFVGridGeometry(std::shared_ptr<BasicGridGeometry> gg)
423
6/14
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 54 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 54 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 54 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 54 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 54 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
1650 : ParentType(std::move(gg))
424 {
425 // Check if the overlap size is what we expect
426
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 221 times.
550 if (!CheckOverlapSize<DiscretizationMethod>::isValid(this->gridView()))
427 DUNE_THROW(Dune::InvalidStateException, "The cctpfa discretization method needs at least an overlap of 1 for parallel computations. "
428 << " Set the parameter \"Grid.Overlap\" in the input file.");
429
430
1/2
✓ Branch 1 taken 221 times.
✗ Branch 2 not taken.
275 update_();
431 275 }
432
433 //! Constructor from gridView
434 272 CCTpfaFVGridGeometry(const GridView& gridView)
435
2/6
✓ Branch 2 taken 218 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 218 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
272 : CCTpfaFVGridGeometry(std::make_shared<BasicGridGeometry>(gridView))
436 272 {}
437
438 //! the element mapper is the dofMapper
439 //! this is convenience to have better chance to have the same main files for box/tpfa/mpfa...
440 const DofMapper& dofMapper() const
441
4/8
✓ Branch 1 taken 96 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 96 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
194 { return this->elementMapper(); }
442
443 //! The total number of sub control volumes
444 std::size_t numScv() const
445 {
446 return numScvs_;
447 }
448
449 //! The total number of sub control volume faces
450 std::size_t numScvf() const
451 {
452 return numScvf_;
453 }
454
455 //! The total number of boundary sub control volume faces
456 std::size_t numBoundaryScvf() const
457 {
458 return numBoundaryScvf_;
459 }
460
461 //! The total number of degrees of freedom
462 std::size_t numDofs() const
463
70/90
✓ Branch 1 taken 236 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 525 times.
✓ Branch 5 taken 11 times.
✓ Branch 6 taken 2 times.
✓ Branch 7 taken 292 times.
✓ Branch 8 taken 11 times.
✓ Branch 9 taken 4 times.
✓ Branch 10 taken 3 times.
✓ Branch 11 taken 25 times.
✓ Branch 12 taken 2 times.
✓ Branch 13 taken 32 times.
✓ Branch 14 taken 3 times.
✓ Branch 15 taken 12 times.
✓ Branch 16 taken 21844 times.
✓ Branch 17 taken 4 times.
✓ Branch 18 taken 29 times.
✓ Branch 19 taken 21868 times.
✓ Branch 20 taken 8 times.
✓ Branch 21 taken 5 times.
✓ Branch 22 taken 21833 times.
✓ Branch 23 taken 8 times.
✓ Branch 24 taken 1262 times.
✓ Branch 25 taken 26 times.
✓ Branch 26 taken 6 times.
✓ Branch 27 taken 1190 times.
✓ Branch 28 taken 26 times.
✓ Branch 29 taken 1 times.
✓ Branch 30 taken 1180 times.
✓ Branch 31 taken 13 times.
✓ Branch 32 taken 24 times.
✓ Branch 33 taken 19 times.
✓ Branch 34 taken 2 times.
✓ Branch 35 taken 3 times.
✓ Branch 36 taken 16 times.
✓ Branch 37 taken 4 times.
✓ Branch 38 taken 3 times.
✓ Branch 39 taken 7 times.
✓ Branch 40 taken 19 times.
✗ Branch 41 not taken.
✓ Branch 42 taken 8 times.
✓ Branch 43 taken 17 times.
✓ Branch 44 taken 1 times.
✓ Branch 45 taken 9 times.
✓ Branch 46 taken 17 times.
✓ Branch 47 taken 2 times.
✓ Branch 48 taken 10 times.
✓ Branch 49 taken 17 times.
✗ Branch 50 not taken.
✓ Branch 51 taken 28 times.
✓ Branch 52 taken 18 times.
✓ Branch 53 taken 1 times.
✓ Branch 54 taken 28 times.
✓ Branch 55 taken 3 times.
✓ Branch 56 taken 12 times.
✓ Branch 57 taken 29 times.
✗ Branch 58 not taken.
✓ Branch 59 taken 12 times.
✓ Branch 60 taken 8 times.
✗ Branch 61 not taken.
✓ Branch 62 taken 33 times.
✗ Branch 63 not taken.
✗ Branch 64 not taken.
✓ Branch 65 taken 12 times.
✗ Branch 66 not taken.
✓ Branch 68 taken 14 times.
✗ Branch 69 not taken.
✓ Branch 71 taken 12 times.
✗ Branch 72 not taken.
✓ Branch 73 taken 1 times.
✗ Branch 74 not taken.
✗ Branch 76 not taken.
✗ Branch 77 not taken.
✓ Branch 99 taken 1 times.
✗ Branch 100 not taken.
✓ Branch 102 taken 1 times.
✗ Branch 103 not taken.
✓ Branch 105 taken 1 times.
✗ Branch 106 not taken.
✓ Branch 110 taken 1 times.
✗ Branch 111 not taken.
✓ Branch 113 taken 1 times.
✗ Branch 114 not taken.
✓ Branch 116 taken 1 times.
✗ Branch 117 not taken.
✓ Branch 119 taken 1 times.
✗ Branch 120 not taken.
✓ Branch 124 taken 1 times.
✗ Branch 125 not taken.
49880 { return this->gridView().size(0); }
464
465 //! update all fvElementGeometries (call this after grid adaption)
466 void update(const GridView& gridView)
467 {
468 4 ParentType::update(gridView);
469 4 update_();
470 }
471
472 //! update all fvElementGeometries (call this after grid adaption)
473 void update(GridView&& gridView)
474 {
475 11 ParentType::update(std::move(gridView));
476 11 update_();
477 }
478
479 const std::vector<GridIndexType>& scvfIndicesOfScv(GridIndexType scvIdx) const
480
14/26
✓ Branch 1 taken 7437292 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7437292 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 6358689 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1384 times.
✓ Branch 10 taken 6358689 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1384 times.
✓ Branch 13 taken 1174192 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1174192 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 3443131 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 3443131 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 1396 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 1396 times.
✗ Branch 29 not taken.
✓ Branch 31 taken 12002 times.
✗ Branch 32 not taken.
✓ Branch 34 taken 12002 times.
✗ Branch 35 not taken.
132593860 { return scvfIndicesOfScv_[scvIdx]; }
481
482 //! Return the neighbor volVar indices for all scvfs in the scv with index scvIdx
483 const std::vector<NeighborVolVarIndices>& neighborVolVarIndices(GridIndexType scvIdx) const
484
14/26
✓ Branch 1 taken 7437292 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7437292 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 6358689 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1384 times.
✓ Branch 10 taken 6358689 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1384 times.
✓ Branch 13 taken 1174192 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1174192 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 3443131 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 3443131 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 1396 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 1396 times.
✗ Branch 29 not taken.
✓ Branch 31 taken 12002 times.
✗ Branch 32 not taken.
✓ Branch 34 taken 12002 times.
✗ Branch 35 not taken.
132584372 { return neighborVolVarIndices_[scvIdx]; }
485
486 /*!
487 * \brief Returns the connectivity map of which dofs have derivatives with respect
488 * to a given dof.
489 */
490 const ConnectivityMap &connectivityMap() const
491 38980402 { return connectivityMap_; }
492
493 private:
494
495 292 void update_()
496 {
497 // clear local data
498 292 scvfIndicesOfScv_.clear();
499
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46 times.
292 neighborVolVarIndices_.clear();
500
501 // reserve memory or resize the containers
502 292 numScvs_ = numDofs();
503 292 numScvf_ = 0;
504 292 numBoundaryScvf_ = 0;
505 292 scvfIndicesOfScv_.resize(numScvs_);
506 292 neighborVolVarIndices_.resize(numScvs_);
507
508 // Build the SCV and SCV face
509
11/12
✓ Branch 2 taken 323322 times.
✓ Branch 3 taken 98 times.
✓ Branch 4 taken 39504 times.
✓ Branch 5 taken 54 times.
✓ Branch 6 taken 48 times.
✓ Branch 7 taken 2016 times.
✓ Branch 8 taken 160970 times.
✓ Branch 9 taken 48 times.
✓ Branch 10 taken 160970 times.
✓ Branch 11 taken 48 times.
✓ Branch 13 taken 160970 times.
✗ Branch 14 not taken.
1108534 for (const auto& element : elements(this->gridView()))
510 {
511
2/4
✓ Branch 1 taken 162986 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 162986 times.
✗ Branch 5 not taken.
1107938 const auto eIdx = this->elementMapper().index(element);
512
513 // the element-wise index sets for finite volume geometry
514
1/2
✓ Branch 1 taken 448068 times.
✗ Branch 2 not taken.
553969 auto numLocalFaces = element.subEntities(1);
515
2/6
✓ Branch 1 taken 484154 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 160970 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1107938 std::vector<GridIndexType> scvfsIndexSet;
516
3/6
✓ Branch 1 taken 484154 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 472126 times.
✓ Branch 4 taken 12028 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
1107938 std::vector<NeighborVolVarIndices> neighborVolVarIndexSet;
517
1/2
✓ Branch 1 taken 484154 times.
✗ Branch 2 not taken.
553969 scvfsIndexSet.reserve(numLocalFaces);
518
1/2
✓ Branch 1 taken 484154 times.
✗ Branch 2 not taken.
553969 neighborVolVarIndexSet.reserve(numLocalFaces);
519
520 // for network grids there might be multiple intersection with the same geometryInInside
521 // we identify those by the indexInInside for now (assumes conforming grids at branching facets)
522
3/6
✓ Branch 1 taken 484154 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 472126 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 160222 times.
✗ Branch 6 not taken.
1640247 std::vector<NeighborVolVarIndices> outsideIndices;
523 if (dim < dimWorld)
524 {
525
1/2
✓ Branch 1 taken 12028 times.
✗ Branch 2 not taken.
21660 outsideIndices.resize(numLocalFaces);
526
6/13
✓ Branch 1 taken 12028 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 12028 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 53562 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 13 taken 6950 times.
✓ Branch 14 taken 34584 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 7094 times.
✗ Branch 17 not taken.
229956 for (const auto& intersection : intersections(this->gridView(), element))
527 {
528
4/4
✓ Branch 0 taken 6950 times.
✓ Branch 1 taken 33820 times.
✓ Branch 2 taken 7714 times.
✓ Branch 3 taken 144 times.
87444 if (intersection.neighbor())
529 {
530
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 37768 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4092 times.
✓ Branch 4 taken 33676 times.
✓ Branch 5 taken 4092 times.
✓ Branch 7 taken 33676 times.
✗ Branch 8 not taken.
161866 const auto nIdx = this->elementMapper().index(intersection.outside());
531
5/9
✗ Branch 0 not taken.
✓ Branch 1 taken 40626 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6950 times.
✓ Branch 4 taken 33676 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6950 times.
✓ Branch 7 taken 33676 times.
✗ Branch 8 not taken.
76406 outsideIndices[intersection.indexInInside()].push_back(nIdx);
532 }
533 }
534 }
535
536
17/21
✓ Branch 1 taken 172250 times.
✓ Branch 2 taken 311904 times.
✓ Branch 3 taken 1235352 times.
✓ Branch 4 taken 306348 times.
✓ Branch 5 taken 30422 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 129462 times.
✓ Branch 8 taken 813835 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 7862 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 41974 times.
✓ Branch 13 taken 9126 times.
✓ Branch 14 taken 651201 times.
✓ Branch 15 taken 2176 times.
✓ Branch 16 taken 15798 times.
✓ Branch 17 taken 25268 times.
✓ Branch 18 taken 2316 times.
✓ Branch 19 taken 8704 times.
✓ Branch 20 taken 27584 times.
✗ Branch 21 not taken.
4715713 for (const auto& intersection : intersections(this->gridView(), element))
537 {
538 // inner sub control volume faces (includes periodic boundaries)
539
4/4
✓ Branch 0 taken 1145977 times.
✓ Branch 1 taken 764045 times.
✓ Branch 2 taken 43283 times.
✓ Branch 3 taken 2460 times.
2232401 if (intersection.neighbor())
540 {
541 // update the grid geometry if we have periodic boundaries
542
4/4
✓ Branch 0 taken 1110686 times.
✓ Branch 1 taken 26826 times.
✓ Branch 2 taken 752088 times.
✓ Branch 3 taken 6950 times.
2167470 if (intersection.boundary())
543 800 this->setPeriodic();
544
545 if (dim == dimWorld)
546 {
547
1/2
✓ Branch 1 taken 1848974 times.
✗ Branch 2 not taken.
2082010 scvfsIndexSet.push_back(numScvf_++);
548
3/6
✓ Branch 1 taken 632024 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 632024 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 632024 times.
✗ Branch 8 not taken.
5263814 const auto nIdx = this->elementMapper().index(intersection.outside());
549
1/2
✓ Branch 2 taken 1848974 times.
✗ Branch 3 not taken.
2082010 neighborVolVarIndexSet.emplace_back(NeighborVolVarIndices({nIdx}));
550 }
551 // this is for network grids
552 // (will be optimized away of dim == dimWorld)
553 else
554 {
555
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 40626 times.
✗ Branch 2 not taken.
76406 auto indexInInside = intersection.indexInInside();
556 // check if we already handled this facet
557
6/6
✓ Branch 0 taken 40456 times.
✓ Branch 1 taken 170 times.
✓ Branch 2 taken 40456 times.
✓ Branch 3 taken 170 times.
✓ Branch 4 taken 40456 times.
✓ Branch 5 taken 170 times.
229218 if (outsideIndices[indexInInside].empty())
558 continue;
559 else
560 {
561
1/2
✓ Branch 1 taken 40456 times.
✗ Branch 2 not taken.
76180 scvfsIndexSet.push_back(numScvf_++);
562
2/4
✓ Branch 1 taken 40456 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 40456 times.
✗ Branch 5 not taken.
152360 neighborVolVarIndexSet.emplace_back(std::move(outsideIndices[indexInInside]));
563
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 40456 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 40456 times.
152360 outsideIndices[indexInInside].clear();
564 }
565 }
566 }
567 // boundary sub control volume faces
568
3/4
✓ Branch 0 taken 19826 times.
✓ Branch 1 taken 11261 times.
✓ Branch 2 taken 544 times.
✗ Branch 3 not taken.
37347 else if (intersection.boundary())
569 {
570
1/2
✓ Branch 1 taken 30991 times.
✗ Branch 2 not taken.
36623 scvfsIndexSet.push_back(numScvf_++);
571
5/11
✓ Branch 1 taken 908 times.
✓ Branch 2 taken 30083 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 908 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 908 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 908 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
38379 neighborVolVarIndexSet.emplace_back(NeighborVolVarIndices({static_cast<GridIndexType>(numScvs_ + numBoundaryScvf_++)}));
572 }
573 }
574
575 // store the sets of indices in the data container
576
2/4
✓ Branch 1 taken 484154 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 484154 times.
✗ Branch 5 not taken.
1107938 scvfIndicesOfScv_[eIdx] = scvfsIndexSet;
577
2/4
✓ Branch 1 taken 484154 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 484154 times.
✗ Branch 5 not taken.
1107938 neighborVolVarIndices_[eIdx] = neighborVolVarIndexSet;
578 }
579
580 // build the connectivity map for an efficient assembly
581 292 connectivityMap_.update(*this);
582 292 }
583
584 //! Information on the global number of geometries
585 std::size_t numScvs_;
586 std::size_t numScvf_;
587 std::size_t numBoundaryScvf_;
588
589 //! connectivity map for efficient assembly
590 ConnectivityMap connectivityMap_;
591
592 //! vectors that store the global data
593 std::vector<std::vector<GridIndexType>> scvfIndicesOfScv_;
594 std::vector<std::vector<NeighborVolVarIndices>> neighborVolVarIndices_;
595 };
596
597 } // end namespace Dumux
598
599 #endif
600