GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: dumux/dumux/porousmediumflow/boxdfm/subcontrolvolume.hh
Date: 2025-06-14 19:21:29
Exec Total Coverage
Lines: 54 54 100.0%
Functions: 10 10 100.0%
Branches: 72 91 79.1%

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 for the box discrete fracture scheme
11 */
12
13 #ifndef DUMUX_POROUSMEDIUMFLOW_BOXDFM_SUBCONTROLVOLUME_HH
14 #define DUMUX_POROUSMEDIUMFLOW_BOXDFM_SUBCONTROLVOLUME_HH
15
16 #include <dune/common/reservedvector.hh>
17 #include <dune/geometry/type.hh>
18 #include <dune/geometry/multilineargeometry.hh>
19
20 #include <dumux/porousmediumflow/boxdfm/geometryhelper.hh>
21 #include <dumux/common/math.hh>
22 #include <dumux/geometry/volume.hh>
23
24 namespace Dumux {
25
26 /*!
27 * \ingroup BoxDFMModel
28 * \brief Default traits class to be used for the sub-control volumes
29 * for the box discrete fracture scheme
30 *
31 * \tparam GV the type of the grid view
32 *
33 * \note We define new traits for the box-dfm sub-control volume face
34 * as we use a different type of container for storing the scvf corners!
35 */
36 template<class GridView>
37 struct BoxDfmDefaultScvGeometryTraits
38 {
39 using Grid = typename GridView::Grid;
40
41 static const int dim = Grid::dimension;
42 static const int dimWorld = Grid::dimensionworld;
43 using GridIndexType = typename Grid::LeafGridView::IndexSet::IndexType;
44 using LocalIndexType = unsigned int;
45 using Scalar = typename Grid::ctype;
46 using GeometryTraits = BoxDfmMLGeometryTraits<Scalar>;
47 using Geometry = Dune::MultiLinearGeometry<Scalar, dim, dimWorld, GeometryTraits>;
48 using CornerStorage = typename GeometryTraits::template CornerStorage<dim, dimWorld>::Type;
49 using GlobalPosition = typename CornerStorage::value_type;
50 };
51
52 /*!
53 * \ingroup BoxDFMModel
54 * \brief the sub control volume for the box discrete fracture scheme
55 *
56 * \tparam GV the type of the grid view
57 * \tparam T the scvf geometry traits
58 */
59 template<class GV,
60 class T = BoxDfmDefaultScvGeometryTraits<GV> >
61 class BoxDfmSubControlVolume
62 {
63 using ThisType = BoxDfmSubControlVolume<GV, T>;
64 using Geometry = typename T::Geometry;
65 using GridIndexType = typename T::GridIndexType;
66 using LocalIndexType = typename T::LocalIndexType;
67 using Scalar = typename T::Scalar;
68 static constexpr int dim = Geometry::mydimension;
69
70 static_assert(dim == 2 || dim == 3, "Box-Dfm sub-control volume only implemented in 2d or 3d");
71
72 public:
73 //! export the type used for global coordinates
74 using GlobalPosition = typename T::GlobalPosition;
75 //! State the traits public and thus export all types
76 using Traits = T;
77
78 //! The default constructor
79 8710636 BoxDfmSubControlVolume() = default;
80
81 // the constructor for standard scvs
82 template<class GeometryHelper>
83 8791080 BoxDfmSubControlVolume(const GeometryHelper& geometryHelper,
84 LocalIndexType scvIdx,
85 GridIndexType elementIndex,
86 GridIndexType dofIndex)
87 8791080 : isFractureScv_(false)
88 8791080 , center_(0.0)
89 8791080 , elementIndex_(elementIndex)
90 8791080 , vIdxLocal_(scvIdx)
91 8791080 , elemLocalScvIdx_(scvIdx)
92 8791080 , dofIndex_(dofIndex)
93 8791080 , facetIdx_(0)
94 8791080 , indexInIntersection_(0)
95 {
96 8791080 const auto corners = geometryHelper.getScvCorners(scvIdx);
97 8791080 dofPosition_ = corners[0];
98 11556408 volume_ = Dumux::convexPolytopeVolume<T::dim>(
99 Dune::GeometryTypes::cube(T::dim),
100 31408800 [&](unsigned int i){ return corners[i]; });
101 // compute center point
102
2/2
✓ Branch 0 taken 46225632 times.
✓ Branch 1 taken 8791080 times.
55016712 for (const auto& corner : corners)
103
2/2
✓ Branch 0 taken 114573888 times.
✓ Branch 1 taken 46225632 times.
160799520 center_ += corner;
104 8791080 center_ /= corners.size();
105 8791080 }
106
107 /*!
108 * \brief Constructor for fracture scvs
109 *
110 * The corner computation is the same as for boundary scvfs.
111 * Also, the scvf area of a boundary scvf is equal to the scv
112 * volume (unscaled by the aperture) Thus, we reuse functionality here.
113 * In order to get the right dimensions later, one must provide appropriate
114 * extrusion factors in the problem corresponding to the fracture aperture. *
115 */
116 template<class GeometryHelper, class Intersection>
117 603432 BoxDfmSubControlVolume(const GeometryHelper& geometryHelper,
118 const Intersection& intersection,
119 const typename Intersection::Geometry& isGeometry,
120 LocalIndexType indexInIntersection,
121 LocalIndexType vIdxLocal,
122 LocalIndexType elemLocalScvIdx,
123 LocalIndexType elemLocalFacetIdx,
124 GridIndexType elementIndex,
125 GridIndexType dofIndex)
126 603432 : isFractureScv_(true)
127 603432 , center_(0.0)
128 603432 , volume_(0.0)
129 603432 , elementIndex_(elementIndex)
130 603432 , vIdxLocal_(vIdxLocal)
131 603432 , elemLocalScvIdx_(elemLocalScvIdx)
132 603432 , dofIndex_(dofIndex)
133 603432 , facetIdx_(elemLocalFacetIdx)
134 603432 , indexInIntersection_(indexInIntersection)
135 {
136 603432 const auto corners = geometryHelper.getBoundaryScvfCorners(intersection.indexInInside(), indexInIntersection);
137 603432 dofPosition_ = corners[0];
138
139 // compute volume and scv center
140 1206864 volume_ = Dumux::convexPolytopeVolume<T::dim-1>(
141 Dune::GeometryTypes::cube(T::dim-1),
142 1416744 [&](unsigned int i){ return corners[i]; }
143 );
144
2/2
✓ Branch 0 taken 1626624 times.
✓ Branch 1 taken 603432 times.
2230056 for (const auto& corner : corners)
145
2/2
✓ Branch 0 taken 4092768 times.
✓ Branch 1 taken 1626624 times.
5719392 center_ += corner;
146 603432 center_ /= corners.size();
147 603432 }
148
149 //! The center of the sub control volume
150 25595024 const GlobalPosition& center() const
151 86072224 { return center_; }
152
153 //! The volume of the sub control volume
154 69764352 Scalar volume() const
155 69764352 { return volume_; }
156
157 //! The element-local vertex index this scv is connected to
158 367046622 LocalIndexType localDofIndex() const
159
15/20
✓ Branch 0 taken 21756780 times.
✓ Branch 1 taken 18206280 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5098514 times.
✓ Branch 4 taken 9892752 times.
✓ Branch 5 taken 499080 times.
✓ Branch 6 taken 9892752 times.
✓ Branch 7 taken 499080 times.
✓ Branch 8 taken 4946376 times.
✓ Branch 9 taken 249540 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 24687936 times.
✓ Branch 14 taken 902280 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 902280 times.
✓ Branch 17 taken 368880 times.
✓ Branch 20 taken 107880 times.
✗ Branch 21 not taken.
✓ Branch 23 taken 57320 times.
✗ Branch 24 not taken.
367236294 { return vIdxLocal_; }
160
161 //! The element-local index of this scv
162 537696356 LocalIndexType indexInElement() const
163
4/8
✓ Branch 0 taken 80159952 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 309477192 times.
✓ Branch 10 taken 751344 times.
✓ Branch 11 taken 51848 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
537696356 { return elemLocalScvIdx_; }
164
165 //! The element-local facet index for which a fracture scv was created
166 2790548 LocalIndexType facetIndexInElement() const
167
6/6
✓ Branch 0 taken 902280 times.
✓ Branch 1 taken 10620 times.
✓ Branch 2 taken 902280 times.
✓ Branch 3 taken 10620 times.
✓ Branch 4 taken 10620 times.
✓ Branch 5 taken 902280 times.
2790548 { assert(isFractureScv_); return facetIdx_; }
168
169 //! The local vertex index in the intersection
170 LocalIndexType indexInsideIntersection() const
171 { assert(isFractureScv_); return indexInIntersection_; }
172
173 //! The index of the dof this scv is embedded in
174 72274246 GridIndexType dofIndex() const
175
10/15
✓ Branch 1 taken 1404365 times.
✓ Branch 2 taken 7100755 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 24687936 times.
✓ Branch 6 taken 4331178 times.
✓ Branch 7 taken 21263846 times.
✓ Branch 9 taken 107880 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 81028 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1940 times.
✓ Branch 15 taken 14932 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✓ Branch 11 taken 2520 times.
72274246 { return dofIndex_; }
176
177 // The position of the dof this scv is embedded in (list is defined such that first entry is vertex itself)
178 1404365 const GlobalPosition& dofPosition() const
179
6/6
✓ Branch 0 taken 142028 times.
✓ Branch 1 taken 129516 times.
✓ Branch 2 taken 149867 times.
✓ Branch 3 taken 133494 times.
✓ Branch 4 taken 1048660 times.
✓ Branch 5 taken 355705 times.
1959270 { return dofPosition_; }
180
181 //! The global index of the element this scv is embedded in
182 3641256 GridIndexType elementIndex() const
183
3/6
✗ Branch 1 not taken.
✓ Branch 2 taken 24687936 times.
✓ Branch 4 taken 107880 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 57320 times.
✗ Branch 8 not taken.
36478104 { return elementIndex_; }
184
185 //! Return true if this scv is part of the fracture domain
186 125424962 bool isOnFracture() const
187
20/22
✓ Branch 0 taken 1642688 times.
✓ Branch 1 taken 2688490 times.
✓ Branch 2 taken 1642688 times.
✓ Branch 3 taken 23952336 times.
✓ Branch 4 taken 912900 times.
✓ Branch 5 taken 1271160 times.
✓ Branch 6 taken 34618320 times.
✓ Branch 7 taken 2291920 times.
✓ Branch 8 taken 912900 times.
✓ Branch 9 taken 1271160 times.
✓ Branch 10 taken 912900 times.
✓ Branch 11 taken 1271160 times.
✓ Branch 12 taken 1642688 times.
✓ Branch 13 taken 23952336 times.
✓ Branch 14 taken 1642688 times.
✓ Branch 15 taken 23952336 times.
✓ Branch 16 taken 2852 times.
✓ Branch 17 taken 40248 times.
✓ Branch 18 taken 751344 times.
✓ Branch 19 taken 51848 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
125424962 { return isFractureScv_; }
188
189 private:
190 bool isFractureScv_;
191 GlobalPosition dofPosition_;
192 GlobalPosition center_;
193 Scalar volume_;
194 GridIndexType elementIndex_;
195 LocalIndexType vIdxLocal_;
196 LocalIndexType elemLocalScvIdx_;
197 GridIndexType dofIndex_;
198
199 // for fracture scvs only!
200 LocalIndexType facetIdx_;
201 LocalIndexType indexInIntersection_;
202 };
203
204 } // end namespace
205
206 #endif
207