25#ifndef DUMUX_PNM_SPATIAL_PARAMS_BASE_HH
26#define DUMUX_PNM_SPATIAL_PARAMS_BASE_HH
31#include <dune/common/fvector.hh>
41template<
class GlobalPosition>
42struct hasMaterialLawParamsAtPos
44 template<
class SpatialParams>
45 auto operator()(
const SpatialParams& a)
46 ->
decltype(a.materialLawParamsAtPos(std::declval<GlobalPosition>()))
52template<
class GlobalPosition>
53struct hasPermeabilityAtPos
55 template<
class SpatialParams>
56 auto operator()(
const SpatialParams& a)
57 ->
decltype(a.permeabilityAtPos(std::declval<GlobalPosition>()))
61template<
class GlobalPosition,
class Sol
idSystem>
62struct hasInertVolumeFractionAtPos
64 template<
class SpatialParams>
65 auto operator()(
const SpatialParams& a)
66 ->
decltype(a.template inertVolumeFractionAtPos<SolidSystem>(std::declval<GlobalPosition>(), 0))
70template<
class GlobalPosition>
71struct hasPorosityAtPos
73 template<
class SpatialParams>
74 auto operator()(
const SpatialParams& a)
75 ->
decltype(a.porosityAtPos(std::declval<GlobalPosition>()))
90template<
class Gr
idGeometry,
class Scalar,
class Implementation>
93 using GridView =
typename GridGeometry::GridView;
94 using SubControlVolume =
typename GridGeometry::SubControlVolume;
95 using Element =
typename GridView::template Codim<0>::Entity;
97 using GlobalPosition =
typename Element::Geometry::GlobalCoordinate;
98 static constexpr auto dimWorld = GridView::dimensionworld;
107 const bool enableGravity = getParam<bool>(
"Problem.EnableGravity");
109 gravity_[dimWorld-1] = -9.81;
119 template<
class ElementVolumeVariables>
121 const ElementVolumeVariables& elemVolVars)
const
123 const auto eIdx =
gridGeometry().elementMapper().index(element);
134 template<
class ElementVolumeVariables>
136 const ElementVolumeVariables& elemVolVars)
const
138 const auto eIdx =
gridGeometry().elementMapper().index(element);
149 template<
class ElementVolumeVariables>
151 const ElementVolumeVariables& elemVolVars)
const
153 const auto eIdx =
gridGeometry().elementMapper().index(element);
165 template<
class ElementSolutionVector>
167 const SubControlVolume& scv,
168 const ElementSolutionVector& elemSol)
const
170 return gridGeometry().poreInscribedRadius(scv.dofIndex());
183 template<
class ElementSolutionVector>
185 const SubControlVolume& scv,
186 const ElementSolutionVector& elemSol)
const
199 const GlobalPosition&
gravity(
const GlobalPosition& pos)
const
204 {
return *gridGeometry_; }
216 template<
class ElementSolution>
218 const SubControlVolume& scv,
219 const ElementSolution& elemSol)
const
221 static_assert(
decltype(
isValid(Detail::hasPorosityAtPos<GlobalPosition>())(this->
asImp_()))::value,
" \n\n"
222 " Your spatial params class has to either implement\n\n"
223 " Scalar porosityAtPos(const GlobalPosition& globalPos) const\n\n"
224 " or overload this function\n\n"
225 " template<class ElementSolution>\n"
226 " Scalar porosity(const Element& element,\n"
227 " const SubControlVolume& scv,\n"
228 " const ElementSolution& elemSol) const\n\n");
230 return asImp_().porosityAtPos(scv.center());
252 template<
class SolidSystem,
class ElementSolution,
253 typename std::enable_if_t<SolidSystem::isInert()
254 && SolidSystem::numInertComponents == 1
255 && !
decltype(
isValid(Detail::hasInertVolumeFractionAtPos<GlobalPosition, SolidSystem>())(std::declval<Implementation>()))::value,
258 const SubControlVolume& scv,
259 const ElementSolution& elemSol,
262 return 1.0 -
asImp_().porosity(element, scv, elemSol);
266 template<
class SolidSystem,
class ElementSolution,
267 typename std::enable_if_t<SolidSystem::numInertComponents == 0, int> = 0>
269 const SubControlVolume& scv,
270 const ElementSolution& elemSol,
277 template<
class SolidSystem,
class ElementSolution,
278 typename std::enable_if_t<(SolidSystem::numInertComponents > 1) ||
280 (SolidSystem::numInertComponents > 0) &&
282 !SolidSystem::isInert()
283 ||
decltype(
isValid(Detail::hasInertVolumeFractionAtPos<GlobalPosition, SolidSystem>())
284 (std::declval<Implementation>()))::value
289 const SubControlVolume& scv,
290 const ElementSolution& elemSol,
293 static_assert(
decltype(
isValid(Detail::hasInertVolumeFractionAtPos<GlobalPosition, SolidSystem>())(this->
asImp_()))::value,
" \n\n"
294 " Your spatial params class has to either implement\n\n"
295 " template<class SolidSystem>\n"
296 " Scalar inertVolumeFractionAtPos(const GlobalPosition& globalPos, int compIdx) const\n\n"
297 " or overload this function\n\n"
298 " template<class SolidSystem, class ElementSolution>\n"
299 " Scalar inertVolumeFraction(const Element& element,\n"
300 " const SubControlVolume& scv,\n"
301 " const ElementSolution& elemSol,\n"
302 " int compIdx) const\n\n");
304 return asImp_().template inertVolumeFractionAtPos<SolidSystem>(scv.center(), compIdx);
309 {
return *
static_cast<Implementation*
>(
this); }
312 {
return *
static_cast<const Implementation*
>(
this); }
315 std::shared_ptr<const GridGeometry> gridGeometry_;
316 GlobalPosition gravity_;
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:33
Base class for the finite volume geometry for porenetwork models.
Definition: discretization/porenetwork/gridgeometry.hh:488
The base class for spatial parameters for pore-network models.
Definition: porenetworkbase.hh:92
Implementation & asImp_()
Definition: porenetworkbase.hh:308
Scalar porosityAtPos(const GlobalPosition &globalPos) const
Definition: porenetworkbase.hh:233
Scalar throatLength(const Element &element, const ElementVolumeVariables &elemVolVars) const
Length of the throat . Can be solution-dependent.
Definition: porenetworkbase.hh:120
const Implementation & asImp_() const
Definition: porenetworkbase.hh:311
Scalar permeability(const Element &element, const SubControlVolume &scv, const ElementSolutionVector &elemSol) const
Definition: porenetworkbase.hh:184
Scalar throatInscribedRadius(const Element &element, const ElementVolumeVariables &elemVolVars) const
Inscribed radius of the throat . Can be solution-dependent.
Definition: porenetworkbase.hh:135
const GridGeometry & gridGeometry() const
The finite volume grid geometry.
Definition: porenetworkbase.hh:203
const GlobalPosition & gravity(const GlobalPosition &pos) const
Returns the acceleration due to gravity .
Definition: porenetworkbase.hh:199
Scalar throatCrossSectionalArea(const Element &element, const ElementVolumeVariables &elemVolVars) const
Cross-sectional area of the throat . Can be solution-dependent.
Definition: porenetworkbase.hh:150
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:217
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:257
Scalar PermeabilityType
Definition: porenetworkbase.hh:101
BaseSpatialParams(std::shared_ptr< const GridGeometry > gridGeometry)
Definition: porenetworkbase.hh:103
const GridView & gridView() const
Returns a reference to the gridview.
Definition: porenetworkbase.hh:176
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:166