3.3.0
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
fv.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_FV_SPATIAL_PARAMS_HH
26#define DUMUX_FV_SPATIAL_PARAMS_HH
27
28#include <dune/common/exceptions.hh>
30#include "fv1p.hh"
31
32namespace Dumux {
33
34#ifndef DOXYGEN
35namespace Detail {
36// helper struct detecting if the user-defined spatial params class has a materialLawParamsAtPos function
37// for g++ > 5.3, this can be replaced by a lambda
38template<class GlobalPosition>
39struct hasMaterialLawParamsAtPos
40{
41 template<class SpatialParams>
42 auto operator()(const SpatialParams& a)
43 -> decltype(a.materialLawParamsAtPos(std::declval<GlobalPosition>()))
44 {}
45};
46} // end namespace Detail
47#endif
48
49
55template<class GridGeometry, class Scalar, class Implementation>
56class FVSpatialParams : public FVSpatialParamsOneP<GridGeometry, Scalar, Implementation>
57{
59 using GridView = typename GridGeometry::GridView;
60 using FVElementGeometry = typename GridGeometry::LocalView;
61 using SubControlVolume = typename GridGeometry::SubControlVolume;
62 using Element = typename GridView::template Codim<0>::Entity;
63
64 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
65
66public:
67 FVSpatialParams(std::shared_ptr<const GridGeometry> gridGeometry)
69 {}
70
71 // make sure we get a deprecation warning (remove this after release 3.3)
72 template<class ElementSolution>
73 [[deprecated("Use the new style material laws. Old material laws and this interface will no longer be supported after release 3.3")]]
74 decltype(auto) materialLawParamsDeprecated(const Element& element,
75 const SubControlVolume& scv,
76 const ElementSolution& elemSol) const
77 {
78 return this->asImp_().materialLawParams(element, scv, elemSol);
79 }
80
89 template<class ElementSolution>
90 [[deprecated("Use the new style material laws. Old material laws and this interface will no longer be supported after release 3.3")]]
91 decltype(auto) materialLawParams(const Element& element,
92 const SubControlVolume& scv,
93 const ElementSolution& elemSol) const
94 {
95 static_assert(decltype(isValid(Detail::hasMaterialLawParamsAtPos<GlobalPosition>())(this->asImp_()))::value," \n\n"
96 " Your spatial params class has to either implement\n\n"
97 " const MaterialLawParams& materialLawParamsAtPos(const GlobalPosition& globalPos) const\n\n"
98 " or overload this function\n\n"
99 " template<class ElementSolution>\n"
100 " const MaterialLawParams& materialLawParams(const Element& element,\n"
101 " const SubControlVolume& scv,\n"
102 " const ElementSolution& elemSol) const\n\n");
103
104 return this->asImp_().materialLawParamsAtPos(scv.center());
105 }
106
115 template<class FluidSystem, class ElementSolution>
116 int wettingPhase(const Element& element,
117 const SubControlVolume& scv,
118 const ElementSolution& elemSol) const
119 {
120 return this->asImp_().template wettingPhaseAtPos<FluidSystem>(scv.center());
121 }
122
129 template<class FluidSystem>
130 int wettingPhaseAtPos(const GlobalPosition& globalPos) const
131 {
132 DUNE_THROW(Dune::InvalidStateException,
133 "The spatial parameters do not provide "
134 "a wettingPhaseAtPos() method.");
135 }
136};
137
138} // namespace Dumux
139
140#endif
A helper function for class member function introspection.
The base class for spatial parameters of one-phase problems using a fully implicit discretization met...
Definition: adapt.hh:29
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
The base class for spatial parameters of multi-phase problems using a fully implicit discretization m...
Definition: fv.hh:57
decltype(auto) materialLawParams(const Element &element, const SubControlVolume &scv, const ElementSolution &elemSol) const
Function for defining the parameters needed by constitutive relationships (kr-sw, pc-sw,...
Definition: fv.hh:91
decltype(auto) materialLawParamsDeprecated(const Element &element, const SubControlVolume &scv, const ElementSolution &elemSol) const
Definition: fv.hh:74
int wettingPhase(const Element &element, const SubControlVolume &scv, const ElementSolution &elemSol) const
Function for defining which phase is to be considered as the wetting phase.
Definition: fv.hh:116
FVSpatialParams(std::shared_ptr< const GridGeometry > gridGeometry)
Definition: fv.hh:67
int wettingPhaseAtPos(const GlobalPosition &globalPos) const
Function for defining which phase is to be considered as the wetting phase.
Definition: fv.hh:130
The base class for spatial parameters of one-phase problems using a fully implicit discretization met...
Definition: fv1p.hh:77
Implementation & asImp_()
Definition: fv1p.hh:334
const GridGeometry & gridGeometry() const
The finite volume grid geometry.
Definition: fv1p.hh:329