GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/common/fvporousmediumspatialparams.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 7 12 58.3%
Functions: 181 529 34.2%
Branches: 40 76 52.6%

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 Core
10 * \ingroup SpatialParameters
11 * \brief The base class for spatial parameters in porous medium problems.
12 */
13 #ifndef DUMUX_POROUS_MEDIUM_FV_SPATIAL_PARAMS_HH
14 #define DUMUX_POROUS_MEDIUM_FV_SPATIAL_PARAMS_HH
15
16 #include <dumux/common/fvspatialparams.hh>
17 #include <dumux/common/typetraits/isvalid.hh>
18
19 namespace Dumux {
20
21 #ifndef DOXYGEN
22 namespace Detail {
23 template<class GlobalPosition, class SolidSystem>
24 struct hasInertVolumeFractionAtPos
25 {
26 template<class SpatialParams>
27 auto operator()(const SpatialParams& a)
28 -> decltype(a.template inertVolumeFractionAtPos<SolidSystem>(std::declval<GlobalPosition>(), 0))
29 {}
30 };
31
32 template<class GlobalPosition>
33 struct hasPorosityAtPos
34 {
35 template<class SpatialParams>
36 auto operator()(const SpatialParams& a)
37 -> decltype(a.porosityAtPos(std::declval<GlobalPosition>()))
38 {}
39 };
40 } // end namespace Detail
41 #endif
42
43 /*!
44 * \ingroup Core
45 * \ingroup SpatialParameters
46 * \brief The base class for spatial parameters of porous-medium problems.
47 */
48 template<class GridGeometry, class Scalar, class Implementation>
49
6/30
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 293 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 75 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 75 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 2 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 2 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
449 class FVPorousMediumSpatialParams
50 : public FVSpatialParams<GridGeometry, Scalar, Implementation>
51 {
52 using ParentType = FVSpatialParams<GridGeometry, Scalar, Implementation>;
53 using GridView = typename GridGeometry::GridView;
54 using FVElementGeometry = typename GridGeometry::LocalView;
55 using SubControlVolume = typename GridGeometry::SubControlVolume;
56 using Element = typename GridView::template Codim<0>::Entity;
57 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
58
59 public:
60 717 FVPorousMediumSpatialParams(std::shared_ptr<const GridGeometry> gridGeometry)
61
2/6
✓ Branch 2 taken 530 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 530 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
717 : ParentType(gridGeometry)
62 717 {}
63
64 /*!
65 * \brief Function for defining the porosity.
66 * That is possibly solution dependent.
67 * \note this can only be used for solids with one inert component
68 * (see inertVolumeFraction for the more general interface)
69 * \param element The current element
70 * \param scv The sub-control volume inside the element.
71 * \param elemSol The solution at the dofs connected to the element.
72 * \return the porosity
73 */
74 template<class ElementSolution>
75 Scalar porosity(const Element& element,
76 const SubControlVolume& scv,
77 const ElementSolution& elemSol) const
78 {
79 static_assert(decltype(isValid(Detail::hasPorosityAtPos<GlobalPosition>())(this->asImp_()))::value," \n\n"
80 " Your spatial params class has to either implement\n\n"
81 " Scalar porosityAtPos(const GlobalPosition& globalPos) const\n\n"
82 " or overload this function\n\n"
83 " template<class ElementSolution>\n"
84 " Scalar porosity(const Element& element,\n"
85 " const SubControlVolume& scv,\n"
86 " const ElementSolution& elemSol) const\n\n");
87
88
16/20
✓ Branch 0 taken 3370 times.
✓ Branch 1 taken 992361 times.
✓ Branch 2 taken 3100 times.
✓ Branch 3 taken 793709 times.
✓ Branch 4 taken 1793 times.
✓ Branch 5 taken 6286 times.
✓ Branch 6 taken 528 times.
✓ Branch 7 taken 5638 times.
✓ Branch 8 taken 6582047 times.
✓ Branch 9 taken 10814346 times.
✓ Branch 10 taken 12 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 477999 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1170 times.
✓ Branch 17 taken 24 times.
✓ Branch 18 taken 3384 times.
✓ Branch 19 taken 528 times.
✗ Branch 20 not taken.
220926339 return this->asImp_().porosityAtPos(scv.center());
89 }
90
91 /*!
92 * \brief Function for defining the solid volume fraction.
93 * That is possibly solution dependent.
94 *
95 * \param element The current element
96 * \param scv The sub-control volume inside the element.
97 * \param elemSol The solution at the dofs connected to the element.
98 * \param compIdx The solid component index
99 * \return the volume fraction of the inert solid component with index compIdx
100 *
101 * \note this overload is enable if there is only one inert solid component and the
102 * user didn't choose to implement a inertVolumeFractionAtPos overload.
103 * It then forwards to the simpler porosity interface.
104 * With more than one solid components or active solid components (i.e. dissolution)
105 * please overload the more general inertVolumeFraction/inertVolumeFractionAtPos interface.
106 */
107 template<class SolidSystem, class ElementSolution,
108 typename std::enable_if_t<SolidSystem::isInert()
109 && SolidSystem::numInertComponents == 1
110 && !decltype(isValid(Detail::hasInertVolumeFractionAtPos<GlobalPosition, SolidSystem>())(std::declval<Implementation>()))::value,
111 int> = 0>
112 Scalar inertVolumeFraction(const Element& element,
113 const SubControlVolume& scv,
114 const ElementSolution& elemSol,
115 int compIdx) const
116 {
117
16/20
✓ Branch 0 taken 9517425 times.
✓ Branch 1 taken 8256229 times.
✓ Branch 2 taken 9516995 times.
✓ Branch 3 taken 8058048 times.
✓ Branch 4 taken 38203145 times.
✓ Branch 5 taken 12983395 times.
✓ Branch 6 taken 31922741 times.
✓ Branch 7 taken 2563849 times.
✓ Branch 8 taken 528 times.
✓ Branch 9 taken 5029 times.
✓ Branch 10 taken 12 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 477999 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1170 times.
✓ Branch 17 taken 24 times.
✓ Branch 18 taken 3384 times.
✓ Branch 19 taken 528 times.
✗ Branch 20 not taken.
343486744 return 1.0 - this->asImp_().porosity(element, scv, elemSol);
118 }
119
120 // specialization if there are no inert components at all
121 template<class SolidSystem, class ElementSolution,
122 typename std::enable_if_t<SolidSystem::numInertComponents == 0, int> = 0>
123 Scalar inertVolumeFraction(const Element& element,
124 const SubControlVolume& scv,
125 const ElementSolution& elemSol,
126 int compIdx) const
127 {
128 return 0.0;
129 }
130
131 // the more general interface forwarding to inertVolumeFractionAtPos
132 template<class SolidSystem, class ElementSolution,
133 typename std::enable_if_t<(SolidSystem::numInertComponents > 1) ||
134 (
135 (SolidSystem::numInertComponents > 0) &&
136 (
137 !SolidSystem::isInert()
138 || decltype(isValid(Detail::hasInertVolumeFractionAtPos<GlobalPosition, SolidSystem>())
139 (std::declval<Implementation>()))::value
140 )
141 ),
142 int> = 0>
143 Scalar inertVolumeFraction(const Element& element,
144 const SubControlVolume& scv,
145 const ElementSolution& elemSol,
146 int compIdx) const
147 {
148 static_assert(decltype(isValid(Detail::hasInertVolumeFractionAtPos<GlobalPosition, SolidSystem>())(this->asImp_()))::value," \n\n"
149 " Your spatial params class has to either implement\n\n"
150 " template<class SolidSystem>\n"
151 " Scalar inertVolumeFractionAtPos(const GlobalPosition& globalPos, int compIdx) const\n\n"
152 " or overload this function\n\n"
153 " template<class SolidSystem, class ElementSolution>\n"
154 " Scalar inertVolumeFraction(const Element& element,\n"
155 " const SubControlVolume& scv,\n"
156 " const ElementSolution& elemSol,\n"
157 " int compIdx) const\n\n");
158
159 9798538 return this->asImp_().template inertVolumeFractionAtPos<SolidSystem>(scv.center(), compIdx);
160 }
161 };
162
163 } // namespace Dumux
164
165 #endif
166