GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/discretization/cellcentered/mpfa/subcontrolvolumeface.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 17 27 63.0%
Functions: 14 52 26.9%
Branches: 67 98 68.4%

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 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
2/22
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ 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 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 41868 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✓ Branch 20 taken 2776896 times.
✗ Branch 21 not taken.
5637528 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 51749848 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 : boundary_(boundary)
138 , vertexIndex_(vIdxGlobal)
139 , scvfIndex_(scvfIndex)
140 , insideScvIdx_(insideScvIdx)
141 , outsideScvIndices_(outsideScvIndices)
142 , vIdxInElement_(vIdxLocal)
143 , center_(0.0)
144 , unitOuterNormal_(intersection.centerUnitOuterNormal())
145 , boundaryFlag_{intersection}
146
4/9
✓ Branch 2 taken 3028348 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 3028348 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1268 times.
✓ Branch 8 taken 3027080 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
159490976 , facetInfo_{std::move(facetInfo)}
147 {
148 // compute the center of the scvf
149
2/2
✓ Branch 0 taken 103523264 times.
✓ Branch 1 taken 51749848 times.
258772808 for (const auto& corner : corners)
150 103523264 center_ += corner;
151 51749848 center_ /= corners.size();
152
153 // use helper class to obtain area & integration point
154 51749848 ipGlobal_ = helper.getScvfIntegrationPoint(corners, q);
155 51749848 area_ = helper.computeScvfArea(corners);
156 51749848 }
157
158 //! The area of the sub control volume face
159 Scalar area() const
160 { return area_; }
161
162 //! returns true if the sub control volume face is on the domain boundary
163 bool boundary() const
164 { return boundary_; }
165
166 //! The global index of this sub control volume face
167 GridIndexType index() const
168 { return scvfIndex_; }
169
170 //! Returns the index of the vertex the scvf is connected to
171 GridIndexType vertexIndex() const
172 { 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 GridIndexType insideScvIdx() const
180 { return insideScvIdx_; }
181
182 //! The number of scvs on the outside of this scv face
183 std::size_t numOutsideScvs() const
184
15/16
✓ Branch 0 taken 163013187 times.
✓ Branch 1 taken 168146883 times.
✓ Branch 2 taken 133737028 times.
✓ Branch 3 taken 134913548 times.
✓ Branch 4 taken 283875280 times.
✓ Branch 5 taken 28264048 times.
✓ Branch 6 taken 13295142 times.
✓ Branch 7 taken 8130718 times.
✓ Branch 8 taken 4535804 times.
✓ Branch 9 taken 4576404 times.
✓ Branch 10 taken 26144 times.
✓ Branch 11 taken 90844014 times.
✓ Branch 12 taken 79292974 times.
✓ Branch 13 taken 1354702 times.
✓ Branch 14 taken 1313786 times.
✗ Branch 15 not taken.
1345531480 { 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 GridIndexType outsideScvIdx(int i = 0) const
189
15/18
✓ Branch 5 taken 5124 times.
✓ Branch 6 taken 7992 times.
✓ Branch 7 taken 305456 times.
✓ Branch 8 taken 380428 times.
✓ Branch 9 taken 122766 times.
✓ Branch 10 taken 305456 times.
✓ Branch 11 taken 8814 times.
✓ Branch 12 taken 114858 times.
✓ Branch 13 taken 8880 times.
✓ Branch 14 taken 8814 times.
✓ Branch 15 taken 11880 times.
✓ Branch 16 taken 8880 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 11880 times.
✓ Branch 19 taken 380 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 380 times.
✗ Branch 23 not taken.
1472684834 { 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 105507 times.
✓ Branch 1 taken 200196 times.
634798357 { return outsideScvIndices_; }
194
195 //! The center of the sub control volume face
196 const GlobalPosition& center() const
197
2/2
✓ Branch 0 taken 15685800 times.
✓ Branch 1 taken 24014200 times.
39700768 { return center_; }
198
199 //! The integration point for flux evaluations in global coordinates
200 const GlobalPosition& ipGlobal() const
201
24/25
✓ Branch 0 taken 50400 times.
✓ Branch 1 taken 853652 times.
✓ Branch 2 taken 1785122 times.
✓ Branch 3 taken 6724152 times.
✓ Branch 4 taken 5781994 times.
✓ Branch 5 taken 179544 times.
✓ Branch 6 taken 1217520 times.
✓ Branch 7 taken 706752 times.
✓ Branch 8 taken 61188 times.
✓ Branch 9 taken 246292 times.
✓ Branch 10 taken 23632 times.
✓ Branch 11 taken 363972 times.
✓ Branch 12 taken 160914 times.
✓ Branch 13 taken 27864 times.
✓ Branch 14 taken 8018 times.
✓ Branch 15 taken 14008 times.
✓ Branch 16 taken 19554 times.
✓ Branch 17 taken 5404 times.
✓ Branch 18 taken 5124 times.
✓ Branch 19 taken 23520 times.
✓ Branch 20 taken 4588 times.
✓ Branch 21 taken 7252 times.
✓ Branch 22 taken 7292 times.
✓ Branch 23 taken 80 times.
✗ Branch 24 not taken.
249107544 { return ipGlobal_; }
202
203 //! returns the unit outer normal vector (assumes non-curved geometries)
204 const GlobalPosition& unitOuterNormal() const
205 1289312426 { return unitOuterNormal_; }
206
207 //! Return the boundary flag
208 typename BoundaryFlag::value_type boundaryFlag() const
209
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2099862 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