GCC Code Coverage Report


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