GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: dumux/dumux/multidomain/facet/box/subcontrolvolumeface.hh
Date: 2025-06-14 19:21:29
Exec Total Coverage
Lines: 58 58 100.0%
Functions: 31 31 100.0%
Branches: 91 119 76.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 FacetCoupling
10 * \brief Base class for a sub control volume face of the box method
11 * in the context of of models considering coupling of different
12 * domains across the bulk grid facets.
13 */
14 #ifndef DUMUX_FACETCOUPLING_BOX_SUBCONTROLVOLUMEFACE_HH
15 #define DUMUX_FACETCOUPLING_BOX_SUBCONTROLVOLUMEFACE_HH
16
17 #include <utility>
18
19 #include <dune/geometry/type.hh>
20 #include <dune/geometry/multilineargeometry.hh>
21
22 #include <dumux/common/boundaryflag.hh>
23 #include <dumux/discretization/box/boxgeometryhelper.hh>
24 #include <dumux/discretization/box/subcontrolvolumeface.hh>
25 #include <dumux/geometry/volume.hh>
26
27 namespace Dumux {
28
29 /*!
30 * \ingroup FacetCoupling
31 * \brief Class for a sub control volume face in the box method, i.e a part of the boundary
32 * of a sub control volume we compute fluxes on. This is a specialization for models
33 * considering coupling of different domains across the bulk grid facets.
34 * \tparam GV the type of the grid view
35 * \tparam T the scvf geometry traits
36 */
37 template<class GV, class T = BoxDefaultScvfGeometryTraits<GV> >
38
2/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2976 times.
✓ Branch 2 taken 7716 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
7940058 class BoxFacetCouplingSubControlVolumeFace
39 {
40 using GridIndexType = typename T::GridIndexType;
41 using LocalIndexType = typename T::LocalIndexType;
42 using Scalar = typename T::Scalar;
43 using CornerStorage = typename T::CornerStorage;
44 using Geometry = typename T::Geometry;
45 using BoundaryFlag = typename T::BoundaryFlag;
46
47 public:
48 //! export the type used for global coordinates
49 using GlobalPosition = typename T::GlobalPosition;
50 //! state the traits public and thus export all types
51 using Traits = T;
52
53 //! The default constructor
54 BoxFacetCouplingSubControlVolumeFace() = default;
55
56 //! Constructor for inner scvfs
57 template<class GeometryHelper, class Element>
58 5561491 BoxFacetCouplingSubControlVolumeFace(const GeometryHelper& geometryHelper,
59 const Element& element,
60 const typename Element::Geometry& elemGeometry,
61 unsigned int scvfIndex,
62 std::vector<LocalIndexType>&& scvIndices)
63 5561491 : center_(0.0)
64 5561491 , scvfIndex_(scvfIndex)
65
1/2
✓ Branch 1 taken 5439985 times.
✗ Branch 2 not taken.
5561491 , scvIndices_(std::move(scvIndices))
66 5561491 , facetIndex_(/*undefined*/)
67 5561491 , indexInFacet_(/*undefined*/)
68 5561491 , boundary_(false)
69
1/2
✓ Branch 1 taken 5439985 times.
✗ Branch 2 not taken.
5561491 , interiorBoundary_(false)
70
1/2
✓ Branch 1 taken 5439985 times.
✗ Branch 2 not taken.
5561491 , boundaryFlag_{}
71 {
72
1/2
✓ Branch 1 taken 9162 times.
✗ Branch 2 not taken.
5561491 const auto corners = geometryHelper.getScvfCorners(scvfIndex);
73
1/2
✓ Branch 1 taken 2946 times.
✗ Branch 2 not taken.
5561491 unitOuterNormal_ = geometryHelper.normal(corners, scvIndices_);
74 11122982 area_ = Dumux::convexPolytopeVolume<T::dim-1>(
75 Dune::GeometryTypes::cube(T::dim-1),
76 11122658 [&](unsigned int i){ return corners[i]; });
77
2/2
✓ Branch 0 taken 11122334 times.
✓ Branch 1 taken 5439985 times.
17157417 for (const auto& corner : corners)
78
2/2
✓ Branch 0 taken 23350660 times.
✓ Branch 1 taken 11122334 times.
36367362 center_ += corner;
79
2/2
✓ Branch 0 taken 11311784 times.
✓ Branch 1 taken 5439985 times.
17237793 center_ /= corners.size();
80 5561491 }
81
82 //! Constructor for domain or interior boundary scvfs
83 template<class GeometryHelper, class Intersection>
84 1018842 BoxFacetCouplingSubControlVolumeFace(const GeometryHelper& geometryHelper,
85 const Intersection& intersection,
86 const typename Intersection::Geometry& isGeometry,
87 LocalIndexType indexInIntersection,
88 GridIndexType scvfIndex,
89 std::vector<LocalIndexType>&& scvIndices,
90 bool boundary,
91 bool interiorBoundary)
92 2037684 : center_(0.0)
93 1018842 , unitOuterNormal_(intersection.centerUnitOuterNormal())
94 1018842 , scvfIndex_(scvfIndex)
95
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 985058 times.
✗ Branch 2 not taken.
1018842 , scvIndices_(std::move(scvIndices))
96 1018842 , facetIndex_(intersection.indexInInside())
97 1018842 , indexInFacet_(indexInIntersection)
98 1018842 , boundary_(boundary)
99 1018842 , interiorBoundary_(interiorBoundary)
100
4/6
✓ Branch 0 taken 1344 times.
✓ Branch 1 taken 983714 times.
✓ Branch 3 taken 2464 times.
✓ Branch 4 taken 982594 times.
✗ Branch 2 not taken.
✗ Branch 5 not taken.
1021530 , boundaryFlag_{intersection}
101 {
102
1/2
✓ Branch 1 taken 985058 times.
✗ Branch 2 not taken.
1018842 auto corners = geometryHelper.getBoundaryScvfCorners(intersection.indexInInside(), indexInIntersection);
103 2037684 area_ = Dumux::convexPolytopeVolume<T::dim-1>(
104 Dune::GeometryTypes::cube(T::dim-1),
105 2037044 [&](unsigned int i){ return corners[i]; });
106
2/2
✓ Branch 0 taken 2036404 times.
✓ Branch 1 taken 985058 times.
3185454 for (const auto& corner : corners)
107
2/2
✓ Branch 0 taken 4287400 times.
✓ Branch 1 taken 2036404 times.
6844636 center_ += corner;
108
2/2
✓ Branch 0 taken 2044268 times.
✓ Branch 1 taken 985058 times.
3164462 center_ /= corners.size();
109 1018842 }
110
111 //! The center of the sub control volume face
112 const GlobalPosition& center() const
113 2304 { return center_; }
114
115 //! The integration point for flux evaluations in global coordinates
116 5505928 const GlobalPosition& ipGlobal() const
117
1/2
✓ Branch 5 taken 34 times.
✗ Branch 6 not taken.
10423304 { return center_; }
118
119 //! The area of the sub control volume face
120 23027714 Scalar area() const
121 11586466 { return area_; }
122
123 //! returns true if the sub control volume face is on the boundary
124 84047432 bool boundary() const
125
10/10
✓ Branch 0 taken 596632 times.
✓ Branch 1 taken 9889096 times.
✓ Branch 2 taken 9278152 times.
✓ Branch 3 taken 884160 times.
✓ Branch 4 taken 72736 times.
✓ Branch 5 taken 3293024 times.
✓ Branch 6 taken 3333800 times.
✓ Branch 7 taken 112640 times.
✓ Branch 8 taken 6184 times.
✓ Branch 9 taken 136 times.
27466560 { return boundary_; }
126
127 //! returns true if the sub control volume face is on an interior boundary
128 118497690 bool interiorBoundary() const
129
24/24
✓ Branch 0 taken 4968112 times.
✓ Branch 1 taken 8165600 times.
✓ Branch 2 taken 4737280 times.
✓ Branch 3 taken 417096 times.
✓ Branch 4 taken 780896 times.
✓ Branch 5 taken 7144112 times.
✓ Branch 6 taken 3865472 times.
✓ Branch 7 taken 9047472 times.
✓ Branch 8 taken 6242664 times.
✓ Branch 9 taken 524944 times.
✓ Branch 10 taken 2894392 times.
✓ Branch 11 taken 424440 times.
✓ Branch 12 taken 7201776 times.
✓ Branch 13 taken 436496 times.
✓ Branch 14 taken 98496 times.
✓ Branch 15 taken 82016 times.
✓ Branch 16 taken 4224 times.
✓ Branch 17 taken 315008 times.
✓ Branch 18 taken 4471524 times.
✓ Branch 19 taken 92702 times.
✓ Branch 20 taken 144 times.
✓ Branch 21 taken 272 times.
✓ Branch 22 taken 624 times.
✓ Branch 23 taken 1056 times.
61916818 { return interiorBoundary_; }
130
131 //! returns the unit nurmal vector pointing outwards
132 //! of the sub-control volume that this scvf encloses
133 const GlobalPosition& unitOuterNormal() const
134
3/6
✓ Branch 0 taken 9075480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7432616 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4239872 times.
✗ Branch 5 not taken.
39165346 { return unitOuterNormal_; }
135
136 //! index of the inside sub control volume
137 62731506 LocalIndexType insideScvIdx() const
138
16/16
✓ Branch 2 taken 2327472 times.
✓ Branch 3 taken 6299982 times.
✓ Branch 4 taken 4774582 times.
✓ Branch 5 taken 3172196 times.
✓ Branch 6 taken 61056 times.
✓ Branch 7 taken 976712 times.
✓ Branch 8 taken 8479745 times.
✓ Branch 9 taken 61057 times.
✓ Branch 1 taken 600768 times.
✓ Branch 10 taken 373134 times.
✓ Branch 0 taken 36640 times.
✓ Branch 11 taken 5784 times.
✓ Branch 12 taken 1 times.
✓ Branch 13 taken 37039 times.
✓ Branch 14 taken 34 times.
✓ Branch 15 taken 102 times.
62731506 { return scvIndices_[0]; }
139
140 //! The element-local index of this sub control volume face
141 35184950 GridIndexType index() const
142
8/8
✓ Branch 2 taken 421424 times.
✓ Branch 3 taken 61481 times.
✓ Branch 4 taken 372735 times.
✓ Branch 5 taken 61055 times.
✓ Branch 1 taken 3292017 times.
✓ Branch 0 taken 372736 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 37039 times.
30948346 { return scvfIndex_; }
143
144 //! Index of the i-th outside sub control volume or boundary scv index.
145 // Results in undefined behaviour if i >= numOutsideScvs()
146 57287264 LocalIndexType outsideScvIdx(int i = 0) const
147 {
148
2/4
✓ Branch 0 taken 56580872 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 56580872 times.
57287264 assert(!boundary() && !interiorBoundary());
149 57287264 return scvIndices_[1];
150 }
151
152 //! The number of scvs on the outside of this face
153 std::size_t numOutsideScvs() const
154 {
155 return static_cast<std::size_t>(!(boundary() || interiorBoundary()));
156 }
157
158 //! returns the element-local index of the facet this scvf is embedded in.
159 //! This is only valid to be called for scvfs on domain/interior boundaries.
160 21676 LocalIndexType facetIndexInElement() const
161 {
162
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 21020 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
21676 assert(interiorBoundary_ || boundary_);
163 21676 return facetIndex_;
164 }
165
166 //! returns the facet-local (intersection-local) index of this scvf.
167 //! This is only valid to be called for scvfs on domain/interior boundaries.
168 4400 LocalIndexType indexInElementFacet() const
169 {
170
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3840 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4400 assert(interiorBoundary_ || boundary_);
171 4400 return indexInFacet_;
172 }
173
174 //! Return the boundary flag
175 typename BoundaryFlag::value_type boundaryFlag() const
176 { return boundaryFlag_.get(); }
177
178 private:
179 // geometrical information
180 GlobalPosition center_;
181 GlobalPosition unitOuterNormal_;
182 Scalar area_;
183
184 // indices
185 GridIndexType scvfIndex_;
186 std::vector<LocalIndexType> scvIndices_;
187
188 // indices valid for domain/interior boundary scvfs
189 LocalIndexType facetIndex_;
190 LocalIndexType indexInFacet_;
191
192 // boundary information
193 bool boundary_;
194 bool interiorBoundary_;
195 BoundaryFlag boundaryFlag_;
196 };
197
198 } // end namespace Dumux
199
200 #endif
201