version 3.11-dev
Loading...
Searching...
No Matches
porousmediumflow/fvspatialparams.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// SPDX-FileCopyrightText: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
12#ifndef DUMUX_POROUS_MEDIUM_FLOW_FV_SPATIAL_PARAMS_HH
13#define DUMUX_POROUS_MEDIUM_FLOW_FV_SPATIAL_PARAMS_HH
14
15#include <dune/common/exceptions.hh>
16#include <dune/common/fmatrix.hh>
17
19#include <dumux/common/math.hh>
23
24namespace Dumux {
25
26#ifndef DOXYGEN
27namespace Detail {
28// helper struct detecting if the user-defined spatial params class has a permeabilityAtPos function
29template<class GlobalPosition>
30struct hasPermeabilityAtPos
31{
32 template<class SpatialParams>
33 auto operator()(const SpatialParams& a)
34 -> decltype(a.permeabilityAtPos(std::declval<GlobalPosition>()))
35 {}
36};
37} // end namespace Detail
38#endif
39
44template<class GridGeometry, class Scalar, class Implementation>
46: public FVPorousMediumSpatialParams<GridGeometry, Scalar, Implementation>
47{
49 using GridView = typename GridGeometry::GridView;
50 using FVElementGeometry = typename GridGeometry::LocalView;
51 using SubControlVolume = typename GridGeometry::SubControlVolume;
52 using SubControlVolumeFace = typename GridGeometry::SubControlVolumeFace;
53 using Element = typename GridView::template Codim<0>::Entity;
54
55 enum { dim = GridView::dimension };
56 enum { dimWorld = GridView::dimensionworld };
57 using DimWorldMatrix = Dune::FieldMatrix<Scalar, dimWorld, dimWorld>;
58
59 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
60
61public:
62 FVPorousMediumFlowSpatialParams(std::shared_ptr<const GridGeometry> gridGeometry)
63 : ParentType(gridGeometry)
64 {
65 /* \brief default forchheimer coefficient
66 * Source: Ward, J.C. 1964 Turbulent flow in porous media. ASCE J. Hydraul. Div 90 \cite ward1964 .
67 * Actually the Forchheimer coefficient is also a function of the dimensions of the
68 * porous medium. Taking it as a constant is only a first approximation
69 * (Nield, Bejan, Convection in porous media, 2006, p. 10 \cite nield2006 )
70 */
71 forchCoeffDefault_ = getParam<Scalar>("SpatialParams.ForchCoeff", 0.55);
72 }
73
83 template<class ElementSolution>
84 decltype(auto) permeability(const Element& element,
85 const SubControlVolume& scv,
86 const ElementSolution& elemSol) const
87 {
88 static_assert(decltype(isValid(Detail::hasPermeabilityAtPos<GlobalPosition>())(this->asImp_()))::value," \n\n"
89 " Your spatial params class has to either implement\n\n"
90 " const PermeabilityType& permeabilityAtPos(const GlobalPosition& globalPos) const\n\n"
91 " or overload this function\n\n"
92 " template<class ElementSolution>\n"
93 " const PermeabilityType& permeability(const Element& element,\n"
94 " const SubControlVolume& scv,\n"
95 " const ElementSolution& elemSol) const\n\n");
96
97 return this->asImp_().permeabilityAtPos(scv.center());
98 }
99
113 template<class ElementDiscretization, class IpData, class ElementSolution>
114 void permeability(const ElementDiscretization& elemDisc,
115 const IpData& ipData,
116 const ElementSolution& elemSol) const
117 {
118 static_assert(AlwaysFalse<IpData>::value, " \n\n"
119 " Your spatial params class has to overload\n\n"
120 " template<class ElementDiscretization, class IpData, class ElementSolution>\n"
121 " PermeabilityType permeability(const ElementDiscretization& elemDisc,\n"
122 " const IpData& ipData,\n"
123 " const ElementSolution& elemSol) const\n\n"
124 " returning e.g. permeabilityAtPos(ipData.global()) for a smooth permeability\n"
125 " or a value determined by elemDisc.element() for a permeability that is constant per element.\n\n");
126 }
127
133 static constexpr bool evaluatePermeabilityAtScvfIP()
134 { return false; }
135
143 Scalar beaversJosephCoeffAtPos(const GlobalPosition& globalPos) const
144 {
145 DUNE_THROW(Dune::InvalidStateException,
146 "The spatial parameters do not provide a beaversJosephCoeffAtPos() method.");
147 }
148
155 Scalar forchCoeff(const SubControlVolumeFace &scvf) const
156 {
157 return forchCoeffDefault_;
158 }
159
160private:
161 Scalar forchCoeffDefault_;
162};
163
164} // namespace Dumux
165
166#endif
void permeability(const ElementDiscretization &elemDisc, const IpData &ipData, const ElementSolution &elemSol) const
Function for defining the (intrinsic) permeability at an interpolation point.
Definition porousmediumflow/fvspatialparams.hh:114
decltype(auto) permeability(const Element &element, const SubControlVolume &scv, const ElementSolution &elemSol) const
Function for defining the (intrinsic) permeability .
Definition porousmediumflow/fvspatialparams.hh:84
static constexpr bool evaluatePermeabilityAtScvfIP()
If the permeability should be evaluated directly at the scvf integration point (for convergence tests...
Definition porousmediumflow/fvspatialparams.hh:133
FVPorousMediumFlowSpatialParams(std::shared_ptr< const GridGeometry > gridGeometry)
Definition porousmediumflow/fvspatialparams.hh:62
Scalar beaversJosephCoeffAtPos(const GlobalPosition &globalPos) const
Function for defining the Beavers-Joseph coefficient for multidomain problems .
Definition porousmediumflow/fvspatialparams.hh:143
Scalar forchCoeff(const SubControlVolumeFace &scvf) const
Apply the Forchheimer coefficient for inertial forces calculation.
Definition porousmediumflow/fvspatialparams.hh:155
FVPorousMediumSpatialParams(std::shared_ptr< const GridGeometry > gridGeometry)
Definition fvporousmediumspatialparams.hh:61
Implementation & asImp_()
Returns the implementation of the spatial parameters (static polymorphism).
Definition common/fvspatialparams.hh:166
const GridGeometry & gridGeometry() const
The finite volume grid geometry.
Definition common/fvspatialparams.hh:161
Type traits.
The base class for spatial parameters in porous medium problems.
T getParam(Args &&... args)
A free function to get a parameter from the parameter tree singleton.
Definition parameters.hh:155
constexpr auto isValid(const Expression &t)
A function that creates a test functor to do class member introspection at compile time.
Definition isvalid.hh:81
A helper function for class member function introspection.
Define some often used mathematical functions.
Definition cvfelocalresidual.hh:25
Definition adapt.hh:17
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.
Template which always yields a false value.
Definition common/typetraits/typetraits.hh:24