version 3.11-dev
Loading...
Searching...
No Matches
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-FileCopyrightText: 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)
61 : ParentType(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
99 template<class IpData, class ElementSolution>
100 Scalar porosity(const FVElementGeometry& fvGeometry,
101 const IpData& ipData,
102 const ElementSolution& elemSol) const
103 {
104 // forward to generic interface
105 return this->asImp_().porosityAtPos(ipData.global());
106 }
107
124 template<class SolidSystem, class ElementSolution,
125 typename std::enable_if_t<SolidSystem::isInert()
126 && SolidSystem::numInertComponents == 1
127 && !decltype(isValid(Detail::hasInertVolumeFractionAtPos<GlobalPosition, SolidSystem>())(std::declval<Implementation>()))::value,
128 int> = 0>
129 Scalar inertVolumeFraction(const Element& element,
130 const SubControlVolume& scv,
131 const ElementSolution& elemSol,
132 int compIdx) const
133 {
134 return 1.0 - this->asImp_().porosity(element, scv, elemSol);
135 }
136
138 template<class SolidSystem, class IpData, class ElementSolution>
139 requires (SolidSystem::isInert()
140 && SolidSystem::numInertComponents == 1
141 && !decltype(isValid(Detail::hasInertVolumeFractionAtPos<GlobalPosition, SolidSystem>())(std::declval<Implementation>()))::value)
142 Scalar inertVolumeFraction(const FVElementGeometry& fvGeometry,
143 const IpData& ipData,
144 const ElementSolution& elemSol,
145 int compIdx) const
146 {
147 return 1.0 - this->asImp_().porosity(fvGeometry, ipData, elemSol);
148 }
149
150 // specialization if there are no inert components at all
151 template<class SolidSystem, class ElementSolution,
152 typename std::enable_if_t<SolidSystem::numInertComponents == 0, int> = 0>
153 Scalar inertVolumeFraction(const Element& element,
154 const SubControlVolume& scv,
155 const ElementSolution& elemSol,
156 int compIdx) const
157 {
158 return 0.0;
159 }
160
162 template<class SolidSystem, class IpData, class ElementSolution>
163 requires (SolidSystem::numInertComponents == 0)
164 Scalar inertVolumeFraction(const FVElementGeometry& fvGeometry,
165 const IpData& ipData,
166 const ElementSolution& elemSol,
167 int compIdx) const
168 {
169 return 0.0;
170 }
171
172 // the more general interface forwarding to inertVolumeFractionAtPos
173 template<class SolidSystem, class ElementSolution,
174 typename std::enable_if_t<(SolidSystem::numInertComponents > 1) ||
175 (
176 (SolidSystem::numInertComponents > 0) &&
177 (
178 !SolidSystem::isInert()
179 || decltype(isValid(Detail::hasInertVolumeFractionAtPos<GlobalPosition, SolidSystem>())
180 (std::declval<Implementation>()))::value
181 )
182 ),
183 int> = 0>
184 Scalar inertVolumeFraction(const Element& element,
185 const SubControlVolume& scv,
186 const ElementSolution& elemSol,
187 int compIdx) const
188 {
189 static_assert(decltype(isValid(Detail::hasInertVolumeFractionAtPos<GlobalPosition, SolidSystem>())(this->asImp_()))::value," \n\n"
190 " Your spatial params class has to either implement\n\n"
191 " template<class SolidSystem>\n"
192 " Scalar inertVolumeFractionAtPos(const GlobalPosition& globalPos, int compIdx) const\n\n"
193 " or overload this function\n\n"
194 " template<class SolidSystem, class ElementSolution>\n"
195 " Scalar inertVolumeFraction(const Element& element,\n"
196 " const SubControlVolume& scv,\n"
197 " const ElementSolution& elemSol,\n"
198 " int compIdx) const\n\n");
199
200 return this->asImp_().template inertVolumeFractionAtPos<SolidSystem>(scv.center(), compIdx);
201 }
202
204 template<class SolidSystem, class IpData, class ElementSolution>
205 requires ((SolidSystem::numInertComponents > 1)
206 || ((SolidSystem::numInertComponents > 0)
207 && (!SolidSystem::isInert()
208 || decltype(isValid(Detail::hasInertVolumeFractionAtPos<GlobalPosition, SolidSystem>())
209 (std::declval<Implementation>()))::value)))
210 Scalar inertVolumeFraction(const FVElementGeometry& fvGeometry,
211 const IpData& ipData,
212 const ElementSolution& elemSol,
213 int compIdx) const
214 { return this->asImp_().template inertVolumeFractionAtPos<SolidSystem>(ipData.global(), compIdx); }
215};
216
217} // namespace Dumux
218
219#endif
FVPorousMediumSpatialParams(std::shared_ptr< const GridGeometry > gridGeometry)
Definition fvporousmediumspatialparams.hh:60
Scalar porosity(const FVElementGeometry &fvGeometry, const IpData &ipData, const ElementSolution &elemSol) const
Function for defining the porosity at an interpolation point, for degrees of freedom that own no sub-...
Definition fvporousmediumspatialparams.hh:100
Scalar inertVolumeFraction(const FVElementGeometry &fvGeometry, const IpData &ipData, const ElementSolution &elemSol, int compIdx) const
Function for defining the solid volume fraction. That is possibly solution dependent.
Definition fvporousmediumspatialparams.hh:142
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:129
Implementation & asImp_()
Returns the implementation of the spatial parameters (static polymorphism).
Definition common/fvspatialparams.hh:166
FVSpatialParams(std::shared_ptr< const GridGeometry > gridGeometry)
Definition common/fvspatialparams.hh:46
const GridGeometry & gridGeometry() const
The finite volume grid geometry.
Definition common/fvspatialparams.hh:161
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 cvfelocalresidual.hh:25
Definition adapt.hh:17