GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/geomechanics/poroelastic/fvspatialparams.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 6 12 50.0%
Functions: 3 11 27.3%
Branches: 3 12 25.0%

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 SpatialParameters
10 * \brief The base class for spatial parameters of poro-elastic geomechanical problems
11 */
12 #ifndef DUMUX_GEOMECHANICS_POROELASTIC_FV_SPATIAL_PARAMS_HH
13 #define DUMUX_GEOMECHANICS_POROELASTIC_FV_SPATIAL_PARAMS_HH
14
15 #include <memory>
16
17 #include <dumux/common/typetraits/isvalid.hh>
18 #include <dumux/common/fvporousmediumspatialparams.hh>
19 #include <dumux/geomechanics/spatialparamstraits_.hh>
20
21 namespace Dumux {
22
23 #ifndef DOXYGEN
24 namespace Detail {
25
26 // helper struct detecting if the user-defined problem class has an effectiveFluidDensityAtPos function
27 template<class GlobalPosition>
28 struct hasEffFluidDensityAtPos
29 {
30 template<class Problem>
31 auto operator()(const Problem& a)
32 -> decltype(a.effectiveFluidDensityAtPos(std::declval<GlobalPosition>()))
33 {}
34 };
35
36 // helper struct detecting if the user-defined problem class has an effectivePorePressureAtPos function
37 template<class GlobalPosition>
38 struct hasEffPorePressureAtPos
39 {
40 template<class Problem>
41 auto operator()(const Problem& a)
42 -> decltype(a.effectivePorePressureAtPos(std::declval<GlobalPosition>()))
43 {}
44 };
45
46 // helper struct detecting if the user-defined spatial params class has a reactiveVolumeFractionAtPos function
47 template<class GlobalPosition, class SolidSystem>
48 struct hasReactiveVolumeFractionAtPos
49 {
50 template<class SpatialParams>
51 auto operator()(const SpatialParams& a)
52 -> decltype(a.template reactiveVolumeFractionAtPos<SolidSystem>(std::declval<GlobalPosition>(), 0))
53 {}
54 };
55
56 // helper struct detecting if the user-defined spatial params class has a biotCoefficientAtPos function
57 template<class GlobalPosition>
58 struct hasBiotCoeffAtPos
59 {
60 template<class SpatialParams>
61 auto operator()(const SpatialParams& a)
62 -> decltype(a.biotCoefficientAtPos(std::declval<GlobalPosition>()))
63 {}
64 };
65
66 } // end namespace Detail
67 #endif
68
69 /*!
70 * \ingroup SpatialParameters
71 * \brief The base class for spatial parameters of poro-elastic geomechanical problems
72 */
73 template<class GridGeometry, class Scalar, class Implementation>
74
1/6
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 class FVPoroElasticSpatialParams
75 : public FVPorousMediumSpatialParams<GridGeometry, Scalar, Implementation>
76 {
77 using ParentType = FVPorousMediumSpatialParams<GridGeometry, Scalar, Implementation>;
78 using FVElementGeometry = typename GridGeometry::LocalView;
79 using SubControlVolume = typename GridGeometry::SubControlVolume;
80 using GridView = typename GridGeometry::GridView;
81 using Element = typename GridView::template Codim<0>::Entity;
82 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
83
84 public:
85 //! The constructor
86 4 FVPoroElasticSpatialParams(std::shared_ptr<const GridGeometry> gridGeometry)
87
2/6
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
4 : ParentType(gridGeometry)
88 4 {}
89
90 /*!
91 * \brief Returns the effective fluid density within an scv.
92 * \note This is only enabled if the model considers fluid phases.
93 *
94 * \param element The current element
95 * \param scv The sub-control volume
96 */
97 Scalar effectiveFluidDensity(const Element& element,
98 const SubControlVolume& scv) const
99 {
100 static_assert(decltype(isValid(Detail::hasEffFluidDensityAtPos<GlobalPosition>())(this->asImp_()))::value," \n\n"
101 " Your problem class has to either implement\n\n"
102 " Scalar effectiveFluidDensityAtPos(const GlobalPosition& globalPos) const\n\n"
103 " or overload this function\n\n"
104 " template<class ElementSolution>\n"
105 " Scalar effectiveFluidDensity(const Element& element,\n\
106 const SubControlVolume& scv) const\n\n");
107
108 return this->asImp_().effectiveFluidDensityAtPos(scv.center());
109 }
110
111 /*!
112 * \brief Returns the effective pore pressure
113 * \note This is only enabled if the model considers fluid phases.
114 * This is possibly solution dependent and is evaluated
115 * for an integration point inside the element. Therefore,
116 * a flux variables cache object is passed to this function
117 * containing data on shape functions at the integration point.
118 *
119 * \param element The current element
120 * \param fvGeometry The local finite volume geometry
121 * \param elemVolVars Primary/Secondary variables inside the element
122 * \param fluxVarsCache Contains data on shape functions at the integration point
123 */
124 template<class ElemVolVars, class FluxVarsCache>
125 Scalar effectivePorePressure(const Element& element,
126 const FVElementGeometry& fvGeometry,
127 const ElemVolVars& elemVolVars,
128 const FluxVarsCache& fluxVarsCache) const
129 {
130 static_assert(decltype(isValid(Detail::hasEffPorePressureAtPos<GlobalPosition>())(this->asImp_()))::value," \n\n"
131 " Your problem class has to either implement\n\n"
132 " Scalar effectivePorePressureAtPos(const GlobalPosition& globalPos) const\n\n"
133 " or overload this function\n\n"
134 " template<class ElementSolution>\n"
135 " Scalar effectivePorePressure(const Element& element,\n"
136 " const FVElementGeometry& fvGeometry,\n"
137 " const ElemVolVars& elemVolVars,\n"
138 " const FluxVarsCache& fluxVarsCache) const\n\n");
139
140 return this->asImp_().effectivePorePressureAtPos(element.geometry().center());
141 }
142
143 /*!
144 * \brief Function for defining the solid volume fraction of a solid
145 * component that takes part in some sort of reaction. The reaction
146 * may be described in a flow model coupled to the poroelastic model,
147 * so implementations may access quantities of the coupled domain.
148 *
149 * \param element The current element
150 * \param scv The sub-control volume inside the element.
151 * \param elemSol The solution at the dofs connected to the element.
152 * \param compIdx The solid component index
153 * \return the volume fraction of the inert solid component with index compIdx
154 *
155 * \note This overload is enabled if there are only inert solid components
156 * and the user did not choose to implement a reactiveVolumeFractionAtPos
157 * function. The reactive volume fraction is zero in this case.
158 */
159 template<class SolidSystem, class ElementSolution,
160 std::enable_if_t< SolidSystem::isInert() &&
161 !decltype(isValid(Detail::hasReactiveVolumeFractionAtPos<GlobalPosition, SolidSystem>())
162 (std::declval<Implementation>()))::value, int > = 0 >
163 Scalar reactiveVolumeFraction(const Element& element,
164 const SubControlVolume& scv,
165 const ElementSolution& elemSol,
166 int compIdx) const
167 { return 0.0; }
168
169 //! overload for the case of reactive solids or user-provided overload
170 template<class SolidSystem, class ElementSolution,
171 std::enable_if_t< !SolidSystem::isInert() ||
172 decltype(isValid(Detail::hasReactiveVolumeFractionAtPos<GlobalPosition, SolidSystem>())
173 (std::declval<Implementation>()))::value, int > = 0 >
174 Scalar reactiveVolumeFraction(const Element& element,
175 const SubControlVolume& scv,
176 const ElementSolution& elemSol,
177 int compIdx) const
178 {
179 static_assert(decltype(isValid(Detail::hasReactiveVolumeFractionAtPos<GlobalPosition, SolidSystem>())(this->asImp_()))::value," \n\n"
180 " Your spatial params class has to either implement\n\n"
181 " template<class SolidSystem>\n"
182 " Scalar inertVolumeFractionAtPos(const GlobalPosition& globalPos, int compIdx) const\n\n"
183 " or overload this function\n\n"
184 " template<class SolidSystem, class ElementSolution>\n"
185 " Scalar inertVolumeFraction(const Element& element,\n"
186 " const SubControlVolume& scv,\n"
187 " const ElementSolution& elemSol,\n"
188 " int compIdx) const\n\n");
189
190 return this->asImp_().template reactiveVolumeFractionAtPos<SolidSystem>(scv.center(), compIdx);
191 }
192
193 /*!
194 * \brief Define the Lame parameters
195 * \note These are possibly solution dependent and are evaluated
196 * for an integration point inside the element. Therefore,
197 * a flux variables cache object is passed to this function
198 * containing data on shape functions at the integration point.
199 *
200 * \param element The current element
201 * \param fvGeometry The local finite volume geometry
202 * \param elemVolVars Primary/Secondary variables inside the element
203 * \param fluxVarsCache Contains data on shape functions at the integration point
204 * \return lame parameters
205 */
206 template<class ElemVolVars, class FluxVarsCache>
207 decltype(auto) lameParams(const Element& element,
208 const FVElementGeometry& fvGeometry,
209 const ElemVolVars& elemVolVars,
210 const FluxVarsCache& fluxVarsCache) const
211 {
212 static_assert(decltype(isValid(Detail::hasLameParamsAtPos<GlobalPosition>())(this->asImp_()))::value," \n\n"
213 " Your spatial params class has to either implement\n\n"
214 " const LameParams& lameParamsAtPos(const GlobalPosition& globalPos) const\n\n"
215 " or overload this function\n\n"
216 " template<class ElementSolution>\n"
217 " const LameParams& lameParams(const Element& element,\n"
218 " const FVElementGeometry& fvGeometry,\n"
219 " const ElemVolVars& elemVolVars,\n"
220 " const FluxVarsCache& fluxVarsCache) const\n\n");
221
222 3592128 return this->asImp_().lameParamsAtPos(fluxVarsCache.ipGlobal());
223 }
224
225 /*!
226 * \brief Returns the Biot coefficient in an element
227 * \note This is possibly solution dependent and is evaluated
228 * for an integration point inside the element. Therefore,
229 * a flux variables cache object is passed to this function
230 * containing data on shape functions at the integration point.
231 *
232 * \param element The current element
233 * \param fvGeometry The local finite volume geometry
234 * \param elemVolVars Primary/Secondary variables inside the element
235 * \param fluxVarsCache Contains data on shape functions at the integration point
236 * \return Biot coefficient
237 */
238 template<class ElemVolVars, class FluxVarsCache>
239 Scalar biotCoefficient(const Element& element,
240 const FVElementGeometry& fvGeometry,
241 const ElemVolVars& elemVolVars,
242 const FluxVarsCache& fluxVarsCache) const
243 {
244 static_assert(decltype(isValid(Detail::hasBiotCoeffAtPos<GlobalPosition>())(this->asImp_()))::value," \n\n"
245 " Your spatial params class has to either implement\n\n"
246 " const LameParams& biotCoefficientAtPos(const GlobalPosition& globalPos) const\n\n"
247 " or overload this function\n\n"
248 " template<class ElementSolution>\n"
249 " const LameParams& biotCoefficient(const Element& element,\n"
250 " const FVElementGeometry& fvGeometry,\n"
251 " const ElemVolVars& elemVolVars,\n"
252 " const FluxVarsCache& fluxVarsCache) const\n\n");
253
254 2394352 return this->asImp_().biotCoefficientAtPos(fluxVarsCache.ipGlobal());
255 }
256 };
257
258 } // end namespace Dumux
259
260 #endif
261