3.5-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
porenetworkbase.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_PNM_SPATIAL_PARAMS_BASE_HH
26#define DUMUX_PNM_SPATIAL_PARAMS_BASE_HH
27
28#warning "This file is deprecated, use PoreNetwork::SpatialParams from dumux/porenetwork/common/spatialparams.hh instead!"
29
30#include <type_traits>
31#include <memory>
32
33#include <dune/common/fvector.hh>
34
36
37namespace Dumux::PoreNetwork {
38
39#ifndef DOXYGEN
40namespace Detail {
41// helper struct detecting if the user-defined spatial params class has a materialLawParamsAtPos function
42template<class GlobalPosition>
43struct hasMaterialLawParamsAtPos
44{
45 template<class SpatialParams>
46 auto operator()(const SpatialParams& a)
47 -> decltype(a.materialLawParamsAtPos(std::declval<GlobalPosition>()))
48 {}
49};
50
51// helper struct detecting if the user-defined spatial params class has a permeabilityAtPos function
52template<class GlobalPosition>
53struct hasPermeabilityAtPos
54{
55 template<class SpatialParams>
56 auto operator()(const SpatialParams& a)
57 -> decltype(a.permeabilityAtPos(std::declval<GlobalPosition>()))
58 {}
59};
60
61template<class GlobalPosition, class SolidSystem>
62struct hasInertVolumeFractionAtPos
63{
64 template<class SpatialParams>
65 auto operator()(const SpatialParams& a)
66 -> decltype(a.template inertVolumeFractionAtPos<SolidSystem>(std::declval<GlobalPosition>(), 0))
67 {}
68};
69
70template<class GlobalPosition>
71struct hasPorosityAtPos
72{
73 template<class SpatialParams>
74 auto operator()(const SpatialParams& a)
75 -> decltype(a.porosityAtPos(std::declval<GlobalPosition>()))
76 {}
77};
78
79} // end namespace Detail
80#endif
81
90template<class GridGeometry, class Scalar, class Implementation>
91class
92[[deprecated("Use PoreNetwork::SpatialParams from dumux/porenetwork/common/spatialparams.hh instead. This class will be removed after 3.5.")]]
94{
95 using GridView = typename GridGeometry::GridView;
96 using SubControlVolume = typename GridGeometry::SubControlVolume;
97 using Element = typename GridView::template Codim<0>::Entity;
98
99 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
100 static constexpr auto dimWorld = GridView::dimensionworld;
101
102public:
103 using PermeabilityType = Scalar;
104
105 BaseSpatialParams(std::shared_ptr<const GridGeometry> gridGeometry)
106 : gridGeometry_(gridGeometry)
107 , gravity_(0.0)
108 {
109 const bool enableGravity = getParam<bool>("Problem.EnableGravity");
110 if (enableGravity)
111 gravity_[dimWorld-1] = -9.81;
112 }
113
121 template<class ElementVolumeVariables>
122 Scalar throatLength(const Element& element,
123 const ElementVolumeVariables& elemVolVars) const
124 {
125 const auto eIdx = gridGeometry().elementMapper().index(element);
126 return gridGeometry().throatLength(eIdx);
127 }
128
136 template<class ElementVolumeVariables>
137 Scalar throatInscribedRadius(const Element& element,
138 const ElementVolumeVariables& elemVolVars) const
139 {
140 const auto eIdx = gridGeometry().elementMapper().index(element);
141 return gridGeometry().throatInscribedRadius(eIdx);
142 }
143
151 template<class ElementVolumeVariables>
152 Scalar throatCrossSectionalArea(const Element& element,
153 const ElementVolumeVariables& elemVolVars) const
154 {
155 const auto eIdx = gridGeometry().elementMapper().index(element);
156 return gridGeometry().throatCrossSectionalArea(eIdx);
157 }
158
167 template<class ElementSolutionVector>
168 Scalar poreInscribedRadius(const Element& element,
169 const SubControlVolume& scv,
170 const ElementSolutionVector& elemSol) const
171 {
172 return gridGeometry().poreInscribedRadius(scv.dofIndex());
173 }
174
178 const GridView& gridView() const
179 { return gridGeometry().gridView(); }
180
181
185 template<class ElementSolutionVector>
186 Scalar permeability(const Element& element,
187 const SubControlVolume& scv,
188 const ElementSolutionVector& elemSol) const
189 { return 1.0; }
190
201 const GlobalPosition& gravity(const GlobalPosition& pos) const
202 { return gravity_; }
203
206 { return *gridGeometry_; }
207
218 template<class ElementSolution>
219 Scalar porosity(const Element& element,
220 const SubControlVolume& scv,
221 const ElementSolution& elemSol) const
222 {
223 static_assert(decltype(isValid(Detail::hasPorosityAtPos<GlobalPosition>())(this->asImp_()))::value," \n\n"
224 " Your spatial params class has to either implement\n\n"
225 " Scalar porosityAtPos(const GlobalPosition& globalPos) const\n\n"
226 " or overload this function\n\n"
227 " template<class ElementSolution>\n"
228 " Scalar porosity(const Element& element,\n"
229 " const SubControlVolume& scv,\n"
230 " const ElementSolution& elemSol) const\n\n");
231
232 return asImp_().porosityAtPos(scv.center());
233 }
234
235 Scalar porosityAtPos(const GlobalPosition& globalPos) const
236 { return 1.0; }
237
254 template<class SolidSystem, class ElementSolution,
255 typename std::enable_if_t<SolidSystem::isInert()
256 && SolidSystem::numInertComponents == 1
257 && !decltype(isValid(Detail::hasInertVolumeFractionAtPos<GlobalPosition, SolidSystem>())(std::declval<Implementation>()))::value,
258 int> = 0>
259 Scalar inertVolumeFraction(const Element& element,
260 const SubControlVolume& scv,
261 const ElementSolution& elemSol,
262 int compIdx) const
263 {
264 return 1.0 - asImp_().porosity(element, scv, elemSol);
265 }
266
267 // specialization if there are no inert components at all
268 template<class SolidSystem, class ElementSolution,
269 typename std::enable_if_t<SolidSystem::numInertComponents == 0, int> = 0>
270 Scalar inertVolumeFraction(const Element& element,
271 const SubControlVolume& scv,
272 const ElementSolution& elemSol,
273 int compIdx) const
274 {
275 return 0.0;
276 }
277
278 // the more general interface forwarding to inertVolumeFractionAtPos
279 template<class SolidSystem, class ElementSolution,
280 typename std::enable_if_t<(SolidSystem::numInertComponents > 1) ||
281 (
282 (SolidSystem::numInertComponents > 0) &&
283 (
284 !SolidSystem::isInert()
285 || decltype(isValid(Detail::hasInertVolumeFractionAtPos<GlobalPosition, SolidSystem>())
286 (std::declval<Implementation>()))::value
287 )
288 ),
289 int> = 0>
290 Scalar inertVolumeFraction(const Element& element,
291 const SubControlVolume& scv,
292 const ElementSolution& elemSol,
293 int compIdx) const
294 {
295 static_assert(decltype(isValid(Detail::hasInertVolumeFractionAtPos<GlobalPosition, SolidSystem>())(this->asImp_()))::value," \n\n"
296 " Your spatial params class has to either implement\n\n"
297 " template<class SolidSystem>\n"
298 " Scalar inertVolumeFractionAtPos(const GlobalPosition& globalPos, int compIdx) const\n\n"
299 " or overload this function\n\n"
300 " template<class SolidSystem, class ElementSolution>\n"
301 " Scalar inertVolumeFraction(const Element& element,\n"
302 " const SubControlVolume& scv,\n"
303 " const ElementSolution& elemSol,\n"
304 " int compIdx) const\n\n");
305
306 return asImp_().template inertVolumeFractionAtPos<SolidSystem>(scv.center(), compIdx);
307 }
308
309protected:
310 Implementation &asImp_()
311 { return *static_cast<Implementation*>(this); }
312
313 const Implementation &asImp_() const
314 { return *static_cast<const Implementation*>(this); }
315
316private:
317 std::shared_ptr<const GridGeometry> gridGeometry_;
318 GlobalPosition gravity_;
319};
320
321} // namespace Dumux::PoreNetwork
322
323#endif
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.
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
Definition: discretization/porenetwork/fvelementgeometry.hh:34
Base class for the finite volume geometry for porenetwork models.
Definition: discretization/porenetwork/gridgeometry.hh:489
The base class for spatial parameters for pore-network models.
Definition: porenetworkbase.hh:94
Implementation & asImp_()
Definition: porenetworkbase.hh:310
Scalar porosityAtPos(const GlobalPosition &globalPos) const
Definition: porenetworkbase.hh:235
Scalar throatLength(const Element &element, const ElementVolumeVariables &elemVolVars) const
Length of the throat . Can be solution-dependent.
Definition: porenetworkbase.hh:122
const Implementation & asImp_() const
Definition: porenetworkbase.hh:313
Scalar permeability(const Element &element, const SubControlVolume &scv, const ElementSolutionVector &elemSol) const
Definition: porenetworkbase.hh:186
Scalar throatInscribedRadius(const Element &element, const ElementVolumeVariables &elemVolVars) const
Inscribed radius of the throat . Can be solution-dependent.
Definition: porenetworkbase.hh:137
const GridGeometry & gridGeometry() const
The finite volume grid geometry.
Definition: porenetworkbase.hh:205
const GlobalPosition & gravity(const GlobalPosition &pos) const
Returns the acceleration due to gravity .
Definition: porenetworkbase.hh:201
Scalar throatCrossSectionalArea(const Element &element, const ElementVolumeVariables &elemVolVars) const
Cross-sectional area of the throat . Can be solution-dependent.
Definition: porenetworkbase.hh:152
Scalar porosity(const Element &element, const SubControlVolume &scv, const ElementSolution &elemSol) const
Function for defining the porosity. That is possibly solution dependent.
Definition: porenetworkbase.hh:219
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: porenetworkbase.hh:259
Scalar PermeabilityType
Definition: porenetworkbase.hh:103
BaseSpatialParams(std::shared_ptr< const GridGeometry > gridGeometry)
Definition: porenetworkbase.hh:105
const GridView & gridView() const
Returns a reference to the gridview.
Definition: porenetworkbase.hh:178
Scalar poreInscribedRadius(const Element &element, const SubControlVolume &scv, const ElementSolutionVector &elemSol) const
Inscribed radius of the pore body . Can be solution-dependent.
Definition: porenetworkbase.hh:168