version 3.8
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// SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
13#ifndef DUMUX_POROUS_MEDIUM_FV_SPATIAL_PARAMS_HH
14#define DUMUX_POROUS_MEDIUM_FV_SPATIAL_PARAMS_HH
15
18
19namespace Dumux {
20
21#ifndef DOXYGEN
22namespace Detail {
23template<class GlobalPosition, class SolidSystem>
24struct hasInertVolumeFractionAtPos
25{
26 template<class SpatialParams>
27 auto operator()(const SpatialParams& a)
28 -> decltype(a.template inertVolumeFractionAtPos<SolidSystem>(std::declval<GlobalPosition>(), 0))
29 {}
30};
31
32template<class GlobalPosition>
33struct hasPorosityAtPos
34{
35 template<class SpatialParams>
36 auto operator()(const SpatialParams& a)
37 -> decltype(a.porosityAtPos(std::declval<GlobalPosition>()))
38 {}
39};
40} // end namespace Detail
41#endif
42
48template<class GridGeometry, class Scalar, class Implementation>
50: public FVSpatialParams<GridGeometry, Scalar, Implementation>
51{
53 using GridView = typename GridGeometry::GridView;
54 using FVElementGeometry = typename GridGeometry::LocalView;
55 using SubControlVolume = typename GridGeometry::SubControlVolume;
56 using Element = typename GridView::template Codim<0>::Entity;
57 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
58
59public:
60 FVPorousMediumSpatialParams(std::shared_ptr<const GridGeometry> gridGeometry)
62 {}
63
74 template<class ElementSolution>
75 Scalar porosity(const Element& element,
76 const SubControlVolume& scv,
77 const ElementSolution& elemSol) const
78 {
79 static_assert(decltype(isValid(Detail::hasPorosityAtPos<GlobalPosition>())(this->asImp_()))::value," \n\n"
80 " Your spatial params class has to either implement\n\n"
81 " Scalar porosityAtPos(const GlobalPosition& globalPos) const\n\n"
82 " or overload this function\n\n"
83 " template<class ElementSolution>\n"
84 " Scalar porosity(const Element& element,\n"
85 " const SubControlVolume& scv,\n"
86 " const ElementSolution& elemSol) const\n\n");
87
88 return this->asImp_().porosityAtPos(scv.center());
89 }
90
107 template<class SolidSystem, class ElementSolution,
108 typename std::enable_if_t<SolidSystem::isInert()
109 && SolidSystem::numInertComponents == 1
110 && !decltype(isValid(Detail::hasInertVolumeFractionAtPos<GlobalPosition, SolidSystem>())(std::declval<Implementation>()))::value,
111 int> = 0>
112 Scalar inertVolumeFraction(const Element& element,
113 const SubControlVolume& scv,
114 const ElementSolution& elemSol,
115 int compIdx) const
116 {
117 return 1.0 - this->asImp_().porosity(element, scv, elemSol);
118 }
119
120 // specialization if there are no inert components at all
121 template<class SolidSystem, class ElementSolution,
122 typename std::enable_if_t<SolidSystem::numInertComponents == 0, int> = 0>
123 Scalar inertVolumeFraction(const Element& element,
124 const SubControlVolume& scv,
125 const ElementSolution& elemSol,
126 int compIdx) const
127 {
128 return 0.0;
129 }
130
131 // the more general interface forwarding to inertVolumeFractionAtPos
132 template<class SolidSystem, class ElementSolution,
133 typename std::enable_if_t<(SolidSystem::numInertComponents > 1) ||
134 (
135 (SolidSystem::numInertComponents > 0) &&
136 (
137 !SolidSystem::isInert()
138 || decltype(isValid(Detail::hasInertVolumeFractionAtPos<GlobalPosition, SolidSystem>())
139 (std::declval<Implementation>()))::value
140 )
141 ),
142 int> = 0>
143 Scalar inertVolumeFraction(const Element& element,
144 const SubControlVolume& scv,
145 const ElementSolution& elemSol,
146 int compIdx) const
147 {
148 static_assert(decltype(isValid(Detail::hasInertVolumeFractionAtPos<GlobalPosition, SolidSystem>())(this->asImp_()))::value," \n\n"
149 " Your spatial params class has to either implement\n\n"
150 " template<class SolidSystem>\n"
151 " Scalar inertVolumeFractionAtPos(const GlobalPosition& globalPos, int compIdx) const\n\n"
152 " or overload this function\n\n"
153 " template<class SolidSystem, class ElementSolution>\n"
154 " Scalar inertVolumeFraction(const Element& element,\n"
155 " const SubControlVolume& scv,\n"
156 " const ElementSolution& elemSol,\n"
157 " int compIdx) const\n\n");
158
159 return this->asImp_().template inertVolumeFractionAtPos<SolidSystem>(scv.center(), compIdx);
160 }
161};
162
163} // namespace Dumux
164
165#endif
The base class for spatial parameters of porous-medium problems.
Definition: fvporousmediumspatialparams.hh:51
FVPorousMediumSpatialParams(std::shared_ptr< const GridGeometry > gridGeometry)
Definition: fvporousmediumspatialparams.hh:60
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:75
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:112
The base class for spatial parameters used with finite-volume schemes.
Definition: common/fvspatialparams.hh:34
Implementation & asImp_()
Returns the implementation of the spatial parameters (static polymorphism)
Definition: common/fvspatialparams.hh:135
const GridGeometry & gridGeometry() const
The finite volume grid geometry.
Definition: common/fvspatialparams.hh:130
Basic spatial parameters to be used with finite-volume schemes.
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.
Definition: adapt.hh:17