GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/porousmediumflow/boxdfm/subcontrolvolumeface.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 37 48 77.1%
Functions: 15 55 27.3%
Branches: 37 79 46.8%

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.
31198996 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 CornerStorage = typename T::CornerStorage;
73 using Geometry = typename T::Geometry;
74 using BoundaryFlag = typename T::BoundaryFlag;
75
76 static_assert(T::dim == 2 || T::dim == 3, "Box-Dfm sub-control volume face only implemented in 2d or 3d");
77
78 public:
79 //! State the traits public and thus export all types
80 using Traits = T;
81
82 //! The default constructor
83 55372776 BoxDfmSubControlVolumeFace() = default;
84
85 //! Constructor for inner scvfs
86 template<class GeometryHelper, class Element>
87 9309240 BoxDfmSubControlVolumeFace(const GeometryHelper& geometryHelper,
88 const Element& element,
89 const typename Element::Geometry& elemGeometry,
90 GridIndexType scvfIndex,
91 std::vector<LocalIndexType>&& scvIndices)
92 : corners_(geometryHelper.getScvfCorners(scvfIndex))
93 , center_(0.0)
94 9309240 , unitOuterNormal_(geometryHelper.normal(corners_, scvIndices))
95 9309240 , area_(Dumux::convexPolytopeVolume<T::dim-1>(
96 Dune::GeometryTypes::cube(T::dim-1),
97 13148352 [&](unsigned int i){ return corners_[i]; })
98 )
99 , scvfIndex_(scvfIndex)
100 9309240 , scvIndices_(std::move(scvIndices))
101 , boundary_(false)
102 , isFractureScvf_(false)
103 , boundaryFlag_{}
104 37236960 , facetIdx_(0)
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 : corners_(geometryHelper.getBoundaryScvfCorners(intersection.indexInInside(), indexInIntersection))
120 , center_(0.0)
121 , unitOuterNormal_(intersection.centerUnitOuterNormal())
122 1026888 , area_(Dumux::convexPolytopeVolume<T::dim-1>(
123 Dune::GeometryTypes::cube(T::dim-1),
124 2449440 [&](unsigned int i){ return corners_[i]; })
125 )
126 , scvfIndex_(scvfIndex)
127 513444 , scvIndices_(std::move(scvIndices))
128 , boundary_(true)
129 , isFractureScvf_(false)
130 , boundaryFlag_{intersection}
131
6/10
✓ Branch 0 taken 17136 times.
✓ Branch 1 taken 86496 times.
✓ Branch 5 taken 409812 times.
✓ Branch 6 taken 103632 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 409812 times.
✓ Branch 9 taken 103632 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
1283610 , facetIdx_(0)
132 {
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 : corners_(geometryHelper.getFractureScvfCorners(intersection.indexInInside(), indexInIntersection))
148 , center_(0.0)
149 , scvfIndex_(scvfIndex)
150 341844 , scvIndices_(std::move(scvIndices))
151 , boundary_(boundary)
152 , isFractureScvf_(true)
153 , boundaryFlag_{intersection}
154
10/15
✓ Branch 0 taken 2142 times.
✓ Branch 1 taken 127200 times.
✓ Branch 3 taken 212502 times.
✓ Branch 4 taken 129342 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 212502 times.
✓ Branch 7 taken 129342 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 212502 times.
✓ Branch 10 taken 129342 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 173064 times.
✓ Branch 13 taken 127200 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
1538298 , facetIdx_(intersection.indexInInside())
155 {
156 // The area here is given in meters. In order to
157 // get the right dimensions, the user has to provide
158 // the appropriate aperture in the problem (via an extrusion factor)
159 341844 if (T::dim == 3)
160 249480 area_ = (corners_[1]-corners_[0]).two_norm();
161 else if (T::dim == 2)
162 area_ = 1.0;
163
164 // obtain the unit normal vector
165
1/2
✓ Branch 1 taken 341844 times.
✗ Branch 2 not taken.
341844 unitOuterNormal_ = geometryHelper.fractureNormal(corners_, intersection, indexInIntersection);
166
167 // compute the scvf center
168
2/2
✓ Branch 0 taken 425004 times.
✓ Branch 1 taken 341844 times.
1450536 for (const auto& corner : corners_)
169 425004 center_ += corner;
170 341844 center_ /= corners_.size();
171 341844 }
172
173 //! The center of the sub control volume face
174 const GlobalPosition& center() const
175 { return center_; }
176
177 //! The integration point for flux evaluations in global coordinates
178 const GlobalPosition& ipGlobal() const
179
1/2
✓ Branch 1 taken 4376172 times.
✗ Branch 2 not taken.
10738920 { return center_; }
180
181 //! The area of the sub control volume face
182 Scalar area() const
183 { return area_; }
184
185 //! returns true if the sub control volume face is on the boundary
186 bool boundary() const
187 { return boundary_; }
188
189 //! returns the unit normal vector pointing outwards
190 const GlobalPosition& unitOuterNormal() const
191
1/2
✓ Branch 0 taken 132628712 times.
✗ Branch 1 not taken.
265257424 { return unitOuterNormal_; }
192
193 //! The global index of this sub control volume face
194 GridIndexType index() const
195 { return scvfIndex_; }
196
197 //! Return if this is a fracture scvf
198 bool isOnFracture() const
199 { return isFractureScvf_; }
200
201 //! The element-local facet index for which a fracture scv was created
202 LocalIndexType facetIndexInElement() const
203
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
585976 { assert(isFractureScvf_); return facetIdx_; }
204
205 //! Returns the boundary flag
206 typename BoundaryFlag::value_type boundaryFlag() const
207 { return boundaryFlag_.get(); }
208
209 //! index of the inside sub control volume
210 LocalIndexType insideScvIdx() const
211
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 132628712 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 132628712 times.
338521372 { return scvIndices_[0]; }
212
213 //! Index of the i-th outside sub control volume or boundary scv index.
214 // Results in undefined behaviour if i >= numOutsideScvs()
215 LocalIndexType outsideScvIdx(int i = 0) const
216 {
217
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());
218
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];
219 }
220
221 //! The number of scvs on the outside of this face
222 std::size_t numOutsideScvs() const
223 {
224 return static_cast<std::size_t>(!boundary());
225 }
226
227 //! The geometry of the sub control volume face
228 [[deprecated("Will be removed after 3.7. Use fvGeometry.geometry(scvf).")]]
229 Geometry geometry() const
230 {
231 if (isFractureScvf_)
232 DUNE_THROW(Dune::InvalidStateException, "The geometry object cannot be defined for fracture scvs "
233 "because the number of known corners is insufficient. "
234 "You can do this manually by extract the corners from this scv "
235 "and extrude them by the corresponding aperture. ");
236
237 return Geometry(Dune::GeometryTypes::cube(Geometry::mydimension), corners_);
238 }
239
240 private:
241 CornerStorage corners_;
242 GlobalPosition center_;
243 GlobalPosition unitOuterNormal_;
244 Scalar area_;
245 GridIndexType scvfIndex_;
246 std::vector<LocalIndexType> scvIndices_;
247 bool boundary_;
248 bool isFractureScvf_;
249 BoundaryFlag boundaryFlag_;
250 LocalIndexType facetIdx_;
251 };
252
253 } // end namespace Dumux
254
255 #endif
256