GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: dumux/dumux/discretization/box/subcontrolvolumeface.hh
Date: 2025-06-14 19:21:29
Exec Total Coverage
Lines: 41 41 100.0%
Functions: 37 37 100.0%
Branches: 107 154 69.5%

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 BoxDiscretization
10 * \brief Base class for a sub control volume face
11 */
12 #ifndef DUMUX_DISCRETIZATION_BOX_SUBCONTROLVOLUMEFACE_HH
13 #define DUMUX_DISCRETIZATION_BOX_SUBCONTROLVOLUMEFACE_HH
14
15 #include <utility>
16
17 #include <dune/geometry/type.hh>
18 #include <dune/geometry/multilineargeometry.hh>
19
20 #include <dumux/common/boundaryflag.hh>
21 #include <dumux/common/indextraits.hh>
22 #include <dumux/geometry/volume.hh>
23 #include <dumux/geometry/center.hh>
24 #include <dumux/discretization/box/boxgeometryhelper.hh>
25
26 namespace Dumux {
27
28 /*!
29 * \ingroup BoxDiscretization
30 * \brief Default traits class to be used for the sub-control volume faces
31 * for the box scheme
32 * \tparam GV the type of the grid view
33 */
34 template<class GridView>
35 struct BoxDefaultScvfGeometryTraits
36 {
37 using Grid = typename GridView::Grid;
38 static constexpr int dim = Grid::dimension;
39 static constexpr int dimWorld = Grid::dimensionworld;
40 using GridIndexType = typename IndexTraits<GridView>::GridIndex;
41 using LocalIndexType = typename IndexTraits<GridView>::LocalIndex;
42 using Scalar = typename Grid::ctype;
43 using GeometryTraits = BoxMLGeometryTraits<Scalar>;
44 using Geometry = Dune::MultiLinearGeometry<Scalar, dim-1, dimWorld, GeometryTraits>;
45 using CornerStorage = typename GeometryTraits::template CornerStorage<dim-1, dimWorld>::Type;
46 using GlobalPosition = typename Geometry::GlobalCoordinate;
47 using BoundaryFlag = Dumux::BoundaryFlag<Grid>;
48 };
49
50 /*!
51 * \ingroup BoxDiscretization
52 * \brief Class for a sub control volume face in the box method, i.e a part of the boundary
53 * of a sub control volume we compute fluxes on. We simply use the base class here.
54 * \tparam GV the type of the grid view
55 * \tparam T the scvf geometry traits
56 */
57 template<class GV,
58 class T = BoxDefaultScvfGeometryTraits<GV> >
59
12/28
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7776 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 10824 times.
✓ Branch 6 taken 320 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 17152 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 56922 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 17 not taken.
✓ Branch 18 taken 256 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 256 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 13824 times.
✗ Branch 23 not taken.
✓ Branch 24 taken 13824 times.
✗ Branch 25 not taken.
✓ Branch 26 taken 51492 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 51492 times.
50287732 class BoxSubControlVolumeFace
60 {
61 using ThisType = BoxSubControlVolumeFace<GV, T>;
62 using GridIndexType = typename T::GridIndexType;
63 using LocalIndexType = typename T::LocalIndexType;
64 using Scalar = typename T::Scalar;
65 using Geometry = typename T::Geometry;
66 using BoundaryFlag = typename T::BoundaryFlag;
67 static constexpr int dim = Geometry::mydimension;
68
69 public:
70 //! export the type used for global coordinates
71 using GlobalPosition = typename T::GlobalPosition;
72 //! state the traits public and thus export all types
73 using Traits = T;
74
75 //! The default constructor
76 16613613 BoxSubControlVolumeFace() = default;
77
78 //! Constructor for inner scvfs
79 template<class Corners, class Element>
80 27923881 BoxSubControlVolumeFace(const Corners& corners,
81 const GlobalPosition& normal,
82 const Element& element,
83 const typename Element::Geometry& elemGeometry,
84 GridIndexType scvfIndex,
85 std::vector<LocalIndexType>&& scvIndices,
86 bool boundary = false)
87 27923881 : center_(Dumux::center(corners))
88 27923881 , unitOuterNormal_(normal)
89 27923881 , scvfIndex_(scvfIndex)
90 27923881 , scvIndices_(std::move(scvIndices))
91 27923881 , boundary_(boundary)
92 27923881 , boundaryFlag_{}
93 {
94 53015820 area_ = Dumux::convexPolytopeVolume<dim>(
95 Dune::GeometryTypes::cube(dim),
96 53862476 [&](unsigned int i){ return corners[i]; }
97 );
98 25256555 }
99
100 //! Constructor for boundary scvfs
101 template<class Corners, class Intersection>
102 3041575 BoxSubControlVolumeFace(const Corners& corners,
103 const GlobalPosition& normal,
104 const Intersection& intersection,
105 const typename Intersection::Geometry& isGeometry,
106 LocalIndexType indexInIntersection,
107 GridIndexType scvfIndex,
108 std::vector<LocalIndexType>&& scvIndices,
109 bool boundary = false)
110 3041575 : center_(Dumux::center(corners))
111 3041575 , unitOuterNormal_(normal)
112 3041575 , scvfIndex_(scvfIndex)
113
2/3
✓ Branch 0 taken 19927 times.
✓ Branch 1 taken 2571048 times.
✗ Branch 2 not taken.
3041575 , scvIndices_(std::move(scvIndices))
114 3041575 , boundary_(boundary)
115
2/3
✓ Branch 0 taken 19927 times.
✓ Branch 1 taken 2571048 times.
✗ Branch 2 not taken.
3041575 , boundaryFlag_{intersection}
116 {
117 6015439 area_ = Dumux::convexPolytopeVolume<dim>(
118 Dune::GeometryTypes::cube(dim),
119 6117989 [&](unsigned int i){ return corners[i]; }
120 );
121 3041575 }
122
123 //! The center of the sub control volume face
124 const GlobalPosition& center() const
125 {
126
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6012048 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3539200 times.
489089603 return center_;
127 }
128
129 //! The integration point for flux evaluations in global coordinates
130 34577532 const GlobalPosition& ipGlobal() const
131 {
132
10/12
✓ Branch 0 taken 469194 times.
✓ Branch 1 taken 22387530 times.
✓ Branch 2 taken 11742 times.
✓ Branch 3 taken 51440 times.
✓ Branch 4 taken 485006 times.
✓ Branch 5 taken 512 times.
✓ Branch 6 taken 2048 times.
✓ Branch 7 taken 10432 times.
✓ Branch 8 taken 5430 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 15350 times.
✗ Branch 11 not taken.
329592729 return center_;
133 }
134
135 //! The area of the sub control volume face
136 1207249984 Scalar area() const
137 {
138
0/2
✗ Branch 2 not taken.
✗ Branch 3 not taken.
592066942 return area_;
139 }
140
141 //! returns true if the sub control volume face is on the boundary
142 3044269412 bool boundary() const
143 {
144
18/18
✓ Branch 0 taken 67928806 times.
✓ Branch 1 taken 9154420 times.
✓ Branch 2 taken 309318628 times.
✓ Branch 3 taken 35657765 times.
✓ Branch 4 taken 242828534 times.
✓ Branch 5 taken 28269459 times.
✓ Branch 6 taken 734540 times.
✓ Branch 7 taken 48984 times.
✓ Branch 8 taken 1001332 times.
✓ Branch 9 taken 86304 times.
✓ Branch 10 taken 5430 times.
✓ Branch 11 taken 10824 times.
✓ Branch 12 taken 64 times.
✓ Branch 13 taken 112 times.
✓ Branch 14 taken 3072 times.
✓ Branch 15 taken 7104 times.
✓ Branch 16 taken 5430 times.
✓ Branch 17 taken 10824 times.
695071632 return boundary_;
145 }
146
147 28437384 const GlobalPosition& unitOuterNormal() const
148 {
149
7/8
✓ Branch 0 taken 380949644 times.
✓ Branch 1 taken 89833450 times.
✓ Branch 2 taken 274343126 times.
✓ Branch 3 taken 102697656 times.
✓ Branch 4 taken 268729033 times.
✓ Branch 5 taken 565487 times.
✓ Branch 6 taken 2128000 times.
✗ Branch 7 not taken.
2097017620 return unitOuterNormal_;
150 }
151
152 //! index of the inside sub control volume
153 2740742737 LocalIndexType insideScvIdx() const
154 {
155
15/18
✗ Branch 0 not taken.
✓ Branch 1 taken 47611564 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 607391402 times.
✓ Branch 4 taken 62139252 times.
✓ Branch 5 taken 763710734 times.
✓ Branch 6 taken 13335132 times.
✓ Branch 7 taken 258898304 times.
✓ Branch 8 taken 14122770 times.
✓ Branch 9 taken 284375812 times.
✓ Branch 10 taken 530050 times.
✓ Branch 11 taken 275656245 times.
✓ Branch 12 taken 220912 times.
✓ Branch 13 taken 13820350 times.
✓ Branch 14 taken 15849 times.
✓ Branch 15 taken 8061675 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 2084864 times.
2738140287 return scvIndices_[0];
156 }
157
158 //! Index of the i-th outside sub control volume or boundary scv index.
159 // Results in undefined behaviour if i >= numOutsideScvs()
160 2659557868 LocalIndexType outsideScvIdx(int i = 0) const
161 {
162
10/20
✗ Branch 0 not taken.
✓ Branch 1 taken 47611564 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 110482874 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 574170086 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 778241640 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 258893208 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 283967344 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 275089544 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 13035920 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 5622400 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 2083200 times.
2380304968 assert(!boundary());
163
15/16
✓ Branch 0 taken 22543106 times.
✓ Branch 1 taken 25068458 times.
✓ Branch 2 taken 308368111 times.
✓ Branch 3 taken 361162543 times.
✓ Branch 4 taken 431414342 times.
✓ Branch 5 taken 340761810 times.
✓ Branch 6 taken 159441813 times.
✓ Branch 7 taken 3427859 times.
✓ Branch 8 taken 273322109 times.
✓ Branch 9 taken 2157855 times.
✓ Branch 10 taken 298800 times.
✓ Branch 11 taken 2128000 times.
✓ Branch 12 taken 375 times.
✓ Branch 13 taken 985 times.
✓ Branch 14 taken 1360 times.
✗ Branch 15 not taken.
2659557868 return scvIndices_[1];
164 }
165
166 //! The number of scvs on the outside of this face
167 std::size_t numOutsideScvs() const
168 {
169
1/2
✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
72 return static_cast<std::size_t>(!boundary());
170 }
171
172 //! The local index of this sub control volume face
173 1113868328 GridIndexType index() const
174 {
175
10/16
✓ Branch 2 taken 12892444 times.
✓ Branch 3 taken 803522 times.
✓ Branch 6 taken 3130900 times.
✓ Branch 7 taken 3072 times.
✓ Branch 9 taken 10860 times.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 32 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 2048 times.
✓ Branch 1 taken 37071209 times.
✓ Branch 4 taken 455422836 times.
✓ Branch 5 taken 1244980 times.
✗ Branch 0 not taken.
1113871288 return scvfIndex_;
176 }
177
178 //! Return the boundary flag
179 3446322 typename BoundaryFlag::value_type boundaryFlag() const
180 {
181
3/4
✓ Branch 0 taken 231456 times.
✓ Branch 1 taken 2823318 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2016 times.
3446322 return boundaryFlag_.get();
182 }
183
184 private:
185 GlobalPosition center_;
186 GlobalPosition unitOuterNormal_;
187 Scalar area_;
188 GridIndexType scvfIndex_;
189 std::vector<LocalIndexType> scvIndices_;
190 bool boundary_;
191 BoundaryFlag boundaryFlag_;
192 };
193
194 } // end namespace Dumux
195
196 #endif
197