GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: dumux/dumux/porousmediumflow/boxdfm/subcontrolvolume.hh
Date: 2025-05-03 19:19:02
Exec Total Coverage
Lines: 54 54 100.0%
Functions: 10 10 100.0%
Branches: 62 78 79.5%

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/discretization/subcontrolvolumebase.hh>
21 #include <dumux/porousmediumflow/boxdfm/geometryhelper.hh>
22 #include <dumux/common/math.hh>
23 #include <dumux/geometry/volume.hh>
24
25 namespace Dumux {
26
27 /*!
28 * \ingroup BoxDFMModel
29 * \brief Default traits class to be used for the sub-control volumes
30 * for the box discrete fracture scheme
31 *
32 * \tparam GV the type of the grid view
33 *
34 * \note We define new traits for the box-dfm sub-control volume face
35 * as we use a different type of container for storing the scvf corners!
36 */
37 template<class GridView>
38 struct BoxDfmDefaultScvGeometryTraits
39 {
40 using Grid = typename GridView::Grid;
41
42 static const int dim = Grid::dimension;
43 static const 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, dimWorld, GeometryTraits>;
49 using CornerStorage = typename GeometryTraits::template CornerStorage<dim, dimWorld>::Type;
50 using GlobalPosition = typename CornerStorage::value_type;
51 };
52
53 /*!
54 * \ingroup BoxDFMModel
55 * \brief the sub control volume for the box discrete fracture scheme
56 *
57 * \tparam GV the type of the grid view
58 * \tparam T the scvf geometry traits
59 */
60 template<class GV,
61 class T = BoxDfmDefaultScvGeometryTraits<GV> >
62 class BoxDfmSubControlVolume
63 : public SubControlVolumeBase<BoxDfmSubControlVolume<GV, T>, T>
64 {
65 using ThisType = BoxDfmSubControlVolume<GV, T>;
66 using ParentType = SubControlVolumeBase<ThisType, T>;
67 using Geometry = typename T::Geometry;
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 enum { dim = Geometry::mydimension };
73
74 static_assert(dim == 2 || dim == 3, "Box-Dfm sub-control volume only implemented in 2d or 3d");
75
76 public:
77 //! State the traits public and thus export all types
78 using Traits = T;
79
80 //! The default constructor
81 7806244 BoxDfmSubControlVolume() = default;
82
83 // the constructor for standard scvs
84 template<class GeometryHelper>
85 7869304 BoxDfmSubControlVolume(const GeometryHelper& geometryHelper,
86 LocalIndexType scvIdx,
87 GridIndexType elementIndex,
88 GridIndexType dofIndex)
89 7869304 : isFractureScv_(false)
90 7869304 , center_(0.0)
91 7869304 , elementIndex_(elementIndex)
92 7869304 , vIdxLocal_(scvIdx)
93 7869304 , elemLocalScvIdx_(scvIdx)
94 7869304 , dofIndex_(dofIndex)
95 7869304 , facetIdx_(0)
96 7869304 , indexInIntersection_(0)
97 {
98 7869304 const auto corners = geometryHelper.getScvCorners(scvIdx);
99 7869304 dofPosition_ = corners[0];
100 9712856 volume_ = Dumux::convexPolytopeVolume<T::dim>(
101 Dune::GeometryTypes::cube(T::dim),
102 26799920 [&](unsigned int i){ return corners[i]; });
103 // compute center point
104
2/2
✓ Branch 0 taken 38851424 times.
✓ Branch 1 taken 7869304 times.
46720728 for (const auto& corner : corners)
105
2/2
✓ Branch 0 taken 92451264 times.
✓ Branch 1 taken 38851424 times.
131302688 center_ += corner;
106 7869304 center_ /= corners.size();
107 7869304 }
108
109 /*!
110 * \brief Constructor for fracture scvs
111 *
112 * The corner computation is the same as for boundary scvfs.
113 * Also, the scvf area of a boundary scvf is equal to the scv
114 * volume (unscaled by the aperture) Thus, we reuse functionality here.
115 * In order to get the right dimensions later, one must provide appropriate
116 * extrusion factors in the problem corresponding to the fracture aperture. *
117 */
118 template<class GeometryHelper, class Intersection>
119 533472 BoxDfmSubControlVolume(const GeometryHelper& geometryHelper,
120 const Intersection& intersection,
121 const typename Intersection::Geometry& isGeometry,
122 LocalIndexType indexInIntersection,
123 LocalIndexType vIdxLocal,
124 LocalIndexType elemLocalScvIdx,
125 LocalIndexType elemLocalFacetIdx,
126 GridIndexType elementIndex,
127 GridIndexType dofIndex)
128 533472 : isFractureScv_(true)
129 533472 , center_(0.0)
130 533472 , volume_(0.0)
131 533472 , elementIndex_(elementIndex)
132 533472 , vIdxLocal_(vIdxLocal)
133 533472 , elemLocalScvIdx_(elemLocalScvIdx)
134 533472 , dofIndex_(dofIndex)
135 533472 , facetIdx_(elemLocalFacetIdx)
136 533472 , indexInIntersection_(indexInIntersection)
137 {
138 533472 const auto corners = geometryHelper.getBoundaryScvfCorners(intersection.indexInInside(), indexInIntersection);
139 533472 dofPosition_ = corners[0];
140
141 // compute volume and scv center
142 1066944 volume_ = Dumux::convexPolytopeVolume<T::dim-1>(
143 Dune::GeometryTypes::cube(T::dim-1),
144 1206864 [&](unsigned int i){ return corners[i]; }
145 );
146
2/2
✓ Branch 0 taken 1346784 times.
✓ Branch 1 taken 533472 times.
1880256 for (const auto& corner : corners)
147
2/2
✓ Branch 0 taken 3253248 times.
✓ Branch 1 taken 1346784 times.
4600032 center_ += corner;
148 533472 center_ /= corners.size();
149 533472 }
150
151 //! The center of the sub control volume
152 22937920 const GlobalPosition& center() const
153 79015928 { return center_; }
154
155 //! The volume of the sub control volume
156 66280176 Scalar volume() const
157 66280176 { return volume_; }
158
159 //! The element-local vertex index this scv is connected to
160 301397270 LocalIndexType localDofIndex() const
161
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 3790470 times.
✓ Branch 2 taken 17348880 times.
✓ Branch 3 taken 46343640 times.
✓ Branch 5 taken 724080 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 724080 times.
✓ Branch 8 taken 309480 times.
301397270 { return vIdxLocal_; }
162
163 //! The element-local index of this scv
164 10409328 LocalIndexType indexInElement() const
165
6/12
✓ Branch 0 taken 72577584 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 283150872 times.
✓ Branch 9 taken 6939552 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 17348880 times.
✗ Branch 13 not taken.
✓ Branch 15 taken 629600 times.
✓ Branch 16 taken 42608 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
496304220 { return elemLocalScvIdx_; }
166
167 //! The element-local facet index for which a fracture scv was created
168 2246708 LocalIndexType facetIndexInElement() const
169
6/6
✓ Branch 0 taken 724080 times.
✓ Branch 1 taken 10620 times.
✓ Branch 2 taken 724080 times.
✓ Branch 3 taken 10620 times.
✓ Branch 4 taken 10620 times.
✓ Branch 5 taken 724080 times.
2246708 { assert(isFractureScv_); return facetIdx_; }
170
171 //! The local vertex index in the intersection
172 LocalIndexType indexInsideIntersection() const
173 { assert(isFractureScv_); return indexInIntersection_; }
174
175 //! The index of the dof this scv is embedded in
176 68630178 GridIndexType dofIndex() const
177
8/12
✓ Branch 1 taken 1020605 times.
✓ Branch 2 taken 6642475 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 25477008 times.
✓ Branch 6 taken 3796122 times.
✓ Branch 7 taken 19141798 times.
✓ Branch 9 taken 136328 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 3880 times.
✓ Branch 12 taken 29864 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
68630178 { return dofIndex_; }
178
179 // The position of the dof this scv is embedded in (list is defined such that first entry is vertex itself)
180 1020605 const GlobalPosition& dofPosition() const
181
6/6
✓ Branch 0 taken 105668 times.
✓ Branch 1 taken 92976 times.
✓ Branch 2 taken 113507 times.
✓ Branch 3 taken 96954 times.
✓ Branch 4 taken 768310 times.
✓ Branch 5 taken 252295 times.
1429710 { return dofPosition_; }
182
183 //! The global index of the element this scv is embedded in
184 3469776 GridIndexType elementIndex() const
185
2/4
✗ Branch 1 not taken.
✓ Branch 2 taken 25477008 times.
✓ Branch 4 taken 136328 times.
✗ Branch 5 not taken.
36779936 { return elementIndex_; }
186
187 //! Return true if this scv is part of the fracture domain
188 109573034 bool isOnFracture() const
189
20/22
✓ Branch 0 taken 1455248 times.
✓ Branch 1 taken 2340874 times.
✓ Branch 2 taken 1455248 times.
✓ Branch 3 taken 21482672 times.
✓ Branch 4 taken 734700 times.
✓ Branch 5 taken 1033560 times.
✓ Branch 6 taken 29047680 times.
✓ Branch 7 taken 1904740 times.
✓ Branch 8 taken 734700 times.
✓ Branch 9 taken 1033560 times.
✓ Branch 10 taken 734700 times.
✓ Branch 11 taken 1033560 times.
✓ Branch 12 taken 1455248 times.
✓ Branch 13 taken 21482672 times.
✓ Branch 14 taken 1455248 times.
✓ Branch 15 taken 21482672 times.
✓ Branch 16 taken 2192 times.
✓ Branch 17 taken 31552 times.
✓ Branch 18 taken 629600 times.
✓ Branch 19 taken 42608 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
109573034 { return isFractureScv_; }
190
191 private:
192 bool isFractureScv_;
193 GlobalPosition dofPosition_;
194 GlobalPosition center_;
195 Scalar volume_;
196 GridIndexType elementIndex_;
197 LocalIndexType vIdxLocal_;
198 LocalIndexType elemLocalScvIdx_;
199 GridIndexType dofIndex_;
200
201 // for fracture scvs only!
202 LocalIndexType facetIdx_;
203 LocalIndexType indexInIntersection_;
204 };
205
206 } // end namespace
207
208 #endif
209