GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/multidomain/facet/box/subcontrolvolumeface.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 30 41 73.2%
Functions: 26 65 40.0%
Branches: 38 94 40.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 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.
13078845 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 : corners_(geometryHelper.getScvfCorners(scvfIndex))
66 , center_(0.0)
67 5561491 , unitOuterNormal_(geometryHelper.normal(corners_, scvIndices))
68 5561491 , area_(Dumux::convexPolytopeVolume<T::dim-1>(
69 Dune::GeometryTypes::cube(T::dim-1),
70 2211984 [&](unsigned int i){ return corners_[i]; })
71 )
72 , scvfIndex_(scvfIndex)
73 5561491 , scvIndices_(std::move(scvIndices))
74 , facetIndex_(/*undefined*/)
75 , indexInFacet_(/*undefined*/)
76 , boundary_(false)
77 , interiorBoundary_(false)
78 22245964 , boundaryFlag_{}
79 {
80
2/2
✓ Branch 0 taken 11122334 times.
✓ Branch 1 taken 5439985 times.
28280399 for (const auto& corner : corners_)
81 11595926 center_ += corner;
82 5561491 center_ /= corners_.size();
83 5561491 }
84
85 //! Constructor for domain or interior boundary scvfs
86 template<class GeometryHelper, class Intersection>
87 1018842 BoxFacetCouplingSubControlVolumeFace(const GeometryHelper& geometryHelper,
88 const Intersection& intersection,
89 const typename Intersection::Geometry& isGeometry,
90 LocalIndexType indexInIntersection,
91 GridIndexType scvfIndex,
92 std::vector<LocalIndexType>&& scvIndices,
93 bool boundary,
94 bool interiorBoundary)
95 : corners_(geometryHelper.getBoundaryScvfCorners(intersection.indexInInside(), indexInIntersection))
96 , center_(0.0)
97 , unitOuterNormal_(intersection.centerUnitOuterNormal())
98 2037684 , area_(Dumux::convexPolytopeVolume<T::dim-1>(
99 Dune::GeometryTypes::cube(T::dim-1),
100 429184 [&](unsigned int i){ return corners_[i]; })
101 )
102 , scvfIndex_(scvfIndex)
103 1018842 , scvIndices_(std::move(scvIndices))
104 , facetIndex_(intersection.indexInInside())
105 , indexInFacet_(indexInIntersection)
106 , boundary_(boundary)
107 , interiorBoundary_(interiorBoundary)
108
7/12
✗ Branch 0 not taken.
✓ Branch 1 taken 2464 times.
✓ Branch 5 taken 982594 times.
✓ Branch 6 taken 2464 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 985058 times.
✓ Branch 9 taken 1344 times.
✓ Branch 10 taken 1120 times.
✓ Branch 11 taken 982594 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
2038596 , boundaryFlag_{intersection}
109 {
110
2/2
✓ Branch 0 taken 2036404 times.
✓ Branch 1 taken 985058 times.
5223138 for (const auto& corner : corners_)
111 2166612 center_ += corner;
112 1018842 center_ /= corners_.size();
113 1018842 }
114
115 //! The center of the sub control volume face
116 const GlobalPosition& center() const
117 2304 { return center_; }
118
119 //! The integration point for flux evaluations in global coordinates
120 const GlobalPosition& ipGlobal() const
121
1/2
✓ Branch 5 taken 34 times.
✗ Branch 6 not taken.
5810696 { return center_; }
122
123 //! The area of the sub control volume face
124 Scalar area() const
125 { return area_; }
126
127 //! returns true if the sub control volume face is on the boundary
128 bool boundary() const
129 { return boundary_; }
130
131 //! returns true if the sub control volume face is on an interior boundary
132 bool interiorBoundary() const
133 { return interiorBoundary_; }
134
135 //! returns the unit nurmal vector pointing outwards
136 //! of the sub-control volume that this scvf encloses
137 const GlobalPosition& unitOuterNormal() const
138
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_; }
139
140 //! index of the inside sub control volume
141 LocalIndexType insideScvIdx() const
142
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]; }
143
144 //! The element-local index of this sub control volume face
145 GridIndexType index() const
146 { return scvfIndex_; }
147
148 //! Index of the i-th outside sub control volume or boundary scv index.
149 // Results in undefined behaviour if i >= numOutsideScvs()
150 LocalIndexType outsideScvIdx(int i = 0) const
151 {
152 assert(!boundary() && !interiorBoundary());
153 return scvIndices_[1];
154 }
155
156 //! The number of scvs on the outside of this face
157 std::size_t numOutsideScvs() const
158 {
159 return static_cast<std::size_t>(!(boundary() || interiorBoundary()));
160 }
161
162 //! returns the element-local index of the facet this scvf is embedded in.
163 //! This is only valid to be called for scvfs on domain/interior boundaries.
164 21676 LocalIndexType facetIndexInElement() const
165 {
166
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 21020 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
21676 assert(interiorBoundary_ || boundary_);
167 21676 return facetIndex_;
168 }
169
170 //! returns the facet-local (intersection-local) index of this scvf.
171 //! This is only valid to be called for scvfs on domain/interior boundaries.
172 4400 LocalIndexType indexInElementFacet() const
173 {
174
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3840 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4400 assert(interiorBoundary_ || boundary_);
175 4400 return indexInFacet_;
176 }
177
178 //! The geometry of the sub control volume face
179 [[deprecated("Will be removed after 3.7. Use fvGeometry.geometry(scvf).")]]
180 Geometry geometry() const
181 { return Geometry(Dune::GeometryTypes::cube(Geometry::mydimension), corners_); }
182
183 //! Return the boundary flag
184 typename BoundaryFlag::value_type boundaryFlag() const
185 { return boundaryFlag_.get(); }
186
187 private:
188 // geometrical information
189 CornerStorage corners_;
190 GlobalPosition center_;
191 GlobalPosition unitOuterNormal_;
192 Scalar area_;
193
194 // indices
195 GridIndexType scvfIndex_;
196 std::vector<LocalIndexType> scvIndices_;
197
198 // indices valid for domain/interior boundary scvfs
199 LocalIndexType facetIndex_;
200 LocalIndexType indexInFacet_;
201
202 // boundary information
203 bool boundary_;
204 bool interiorBoundary_;
205 BoundaryFlag boundaryFlag_;
206 };
207
208 } // end namespace Dumux
209
210 #endif
211