GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: dumux/dumux/porousmediumflow/boxdfm/subcontrolvolumeface.hh
Date: 2025-04-12 19:19:20
Exec Total Coverage
Lines: 71 72 98.6%
Functions: 15 15 100.0%
Branches: 46 70 65.7%

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 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 18453272 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 8002588 BoxDfmSubControlVolumeFace() = default;
83
84 //! Constructor for inner scvfs
85 template<class GeometryHelper, class Element>
86 8083032 BoxDfmSubControlVolumeFace(const GeometryHelper& geometryHelper,
87 const Element& element,
88 const typename Element::Geometry& elemGeometry,
89 GridIndexType scvfIndex,
90 std::vector<LocalIndexType>&& scvIndices)
91 8083032 : center_(0.0)
92 8083032 , scvfIndex_(scvfIndex)
93
1/2
✓ Branch 1 taken 8083032 times.
✗ Branch 2 not taken.
8083032 , scvIndices_(std::move(scvIndices))
94 8083032 , boundary_(false)
95 8083032 , isFractureScvf_(false)
96
1/2
✓ Branch 1 taken 8083032 times.
✗ Branch 2 not taken.
8083032 , boundaryFlag_{}
97 8083032 , facetIdx_(0)
98
1/2
✓ Branch 1 taken 8083032 times.
✗ Branch 2 not taken.
8083032 , indexInIntersection_(0)
99 {
100
1/2
✓ Branch 1 taken 8083032 times.
✗ Branch 2 not taken.
8083032 const auto corners = geometryHelper.getScvfCorners(scvfIndex);
101
1/2
✓ Branch 1 taken 4041516 times.
✗ Branch 2 not taken.
8083032 unitOuterNormal_ = geometryHelper.normal(corners, scvIndices_);
102 16166064 area_ = Dumux::convexPolytopeVolume<T::dim-1>(
103 Dune::GeometryTypes::cube(T::dim-1),
104 17809608 [&](unsigned int i){ return corners[i]; });
105
106
2/2
✓ Branch 0 taken 19453152 times.
✓ Branch 1 taken 8083032 times.
27536184 for (const auto& corner : corners)
107
2/2
✓ Branch 0 taken 45480480 times.
✓ Branch 1 taken 19453152 times.
64933632 center_ += corner;
108 8083032 center_ /= corners.size();
109 8083032 }
110
111 //! Constructor for boundary scvfs
112 template<class GeometryHelper, class Intersection>
113 484612 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 969224 : center_(0.0)
120 484612 , unitOuterNormal_(intersection.centerUnitOuterNormal())
121 484612 , scvfIndex_(scvfIndex)
122
1/2
✓ Branch 1 taken 484612 times.
✗ Branch 2 not taken.
484612 , scvIndices_(std::move(scvIndices))
123 484612 , boundary_(true)
124 484612 , isFractureScvf_(false)
125
1/2
✓ Branch 1 taken 484612 times.
✗ Branch 2 not taken.
484612 , boundaryFlag_{intersection}
126 484612 , facetIdx_(0)
127 484612 , indexInIntersection_(0)
128 {
129
2/4
✓ Branch 1 taken 484612 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 242306 times.
✗ Branch 5 not taken.
484612 const auto corners = geometryHelper.getBoundaryScvfCorners(intersection.indexInInside(), indexInIntersection);
130 969224 area_ = Dumux::convexPolytopeVolume<T::dim-1>(
131 Dune::GeometryTypes::cube(T::dim-1),
132 1275404 [&](unsigned int i){ return corners[i]; });
133
2/2
✓ Branch 0 taken 1581584 times.
✓ Branch 1 taken 484612 times.
2066196 for (const auto& corner : corners)
134
2/2
✓ Branch 0 taken 4387888 times.
✓ Branch 1 taken 1581584 times.
5969472 center_ += corner;
135 484612 center_ /= corners.size();
136 484612 }
137
138 //! Constructor for inner fracture scvfs
139 template<class GeometryHelper, class Intersection>
140 299444 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 299444 : center_(0.0)
148 299444 , scvfIndex_(scvfIndex)
149
1/2
✓ Branch 1 taken 299444 times.
✗ Branch 2 not taken.
299444 , scvIndices_(std::move(scvIndices))
150 299444 , boundary_(boundary)
151 299444 , isFractureScvf_(true)
152
2/4
✓ Branch 1 taken 299444 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 299444 times.
✗ Branch 5 not taken.
299444 , boundaryFlag_{intersection}
153 299444 , facetIdx_(intersection.indexInInside())
154
2/4
✓ Branch 1 taken 299444 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 149722 times.
✗ Branch 5 not taken.
449166 , indexInIntersection_(indexInIntersection)
155 {
156
1/2
✓ Branch 1 taken 299444 times.
✗ Branch 2 not taken.
299444 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 if (T::dim == 3)
161 166320 area_ = (corners[1]-corners[0]).two_norm();
162 else if (T::dim == 2)
163 216284 area_ = 1.0;
164
165 // obtain the unit normal vector
166
1/2
✓ Branch 1 taken 299444 times.
✗ Branch 2 not taken.
299444 unitOuterNormal_ = geometryHelper.fractureNormal(corners, intersection, indexInIntersection);
167
168 // compute the scvf center
169
2/2
✓ Branch 0 taken 382604 times.
✓ Branch 1 taken 299444 times.
682048 for (const auto& corner : corners)
170
2/2
✓ Branch 0 taken 931528 times.
✓ Branch 1 taken 382604 times.
1314132 center_ += corner;
171 299444 center_ /= corners.size();
172 299444 }
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 7675224 const GlobalPosition& ipGlobal() const
180
1/2
✓ Branch 1 taken 3837612 times.
✗ Branch 2 not taken.
9567816 { return center_; }
181
182 //! The area of the sub control volume face
183 118641880 Scalar area() const
184 118641880 { return area_; }
185
186 //! returns true if the sub control volume face is on the boundary
187 356853904 bool boundary() const
188
4/4
✓ Branch 0 taken 58374644 times.
✓ Branch 1 taken 3303020 times.
✓ Branch 2 taken 58374644 times.
✓ Branch 3 taken 3303020 times.
123355328 { return boundary_; }
189
190 //! returns the unit normal vector pointing outwards
191 const GlobalPosition& unitOuterNormal() const
192
1/2
✓ Branch 0 taken 116749288 times.
✗ Branch 1 not taken.
233498576 { return unitOuterNormal_; }
193
194 //! The global index of this sub control volume face
195 124424512 GridIndexType index() const
196
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116749288 times.
124424512 { return scvfIndex_; }
197
198 //! Return if this is a fracture scvf
199 15350448 bool isOnFracture() const
200
4/4
✓ Branch 0 taken 7417436 times.
✓ Branch 1 taken 257788 times.
✓ Branch 2 taken 7417436 times.
✓ Branch 3 taken 257788 times.
15350448 { return isFractureScvf_; }
201
202 //! The element-local facet index for which a fracture scv was created
203 515576 LocalIndexType facetIndexInElement() const
204 515576 { 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 298479260 LocalIndexType insideScvIdx() const
216
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 116749288 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 116749288 times.
298479260 { 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 291873220 LocalIndexType outsideScvIdx(int i = 0) const
221 {
222
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 116749288 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 116749288 times.
233498576 assert(!boundary());
223
3/4
✓ Branch 0 taken 56483399 times.
✓ Branch 1 taken 60265889 times.
✓ Branch 2 taken 116749288 times.
✗ Branch 3 not taken.
291873220 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