Line | Branch | Exec | Source |
---|---|---|---|
1 | // -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | ||
2 | // vi: set et ts=4 sw=4 sts=4: | ||
3 | // | ||
4 | // SPDX-FileCopyrightText: Copyright © DuMux Project contributors, see AUTHORS.md in root folder | ||
5 | // SPDX-License-Identifier: GPL-3.0-or-later | ||
6 | // | ||
7 | /*! | ||
8 | * \file | ||
9 | * \ingroup CCMpfaDiscretization | ||
10 | * \brief The sub control volume face | ||
11 | */ | ||
12 | #ifndef DUMUX_DISCRETIZATION_CC_MPFA_SUBCONTROLVOLUMEFACE_HH | ||
13 | #define DUMUX_DISCRETIZATION_CC_MPFA_SUBCONTROLVOLUMEFACE_HH | ||
14 | |||
15 | #include <utility> | ||
16 | #include <vector> | ||
17 | #include <array> | ||
18 | |||
19 | #include <dune/common/reservedvector.hh> | ||
20 | #include <dune/common/fvector.hh> | ||
21 | #include <dune/geometry/type.hh> | ||
22 | #include <dune/geometry/multilineargeometry.hh> | ||
23 | |||
24 | #include <dumux/common/indextraits.hh> | ||
25 | #include <dumux/common/boundaryflag.hh> | ||
26 | |||
27 | namespace Dumux { | ||
28 | |||
29 | /*! | ||
30 | * \ingroup CCMpfaDiscretization | ||
31 | * \brief Default traits class to be used for the sub-control volume faces | ||
32 | * for the cell-centered finite volume scheme using MPFA | ||
33 | * \tparam GV the type of the grid view | ||
34 | */ | ||
35 | template<class GridView> | ||
36 | struct CCMpfaDefaultScvfGeometryTraits | ||
37 | { | ||
38 | using Grid = typename GridView::Grid; | ||
39 | |||
40 | static const int dim = Grid::dimension; | ||
41 | static const int dimWorld = Grid::dimensionworld; | ||
42 | |||
43 | using Scalar = typename Grid::ctype; | ||
44 | using GridIndexType = typename IndexTraits<GridView>::GridIndex; | ||
45 | using LocalIndexType = typename IndexTraits<GridView>::LocalIndex; | ||
46 | using OutsideGridIndexStorage = typename std::conditional_t< (dim<dimWorld), | ||
47 | std::vector<GridIndexType>, | ||
48 | Dune::ReservedVector<GridIndexType, 1> >; | ||
49 | |||
50 | // we use geometry traits that use static corner vectors to and a fixed geometry type | ||
51 | template <class ct> | ||
52 | struct ScvfMLGTraits : public Dune::MultiLinearGeometryTraits<ct> | ||
53 | { | ||
54 | // we use static vectors to store the corners as we know | ||
55 | // the number of corners in advance (2^(dim-1) corners (1<<(dim-1)) | ||
56 | template< int mydim, int cdim > | ||
57 | struct CornerStorage | ||
58 | { | ||
59 | using Type = std::array< Dune::FieldVector< ct, cdim >, (1<<(dim-1)) >; | ||
60 | }; | ||
61 | |||
62 | // we know all scvfs will have the same geometry type | ||
63 | template< int dim > | ||
64 | struct hasSingleGeometryType | ||
65 | { | ||
66 | static const bool v = true; | ||
67 | static const unsigned int topologyId = Dune::GeometryTypes::cube(dim).id(); | ||
68 | }; | ||
69 | }; | ||
70 | |||
71 | using Geometry = Dune::MultiLinearGeometry<Scalar, dim-1, dimWorld, ScvfMLGTraits<Scalar> >; | ||
72 | using CornerStorage = typename ScvfMLGTraits<Scalar>::template CornerStorage<dim-1, dimWorld>::Type; | ||
73 | using GlobalPosition = typename CornerStorage::value_type; | ||
74 | using BoundaryFlag = Dumux::BoundaryFlag<Grid>; | ||
75 | }; | ||
76 | |||
77 | /*! | ||
78 | * \ingroup CCMpfaDiscretization | ||
79 | * \brief Class for a sub control volume face in mpfa methods, i.e a part of the boundary | ||
80 | * of a control volume we compute fluxes on. | ||
81 | * \tparam GV the type of the grid view | ||
82 | * \tparam T the scvf geometry traits | ||
83 | */ | ||
84 | template<class GV, | ||
85 | class T = CCMpfaDefaultScvfGeometryTraits<GV> > | ||
86 | 4287188 | class CCMpfaSubControlVolumeFace | |
87 | { | ||
88 | using GridIndexType = typename T::GridIndexType; | ||
89 | using Scalar = typename T::Scalar; | ||
90 | using CornerStorage = typename T::CornerStorage; | ||
91 | using OutsideGridIndexStorage = typename T::OutsideGridIndexStorage; | ||
92 | using Geometry = typename T::Geometry; | ||
93 | using BoundaryFlag = typename T::BoundaryFlag; | ||
94 | |||
95 | public: | ||
96 | // Information on the intersection from which this scvf was constructed | ||
97 | struct FacetInfo | ||
98 | { | ||
99 | GridIndexType elementIndex; | ||
100 | int facetIndex; | ||
101 | int facetCornerIndex; | ||
102 | }; | ||
103 | |||
104 | //! export the type used for global coordinates | ||
105 | using GlobalPosition = typename T::GlobalPosition; | ||
106 | //! state the traits public and thus export all types | ||
107 | using Traits = T; | ||
108 | |||
109 | /*! | ||
110 | * \brief Constructor | ||
111 | * | ||
112 | * \param helper The helper class for mpfa schemes | ||
113 | * \param corners The corners of the scv face | ||
114 | * \param intersection The intersection | ||
115 | * \param facetInfo Information on the facet from which this scvf is constructed | ||
116 | * \param vIdxGlobal The global vertex index the scvf is connected to | ||
117 | * \param vIdxLocal The element-local vertex index the scvf is connected to | ||
118 | * \param scvfIndex The global index of this scv face | ||
119 | * \param insideScvIdx The inside scv index connected to this face | ||
120 | * \param outsideScvIndices The outside scv indices connected to this face | ||
121 | * \param q The parameterization of the quadrature point on the scvf for flux calculation | ||
122 | * \param boundary Boolean to specify whether or not the scvf is on a boundary | ||
123 | */ | ||
124 | //! Construction with given intersection | ||
125 | template<class MpfaHelper, class Intersection> | ||
126 | 53048760 | CCMpfaSubControlVolumeFace(const MpfaHelper& helper, | |
127 | CornerStorage&& corners, | ||
128 | const Intersection& intersection, | ||
129 | FacetInfo facetInfo, | ||
130 | GridIndexType vIdxGlobal, | ||
131 | unsigned int vIdxLocal, | ||
132 | GridIndexType scvfIndex, | ||
133 | GridIndexType insideScvIdx, | ||
134 | const OutsideGridIndexStorage& outsideScvIndices, | ||
135 | Scalar q, | ||
136 | bool boundary) | ||
137 | 53048760 | : boundary_(boundary) | |
138 | 53048760 | , vertexIndex_(vIdxGlobal) | |
139 | 53048760 | , scvfIndex_(scvfIndex) | |
140 | 53048760 | , insideScvIdx_(insideScvIdx) | |
141 | 53048760 | , outsideScvIndices_(outsideScvIndices) | |
142 | 53048760 | , vIdxInElement_(vIdxLocal) | |
143 | 53048760 | , center_(0.0) | |
144 | 53048760 | , unitOuterNormal_(intersection.centerUnitOuterNormal()) | |
145 |
2/3✓ Branch 1 taken 4285920 times.
✗ Branch 2 not taken.
✓ Branch 0 taken 1268 times.
|
53048760 | , boundaryFlag_{intersection} |
146 |
2/3✓ Branch 0 taken 2120716 times.
✓ Branch 1 taken 6407904 times.
✗ Branch 2 not taken.
|
53048760 | , facetInfo_{std::move(facetInfo)} |
147 | { | ||
148 | // compute the center of the scvf | ||
149 |
2/2✓ Branch 0 taken 106121088 times.
✓ Branch 1 taken 53048760 times.
|
159169848 | for (const auto& corner : corners) |
150 |
2/2✓ Branch 0 taken 220863688 times.
✓ Branch 1 taken 106121088 times.
|
326984776 | center_ += corner; |
151 |
2/2✓ Branch 0 taken 110396492 times.
✓ Branch 1 taken 53048760 times.
|
163445252 | center_ /= corners.size(); |
152 | |||
153 | // use helper class to obtain area & integration point | ||
154 | 53048760 | ipGlobal_ = helper.getScvfIntegrationPoint(corners, q); | |
155 | 53048760 | area_ = helper.computeScvfArea(corners); | |
156 | 53048760 | } | |
157 | |||
158 | //! The area of the sub control volume face | ||
159 | 1035421627 | Scalar area() const | |
160 |
3/4✓ Branch 0 taken 261828 times.
✓ Branch 1 taken 16632 times.
✓ Branch 2 taken 471286 times.
✗ Branch 3 not taken.
|
782692749 | { return area_; } |
161 | |||
162 | //! returns true if the sub control volume face is on the domain boundary | ||
163 | 1299537503 | bool boundary() const | |
164 |
39/40✓ Branch 0 taken 27134742 times.
✓ Branch 1 taken 302928 times.
✓ Branch 2 taken 14331401 times.
✓ Branch 3 taken 588640 times.
✓ Branch 4 taken 324333430 times.
✓ Branch 5 taken 2475512 times.
✓ Branch 6 taken 119408276 times.
✓ Branch 7 taken 3516152 times.
✓ Branch 8 taken 78361026 times.
✓ Branch 9 taken 140429348 times.
✓ Branch 10 taken 17272868 times.
✓ Branch 11 taken 22577766 times.
✓ Branch 12 taken 17808852 times.
✓ Branch 13 taken 159361748 times.
✓ Branch 14 taken 24045676 times.
✓ Branch 15 taken 154604758 times.
✓ Branch 16 taken 13697104 times.
✓ Branch 17 taken 65700569 times.
✓ Branch 18 taken 13037828 times.
✓ Branch 19 taken 5748548 times.
✓ Branch 20 taken 14576584 times.
✓ Branch 21 taken 3847574 times.
✓ Branch 22 taken 4278120 times.
✓ Branch 23 taken 2095268 times.
✓ Branch 24 taken 1287783 times.
✓ Branch 25 taken 54931416 times.
✓ Branch 26 taken 852330 times.
✓ Branch 27 taken 724372 times.
✓ Branch 28 taken 9962928 times.
✓ Branch 29 taken 750994 times.
✓ Branch 30 taken 44274 times.
✓ Branch 31 taken 19160 times.
✓ Branch 32 taken 25344 times.
✓ Branch 33 taken 6 times.
✓ Branch 34 taken 59344 times.
✓ Branch 35 taken 1250594 times.
✓ Branch 36 taken 69608 times.
✓ Branch 37 taken 24408 times.
✓ Branch 38 taken 224 times.
✗ Branch 39 not taken.
|
1299537503 | { return boundary_; } |
165 | |||
166 | //! The global index of this sub control volume face | ||
167 | 2134943417 | GridIndexType index() const | |
168 |
56/64✓ Branch 0 taken 257081248 times.
✓ Branch 1 taken 281320184 times.
✓ Branch 3 taken 13733452 times.
✓ Branch 4 taken 16467234 times.
✓ Branch 9 taken 1887017 times.
✓ Branch 10 taken 21007940 times.
✓ Branch 12 taken 270292 times.
✓ Branch 13 taken 1804052 times.
✓ Branch 15 taken 3260474 times.
✓ Branch 16 taken 59267421 times.
✓ Branch 18 taken 38976312 times.
✓ Branch 19 taken 2436276 times.
✓ Branch 25 taken 84863924 times.
✓ Branch 26 taken 422380 times.
✓ Branch 28 taken 792855 times.
✓ Branch 29 taken 6973984 times.
✓ Branch 31 taken 2070 times.
✓ Branch 32 taken 41878 times.
✓ Branch 35 taken 1612522 times.
✓ Branch 36 taken 262098 times.
✓ Branch 38 taken 45370 times.
✓ Branch 39 taken 1325088 times.
✓ Branch 42 taken 1362190 times.
✗ Branch 43 not taken.
✓ Branch 45 taken 424428 times.
✓ Branch 46 taken 10094064 times.
✓ Branch 48 taken 138512 times.
✓ Branch 49 taken 11112 times.
✓ Branch 51 taken 400 times.
✓ Branch 52 taken 16566 times.
✓ Branch 54 taken 272 times.
✓ Branch 55 taken 56 times.
✓ Branch 2 taken 12951208 times.
✓ Branch 6 taken 9721308 times.
✓ Branch 7 taken 6731521 times.
✓ Branch 17 taken 993302 times.
✓ Branch 20 taken 111887100 times.
✓ Branch 23 taken 1512082 times.
✓ Branch 24 taken 73466074 times.
✓ Branch 27 taken 32073 times.
✓ Branch 30 taken 1240496 times.
✓ Branch 33 taken 1304568 times.
✓ Branch 5 taken 5490678 times.
✓ Branch 8 taken 493148 times.
✓ Branch 11 taken 6204460 times.
✓ Branch 14 taken 13903830 times.
✓ Branch 21 taken 8770432 times.
✗ Branch 34 not taken.
✓ Branch 37 taken 409442 times.
✓ Branch 40 taken 90132 times.
✓ Branch 41 taken 2625516 times.
✓ Branch 44 taken 17744 times.
✓ Branch 47 taken 5504 times.
✓ Branch 50 taken 56 times.
✗ Branch 53 not taken.
✓ Branch 56 taken 456 times.
✗ Branch 57 not taken.
✓ Branch 22 taken 24152784 times.
✗ Branch 58 not taken.
✗ Branch 59 not taken.
✓ Branch 61 taken 56 times.
✓ Branch 62 taken 400 times.
✗ Branch 60 not taken.
✗ Branch 63 not taken.
|
2102559006 | { return scvfIndex_; } |
169 | |||
170 | //! Returns the index of the vertex the scvf is connected to | ||
171 | 12693657 | GridIndexType vertexIndex() const | |
172 |
25/26✓ Branch 0 taken 522267467 times.
✓ Branch 1 taken 27362247 times.
✓ Branch 2 taken 7079389 times.
✓ Branch 3 taken 3496239 times.
✓ Branch 4 taken 4958498 times.
✓ Branch 5 taken 1542603 times.
✓ Branch 6 taken 57328 times.
✓ Branch 7 taken 71886 times.
✓ Branch 8 taken 14155574 times.
✓ Branch 9 taken 1101746 times.
✓ Branch 10 taken 42660606 times.
✓ Branch 11 taken 21747210 times.
✓ Branch 12 taken 2512744 times.
✓ Branch 13 taken 110640303 times.
✓ Branch 14 taken 15421863 times.
✓ Branch 15 taken 25088488 times.
✓ Branch 16 taken 1152205 times.
✓ Branch 17 taken 10892691 times.
✓ Branch 18 taken 6957000 times.
✓ Branch 19 taken 822712 times.
✓ Branch 20 taken 168376 times.
✓ Branch 21 taken 19048 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 116963 times.
✓ Branch 24 taken 56504 times.
✓ Branch 25 taken 935704 times.
|
1658471151 | { return vertexIndex_; } |
173 | |||
174 | //! Returns the element-local vertex index the scvf is connected to | ||
175 | unsigned int vertexIndexInElement() const | ||
176 | { return vIdxInElement_; } | ||
177 | |||
178 | //! index of the inside sub control volume | ||
179 | 1347813292 | GridIndexType insideScvIdx() const | |
180 |
22/26✓ Branch 2 taken 963448 times.
✓ Branch 3 taken 1310400 times.
✓ Branch 4 taken 3992768 times.
✓ Branch 5 taken 3678736 times.
✓ Branch 7 taken 634872 times.
✓ Branch 8 taken 596864 times.
✓ Branch 9 taken 1238971 times.
✓ Branch 10 taken 2709653 times.
✓ Branch 11 taken 474552 times.
✓ Branch 12 taken 9266056 times.
✓ Branch 13 taken 3467711 times.
✓ Branch 14 taken 3310908 times.
✓ Branch 16 taken 18333000 times.
✓ Branch 17 taken 1946552 times.
✓ Branch 19 taken 18333000 times.
✗ Branch 20 not taken.
✓ Branch 23 taken 1120 times.
✓ Branch 24 taken 2464 times.
✓ Branch 27 taken 146664 times.
✗ Branch 28 not taken.
✓ Branch 30 taken 146664 times.
✗ Branch 31 not taken.
✓ Branch 1 taken 344 times.
✓ Branch 6 taken 1799052 times.
✓ Branch 15 taken 3114368 times.
✗ Branch 18 not taken.
|
1440064860 | { return insideScvIdx_; } |
181 | |||
182 | //! The number of scvs on the outside of this scv face | ||
183 | 979676568 | std::size_t numOutsideScvs() const | |
184 |
15/16✓ Branch 0 taken 163091555 times.
✓ Branch 1 taken 173093411 times.
✓ Branch 2 taken 133815396 times.
✓ Branch 3 taken 134991916 times.
✓ Branch 4 taken 288126890 times.
✓ Branch 5 taken 32515658 times.
✓ Branch 6 taken 17625120 times.
✓ Branch 7 taken 12460696 times.
✓ Branch 8 taken 8787414 times.
✓ Branch 9 taken 8828014 times.
✓ Branch 10 taken 26144 times.
✓ Branch 11 taken 100580334 times.
✓ Branch 12 taken 79292974 times.
✓ Branch 13 taken 1354702 times.
✓ Branch 14 taken 1313786 times.
✗ Branch 15 not taken.
|
1398879788 | { return outsideScvIndices_.size(); } |
185 | |||
186 | //! Index of the i-th outside sub control volume or boundary scv index. | ||
187 | // Results in undefined behaviour if i >= numOutsideScvs() | ||
188 | 895288236 | GridIndexType outsideScvIdx(int i = 0) const | |
189 |
10/12✓ Branch 3 taken 3764 times.
✓ Branch 4 taken 13552 times.
✓ Branch 6 taken 390542 times.
✓ Branch 7 taken 38552 times.
✓ Branch 9 taken 93916 times.
✓ Branch 10 taken 30196 times.
✓ Branch 5 taken 245506 times.
✓ Branch 8 taken 24412 times.
✓ Branch 11 taken 10192 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 12776 times.
✗ Branch 14 not taken.
|
895288236 | { return outsideScvIndices_[i]; } |
190 | |||
191 | //! returns the outside scv indices (can be more than one index for dim < dimWorld) | ||
192 | const OutsideGridIndexStorage& outsideScvIndices() const | ||
193 |
2/2✓ Branch 0 taken 126573 times.
✓ Branch 1 taken 241928 times.
|
645110389 | { return outsideScvIndices_; } |
194 | |||
195 | //! The center of the sub control volume face | ||
196 | 39700000 | const GlobalPosition& center() const | |
197 |
4/4✓ Branch 0 taken 15605800 times.
✓ Branch 1 taken 23894200 times.
✓ Branch 2 taken 80000 times.
✓ Branch 3 taken 120000 times.
|
39700768 | { return center_; } |
198 | |||
199 | //! The integration point for flux evaluations in global coordinates | ||
200 | 76078886 | const GlobalPosition& ipGlobal() const | |
201 |
28/28✓ Branch 0 taken 50924 times.
✓ Branch 1 taken 866472 times.
✓ Branch 2 taken 172052 times.
✓ Branch 3 taken 54126 times.
✓ Branch 4 taken 1809460 times.
✓ Branch 5 taken 5654678 times.
✓ Branch 6 taken 3400856 times.
✓ Branch 7 taken 9393148 times.
✓ Branch 9 taken 4261652 times.
✓ Branch 10 taken 631184 times.
✓ Branch 11 taken 1840896 times.
✓ Branch 12 taken 2314201 times.
✓ Branch 14 taken 416680 times.
✓ Branch 15 taken 16650 times.
✓ Branch 16 taken 270468 times.
✓ Branch 17 taken 1326348 times.
✓ Branch 18 taken 11902 times.
✓ Branch 19 taken 372392 times.
✓ Branch 20 taken 380 times.
✓ Branch 21 taken 140096 times.
✓ Branch 22 taken 679824 times.
✓ Branch 23 taken 440 times.
✓ Branch 24 taken 40 times.
✓ Branch 25 taken 80 times.
✓ Branch 26 taken 30 times.
✓ Branch 27 taken 106 times.
✓ Branch 8 taken 774268 times.
✓ Branch 13 taken 2095121 times.
|
254106804 | { return ipGlobal_; } |
202 | |||
203 | //! returns the unit outer normal vector (assumes non-curved geometries) | ||
204 | 6108160 | const GlobalPosition& unitOuterNormal() const | |
205 |
4/4✓ Branch 0 taken 15605800 times.
✓ Branch 1 taken 23894200 times.
✓ Branch 2 taken 80000 times.
✓ Branch 3 taken 120000 times.
|
1380614782 | { return unitOuterNormal_; } |
206 | |||
207 | //! Return the boundary flag | ||
208 | 2935050 | typename BoundaryFlag::value_type boundaryFlag() const | |
209 |
4/6✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 32706 times.
✓ Branch 3 taken 1306848 times.
✓ Branch 4 taken 32706 times.
✓ Branch 5 taken 1562790 times.
|
2935050 | { return boundaryFlag_.get(); } |
210 | |||
211 | //! Return information on the facet from which this scvf was constructed | ||
212 | const FacetInfo& facetInfo() const | ||
213 | 1310 | { return facetInfo_; } | |
214 | |||
215 | private: | ||
216 | bool boundary_; | ||
217 | GridIndexType vertexIndex_; | ||
218 | GridIndexType scvfIndex_; | ||
219 | GridIndexType insideScvIdx_; | ||
220 | OutsideGridIndexStorage outsideScvIndices_; | ||
221 | unsigned int vIdxInElement_; | ||
222 | |||
223 | GlobalPosition center_; | ||
224 | GlobalPosition ipGlobal_; | ||
225 | GlobalPosition unitOuterNormal_; | ||
226 | Scalar area_; | ||
227 | BoundaryFlag boundaryFlag_; | ||
228 | FacetInfo facetInfo_; | ||
229 | }; | ||
230 | |||
231 | } // end namespace Dumux | ||
232 | |||
233 | #endif | ||
234 |