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