3.6-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
fvporousmediumspatialparams.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 *****************************************************************************/
25#ifndef DUMUX_POROUS_MEDIUM_FV_SPATIAL_PARAMS_HH
26#define DUMUX_POROUS_MEDIUM_FV_SPATIAL_PARAMS_HH
27
30
31namespace Dumux {
32
33#ifndef DOXYGEN
34namespace Detail {
35template<class GlobalPosition, class SolidSystem>
36struct hasInertVolumeFractionAtPos
37{
38 template<class SpatialParams>
39 auto operator()(const SpatialParams& a)
40 -> decltype(a.template inertVolumeFractionAtPos<SolidSystem>(std::declval<GlobalPosition>(), 0))
41 {}
42};
43
44template<class GlobalPosition>
45struct hasPorosityAtPos
46{
47 template<class SpatialParams>
48 auto operator()(const SpatialParams& a)
49 -> decltype(a.porosityAtPos(std::declval<GlobalPosition>()))
50 {}
51};
52} // end namespace Detail
53#endif
54
60template<class GridGeometry, class Scalar, class Implementation>
62: public FVSpatialParams<GridGeometry, Scalar, Implementation>
63{
65 using GridView = typename GridGeometry::GridView;
66 using FVElementGeometry = typename GridGeometry::LocalView;
67 using SubControlVolume = typename GridGeometry::SubControlVolume;
68 using Element = typename GridView::template Codim<0>::Entity;
69 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
70
71public:
72 FVPorousMediumSpatialParams(std::shared_ptr<const GridGeometry> gridGeometry)
74 {}
75
86 template<class ElementSolution>
87 Scalar porosity(const Element& element,
88 const SubControlVolume& scv,
89 const ElementSolution& elemSol) const
90 {
91 static_assert(decltype(isValid(Detail::hasPorosityAtPos<GlobalPosition>())(this->asImp_()))::value," \n\n"
92 " Your spatial params class has to either implement\n\n"
93 " Scalar porosityAtPos(const GlobalPosition& globalPos) const\n\n"
94 " or overload this function\n\n"
95 " template<class ElementSolution>\n"
96 " Scalar porosity(const Element& element,\n"
97 " const SubControlVolume& scv,\n"
98 " const ElementSolution& elemSol) const\n\n");
99
100 return this->asImp_().porosityAtPos(scv.center());
101 }
102
119 template<class SolidSystem, class ElementSolution,
120 typename std::enable_if_t<SolidSystem::isInert()
121 && SolidSystem::numInertComponents == 1
122 && !decltype(isValid(Detail::hasInertVolumeFractionAtPos<GlobalPosition, SolidSystem>())(std::declval<Implementation>()))::value,
123 int> = 0>
124 Scalar inertVolumeFraction(const Element& element,
125 const SubControlVolume& scv,
126 const ElementSolution& elemSol,
127 int compIdx) const
128 {
129 return 1.0 - this->asImp_().porosity(element, scv, elemSol);
130 }
131
132 // specialization if there are no inert components at all
133 template<class SolidSystem, class ElementSolution,
134 typename std::enable_if_t<SolidSystem::numInertComponents == 0, int> = 0>
135 Scalar inertVolumeFraction(const Element& element,
136 const SubControlVolume& scv,
137 const ElementSolution& elemSol,
138 int compIdx) const
139 {
140 return 0.0;
141 }
142
143 // the more general interface forwarding to inertVolumeFractionAtPos
144 template<class SolidSystem, class ElementSolution,
145 typename std::enable_if_t<(SolidSystem::numInertComponents > 1) ||
146 (
147 (SolidSystem::numInertComponents > 0) &&
148 (
149 !SolidSystem::isInert()
150 || decltype(isValid(Detail::hasInertVolumeFractionAtPos<GlobalPosition, SolidSystem>())
151 (std::declval<Implementation>()))::value
152 )
153 ),
154 int> = 0>
155 Scalar inertVolumeFraction(const Element& element,
156 const SubControlVolume& scv,
157 const ElementSolution& elemSol,
158 int compIdx) const
159 {
160 static_assert(decltype(isValid(Detail::hasInertVolumeFractionAtPos<GlobalPosition, SolidSystem>())(this->asImp_()))::value," \n\n"
161 " Your spatial params class has to either implement\n\n"
162 " template<class SolidSystem>\n"
163 " Scalar inertVolumeFractionAtPos(const GlobalPosition& globalPos, int compIdx) const\n\n"
164 " or overload this function\n\n"
165 " template<class SolidSystem, class ElementSolution>\n"
166 " Scalar inertVolumeFraction(const Element& element,\n"
167 " const SubControlVolume& scv,\n"
168 " const ElementSolution& elemSol,\n"
169 " int compIdx) const\n\n");
170
171 return this->asImp_().template inertVolumeFractionAtPos<SolidSystem>(scv.center(), compIdx);
172 }
173};
174
175} // namespace Dumux
176
177#endif
A helper function for class member function introspection.
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
Adaption of the non-isothermal two-phase two-component flow model to problems with CO2.
Definition: adapt.hh:29
The base class for spatial parameters of porous-medium problems.
Definition: fvporousmediumspatialparams.hh:63
FVPorousMediumSpatialParams(std::shared_ptr< const GridGeometry > gridGeometry)
Definition: fvporousmediumspatialparams.hh:72
Scalar porosity(const Element &element, const SubControlVolume &scv, const ElementSolution &elemSol) const
Function for defining the porosity. That is possibly solution dependent.
Definition: fvporousmediumspatialparams.hh:87
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: fvporousmediumspatialparams.hh:124
The base class for spatial parameters used with finite-volume schemes.
Definition: common/fvspatialparams.hh:46
Implementation & asImp_()
Returns the implementation of the spatial parameters (static polymorphism)
Definition: common/fvspatialparams.hh:147
const GridGeometry & gridGeometry() const
The finite volume grid geometry.
Definition: common/fvspatialparams.hh:142
Basic spatial parameters to be used with finite-volume schemes.