GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/multidomain/facet/box/subcontrolvolumeface.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 32 43 74.4%
Functions: 26 65 40.0%
Branches: 44 111 39.6%

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 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
7/44
✓ Branch 0 taken 7716 times.
✗ 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 taken 1473930 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 2955 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✓ Branch 20 taken 5697032 times.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✓ Branch 23 taken 30414 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✓ Branch 40 taken 6835 times.
✗ Branch 41 not taken.
✓ Branch 42 taken 74190 times.
✗ Branch 43 not taken.
15878257 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 : center_(0.0)
66 , scvfIndex_(scvfIndex)
67 5561491 , scvIndices_(std::move(scvIndices))
68 , facetIndex_(/*undefined*/)
69 , indexInFacet_(/*undefined*/)
70 , boundary_(false)
71 , interiorBoundary_(false)
72
3/8
✓ Branch 1 taken 5439985 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5439985 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 5439985 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
22245964 , boundaryFlag_{}
73 {
74
1/2
✓ Branch 1 taken 5439985 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 5561491 area_ = Dumux::convexPolytopeVolume<T::dim-1>(
77 Dune::GeometryTypes::cube(T::dim-1),
78 2211984 [&](unsigned int i){ return corners[i]; });
79
2/2
✓ Branch 0 taken 11122334 times.
✓ Branch 1 taken 5439985 times.
28280399 for (const auto& corner : corners)
80 11595926 center_ += corner;
81 5561491 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 : center_(0.0)
95 , unitOuterNormal_(intersection.centerUnitOuterNormal())
96 , scvfIndex_(scvfIndex)
97 1018842 , scvIndices_(std::move(scvIndices))
98 , facetIndex_(intersection.indexInInside())
99 , indexInFacet_(indexInIntersection)
100 , boundary_(boundary)
101 , interiorBoundary_(interiorBoundary)
102
5/11
✗ Branch 1 not taken.
✓ Branch 2 taken 985058 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2464 times.
✓ Branch 5 taken 983938 times.
✓ Branch 6 taken 1120 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 982594 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
2037684 , boundaryFlag_{intersection}
103 {
104
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 985058 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2464 times.
✓ Branch 4 taken 982594 times.
✗ Branch 5 not taken.
1019754 auto corners = geometryHelper.getBoundaryScvfCorners(intersection.indexInInside(), indexInIntersection);
105 1018842 area_ = Dumux::convexPolytopeVolume<T::dim-1>(
106 Dune::GeometryTypes::cube(T::dim-1),
107 429184 [&](unsigned int i){ return corners[i]; });
108
2/2
✓ Branch 0 taken 2036404 times.
✓ Branch 1 taken 985058 times.
5223138 for (const auto& corner : corners)
109 2166612 center_ += corner;
110 1018842 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 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 Scalar area() const
123 { return area_; }
124
125 //! returns true if the sub control volume face is on the boundary
126 bool boundary() const
127 { return boundary_; }
128
129 //! returns true if the sub control volume face is on an interior boundary
130 bool interiorBoundary() const
131 { 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 6113976 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3192744 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4239872 times.
✗ Branch 5 not taken.
31963970 { return unitOuterNormal_; }
137
138 //! index of the inside sub control volume
139 LocalIndexType insideScvIdx() const
140
14/14
✓ Branch 0 taken 36640 times.
✓ Branch 1 taken 600768 times.
✓ Branch 2 taken 6967344 times.
✓ Branch 3 taken 8819246 times.
✓ Branch 4 taken 134707 times.
✓ Branch 5 taken 749951 times.
✓ Branch 6 taken 8540800 times.
✓ Branch 7 taken 231240 times.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 61055 times.
✓ Branch 10 taken 400 times.
✓ Branch 11 taken 5784 times.
✓ Branch 12 taken 1 times.
✓ Branch 13 taken 37039 times.
62720506 { return scvIndices_[0]; }
141
142 //! The element-local index of this sub control volume face
143 GridIndexType index() const
144 { 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 LocalIndexType outsideScvIdx(int i = 0) const
149 {
150 assert(!boundary() && !interiorBoundary());
151 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