GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/porousmediumflow/boxdfm/subcontrolvolumeface.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 40 51 78.4%
Functions: 15 55 27.3%
Branches: 41 95 43.2%

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 BoxDFMModel
10 * \brief The sub control volume face class for the box discrete fracture model.
11 */
12
13 #ifndef DUMUX_POROUSMEDIUMFLOW_BOXDFM_SUBCONTROLVOLUMEFACE_HH
14 #define DUMUX_POROUSMEDIUMFLOW_BOXDFM_SUBCONTROLVOLUMEFACE_HH
15
16 #include <utility>
17
18 #include <dune/geometry/type.hh>
19 #include <dune/geometry/multilineargeometry.hh>
20
21 #include <dumux/common/boundaryflag.hh>
22 #include <dumux/discretization/subcontrolvolumefacebase.hh>
23 #include <dumux/porousmediumflow/boxdfm/geometryhelper.hh>
24 #include <dumux/geometry/volume.hh>
25
26 namespace Dumux {
27
28 /*!
29 * \ingroup BoxDFMModel
30 * \brief Default traits class to be used for the sub-control volume faces
31 * for the box discrete fracture scheme
32 *
33 * \tparam GV the type of the grid view
34 *
35 * \note We define new traits for the box-dfm sub-control volume face
36 * as we use a different type of container for storing the scvf corners!
37 */
38 template<class GridView>
39 struct BoxDfmDefaultScvfGeometryTraits
40 {
41 using Grid = typename GridView::Grid;
42 static constexpr int dim = Grid::dimension;
43 static constexpr int dimWorld = Grid::dimensionworld;
44 using GridIndexType = typename Grid::LeafGridView::IndexSet::IndexType;
45 using LocalIndexType = unsigned int;
46 using Scalar = typename Grid::ctype;
47 using GeometryTraits = BoxDfmMLGeometryTraits<Scalar>;
48 using Geometry = Dune::MultiLinearGeometry<Scalar, dim-1, dimWorld, GeometryTraits>;
49 using CornerStorage = typename GeometryTraits::template CornerStorage<dim-1, dimWorld>::Type;
50 using GlobalPosition = typename CornerStorage::value_type;
51 using BoundaryFlag = Dumux::BoundaryFlag<Grid>;
52 };
53
54 /*!
55 * \ingroup BoxDFMModel
56 * \brief Class for a sub control volume face in the box discrete fracture method, i.e a
57 * part of the boundary of a sub control volume we compute fluxes on.
58 * \tparam GV the type of the grid view
59 * \tparam T the scvf geometry traits
60 */
61 template<class GV,
62 class T = BoxDfmDefaultScvfGeometryTraits<GV> >
63
5/26
✗ Branch 0 not taken.
✗ 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 903522 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 846706 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 9309240 times.
✗ Branch 20 not taken.
✓ Branch 21 taken 9309240 times.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✓ Branch 24 taken 10069764 times.
✗ Branch 25 not taken.
33349596 class BoxDfmSubControlVolumeFace
64 : public SubControlVolumeFaceBase<BoxDfmSubControlVolumeFace<GV, T>, T>
65 {
66 using ThisType = BoxDfmSubControlVolumeFace<GV, T>;
67 using ParentType = SubControlVolumeFaceBase<ThisType, T>;
68 using GridIndexType = typename T::GridIndexType;
69 using LocalIndexType = typename T::LocalIndexType;
70 using Scalar = typename T::Scalar;
71 using GlobalPosition = typename T::GlobalPosition;
72 using Geometry = typename T::Geometry;
73 using BoundaryFlag = typename T::BoundaryFlag;
74
75 static_assert(T::dim == 2 || T::dim == 3, "Box-Dfm sub-control volume face only implemented in 2d or 3d");
76
77 public:
78 //! State the traits public and thus export all types
79 using Traits = T;
80
81 //! The default constructor
82 46143980 BoxDfmSubControlVolumeFace() = default;
83
84 //! Constructor for inner scvfs
85 template<class GeometryHelper, class Element>
86 9309240 BoxDfmSubControlVolumeFace(const GeometryHelper& geometryHelper,
87 const Element& element,
88 const typename Element::Geometry& elemGeometry,
89 GridIndexType scvfIndex,
90 std::vector<LocalIndexType>&& scvIndices)
91 : center_(0.0)
92 , scvfIndex_(scvfIndex)
93 9309240 , scvIndices_(std::move(scvIndices))
94 , boundary_(false)
95 , isFractureScvf_(false)
96 , boundaryFlag_{}
97 , facetIdx_(0)
98
3/8
✓ Branch 1 taken 9309240 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 9309240 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 9309240 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
37236960 , indexInIntersection_(0)
99 {
100
1/2
✓ Branch 1 taken 9309240 times.
✗ Branch 2 not taken.
9309240 const auto corners = geometryHelper.getScvfCorners(scvfIndex);
101
1/2
✓ Branch 1 taken 4654620 times.
✗ Branch 2 not taken.
9309240 unitOuterNormal_ = geometryHelper.normal(corners, scvIndices_);
102 9309240 area_ = Dumux::convexPolytopeVolume<T::dim-1>(
103 Dune::GeometryTypes::cube(T::dim-1),
104 13148352 [&](unsigned int i){ return corners[i]; });
105
106
2/2
✓ Branch 0 taken 21905568 times.
✓ Branch 1 taken 9309240 times.
49833288 for (const auto& corner : corners)
107 21905568 center_ += corner;
108 9309240 center_ /= corners.size();
109 9309240 }
110
111 //! Constructor for boundary scvfs
112 template<class GeometryHelper, class Intersection>
113 513444 BoxDfmSubControlVolumeFace(const GeometryHelper& geometryHelper,
114 const Intersection& intersection,
115 const typename Intersection::Geometry& isGeometry,
116 LocalIndexType indexInIntersection,
117 GridIndexType scvfIndex,
118 std::vector<LocalIndexType>&& scvIndices)
119 : center_(0.0)
120 , unitOuterNormal_(intersection.centerUnitOuterNormal())
121 , scvfIndex_(scvfIndex)
122 513444 , scvIndices_(std::move(scvIndices))
123 , boundary_(true)
124 , isFractureScvf_(false)
125 , boundaryFlag_{intersection}
126 , facetIdx_(0)
127
2/6
✓ Branch 2 taken 513444 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 513444 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
1026888 , indexInIntersection_(0)
128 {
129
4/6
✓ Branch 0 taken 17136 times.
✓ Branch 1 taken 496308 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 103632 times.
✓ Branch 4 taken 409812 times.
✗ Branch 5 not taken.
770166 const auto corners = geometryHelper.getBoundaryScvfCorners(intersection.indexInInside(), indexInIntersection);
130 513444 area_ = Dumux::convexPolytopeVolume<T::dim-1>(
131 Dune::GeometryTypes::cube(T::dim-1),
132 2449440 [&](unsigned int i){ return corners[i]; });
133
2/2
✓ Branch 0 taken 1639248 times.
✓ Branch 1 taken 513444 times.
3179580 for (const auto& corner : corners)
134 1639248 center_ += corner;
135 513444 center_ /= corners.size();
136 513444 }
137
138 //! Constructor for inner fracture scvfs
139 template<class GeometryHelper, class Intersection>
140 341844 BoxDfmSubControlVolumeFace(const GeometryHelper& geometryHelper,
141 const Intersection& intersection,
142 const typename Intersection::Geometry& isGeometry,
143 LocalIndexType indexInIntersection,
144 GridIndexType scvfIndex,
145 std::vector<LocalIndexType>&& scvIndices,
146 bool boundary)
147 : center_(0.0)
148 , scvfIndex_(scvfIndex)
149 341844 , scvIndices_(std::move(scvIndices))
150 , boundary_(boundary)
151 , isFractureScvf_(true)
152 , boundaryFlag_{intersection}
153 , facetIdx_(intersection.indexInInside())
154
5/11
✓ Branch 1 taken 341844 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 341844 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 341844 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2142 times.
✓ Branch 10 taken 339702 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
1367376 , indexInIntersection_(indexInIntersection)
155 {
156
4/6
✓ Branch 0 taken 2142 times.
✓ Branch 1 taken 339702 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 129342 times.
✓ Branch 4 taken 212502 times.
✗ Branch 5 not taken.
512766 const auto corners = geometryHelper.getFractureScvfCorners(intersection.indexInInside(), indexInIntersection);
157 // The area here is given in meters. In order to
158 // get the right dimensions, the user has to provide
159 // the appropriate aperture in the problem (via an extrusion factor)
160 341844 if (T::dim == 3)
161 249480 area_ = (corners[1]-corners[0]).two_norm();
162 else if (T::dim == 2)
163 area_ = 1.0;
164
165 // obtain the unit normal vector
166
1/2
✓ Branch 1 taken 341844 times.
✗ Branch 2 not taken.
341844 unitOuterNormal_ = geometryHelper.fractureNormal(corners, intersection, indexInIntersection);
167
168 // compute the scvf center
169
2/2
✓ Branch 0 taken 425004 times.
✓ Branch 1 taken 341844 times.
1450536 for (const auto& corner : corners)
170 425004 center_ += corner;
171 341844 center_ /= corners.size();
172 341844 }
173
174 //! The center of the sub control volume face
175 const GlobalPosition& center() const
176 { return center_; }
177
178 //! The integration point for flux evaluations in global coordinates
179 const GlobalPosition& ipGlobal() const
180
1/2
✓ Branch 1 taken 4376172 times.
✗ Branch 2 not taken.
10738920 { return center_; }
181
182 //! The area of the sub control volume face
183 Scalar area() const
184 { return area_; }
185
186 //! returns true if the sub control volume face is on the boundary
187 bool boundary() const
188 { return boundary_; }
189
190 //! returns the unit normal vector pointing outwards
191 const GlobalPosition& unitOuterNormal() const
192
1/2
✓ Branch 0 taken 132628712 times.
✗ Branch 1 not taken.
265257424 { return unitOuterNormal_; }
193
194 //! The global index of this sub control volume face
195 GridIndexType index() const
196 { return scvfIndex_; }
197
198 //! Return if this is a fracture scvf
199 bool isOnFracture() const
200 { return isFractureScvf_; }
201
202 //! The element-local facet index for which a fracture scv was created
203 LocalIndexType facetIndexInElement() const
204
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
585976 { assert(isFractureScvf_); return facetIdx_; }
205
206 //! The local edge index inside the intersection
207 LocalIndexType indexInIntersection() const
208 { assert(isFractureScvf_); return indexInIntersection_; }
209
210 //! Returns the boundary flag
211 typename BoundaryFlag::value_type boundaryFlag() const
212 { return boundaryFlag_.get(); }
213
214 //! index of the inside sub control volume
215 LocalIndexType insideScvIdx() const
216
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 132628712 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 132628712 times.
338521372 { return scvIndices_[0]; }
217
218 //! Index of the i-th outside sub control volume or boundary scv index.
219 // Results in undefined behaviour if i >= numOutsideScvs()
220 LocalIndexType outsideScvIdx(int i = 0) const
221 {
222
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 132628712 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 132628712 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
265257424 assert(!boundary());
223
3/4
✓ Branch 0 taken 64144666 times.
✓ Branch 1 taken 68484046 times.
✓ Branch 2 taken 132628712 times.
✗ Branch 3 not taken.
331571780 return scvIndices_[1];
224 }
225
226 //! The number of scvs on the outside of this face
227 std::size_t numOutsideScvs() const
228 {
229 return static_cast<std::size_t>(!boundary());
230 }
231
232 private:
233 GlobalPosition center_;
234 GlobalPosition unitOuterNormal_;
235 Scalar area_;
236 GridIndexType scvfIndex_;
237 std::vector<LocalIndexType> scvIndices_;
238 bool boundary_;
239 bool isFractureScvf_;
240 BoundaryFlag boundaryFlag_;
241 LocalIndexType facetIdx_;
242 LocalIndexType indexInIntersection_;
243 };
244
245 } // end namespace Dumux
246
247 #endif
248