3.2-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
fvelastic.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_ELASTIC_FV_SPATIAL_PARAMS_HH
25#define DUMUX_GEOMECHANICS_ELASTIC_FV_SPATIAL_PARAMS_HH
26
27#include <memory>
28
29#include <dune/common/exceptions.hh>
30
33
34namespace Dumux {
35
36#ifndef DOXYGEN
37namespace Detail {
38// helper struct detecting if the user-defined spatial params class has a lameParamsAtPos function
39// for g++ > 5.3, this can be replaced by a lambda
40template<class GlobalPosition>
41struct hasLameParamsAtPos
42{
43 template<class SpatialParams>
44 auto operator()(const SpatialParams& a)
45 -> decltype(a.lameParamsAtPos(std::declval<GlobalPosition>()))
46 {}
47};
48
49} // end namespace Detail
50#endif
51
56template<class Scalar, class GridGeometry, class Implementation>
58{
59 using FVElementGeometry = typename GridGeometry::LocalView;
60 using SubControlVolume = typename GridGeometry::SubControlVolume;
61 using GridView = typename GridGeometry::GridView;
62 using Element = typename GridView::template Codim<0>::Entity;
63 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
64
65 enum { dimWorld = GridView::dimensionworld };
66
67public:
69 FVSpatialParamsElastic(std::shared_ptr<const GridGeometry> gridGeometry)
70 : gridGeometry_(gridGeometry)
71 , gravity_(0.0)
72 {
73 const bool enableGravity = getParam<bool>("Problem.EnableGravity");
74 if (enableGravity)
75 gravity_[dimWorld-1] = -9.81;
76 }
77
88 const GlobalPosition& gravity(const GlobalPosition &pos) const
89 { return gravity_; }
90
101 template<class SolidSystem, class ElementSolution>
102 Scalar inertVolumeFraction(const Element& element,
103 const SubControlVolume& scv,
104 const ElementSolution& elemSol,
105 int compIdx) const
106 {
107 static_assert(SolidSystem::isInert(), "Elastic model can only be used with inert solid systems");
108
109 // when there is only one component, the volume fraction must be one
110 if (SolidSystem::numInertComponents == 1)
111 return 1.0;
112
113 // otherwise we require the user to define the solid composition
114 return asImp_().template inertVolumeFractionAtPos<SolidSystem>(scv.center(), compIdx);
115 }
116
125 template<class SolidSystem>
126 Scalar inertVolumeFractionAtPos(const GlobalPosition& globalPos, int compIdx) const
127 { DUNE_THROW(Dune::InvalidStateException, "The spatial parameters do not provide inertVolumeFractionAtPos() method."); }
128
142 template<class ElemVolVars, class FluxVarsCache>
143 decltype(auto) lameParams(const Element& element,
144 const FVElementGeometry& fvGeometry,
145 const ElemVolVars& elemVolVars,
146 const FluxVarsCache& fluxVarsCache) const
147 {
148 static_assert(decltype(isValid(Detail::hasLameParamsAtPos<GlobalPosition>())(this->asImp_()))::value," \n\n"
149 " Your spatial params class has to either implement\n\n"
150 " const LameParams& lameParamsAtPos(const GlobalPosition& globalPos) const\n\n"
151 " or overload this function\n\n"
152 " template<class ElementSolution>\n"
153 " const LameParams& lameParams(const Element& element,\n"
154 " const FVElementGeometry& fvGeometry,\n"
155 " const ElemVolVars& elemVolVars,\n"
156 " const FluxVarsCache& fluxVarsCache) const\n\n");
157
158 return asImp_().lameParamsAtPos(fluxVarsCache.ipGlobal());
159 }
160
162 const GridGeometry& gridGeometry() const
163 { return *gridGeometry_; }
164
165protected:
166 Implementation &asImp_()
167 { return *static_cast<Implementation*>(this); }
168
169 const Implementation &asImp_() const
170 { return *static_cast<const Implementation*>(this); }
171
172private:
173 std::shared_ptr<const GridGeometry> gridGeometry_;
174 GlobalPosition gravity_;
175};
176} // end namespace Dumuxs
177#endif
A helper function for class member function introspection.
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.
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 linear elastic geomechanical problems.
Definition: fvelastic.hh:58
const Implementation & asImp_() const
Definition: fvelastic.hh:169
decltype(auto) lameParams(const Element &element, const FVElementGeometry &fvGeometry, const ElemVolVars &elemVolVars, const FluxVarsCache &fluxVarsCache) const
Define the Lame parameters.
Definition: fvelastic.hh:143
Scalar inertVolumeFractionAtPos(const GlobalPosition &globalPos, int compIdx) const
Function for defining the solid volume fraction. That is possibly solution dependent.
Definition: fvelastic.hh:126
const GridGeometry & gridGeometry() const
The finite volume grid geometry.
Definition: fvelastic.hh:162
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: fvelastic.hh:102
Implementation & asImp_()
Definition: fvelastic.hh:166
FVSpatialParamsElastic(std::shared_ptr< const GridGeometry > gridGeometry)
The constructor.
Definition: fvelastic.hh:69
const GlobalPosition & gravity(const GlobalPosition &pos) const
Returns the acceleration due to gravity .
Definition: fvelastic.hh:88