3.2-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
fvporoelastic.hh
Go to the documentation of this file.
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 * See the file COPYING for full copying permissions. *
5 * *
6 * This program is free software: you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation, either version 3 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
18 *****************************************************************************/
24#ifndef DUMUX_GEOMECHANICS_POROELASTIC_FV_SPATIAL_PARAMS_HH
25#define DUMUX_GEOMECHANICS_POROELASTIC_FV_SPATIAL_PARAMS_HH
26
27#include <memory>
28
32
33namespace Dumux {
34
35#ifndef DOXYGEN
36namespace Detail {
37// helper struct detecting if the user-defined spatial params class has a lameParamsAtPos function
38// for g++ > 5.3, this can be replaced by a lambda
39template<class GlobalPosition>
40struct hasLameParamsAtPos
41{
42 template<class SpatialParams>
43 auto operator()(const SpatialParams& a)
44 -> decltype(a.lameParamsAtPos(std::declval<GlobalPosition>()))
45 {}
46};
47
48// helper struct detecting if the user-defined spatial params class has a reactiveVolumeFractionAtPos function
49// for g++ > 5.3, this can be replaced by a lambda
50template<class GlobalPosition, class SolidSystem>
51struct hasReactiveVolumeFractionAtPos
52{
53 template<class SpatialParams>
54 auto operator()(const SpatialParams& a)
55 -> decltype(a.template reactiveVolumeFractionAtPos<SolidSystem>(std::declval<GlobalPosition>(), 0))
56 {}
57};
58
59// helper struct detecting if the user-defined spatial params class has a biotCoefficientAtPos function
60// for g++ > 5.3, this can be replaced by a lambda
61template<class GlobalPosition>
62struct hasBiotCoeffAtPos
63{
64 template<class SpatialParams>
65 auto operator()(const SpatialParams& a)
66 -> decltype(a.biotCoefficientAtPos(std::declval<GlobalPosition>()))
67 {}
68};
69
70} // end namespace Detail
71#endif
72
77template<class Scalar, class GridGeometry, class Implementation>
79{
80 using FVElementGeometry = typename GridGeometry::LocalView;
81 using SubControlVolume = typename GridGeometry::SubControlVolume;
82 using GridView = typename GridGeometry::GridView;
83 using Element = typename GridView::template Codim<0>::Entity;
84 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
85
86 enum { dimWorld = GridView::dimensionworld };
87
88public:
90 FVSpatialParamsPoroElastic(std::shared_ptr<const GridGeometry> gridGeometry)
91 : gridGeometry_(gridGeometry)
92 , gravity_(0.0)
93 {
94 const bool enableGravity = getParam<bool>("Problem.EnableGravity");
95 if (enableGravity)
96 gravity_[dimWorld-1] = -9.81;
97 }
98
109 const GlobalPosition& gravity(const GlobalPosition &pos) const
110 { return gravity_; }
111
122 template<class ElementSolution>
123 Scalar porosity(const Element& element,
124 const SubControlVolume& scv,
125 const ElementSolution& elemSol) const
126 {
127 static_assert(decltype(isValid(Detail::hasPorosityAtPos<GlobalPosition>())(this->asImp_()))::value," \n\n"
128 " Your spatial params class has to either implement\n\n"
129 " Scalar porosityAtPos(const GlobalPosition& globalPos) const\n\n"
130 " or overload this function\n\n"
131 " template<class ElementSolution>\n"
132 " Scalar porosity(const Element& element,\n"
133 " const SubControlVolume& scv,\n"
134 " const ElementSolution& elemSol) const\n\n");
135
136 return asImp_().porosityAtPos(scv.center());
137 }
138
155 template<class SolidSystem, class ElementSolution,
156 typename std::enable_if_t<SolidSystem::isInert()
157 && SolidSystem::numInertComponents == 1
158 && !decltype(isValid(Detail::hasInertVolumeFractionAtPos<GlobalPosition, SolidSystem>())
159 (std::declval<Implementation>()))::value, int> = 0>
160 Scalar inertVolumeFraction(const Element& element,
161 const SubControlVolume& scv,
162 const ElementSolution& elemSol,
163 int compIdx) const
164 { return 1.0 - asImp_().porosity(element, scv, elemSol); }
165
166 // specialization if there are no inert components at all
167 template<class SolidSystem, class ElementSolution, typename std::enable_if_t<SolidSystem::numInertComponents == 0, int> = 0>
168 Scalar inertVolumeFraction(const Element& element,
169 const SubControlVolume& scv,
170 const ElementSolution& elemSol,
171 int compIdx) const
172 { return 0.0; }
173
174 // the more general interface forwarding to inertVolumeFractionAtPos
175 template<class SolidSystem, class ElementSolution,
176 typename std::enable_if_t<(SolidSystem::numInertComponents > 1) ||
177 (
178 (SolidSystem::numInertComponents > 0) &&
179 (
180 !SolidSystem::isInert()
181 || decltype(isValid(Detail::hasInertVolumeFractionAtPos<GlobalPosition, SolidSystem>())
182 (std::declval<Implementation>()))::value
183 )
184 ), int> = 0>
185 Scalar inertVolumeFraction(const Element& element,
186 const SubControlVolume& scv,
187 const ElementSolution& elemSol,
188 int compIdx) const
189 {
190 static_assert(decltype(isValid(Detail::hasInertVolumeFractionAtPos<GlobalPosition, SolidSystem>())(this->asImp_()))::value," \n\n"
191 " Your spatial params class has to either implement\n\n"
192 " template<class SolidSystem>\n"
193 " Scalar inertVolumeFractionAtPos(const GlobalPosition& globalPos, int compIdx) const\n\n"
194 " or overload this function\n\n"
195 " template<class SolidSystem, class ElementSolution>\n"
196 " Scalar inertVolumeFraction(const Element& element,\n"
197 " const SubControlVolume& scv,\n"
198 " const ElementSolution& elemSol,\n"
199 " int compIdx) const\n\n");
200
201 return asImp_().template inertVolumeFractionAtPos<SolidSystem>(scv.center(), compIdx);
202 }
203
218 template<class SolidSystem, class ElementSolution,
219 std::enable_if_t< SolidSystem::isInert() &&
220 !decltype(isValid(Detail::hasReactiveVolumeFractionAtPos<GlobalPosition, SolidSystem>())
221 (std::declval<Implementation>()))::value, int > = 0 >
222 Scalar reactiveVolumeFraction(const Element& element,
223 const SubControlVolume& scv,
224 const ElementSolution& elemSol,
225 int compIdx) const
226 { return 0.0; }
227
229 template<class SolidSystem, class ElementSolution,
230 std::enable_if_t< !SolidSystem::isInert() ||
231 decltype(isValid(Detail::hasReactiveVolumeFractionAtPos<GlobalPosition, SolidSystem>())
232 (std::declval<Implementation>()))::value, int > = 0 >
233 Scalar reactiveVolumeFraction(const Element& element,
234 const SubControlVolume& scv,
235 const ElementSolution& elemSol,
236 int compIdx) const
237 {
238 static_assert(decltype(isValid(Detail::hasReactiveVolumeFractionAtPos<GlobalPosition, SolidSystem>())(this->asImp_()))::value," \n\n"
239 " Your spatial params class has to either implement\n\n"
240 " template<class SolidSystem>\n"
241 " Scalar inertVolumeFractionAtPos(const GlobalPosition& globalPos, int compIdx) const\n\n"
242 " or overload this function\n\n"
243 " template<class SolidSystem, class ElementSolution>\n"
244 " Scalar inertVolumeFraction(const Element& element,\n"
245 " const SubControlVolume& scv,\n"
246 " const ElementSolution& elemSol,\n"
247 " int compIdx) const\n\n");
248
249 return asImp_().template reactiveVolumeFractionAtPos<SolidSystem>(scv.center(), compIdx);
250 }
251
265 template<class ElemVolVars, class FluxVarsCache>
266 decltype(auto) lameParams(const Element& element,
267 const FVElementGeometry& fvGeometry,
268 const ElemVolVars& elemVolVars,
269 const FluxVarsCache& fluxVarsCache) const
270 {
271 static_assert(decltype(isValid(Detail::hasLameParamsAtPos<GlobalPosition>())(this->asImp_()))::value," \n\n"
272 " Your spatial params class has to either implement\n\n"
273 " const LameParams& lameParamsAtPos(const GlobalPosition& globalPos) const\n\n"
274 " or overload this function\n\n"
275 " template<class ElementSolution>\n"
276 " const LameParams& lameParams(const Element& element,\n"
277 " const FVElementGeometry& fvGeometry,\n"
278 " const ElemVolVars& elemVolVars,\n"
279 " const FluxVarsCache& fluxVarsCache) const\n\n");
280
281 return asImp_().lameParamsAtPos(fluxVarsCache.ipGlobal());
282 }
283
297 template<class ElemVolVars, class FluxVarsCache>
298 Scalar biotCoefficient(const Element& element,
299 const FVElementGeometry& fvGeometry,
300 const ElemVolVars& elemVolVars,
301 const FluxVarsCache& fluxVarsCache) const
302 {
303 static_assert(decltype(isValid(Detail::hasBiotCoeffAtPos<GlobalPosition>())(this->asImp_()))::value," \n\n"
304 " Your spatial params class has to either implement\n\n"
305 " const LameParams& biotCoefficientAtPos(const GlobalPosition& globalPos) const\n\n"
306 " or overload this function\n\n"
307 " template<class ElementSolution>\n"
308 " const LameParams& biotCoefficient(const Element& element,\n"
309 " const FVElementGeometry& fvGeometry,\n"
310 " const ElemVolVars& elemVolVars,\n"
311 " const FluxVarsCache& fluxVarsCache) const\n\n");
312
313 return asImp_().biotCoefficientAtPos(fluxVarsCache.ipGlobal());
314 }
315
317 const GridGeometry& gridGeometry() const
318 { return *gridGeometry_; }
319
320protected:
321 Implementation &asImp_()
322 { return *static_cast<Implementation*>(this); }
323
324 const Implementation &asImp_() const
325 { return *static_cast<const Implementation*>(this); }
326
327private:
328 std::shared_ptr<const GridGeometry> gridGeometry_;
329 GlobalPosition gravity_;
330};
331} // end namespace Dumux
332#endif
A helper function for class member function introspection.
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.
The base class for spatial parameters of one-phase problems using a fully implicit discretization met...
Definition: adapt.hh:29
constexpr auto isValid(const Expression &t)
A function that creates a test functor to do class member introspection at compile time.
Definition: isvalid.hh:93
The base class for spatial parameters of poro-elastic geomechanical problems.
Definition: fvporoelastic.hh:79
const GlobalPosition & gravity(const GlobalPosition &pos) const
Returns the acceleration due to gravity .
Definition: fvporoelastic.hh:109
const GridGeometry & gridGeometry() const
The finite volume grid geometry.
Definition: fvporoelastic.hh:317
const Implementation & asImp_() const
Definition: fvporoelastic.hh:324
Scalar reactiveVolumeFraction(const Element &element, const SubControlVolume &scv, const ElementSolution &elemSol, int compIdx) const
Function for defining the solid volume fraction of a solid component that takes part in some sort of ...
Definition: fvporoelastic.hh:222
Scalar inertVolumeFraction(const Element &element, const SubControlVolume &scv, const ElementSolution &elemSol, int compIdx) const
Function for defining the solid volume fraction. That is possibly solution dependent.
Definition: fvporoelastic.hh:160
decltype(auto) lameParams(const Element &element, const FVElementGeometry &fvGeometry, const ElemVolVars &elemVolVars, const FluxVarsCache &fluxVarsCache) const
Define the Lame parameters.
Definition: fvporoelastic.hh:266
Scalar porosity(const Element &element, const SubControlVolume &scv, const ElementSolution &elemSol) const
Function for defining the porosity. That is possibly solution dependent.
Definition: fvporoelastic.hh:123
Scalar biotCoefficient(const Element &element, const FVElementGeometry &fvGeometry, const ElemVolVars &elemVolVars, const FluxVarsCache &fluxVarsCache) const
Returns the Biot coefficient in an element.
Definition: fvporoelastic.hh:298
Implementation & asImp_()
Definition: fvporoelastic.hh:321
FVSpatialParamsPoroElastic(std::shared_ptr< const GridGeometry > gridGeometry)
The constructor.
Definition: fvporoelastic.hh:90