25#ifndef DUMUX_COMMON_DEPRECATED_HH
26#define DUMUX_COMMON_DEPRECATED_HH
28#include <dune/common/version.hh>
29#include <dune/common/exceptions.hh>
30#include <dune/common/std/type_traits.hh>
44#pragma clang diagnostic push
45#pragma clang diagnostic ignored "-Wdeprecated-declarations"
47template <
class Mapper,
class Gr
idView>
48using GridViewDetector =
decltype(std::declval<Mapper>().update(std::declval<GridView>()));
50template<
class Mapper,
class Gr
idView>
51static constexpr bool hasUpdateGridView()
52{
return Dune::Std::is_detected<GridViewDetector, Mapper, GridView>::value; }
54template <
typename Problem,
typename GlobalPosition>
55using HasIsOnWallDetector =
decltype(std::declval<Problem>().isOnWallAtPos(std::declval<GlobalPosition>()));
57template<
class Problem,
typename GlobalPosition>
58static constexpr bool hasIsOnWall()
59{
return Dune::Std::is_detected<HasIsOnWallDetector, Problem, GlobalPosition>::value; }
61template <
typename ModelTraits>
62using HasEnableCompositionalDispersionDetector =
decltype(ModelTraits::enableCompositionalDispersion());
64template<
class ModelTraits>
65static constexpr bool hasEnableCompositionalDispersion()
66{
return Dune::Std::is_detected<HasEnableCompositionalDispersionDetector, ModelTraits>::value; }
68template <
typename ModelTraits>
69using HasEnableThermalDispersionDetector =
decltype(ModelTraits::enableThermalDispersion());
71template<
class ModelTraits>
72static constexpr bool hasEnableThermalDispersion()
73{
return Dune::Std::is_detected<HasEnableThermalDispersionDetector, ModelTraits>::value; }
75template<
class SpatialParams,
class Element,
class Scv,
class ElemSol>
76using HasNewTemperatureDetector =
decltype(std::declval<SpatialParams>().temperature(
77 std::declval<Element>(),
79 std::declval<ElemSol>()
82template<
class Problem,
class GlobalPosition>
83using HasBaseProblemTemperatureAtPosDetector =
decltype(std::declval<Problem>().temperatureAtPos(
84 std::declval<GlobalPosition>(),
int{}
87template<
class Problem>
88using HasBaseProblemTemperatureDetector =
decltype(std::declval<Problem>().temperature(
int{}));
90template<
class SpatialParams,
class Element,
class SubControlVolume,
class ElementSolution>
91using HasExtrusionFactorDetector =
decltype(std::declval<SpatialParams>().extrusionFactor(
92 std::declval<Element>(),
93 std::declval<SubControlVolume>(),
94 std::declval<ElementSolution>()
97template<
class Problem,
class Element,
class SubControlVolume,
class ElementSolution>
98using HasBaseProblemExtrusionFactorDetector =
decltype(std::declval<Problem>().extrusionFactor(
99 std::declval<Element>(),
100 std::declval<SubControlVolume>(),
101 std::declval<ElementSolution>(),
105template<
class Problem,
class GlobalPosition>
106using HasBaseProblemExtrusionFactorAtPosDetector =
decltype(std::declval<Problem>().extrusionFactorAtPos(
107 std::declval<GlobalPosition>(),
112template<
class Problem,
class Element,
class SubControlVolume>
113using HasBaseProblemEffectiveFluidDensity =
decltype(std::declval<Problem>().effectiveFluidDensity(
114 std::declval<Element>(),
115 std::declval<SubControlVolume>(),
119template<
class Problem,
class GlobalPosition>
120using HasEffectiveFluidDensityAtPos =
decltype(std::declval<Problem>().effectiveFluidDensityAtPos(
121 std::declval<GlobalPosition>()
124template<
class Problem,
126 class FVElementGeometry,
129using HasBaseProblemEffectivePorePressure =
decltype(std::declval<Problem>().effectivePorePressure(
130 std::declval<Element>(),
131 std::declval<FVElementGeometry>(),
132 std::declval<ElemVolVars>(),
133 std::declval<FluxVarsCache>(),
137template<
class Problem,
class GlobalPosition>
138using HasEffectivePorePressureAtPos =
decltype(std::declval<Problem>().effectivePorePressureAtPos(
139 std::declval<GlobalPosition>()
144#pragma clang diagnostic pop
148template <
class Mapper>
149#if DUNE_VERSION_GTE(DUNE_GRID,2,8)
150[[deprecated(
"The interface mapper.update() is deprecated. All mappers now have to implement `update(gridView)` instead (with a gridView as argument). Only mappers with the new interface will be support for dune-grid 2.7 is dropped.")]]
152void update(Mapper& mapper)
155template<
class Problem,
class Element,
class SubControlVolume,
class ElementSolution>
156decltype(
auto) extrusionFactor(
const Problem& problem,
157 const Element& element,
158 const SubControlVolume& scv,
159 const ElementSolution& elemSol)
161 using SpatialParams = std::decay_t<
decltype(problem.spatialParams())>;
162 using GlobalPosition = std::decay_t<
decltype(scv.center())>;
164 static constexpr bool hasNewSpatialParamsInterface = Dune::Std::is_detected<
165 HasExtrusionFactorDetector, SpatialParams, Element, SubControlVolume, ElementSolution
168 static constexpr bool hasBaseProblemInterface = Dune::Std::is_detected<
169 HasBaseProblemExtrusionFactorDetector, Problem, Element, SubControlVolume, ElementSolution
172 static constexpr bool hasBaseProblemAtPosInterface = Dune::Std::is_detected<
173 HasBaseProblemExtrusionFactorAtPosDetector, Problem, GlobalPosition
176 static constexpr bool hasUserDefinedProblemExtrusionFactor = !hasBaseProblemInterface || !hasBaseProblemAtPosInterface;
178 if constexpr (hasNewSpatialParamsInterface && hasUserDefinedProblemExtrusionFactor)
179 DUNE_THROW(Dune::InvalidStateException,
180 "Extrusion factor defined both in problem implementation (deprecated interface) and spatial params (new interface). "
181 "Please move the overload in your problem implementation to your spatial parameters.");
183 if constexpr (hasNewSpatialParamsInterface)
184 return problem.spatialParams().extrusionFactor(element, scv, elemSol);
186 return problem.extrusionFactor(element, scv, elemSol);
189template<
typename Problem,
typename Element,
typename Scv,
typename ElemSol>
190decltype(
auto)
temperature(
const Problem& problem,
const Element& element,
const Scv& scv,
const ElemSol& elemSol)
192 using SpatialParams = std::decay_t<
decltype(problem.spatialParams())>;
193 using GlobalPosition = std::decay_t<
decltype(scv.dofPosition())>;
195 static constexpr bool hasBaseProbTempAtPosInterface = Dune::Std::is_detected<
196 HasBaseProblemTemperatureAtPosDetector, Problem, GlobalPosition
198 static constexpr bool hasBaseProbTempInterface = Dune::Std::is_detected<
199 HasBaseProblemTemperatureDetector, Problem
201 static constexpr bool spatialParamsHaveNewInterface = Dune::Std::is_detected<
202 HasNewTemperatureDetector, SpatialParams, Element, Scv, ElemSol
205 static constexpr bool problemHasUserDefinedTemperature = !hasBaseProbTempAtPosInterface || !hasBaseProbTempInterface;
207 if constexpr (problemHasUserDefinedTemperature && spatialParamsHaveNewInterface)
208 DUNE_THROW(Dune::InvalidStateException,
209 "Temperature defined both in problem implementation (deprecated interface) and spatial params (new interface). "
210 "Please move the temperature definition in your problem implementation to your spatial parameters.");
212 if constexpr (spatialParamsHaveNewInterface)
213 return problem.spatialParams().temperature(element, scv, elemSol);
215 return problem.temperatureAtPos(scv.dofPosition());
218template<
class Problem,
class Element,
class SubControlVolume>
219decltype(
auto) effectiveFluidDensity(
const Problem& problem,
220 const Element& element,
221 const SubControlVolume& scv)
223 using GlobalPosition =
typename SubControlVolume::Traits::GlobalPosition;
225 static constexpr bool hasBaseProblemDensity = Dune::Std::is_detected<
226 HasBaseProblemEffectiveFluidDensity, Problem, Element, SubControlVolume
229 static constexpr bool hasProblemDensityAtPos = Dune::Std::is_detected<
230 HasEffectiveFluidDensityAtPos, Problem, GlobalPosition
233 static constexpr bool problemDefinesUserDensity =
234 hasProblemDensityAtPos || !hasBaseProblemDensity;
236 if constexpr (problemDefinesUserDensity)
237 return problem.effectiveFluidDensity(element, scv);
239 return problem.spatialParams().effectiveFluidDensity(element, scv);
242template<
class Problem,
class Element,
class FVElementGeometry,
class ElemVolVars,
class FluxVarsCache>
243decltype(
auto) effectivePorePressure(
const Problem& problem,
244 const Element& element,
245 const FVElementGeometry& fvGeometry,
246 const ElemVolVars& elemVolVars,
247 const FluxVarsCache& fluxVarsCache)
249 using GlobalPosition =
typename FVElementGeometry::GridGeometry::SubControlVolume::Traits::GlobalPosition;
251 static constexpr bool hasBaseProblemPressure = Dune::Std::is_detected<
252 HasBaseProblemEffectivePorePressure,
260 static constexpr bool hasProblemPressureAtPos = Dune::Std::is_detected<
261 HasEffectivePorePressureAtPos, Problem, GlobalPosition
264 static constexpr bool problemDefinesUserPressure =
265 hasProblemPressureAtPos || !hasBaseProblemPressure;
267 if constexpr (problemDefinesUserPressure)
268 return problem.effectivePorePressure(
269 element, fvGeometry, elemVolVars, fluxVarsCache
272 return problem.spatialParams().effectivePorePressure(
273 element, fvGeometry, elemVolVars, fluxVarsCache
std::string temperature() noexcept
I/O name of temperature for equilibrium models.
Definition: name.hh:51