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 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 | #include <dumux/io/grid/periodicgridtraits.hh> | ||
33 | |||
34 | namespace Dumux { | ||
35 | |||
36 | /*! | ||
37 | * \ingroup CCTpfaDiscretization | ||
38 | * \brief The default traits for the tpfa finite volume grid geometry | ||
39 | * Defines the scv and scvf types and the mapper types | ||
40 | * \tparam the grid view type | ||
41 | */ | ||
42 | template<class GridView, class MapperTraits = DefaultMapperTraits<GridView>> | ||
43 | struct CCTpfaDefaultGridGeometryTraits | ||
44 | : public MapperTraits | ||
45 | { | ||
46 | using SubControlVolume = CCSubControlVolume<GridView>; | ||
47 | using SubControlVolumeFace = CCTpfaSubControlVolumeFace<GridView>; | ||
48 | |||
49 | template<class GridGeometry> | ||
50 | using ConnectivityMap = CCSimpleConnectivityMap<GridGeometry>; | ||
51 | |||
52 | template<class GridGeometry, bool enableCache> | ||
53 | using LocalView = CCTpfaFVElementGeometry<GridGeometry, enableCache>; | ||
54 | |||
55 | //! State the maximum admissible number of neighbors per scvf | ||
56 | //! Per default, we allow for 8 branches on network/surface grids, where | ||
57 | //! conformity is assumed. For normal grids, we allow a maximum of one | ||
58 | //! hanging node per scvf. Use different traits if you need more. | ||
59 | static constexpr int maxNumScvfNeighbors = int(GridView::dimension)<int(GridView::dimensionworld) ? 8 : 1<<(GridView::dimension-1); | ||
60 | }; | ||
61 | |||
62 | /*! | ||
63 | * \ingroup CCTpfaDiscretization | ||
64 | * \brief The finite volume geometry (scvs and scvfs) for cell-centered TPFA models on a grid view | ||
65 | * This builds up the sub control volumes and sub control volume faces | ||
66 | * \note This class is specialized for versions with and without caching the fv geometries on the grid view | ||
67 | */ | ||
68 | template<class GridView, | ||
69 | bool enableGridGeometryCache = false, | ||
70 | class Traits = CCTpfaDefaultGridGeometryTraits<GridView> > | ||
71 | class CCTpfaFVGridGeometry; | ||
72 | |||
73 | /*! | ||
74 | * \ingroup CCTpfaDiscretization | ||
75 | * \brief The finite volume geometry (scvs and scvfs) for cell-centered TPFA models on a grid view | ||
76 | * This builds up the sub control volumes and sub control volume faces | ||
77 | * \note For caching enabled we store the fv geometries for the whole grid view which is memory intensive but faster | ||
78 | */ | ||
79 | template<class GV, class Traits> | ||
80 | class CCTpfaFVGridGeometry<GV, true, Traits> | ||
81 | : public BaseGridGeometry<GV, Traits> | ||
82 | { | ||
83 | using ThisType = CCTpfaFVGridGeometry<GV, true, Traits>; | ||
84 | using ParentType = BaseGridGeometry<GV, Traits>; | ||
85 | using ConnectivityMap = typename Traits::template ConnectivityMap<ThisType>; | ||
86 | using GridIndexType = typename IndexTraits<GV>::GridIndex; | ||
87 | using Element = typename GV::template Codim<0>::Entity; | ||
88 | |||
89 | static const int dim = GV::dimension; | ||
90 | static const int dimWorld = GV::dimensionworld; | ||
91 | |||
92 | public: | ||
93 | //! export basic grid geometry type for the alternative constructor | ||
94 | using BasicGridGeometry = BasicGridGeometry_t<GV, Traits>; | ||
95 | //! export the type of the fv element geometry (the local view type) | ||
96 | using LocalView = typename Traits::template LocalView<ThisType, true>; | ||
97 | //! export the type of sub control volume | ||
98 | using SubControlVolume = typename Traits::SubControlVolume; | ||
99 | //! export the type of sub control volume | ||
100 | using SubControlVolumeFace = typename Traits::SubControlVolumeFace; | ||
101 | //! export the type of extrusion | ||
102 | using Extrusion = Extrusion_t<Traits>; | ||
103 | //! export dof mapper type | ||
104 | using DofMapper = typename Traits::ElementMapper; | ||
105 | //! export whether the grid(geometry) supports periodicity | ||
106 | using SupportsPeriodicity = typename PeriodicGridTraits<typename GV::Grid>::SupportsPeriodicity; | ||
107 | |||
108 | //! export the discretization method this geometry belongs to | ||
109 | using DiscretizationMethod = DiscretizationMethods::CCTpfa; | ||
110 | static constexpr DiscretizationMethod discMethod{}; | ||
111 | |||
112 | //! The maximum admissible stencil size (used for static memory allocation during assembly) | ||
113 | static constexpr int maxElementStencilSize = LocalView::maxNumElementScvfs*Traits::maxNumScvfNeighbors + 1; | ||
114 | |||
115 | //! export the grid view type | ||
116 | using GridView = GV; | ||
117 | |||
118 | //! Constructor with basic grid geometry used to share state with another grid geometry on the same grid view | ||
119 | 253 | CCTpfaFVGridGeometry(std::shared_ptr<BasicGridGeometry> gg) | |
120 | : ParentType(std::move(gg)) | ||
121 |
2/4✗ Branch 0 not taken.
✓ Branch 1 taken 182 times.
✓ Branch 3 taken 68 times.
✗ Branch 4 not taken.
|
253 | , periodicGridTraits_(this->gridView().grid()) |
122 | { | ||
123 | // Check if the overlap size is what we expect | ||
124 |
2/2✓ Branch 1 taken 68 times.
✓ Branch 2 taken 116 times.
|
253 | if (!CheckOverlapSize<DiscretizationMethod>::isValid(this->gridView())) |
125 |
0/22✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
|
108 | DUNE_THROW(Dune::InvalidStateException, "The cctpfa discretization method needs at least an overlap of 1 for parallel computations. " |
126 | << " Set the parameter \"Grid.Overlap\" in the input file."); | ||
127 | |||
128 |
1/2✓ Branch 1 taken 184 times.
✗ Branch 2 not taken.
|
253 | update_(); |
129 | 253 | } | |
130 | |||
131 | //! Constructor from gridView | ||
132 | 250 | CCTpfaFVGridGeometry(const GridView& gridView) | |
133 |
1/2✓ Branch 1 taken 181 times.
✗ Branch 2 not taken.
|
250 | : CCTpfaFVGridGeometry(std::make_shared<BasicGridGeometry>(gridView)) |
134 | 250 | {} | |
135 | |||
136 | //! the element mapper is the dofMapper | ||
137 | //! this is convenience to have better chance to have the same main files for box/tpfa/mpfa... | ||
138 | 37665 | const DofMapper& dofMapper() const | |
139 |
3/5✓ Branch 1 taken 28 times.
✓ Branch 2 taken 4 times.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 3 not taken.
|
37665 | { return this->elementMapper(); } |
140 | |||
141 | //! The total number of sub control volumes | ||
142 | 49567120 | std::size_t numScv() const | |
143 | { | ||
144 |
18/24✓ Branch 2 taken 1233893 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 173500 times.
✓ Branch 7 taken 7889567 times.
✓ Branch 9 taken 800000 times.
✓ Branch 10 taken 822910 times.
✓ Branch 12 taken 3471 times.
✓ Branch 13 taken 334078 times.
✓ Branch 15 taken 939521 times.
✗ Branch 16 not taken.
✓ Branch 19 taken 17377 times.
✓ Branch 20 taken 9 times.
✓ Branch 23 taken 8000 times.
✗ Branch 24 not taken.
✓ Branch 28 taken 101 times.
✗ Branch 29 not taken.
✓ Branch 1 taken 180588 times.
✓ Branch 4 taken 9262956 times.
✓ Branch 5 taken 2951661 times.
✓ Branch 8 taken 19456326 times.
✓ Branch 11 taken 9217 times.
✓ Branch 14 taken 5000 times.
✗ Branch 0 not taken.
✗ Branch 21 not taken.
|
49567120 | return scvs_.size(); |
145 | } | ||
146 | |||
147 | //! The total number of sub control volume faces | ||
148 | 2810 | std::size_t numScvf() const | |
149 | { | ||
150 |
3/5✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1 times.
|
2810 | return scvfs_.size(); |
151 | } | ||
152 | |||
153 | //! The total number of boundary sub control volume faces | ||
154 | 20 | std::size_t numBoundaryScvf() const | |
155 | { | ||
156 |
12/24✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 3 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 3 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 1 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 3 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 3 times.
✗ Branch 29 not taken.
✓ Branch 31 taken 1 times.
✗ Branch 32 not taken.
✓ Branch 34 taken 1 times.
✗ Branch 35 not taken.
|
10 | return numBoundaryScvf_; |
157 | } | ||
158 | |||
159 | //! The total number of degrees of freedom | ||
160 | 1585308 | std::size_t numDofs() const | |
161 |
44/50✓ Branch 7 taken 19 times.
✓ Branch 8 taken 424 times.
✓ Branch 12 taken 957479 times.
✓ Branch 13 taken 14 times.
✓ Branch 16 taken 37 times.
✓ Branch 17 taken 11 times.
✓ Branch 24 taken 24 times.
✓ Branch 25 taken 4 times.
✓ Branch 2 taken 95 times.
✓ Branch 3 taken 1 times.
✓ Branch 6 taken 23 times.
✓ Branch 9 taken 957466 times.
✓ Branch 10 taken 60850 times.
✓ Branch 11 taken 31 times.
✓ Branch 1 taken 19 times.
✓ Branch 4 taken 22 times.
✗ Branch 5 not taken.
✓ Branch 14 taken 20 times.
✓ Branch 15 taken 542411 times.
✓ Branch 23 taken 6 times.
✓ Branch 26 taken 26 times.
✓ Branch 27 taken 20 times.
✓ Branch 19 taken 19678 times.
✓ Branch 20 taken 31 times.
✓ Branch 22 taken 19680 times.
✓ Branch 18 taken 542415 times.
✓ Branch 21 taken 15 times.
✓ Branch 29 taken 23 times.
✓ Branch 30 taken 19 times.
✓ Branch 32 taken 15 times.
✓ Branch 33 taken 1 times.
✓ Branch 35 taken 13 times.
✓ Branch 36 taken 3 times.
✓ Branch 34 taken 9 times.
✓ Branch 37 taken 5 times.
✓ Branch 38 taken 16 times.
✓ Branch 40 taken 7 times.
✓ Branch 41 taken 28 times.
✓ Branch 43 taken 7 times.
✓ Branch 44 taken 16 times.
✓ Branch 46 taken 7 times.
✗ Branch 47 not taken.
✓ Branch 49 taken 7 times.
✗ Branch 50 not taken.
✓ Branch 28 taken 13 times.
✓ Branch 31 taken 17 times.
✗ Branch 39 not taken.
✗ Branch 42 not taken.
✗ Branch 45 not taken.
✓ Branch 48 taken 16 times.
|
1585444 | { return this->gridView().size(0); } |
162 | |||
163 | |||
164 | //! update all fvElementGeometries (call this after grid adaption) | ||
165 | 1 | void update(const GridView& gridView) | |
166 | { | ||
167 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | ParentType::update(gridView); |
168 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | update_(); |
169 | 1 | } | |
170 | |||
171 | //! update all fvElementGeometries (call this after grid adaption) | ||
172 | void update(GridView&& gridView) | ||
173 | { | ||
174 | ParentType::update(std::move(gridView)); | ||
175 | update_(); | ||
176 | } | ||
177 | |||
178 | //! Get a sub control volume with a global scv index | ||
179 | 2729850008 | const SubControlVolume& scv(GridIndexType scvIdx) const | |
180 | { | ||
181 |
36/41✓ Branch 1 taken 2955564 times.
✓ Branch 2 taken 232415372 times.
✓ Branch 4 taken 667758 times.
✓ Branch 5 taken 382331213 times.
✓ Branch 7 taken 58628784 times.
✓ Branch 8 taken 92565432 times.
✓ Branch 11 taken 61718986 times.
✓ Branch 12 taken 132164591 times.
✓ Branch 13 taken 18941636 times.
✓ Branch 14 taken 2632628 times.
✓ Branch 19 taken 1210426 times.
✓ Branch 20 taken 148752 times.
✓ Branch 21 taken 5000819 times.
✓ Branch 22 taken 1609459 times.
✓ Branch 24 taken 202247 times.
✗ Branch 25 not taken.
✓ Branch 10 taken 32484895 times.
✓ Branch 30 taken 16168 times.
✓ Branch 31 taken 647270 times.
✓ Branch 17 taken 3410818 times.
✓ Branch 18 taken 1638002 times.
✓ Branch 3 taken 20132168 times.
✓ Branch 6 taken 356454 times.
✓ Branch 9 taken 32458764 times.
✓ Branch 23 taken 1213781 times.
✓ Branch 27 taken 568091 times.
✓ Branch 28 taken 656 times.
✓ Branch 29 taken 3238 times.
✓ Branch 32 taken 5304 times.
✓ Branch 33 taken 12096 times.
✓ Branch 15 taken 405346 times.
✓ Branch 16 taken 1261382 times.
✓ Branch 26 taken 3629 times.
✓ Branch 36 taken 112215 times.
✓ Branch 37 taken 8000 times.
✓ Branch 39 taken 901500 times.
✗ Branch 40 not taken.
✓ Branch 34 taken 3463700 times.
✗ Branch 35 not taken.
✗ Branch 38 not taken.
✗ Branch 0 not taken.
|
2865405111 | return scvs_[scvIdx]; |
182 | } | ||
183 | |||
184 | //! Get a sub control volume face with a global scvf index | ||
185 | 868002289 | const SubControlVolumeFace& scvf(GridIndexType scvfIdx) const | |
186 | { | ||
187 |
28/31✓ Branch 1 taken 13658 times.
✓ Branch 2 taken 3319110 times.
✓ Branch 6 taken 1081648 times.
✓ Branch 7 taken 778628 times.
✓ Branch 10 taken 1025756 times.
✓ Branch 11 taken 14550006 times.
✓ Branch 12 taken 36150921 times.
✓ Branch 13 taken 6079753 times.
✓ Branch 18 taken 105142 times.
✓ Branch 19 taken 12726 times.
✓ Branch 20 taken 1071664 times.
✓ Branch 21 taken 242400 times.
✓ Branch 22 taken 504 times.
✓ Branch 23 taken 536 times.
✓ Branch 24 taken 3470 times.
✗ Branch 25 not taken.
✓ Branch 26 taken 3502 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 48000 times.
✗ Branch 29 not taken.
✓ Branch 30 taken 3344 times.
✓ Branch 31 taken 126 times.
✓ Branch 8 taken 336588 times.
✓ Branch 9 taken 3132993 times.
✓ Branch 15 taken 1001694 times.
✓ Branch 16 taken 5530379 times.
✓ Branch 5 taken 1341286 times.
✓ Branch 3 taken 876546 times.
✓ Branch 4 taken 220020 times.
✓ Branch 14 taken 4670402 times.
✓ Branch 17 taken 30753 times.
|
866793170 | return scvfs_[scvfIdx]; |
188 | } | ||
189 | |||
190 | //! Get the scvf on the same face but from the other side | ||
191 | //! Note that e.g. the normals might be different in the case of surface grids | ||
192 | 50568433 | const SubControlVolumeFace& flipScvf(GridIndexType scvfIdx, unsigned int outsideScvfIdx = 0) const | |
193 | { | ||
194 |
4/7✗ Branch 2 not taken.
✓ Branch 3 taken 48029 times.
✓ Branch 5 taken 6322 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 3050 times.
✗ Branch 8 not taken.
✓ Branch 4 taken 176032 times.
|
50568433 | return scvfs_[flipScvfIndices_[scvfIdx][outsideScvfIdx]]; |
195 | } | ||
196 | |||
197 | //! Get the sub control volume face indices of an scv by global index | ||
198 | 149339300 | const std::vector<GridIndexType>& scvfIndicesOfScv(GridIndexType scvIdx) const | |
199 | { | ||
200 |
2/6✗ Branch 0 not taken.
✓ Branch 1 taken 165000 times.
✓ Branch 3 taken 165000 times.
✗ Branch 4 not taken.
✗ Branch 2 not taken.
✗ Branch 5 not taken.
|
134603590 | return scvfIndicesOfScv_[scvIdx]; |
201 | } | ||
202 | |||
203 | /*! | ||
204 | * \brief Returns the connectivity map of which dofs have derivatives with respect | ||
205 | * to a given dof. | ||
206 | */ | ||
207 | 21460235 | const ConnectivityMap &connectivityMap() const | |
208 | 40039042 | { return connectivityMap_; } | |
209 | |||
210 | //! Returns whether one of the geometry's scvfs lies on a boundary | ||
211 | 55287102 | bool hasBoundaryScvf(GridIndexType eIdx) const | |
212 |
12/12✓ Branch 0 taken 2761584 times.
✓ Branch 1 taken 31165083 times.
✓ Branch 2 taken 5723013 times.
✓ Branch 3 taken 15612230 times.
✓ Branch 4 taken 7282 times.
✓ Branch 5 taken 8240 times.
✓ Branch 6 taken 36 times.
✓ Branch 7 taken 28 times.
✓ Branch 8 taken 432 times.
✓ Branch 9 taken 592 times.
✓ Branch 10 taken 6778 times.
✓ Branch 11 taken 1804 times.
|
55287102 | { return hasBoundaryScvf_[eIdx]; } |
213 | |||
214 | private: | ||
215 | |||
216 | 255 | void update_() | |
217 | { | ||
218 | // clear containers (necessary after grid refinement) | ||
219 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 184 times.
|
255 | scvs_.clear(); |
220 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 184 times.
|
255 | scvfs_.clear(); |
221 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 184 times.
|
255 | scvfIndicesOfScv_.clear(); |
222 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 185 times.
|
255 | flipScvfIndices_.clear(); |
223 | |||
224 | // determine size of containers | ||
225 | 255 | std::size_t numScvs = numDofs(); | |
226 | 255 | std::size_t numScvf = 0; | |
227 |
10/11✓ Branch 1 taken 1508997 times.
✓ Branch 2 taken 100341 times.
✓ Branch 3 taken 170 times.
✓ Branch 5 taken 121711 times.
✓ Branch 6 taken 121694 times.
✓ Branch 8 taken 19184 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 19184 times.
✓ Branch 11 taken 11 times.
✓ Branch 4 taken 109 times.
✓ Branch 7 taken 4 times.
|
5319723 | for (const auto& element : elements(this->gridView())) |
228 |
1/2✓ Branch 1 taken 19184 times.
✗ Branch 2 not taken.
|
2716511 | numScvf += element.subEntities(1); |
229 | |||
230 | // reserve memory | ||
231 | 255 | scvs_.resize(numScvs); | |
232 | 255 | scvfs_.reserve(numScvf); | |
233 | 255 | scvfIndicesOfScv_.resize(numScvs); | |
234 | 255 | hasBoundaryScvf_.assign(numScvs, false); | |
235 | |||
236 | // Build the scvs and scv faces | ||
237 | 255 | GridIndexType scvfIdx = 0; | |
238 | 255 | numBoundaryScvf_ = 0; | |
239 |
12/13✓ Branch 2 taken 1922 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 2083 times.
✓ Branch 6 taken 122 times.
✓ Branch 8 taken 130771 times.
✓ Branch 9 taken 121694 times.
✓ Branch 11 taken 9073 times.
✓ Branch 12 taken 10111 times.
✓ Branch 13 taken 9082 times.
✓ Branch 14 taken 2 times.
✓ Branch 4 taken 1607412 times.
✓ Branch 10 taken 10115 times.
✓ Branch 7 taken 2 times.
|
8029796 | for (const auto& element : elements(this->gridView())) |
240 | { | ||
241 |
3/5✓ Branch 1 taken 20919 times.
✓ Branch 2 taken 15705 times.
✓ Branch 4 taken 19184 times.
✗ Branch 5 not taken.
✗ Branch 3 not taken.
|
2716511 | const auto eIdx = this->elementMapper().index(element); |
242 |
2/3✓ Branch 2 taken 1601416 times.
✗ Branch 3 not taken.
✓ Branch 1 taken 17154 times.
|
2735416 | scvs_[eIdx] = SubControlVolume(element.geometry(), eIdx); |
243 | |||
244 | // the element-wise index sets for finite volume geometry | ||
245 |
1/2✓ Branch 1 taken 1628402 times.
✗ Branch 2 not taken.
|
2716511 | std::vector<GridIndexType> scvfsIndexSet; |
246 |
1/2✓ Branch 1 taken 1750205 times.
✗ Branch 2 not taken.
|
2716511 | scvfsIndexSet.reserve(element.subEntities(1)); |
247 | |||
248 | // for network grids there might be multiple intersection with the same geometryInInside | ||
249 | // we identify those by the indexInInside for now (assumes conforming grids at branching facets) | ||
250 | using ScvfGridIndexStorage = typename SubControlVolumeFace::Traits::GridIndexStorage; | ||
251 |
1/2✓ Branch 1 taken 17440 times.
✗ Branch 2 not taken.
|
2716511 | std::vector<ScvfGridIndexStorage> outsideIndices; |
252 | if (dim < dimWorld) | ||
253 | { | ||
254 | //! first, push inside index in all neighbor sets | ||
255 |
1/2✓ Branch 1 taken 17440 times.
✗ Branch 2 not taken.
|
26100 | outsideIndices.resize(element.subEntities(1)); |
256 |
1/2✓ Branch 1 taken 42646 times.
✗ Branch 2 not taken.
|
86854 | std::for_each(outsideIndices.begin(), outsideIndices.end(), [eIdx] (auto& nIndices) { nIndices.push_back(eIdx); }); |
257 | |||
258 | // second, insert neighbors | ||
259 |
5/8✓ Branch 1 taken 17440 times.
✗ Branch 2 not taken.
✓ Branch 6 taken 44842 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 62282 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 43352 times.
✓ Branch 11 taken 1490 times.
|
269088 | for (const auto& intersection : intersections(this->gridView(), element)) |
260 | { | ||
261 |
2/2✓ Branch 0 taken 43352 times.
✓ Branch 1 taken 1490 times.
|
64356 | if (intersection.neighbor()) |
262 | { | ||
263 |
2/3✗ Branch 0 not taken.
✓ Branch 1 taken 3674 times.
✓ Branch 2 taken 39678 times.
|
62076 | const auto nIdx = this->elementMapper().index( intersection.outside() ); |
264 |
1/2✓ Branch 1 taken 43352 times.
✗ Branch 2 not taken.
|
62076 | outsideIndices[intersection.indexInInside()].push_back(nIdx); |
265 | } | ||
266 | } | ||
267 | } | ||
268 | |||
269 |
13/15✓ Branch 1 taken 1750096 times.
✓ Branch 2 taken 7927892 times.
✓ Branch 4 taken 8060900 times.
✓ Branch 5 taken 136346 times.
✓ Branch 7 taken 283568 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 976228 times.
✓ Branch 10 taken 43352 times.
✓ Branch 11 taken 286390 times.
✓ Branch 12 taken 513148 times.
✓ Branch 6 taken 109 times.
✓ Branch 3 taken 499 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 503924 times.
✓ Branch 15 taken 124572 times.
|
19175317 | for (const auto& intersection : intersections(this->gridView(), element)) |
270 | { | ||
271 | // inner sub control volume faces (includes periodic boundaries) | ||
272 |
2/2✓ Branch 0 taken 1002760 times.
✓ Branch 1 taken 47654 times.
|
1262926 | if (intersection.neighbor()) |
273 | { | ||
274 | // update the grid geometry if we have periodic boundaries | ||
275 |
2/3✗ Branch 0 not taken.
✓ Branch 1 taken 44152 times.
✓ Branch 2 taken 465922 times.
|
14265890 | if (periodicGridTraits_.isPeriodic(intersection)) |
276 | 800 | this->setPeriodic(); | |
277 | |||
278 | if (dim == dimWorld) | ||
279 | { | ||
280 |
2/4✓ Branch 1 taken 824066 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 370666 times.
✗ Branch 5 not taken.
|
14203814 | const auto nIdx = this->elementMapper().index(intersection.outside()); |
281 |
1/2✓ Branch 1 taken 811576 times.
✗ Branch 2 not taken.
|
14203814 | scvfs_.emplace_back(intersection, |
282 |
1/2✓ Branch 1 taken 7792232 times.
✗ Branch 2 not taken.
|
13331008 | intersection.geometry(), |
283 | scvfIdx, | ||
284 |
1/2✓ Branch 1 taken 357822 times.
✗ Branch 2 not taken.
|
14203814 | ScvfGridIndexStorage({eIdx, nIdx}), |
285 | 14203814 | false); | |
286 |
1/2✓ Branch 1 taken 8603808 times.
✗ Branch 2 not taken.
|
14203814 | scvfsIndexSet.push_back(scvfIdx++); |
287 | } | ||
288 | // this is for network grids | ||
289 | // (will be optimized away of dim == dimWorld) | ||
290 | else | ||
291 | { | ||
292 | 62076 | auto indexInInside = intersection.indexInInside(); | |
293 | // check if we already handled this facet | ||
294 |
2/2✓ Branch 0 taken 2196 times.
✓ Branch 1 taken 41156 times.
|
62076 | if (outsideIndices[indexInInside].empty()) |
295 | 3602 | continue; | |
296 | else | ||
297 | { | ||
298 | 58474 | scvfs_.emplace_back(intersection, | |
299 |
1/2✓ Branch 1 taken 41156 times.
✗ Branch 2 not taken.
|
58474 | intersection.geometry(), |
300 | scvfIdx, | ||
301 | 58474 | outsideIndices[indexInInside], | |
302 |
1/2✓ Branch 1 taken 41156 times.
✗ Branch 2 not taken.
|
58474 | false); |
303 |
1/2✓ Branch 1 taken 41156 times.
✗ Branch 2 not taken.
|
58474 | scvfsIndexSet.push_back(scvfIdx++); |
304 |
2/4✓ Branch 0 taken 41156 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 44842 times.
✗ Branch 4 not taken.
|
122830 | outsideIndices[indexInInside].clear(); |
305 | } | ||
306 | } | ||
307 | } | ||
308 | // boundary sub control volume faces | ||
309 |
2/3✓ Branch 0 taken 185964 times.
✓ Branch 1 taken 294422 times.
✗ Branch 2 not taken.
|
639828 | else if (intersection.boundary()) |
310 | { | ||
311 |
1/2✓ Branch 1 taken 45846 times.
✗ Branch 2 not taken.
|
327598 | scvfs_.emplace_back(intersection, |
312 |
2/6✓ Branch 1 taken 153564 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 108 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
|
278146 | intersection.geometry(), |
313 | scvfIdx, | ||
314 |
2/4✓ Branch 2 taken 13942 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 1382 times.
✗ Branch 7 not taken.
|
329662 | ScvfGridIndexStorage({eIdx, static_cast<GridIndexType>(this->gridView().size(0) + numBoundaryScvf_++)}), |
315 |
1/2✓ Branch 1 taken 160282 times.
✗ Branch 2 not taken.
|
327598 | true); |
316 |
1/2✓ Branch 1 taken 199410 times.
✗ Branch 2 not taken.
|
327598 | scvfsIndexSet.push_back(scvfIdx++); |
317 | |||
318 | 327598 | hasBoundaryScvf_[eIdx] = true; | |
319 | } | ||
320 | } | ||
321 | |||
322 | // Save the scvf indices belonging to this scv to build up fv element geometries fast | ||
323 |
1/2✓ Branch 1 taken 1750205 times.
✗ Branch 2 not taken.
|
2716511 | scvfIndicesOfScv_[eIdx] = scvfsIndexSet; |
324 | } | ||
325 | |||
326 | // Make the flip index set for network, surface, and periodic grids | ||
327 |
2/2✓ Branch 0 taken 6 times.
✓ Branch 1 taken 136 times.
|
175 | if (dim < dimWorld || this->isPeriodic()) |
328 | { | ||
329 | 86 | flipScvfIndices_.resize(scvfs_.size()); | |
330 |
4/4✓ Branch 0 taken 34886 times.
✓ Branch 1 taken 494972 times.
✓ Branch 2 taken 529858 times.
✓ Branch 3 taken 49 times.
|
548052 | for (auto&& scvf : scvfs_) |
331 | { | ||
332 |
2/2✓ Branch 0 taken 34886 times.
✓ Branch 1 taken 494972 times.
|
547966 | if (scvf.boundary()) |
333 | 35676 | continue; | |
334 | |||
335 | 512290 | flipScvfIndices_[scvf.index()].resize(scvf.numOutsideScvs()); | |
336 | 512290 | const auto insideScvIdx = scvf.insideScvIdx(); | |
337 | // check which outside scvf has the insideScvIdx index in its outsideScvIndices | ||
338 |
2/2✓ Branch 0 taken 497168 times.
✓ Branch 1 taken 494972 times.
|
1028182 | for (unsigned int i = 0; i < scvf.numOutsideScvs(); ++i) |
339 | 515892 | flipScvfIndices_[scvf.index()][i] = findFlippedScvfIndex_(insideScvIdx, scvf.outsideScvIdx(i)); | |
340 | } | ||
341 | } | ||
342 | |||
343 | // build the connectivity map for an efficient assembly | ||
344 | 255 | connectivityMap_.update(*this); | |
345 | 255 | } | |
346 | |||
347 | // find the scvf that has insideScvIdx in its outsideScvIdx list and outsideScvIdx as its insideScvIdx | ||
348 | 497168 | GridIndexType findFlippedScvfIndex_(GridIndexType insideScvIdx, GridIndexType outsideScvIdx) | |
349 | { | ||
350 | // go over all potential scvfs of the outside scv | ||
351 |
1/2✓ Branch 0 taken 1180053 times.
✗ Branch 1 not taken.
|
1209119 | for (auto outsideScvfIndex : scvfIndicesOfScv_[outsideScvIdx]) |
352 | { | ||
353 | 1209119 | const auto& outsideScvf = this->scvf(outsideScvfIndex); | |
354 |
2/2✓ Branch 0 taken 1182253 times.
✓ Branch 1 taken 701609 times.
|
1926470 | for (unsigned int j = 0; j < outsideScvf.numOutsideScvs(); ++j) |
355 |
2/2✓ Branch 0 taken 478444 times.
✓ Branch 1 taken 703809 times.
|
1214519 | if (outsideScvf.outsideScvIdx(j) == insideScvIdx) |
356 | 497168 | return outsideScvf.index(); | |
357 | } | ||
358 | |||
359 | ✗ | DUNE_THROW(Dune::InvalidStateException, "No flipped version of this scvf found!"); | |
360 | } | ||
361 | |||
362 | //! connectivity map for efficient assembly | ||
363 | ConnectivityMap connectivityMap_; | ||
364 | |||
365 | //! containers storing the global data | ||
366 | std::vector<SubControlVolume> scvs_; | ||
367 | std::vector<SubControlVolumeFace> scvfs_; | ||
368 | std::vector<std::vector<GridIndexType>> scvfIndicesOfScv_; | ||
369 | std::size_t numBoundaryScvf_; | ||
370 | std::vector<bool> hasBoundaryScvf_; | ||
371 | |||
372 | //! needed for embedded surface and network grids (dim < dimWorld) | ||
373 | std::vector<std::vector<GridIndexType>> flipScvfIndices_; | ||
374 | |||
375 | PeriodicGridTraits<typename GridView::Grid> periodicGridTraits_; | ||
376 | }; | ||
377 | |||
378 | /*! | ||
379 | * \ingroup CCTpfaDiscretization | ||
380 | * \brief The finite volume geometry (scvs and scvfs) for cell-centered TPFA models on a grid view | ||
381 | * This builds up the sub control volumes and sub control volume faces | ||
382 | * \note For caching disabled we store only some essential index maps to build up local systems on-demand in | ||
383 | * the corresponding FVElementGeometry | ||
384 | */ | ||
385 | template<class GV, class Traits> | ||
386 | class CCTpfaFVGridGeometry<GV, false, Traits> | ||
387 | : public BaseGridGeometry<GV, Traits> | ||
388 | { | ||
389 | using ThisType = CCTpfaFVGridGeometry<GV, false, Traits>; | ||
390 | using ParentType = BaseGridGeometry<GV, Traits>; | ||
391 | using ConnectivityMap = typename Traits::template ConnectivityMap<ThisType>; | ||
392 | |||
393 | using GridIndexType = typename IndexTraits<GV>::GridIndex; | ||
394 | using Element = typename GV::template Codim<0>::Entity; | ||
395 | |||
396 | static const int dim = GV::dimension; | ||
397 | static const int dimWorld = GV::dimensionworld; | ||
398 | |||
399 | using ScvfGridIndexStorage = typename Traits::SubControlVolumeFace::Traits::GridIndexStorage; | ||
400 | using NeighborVolVarIndices = typename std::conditional_t< (dim<dimWorld), | ||
401 | ScvfGridIndexStorage, | ||
402 | Dune::ReservedVector<GridIndexType, 1> >; | ||
403 | |||
404 | public: | ||
405 | //! export basic grid geometry type for the alternative constructor | ||
406 | using BasicGridGeometry = BasicGridGeometry_t<GV, Traits>; | ||
407 | //! export the type of the fv element geometry (the local view type) | ||
408 | using LocalView = typename Traits::template LocalView<ThisType, false>; | ||
409 | //! export the type of sub control volume | ||
410 | using SubControlVolume = typename Traits::SubControlVolume; | ||
411 | //! export the type of sub control volume | ||
412 | using SubControlVolumeFace = typename Traits::SubControlVolumeFace; | ||
413 | //! export the type of extrusion | ||
414 | using Extrusion = Extrusion_t<Traits>; | ||
415 | //! export dof mapper type | ||
416 | using DofMapper = typename Traits::ElementMapper; | ||
417 | //! export whether the grid(geometry) supports periodicity | ||
418 | using SupportsPeriodicity = typename PeriodicGridTraits<typename GV::Grid>::SupportsPeriodicity; | ||
419 | |||
420 | //! Export the discretization method this geometry belongs to | ||
421 | using DiscretizationMethod = DiscretizationMethods::CCTpfa; | ||
422 | static constexpr DiscretizationMethod discMethod{}; | ||
423 | |||
424 | //! The maximum admissible stencil size (used for static memory allocation during assembly) | ||
425 | static constexpr int maxElementStencilSize = LocalView::maxNumElementScvfs*Traits::maxNumScvfNeighbors + 1; | ||
426 | |||
427 | //! Export the type of the grid view | ||
428 | using GridView = GV; | ||
429 | |||
430 | //! Constructor with basic grid geometry used to share state with another grid geometry on the same grid view | ||
431 | 303 | CCTpfaFVGridGeometry(std::shared_ptr<BasicGridGeometry> gg) | |
432 | : ParentType(std::move(gg)) | ||
433 |
2/4✗ Branch 0 not taken.
✓ Branch 1 taken 244 times.
✓ Branch 3 taken 63 times.
✗ Branch 4 not taken.
|
303 | , periodicGridTraits_(this->gridView().grid()) |
434 | { | ||
435 | // Check if the overlap size is what we expect | ||
436 |
2/2✓ Branch 1 taken 63 times.
✓ Branch 2 taken 186 times.
|
303 | if (!CheckOverlapSize<DiscretizationMethod>::isValid(this->gridView())) |
437 |
0/22✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
|
89 | DUNE_THROW(Dune::InvalidStateException, "The cctpfa discretization method needs at least an overlap of 1 for parallel computations. " |
438 | << " Set the parameter \"Grid.Overlap\" in the input file."); | ||
439 | |||
440 |
1/2✓ Branch 1 taken 249 times.
✗ Branch 2 not taken.
|
303 | update_(); |
441 | 303 | } | |
442 | |||
443 | //! Constructor from gridView | ||
444 | 300 | CCTpfaFVGridGeometry(const GridView& gridView) | |
445 |
1/2✓ Branch 1 taken 246 times.
✗ Branch 2 not taken.
|
300 | : CCTpfaFVGridGeometry(std::make_shared<BasicGridGeometry>(gridView)) |
446 | 300 | {} | |
447 | |||
448 | //! the element mapper is the dofMapper | ||
449 | //! this is convenience to have better chance to have the same main files for box/tpfa/mpfa... | ||
450 | 122 | const DofMapper& dofMapper() const | |
451 |
2/4✓ Branch 1 taken 121 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
122 | { return this->elementMapper(); } |
452 | |||
453 | //! The total number of sub control volumes | ||
454 | 4 | std::size_t numScv() const | |
455 | { | ||
456 |
2/5✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 0 not taken.
|
3 | return numScvs_; |
457 | } | ||
458 | |||
459 | //! The total number of sub control volume faces | ||
460 | 83 | std::size_t numScvf() const | |
461 | { | ||
462 |
3/6✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
80 | return numScvf_; |
463 | } | ||
464 | |||
465 | //! The total number of boundary sub control volume faces | ||
466 | std::size_t numBoundaryScvf() const | ||
467 | { | ||
468 | return numBoundaryScvf_; | ||
469 | } | ||
470 | |||
471 | //! The total number of degrees of freedom | ||
472 | 25004 | std::size_t numDofs() const | |
473 |
46/58✓ Branch 2 taken 382 times.
✓ Branch 3 taken 5 times.
✓ Branch 9 taken 21797 times.
✓ Branch 10 taken 119 times.
✓ Branch 11 taken 75 times.
✓ Branch 12 taken 21839 times.
✓ Branch 17 taken 25 times.
✓ Branch 18 taken 1200 times.
✓ Branch 20 taken 21 times.
✓ Branch 21 taken 9 times.
✓ Branch 23 taken 3 times.
✓ Branch 24 taken 22 times.
✓ Branch 28 taken 7 times.
✓ Branch 29 taken 1 times.
✓ Branch 31 taken 6 times.
✓ Branch 32 taken 1 times.
✓ Branch 34 taken 26 times.
✗ Branch 35 not taken.
✓ Branch 37 taken 3 times.
✗ Branch 38 not taken.
✓ Branch 14 taken 77 times.
✓ Branch 15 taken 1200 times.
✓ Branch 4 taken 253 times.
✓ Branch 5 taken 1 times.
✓ Branch 16 taken 38 times.
✓ Branch 19 taken 1 times.
✓ Branch 22 taken 3 times.
✓ Branch 8 taken 24 times.
✓ Branch 13 taken 104 times.
✓ Branch 26 taken 4 times.
✓ Branch 27 taken 42 times.
✓ Branch 30 taken 43 times.
✓ Branch 33 taken 18 times.
✓ Branch 25 taken 3 times.
✓ Branch 36 taken 19 times.
✓ Branch 39 taken 12 times.
✓ Branch 40 taken 1 times.
✓ Branch 42 taken 12 times.
✗ Branch 43 not taken.
✓ Branch 45 taken 12 times.
✗ Branch 46 not taken.
✓ Branch 7 taken 30 times.
✗ Branch 41 not taken.
✗ Branch 44 not taken.
✓ Branch 53 taken 1 times.
✗ Branch 54 not taken.
✓ Branch 56 taken 1 times.
✗ Branch 57 not taken.
✓ Branch 60 taken 1 times.
✗ Branch 61 not taken.
✓ Branch 63 taken 1 times.
✗ Branch 64 not taken.
✓ Branch 66 taken 1 times.
✗ Branch 67 not taken.
✓ Branch 70 taken 1 times.
✗ Branch 71 not taken.
✓ Branch 1 taken 251 times.
✓ Branch 6 taken 2 times.
|
24989 | { return this->gridView().size(0); } |
474 | |||
475 | //! update all fvElementGeometries (call this after grid adaption) | ||
476 | 4 | void update(const GridView& gridView) | |
477 | { | ||
478 | 4 | ParentType::update(gridView); | |
479 | 4 | update_(); | |
480 | } | ||
481 | |||
482 | //! update all fvElementGeometries (call this after grid adaption) | ||
483 | 11 | void update(GridView&& gridView) | |
484 | { | ||
485 | 11 | ParentType::update(std::move(gridView)); | |
486 | 11 | update_(); | |
487 | } | ||
488 | |||
489 | 66891248 | const std::vector<GridIndexType>& scvfIndicesOfScv(GridIndexType scvIdx) const | |
490 |
7/13✓ Branch 1 taken 7437236 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7661767 times.
✓ Branch 5 taken 1384 times.
✓ Branch 7 taken 131338 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 3486909 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1396 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 12002 times.
✗ Branch 17 not taken.
✗ Branch 6 not taken.
|
66891248 | { return scvfIndicesOfScv_[scvIdx]; } |
491 | |||
492 | //! Return the neighbor volVar indices for all scvfs in the scv with index scvIdx | ||
493 | 66885604 | const std::vector<NeighborVolVarIndices>& neighborVolVarIndices(GridIndexType scvIdx) const | |
494 |
7/13✓ Branch 1 taken 7437236 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7661767 times.
✓ Branch 5 taken 1384 times.
✓ Branch 7 taken 131338 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 3486909 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1396 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 12002 times.
✗ Branch 17 not taken.
✗ Branch 6 not taken.
|
66885604 | { return neighborVolVarIndices_[scvIdx]; } |
495 | |||
496 | /*! | ||
497 | * \brief Returns the connectivity map of which dofs have derivatives with respect | ||
498 | * to a given dof. | ||
499 | */ | ||
500 | 5811692 | const ConnectivityMap &connectivityMap() const | |
501 | 39230329 | { return connectivityMap_; } | |
502 | |||
503 | private: | ||
504 | |||
505 | 320 | void update_() | |
506 | { | ||
507 | // clear local data | ||
508 |
2/2✓ Branch 0 taken 15 times.
✓ Branch 1 taken 249 times.
|
320 | scvfIndicesOfScv_.clear(); |
509 |
2/2✓ Branch 0 taken 15 times.
✓ Branch 1 taken 249 times.
|
337 | neighborVolVarIndices_.clear(); |
510 | |||
511 | // reserve memory or resize the containers | ||
512 | 320 | numScvs_ = numDofs(); | |
513 | 320 | numScvf_ = 0; | |
514 | 320 | numBoundaryScvf_ = 0; | |
515 | 320 | scvfIndicesOfScv_.resize(numScvs_); | |
516 | 320 | neighborVolVarIndices_.resize(numScvs_); | |
517 | |||
518 | // Build the SCV and SCV face | ||
519 |
11/13✓ Branch 2 taken 56 times.
✓ Branch 3 taken 824 times.
✓ Branch 5 taken 296855 times.
✓ Branch 6 taken 71292 times.
✓ Branch 11 taken 161771 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 161770 times.
✓ Branch 14 taken 56 times.
✗ Branch 4 not taken.
✓ Branch 7 taken 70400 times.
✓ Branch 8 taken 5 times.
✓ Branch 9 taken 10001 times.
✓ Branch 10 taken 10000 times.
|
1590256 | for (const auto& element : elements(this->gridView())) |
520 | { | ||
521 |
3/5✓ Branch 1 taken 163786 times.
✓ Branch 2 taken 288982 times.
✓ Branch 4 taken 161770 times.
✗ Branch 5 not taken.
✗ Branch 3 not taken.
|
609469 | const auto eIdx = this->elementMapper().index(element); |
522 | |||
523 | // the element-wise index sets for finite volume geometry | ||
524 | 609469 | auto numLocalFaces = element.subEntities(1); | |
525 | 609469 | std::vector<GridIndexType> scvfsIndexSet; | |
526 | 609469 | std::vector<NeighborVolVarIndices> neighborVolVarIndexSet; | |
527 |
1/2✓ Branch 1 taken 539654 times.
✗ Branch 2 not taken.
|
609469 | scvfsIndexSet.reserve(numLocalFaces); |
528 |
1/2✓ Branch 1 taken 539654 times.
✗ Branch 2 not taken.
|
609469 | neighborVolVarIndexSet.reserve(numLocalFaces); |
529 | |||
530 | // for network grids there might be multiple intersection with the same geometryInInside | ||
531 | // we identify those by the indexInInside for now (assumes conforming grids at branching facets) | ||
532 | 609469 | std::vector<NeighborVolVarIndices> outsideIndices; | |
533 | if (dim < dimWorld) | ||
534 | { | ||
535 |
1/2✓ Branch 1 taken 12028 times.
✗ Branch 2 not taken.
|
21660 | outsideIndices.resize(numLocalFaces); |
536 |
7/9✓ Branch 1 taken 12028 times.
✗ Branch 2 not taken.
✓ Branch 6 taken 7094 times.
✓ Branch 7 taken 34440 times.
✓ Branch 8 taken 10512 times.
✓ Branch 9 taken 43050 times.
✓ Branch 10 taken 6950 times.
✓ Branch 11 taken 144 times.
✗ Branch 12 not taken.
|
299238 | for (const auto& intersection : intersections(this->gridView(), element)) |
537 | { | ||
538 |
2/2✓ Branch 0 taken 40626 times.
✓ Branch 1 taken 908 times.
|
78162 | if (intersection.neighbor()) |
539 | { | ||
540 |
4/7✓ Branch 1 taken 37768 times.
✓ Branch 2 taken 2858 times.
✓ Branch 4 taken 33676 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 33676 times.
✗ Branch 9 not taken.
✗ Branch 0 not taken.
|
76406 | const auto nIdx = this->elementMapper().index(intersection.outside()); |
541 |
1/2✓ Branch 1 taken 40626 times.
✗ Branch 2 not taken.
|
76406 | outsideIndices[intersection.indexInInside()].push_back(nIdx); |
542 | } | ||
543 | } | ||
544 | } | ||
545 | |||
546 |
13/15✓ Branch 1 taken 469254 times.
✓ Branch 2 taken 1410952 times.
✓ Branch 4 taken 1196732 times.
✓ Branch 5 taken 19696 times.
✓ Branch 7 taken 629775 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 850247 times.
✓ Branch 10 taken 6950 times.
✓ Branch 12 taken 51340 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 48704 times.
✓ Branch 15 taken 12176 times.
✓ Branch 11 taken 28292 times.
✓ Branch 3 taken 294098 times.
✓ Branch 6 taken 113450 times.
|
5893968 | for (const auto& intersection : intersections(this->gridView(), element)) |
547 | { | ||
548 | // inner sub control volume faces (includes periodic boundaries) | ||
549 |
2/3✓ Branch 0 taken 1009014 times.
✓ Branch 1 taken 14997 times.
✗ Branch 2 not taken.
|
1294399 | if (intersection.neighbor()) |
550 | { | ||
551 | // update the grid geometry if we have periodic boundaries | ||
552 |
2/3✓ Branch 1 taken 42426 times.
✓ Branch 2 taken 326728 times.
✗ Branch 0 not taken.
|
2378558 | if (periodicGridTraits_.isPeriodic(intersection)) |
553 | 1800 | this->setPeriodic(); | |
554 | |||
555 | if (dim == dimWorld) | ||
556 | { | ||
557 |
1/2✓ Branch 1 taken 2069116 times.
✗ Branch 2 not taken.
|
2302152 | scvfsIndexSet.push_back(numScvf_++); |
558 |
2/4✓ Branch 1 taken 677584 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 637784 times.
✗ Branch 5 not taken.
|
2302152 | const auto nIdx = this->elementMapper().index(intersection.outside()); |
559 |
1/2✓ Branch 2 taken 2069116 times.
✗ Branch 3 not taken.
|
2302152 | neighborVolVarIndexSet.emplace_back(NeighborVolVarIndices({nIdx})); |
560 | } | ||
561 | // this is for network grids | ||
562 | // (will be optimized away of dim == dimWorld) | ||
563 | else | ||
564 | { | ||
565 | 76406 | auto indexInInside = intersection.indexInInside(); | |
566 | // check if we already handled this facet | ||
567 |
2/2✓ Branch 0 taken 170 times.
✓ Branch 1 taken 40456 times.
|
76406 | if (outsideIndices[indexInInside].empty()) |
568 | 226 | continue; | |
569 | else | ||
570 | { | ||
571 |
1/2✓ Branch 1 taken 40456 times.
✗ Branch 2 not taken.
|
76180 | scvfsIndexSet.push_back(numScvf_++); |
572 |
1/2✓ Branch 1 taken 40456 times.
✗ Branch 2 not taken.
|
76180 | neighborVolVarIndexSet.emplace_back(std::move(outsideIndices[indexInInside])); |
573 |
2/4✗ Branch 0 not taken.
✓ Branch 1 taken 40456 times.
✓ Branch 3 taken 41534 times.
✗ Branch 4 not taken.
|
78162 | outsideIndices[indexInInside].clear(); |
574 | } | ||
575 | } | ||
576 | } | ||
577 | // boundary sub control volume faces | ||
578 |
2/3✓ Branch 0 taken 29677 times.
✓ Branch 1 taken 31248 times.
✗ Branch 2 not taken.
|
67125 | else if (intersection.boundary()) |
579 | { | ||
580 |
2/4✓ Branch 1 taken 32849 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 908 times.
✗ Branch 5 not taken.
|
38481 | scvfsIndexSet.push_back(numScvf_++); |
581 |
3/5✓ Branch 2 taken 31941 times.
✗ Branch 3 not taken.
✓ Branch 1 taken 908 times.
✓ Branch 4 taken 908 times.
✗ Branch 5 not taken.
|
38481 | neighborVolVarIndexSet.emplace_back(NeighborVolVarIndices({static_cast<GridIndexType>(numScvs_ + numBoundaryScvf_++)})); |
582 | } | ||
583 | } | ||
584 | |||
585 | // store the sets of indices in the data container | ||
586 |
1/2✓ Branch 1 taken 539654 times.
✗ Branch 2 not taken.
|
609469 | scvfIndicesOfScv_[eIdx] = scvfsIndexSet; |
587 |
1/2✓ Branch 1 taken 539654 times.
✗ Branch 2 not taken.
|
609469 | neighborVolVarIndices_[eIdx] = neighborVolVarIndexSet; |
588 | } | ||
589 | |||
590 | // build the connectivity map for an efficient assembly | ||
591 | 320 | connectivityMap_.update(*this); | |
592 | 320 | } | |
593 | |||
594 | //! Information on the global number of geometries | ||
595 | std::size_t numScvs_; | ||
596 | std::size_t numScvf_; | ||
597 | std::size_t numBoundaryScvf_; | ||
598 | |||
599 | //! connectivity map for efficient assembly | ||
600 | ConnectivityMap connectivityMap_; | ||
601 | |||
602 | //! vectors that store the global data | ||
603 | std::vector<std::vector<GridIndexType>> scvfIndicesOfScv_; | ||
604 | std::vector<std::vector<NeighborVolVarIndices>> neighborVolVarIndices_; | ||
605 | |||
606 | PeriodicGridTraits<typename GridView::Grid> periodicGridTraits_; | ||
607 | }; | ||
608 | |||
609 | } // end namespace Dumux | ||
610 | |||
611 | #endif | ||
612 |