Commit fd2d1680 authored by Timo Koch's avatar Timo Koch
Browse files

Merge branch 'fix/mp-adapter-temp' into 'master'

[mpadapter] Store copy of pcKrSw law if called with temporary

See merge request !2501
parents 793d5ee7 17d9f1db
...@@ -12,6 +12,27 @@ Differences Between DuMu<sup>x</sup> 3.4 and DuMu<sup>x</sup> 3.3 ...@@ -12,6 +12,27 @@ Differences Between DuMu<sup>x</sup> 3.4 and DuMu<sup>x</sup> 3.3
- `extractmodulepart.sh` no longer creates an install file, instead, you can now generate install scripts for your module using the new script `bin/util/makeinstallscript.py`. - `extractmodulepart.sh` no longer creates an install file, instead, you can now generate install scripts for your module using the new script `bin/util/makeinstallscript.py`.
- Note: the old shells script will be removed after release 3.4. - Note: the old shells script will be removed after release 3.4.
### Immediate interface changes not allowing/requiring a deprecation period:
- __MPNC__: The `MPAdapter` can now also be called with a temporary `pcKrSw` objects. For this, the compiler needs to deduce the
class's template argument types. You may need to adapt your `spatialParams` from
```
using MPAdapter = Dumux::FluidMatrix::MPAdapter<PcKrSwCurve, 2>;
...
auto fluidMatrixInteractionAtPos(const GlobalPosition &globalPos) const
{
return makeFluidMatrixInteraction(MPAdapter(pcKrSwCurve_));
}
```
to
```
// alias for MPAdapter is removed
auto fluidMatrixInteractionAtPos(const GlobalPosition &globalPos) const
{
return makeFluidMatrixInteraction(FluidMatrix::MPAdapter(pcKrSwCurve_));
}
```
Differences Between DuMu<sup>x</sup> 3.3 and DuMu<sup>x</sup> 3.2 Differences Between DuMu<sup>x</sup> 3.3 and DuMu<sup>x</sup> 3.2
============================================= =============================================
......
...@@ -66,6 +66,12 @@ public: ...@@ -66,6 +66,12 @@ public:
static constexpr bool isRegularized() static constexpr bool isRegularized()
{ return false; } { return false; }
/*!
* \brief Return the number of fluid phases
*/
static constexpr int numFluidPhases()
{ return 2; }
/*! /*!
* \brief The parameter type * \brief The parameter type
* \tparam Scalar The scalar type * \tparam Scalar The scalar type
......
...@@ -107,7 +107,7 @@ namespace Dumux::FluidMatrix { ...@@ -107,7 +107,7 @@ namespace Dumux::FluidMatrix {
* \ingroup Fluidmatrixinteractions * \ingroup Fluidmatrixinteractions
* \brief An adapter for mpnc to use the capillary pressure-saturation relationships * \brief An adapter for mpnc to use the capillary pressure-saturation relationships
*/ */
template <class MaterialLaw, int numFluidPhases = MaterialLaw::numFluidPhases()> template <class MaterialLaw, int numFluidPhases = std::decay_t<MaterialLaw>::numFluidPhases()>
class MPAdapter class MPAdapter
{ {
static_assert(AlwaysFalse<MaterialLaw>::value, "Adapter not implemented for the specified number of phases"); static_assert(AlwaysFalse<MaterialLaw>::value, "Adapter not implemented for the specified number of phases");
...@@ -119,10 +119,10 @@ class MPAdapter<MaterialLaw, 2> ...@@ -119,10 +119,10 @@ class MPAdapter<MaterialLaw, 2>
: public Adapter<MPAdapter<MaterialLaw, 2>, MultiPhasePcKrSw> : public Adapter<MPAdapter<MaterialLaw, 2>, MultiPhasePcKrSw>
{ {
public: public:
using Scalar = typename MaterialLaw::Scalar; using Scalar = typename std::decay_t<MaterialLaw>::Scalar;
MPAdapter(const MaterialLaw& pcKrS) MPAdapter(MaterialLaw&& pcKrS)
: pcKrS_(pcKrS) : pcKrS_(std::forward<MaterialLaw>(pcKrS))
{} {}
/*! /*!
...@@ -161,9 +161,18 @@ public: ...@@ -161,9 +161,18 @@ public:
return values; return values;
} }
private: private:
const MaterialLaw& pcKrS_; MaterialLaw pcKrS_;
}; };
/*!
* \ingroup Fluidmatrixinteractions
* \brief Deduction guide for the MPAdapter class.
* Makes sure that MPAdapter stores a copy of T if
* the constructor is called with a temporary object.
*/
template<typename T>
MPAdapter(T&&) -> MPAdapter<T>;
} // end namespace Dumux::FluidMatrix } // end namespace Dumux::FluidMatrix
......
...@@ -53,7 +53,6 @@ class MPNCComparisonSpatialParams ...@@ -53,7 +53,6 @@ class MPNCComparisonSpatialParams
using GlobalPosition = typename SubControlVolume::GlobalPosition; using GlobalPosition = typename SubControlVolume::GlobalPosition;
using PcKrSwCurve = FluidMatrix::BrooksCoreyDefault<Scalar>; using PcKrSwCurve = FluidMatrix::BrooksCoreyDefault<Scalar>;
using MPAdapter = Dumux::FluidMatrix::MPAdapter<PcKrSwCurve, 2>;
public: public:
using PermeabilityType = Scalar; using PermeabilityType = Scalar;
...@@ -96,7 +95,7 @@ public: ...@@ -96,7 +95,7 @@ public:
*/ */
auto fluidMatrixInteractionAtPos(const GlobalPosition& globalPos) const auto fluidMatrixInteractionAtPos(const GlobalPosition& globalPos) const
{ {
return makeFluidMatrixInteraction(MPAdapter(pcKrSw_)); return makeFluidMatrixInteraction(FluidMatrix::MPAdapter(pcKrSw_));
} }
/*! /*!
......
...@@ -63,7 +63,6 @@ class EvaporationAtmosphereSpatialParams ...@@ -63,7 +63,6 @@ class EvaporationAtmosphereSpatialParams
static constexpr auto dimWorld = GridView::dimensionworld; static constexpr auto dimWorld = GridView::dimensionworld;
using PcKrSwCurve = FluidMatrix::BrooksCoreyDefault<Scalar>; using PcKrSwCurve = FluidMatrix::BrooksCoreyDefault<Scalar>;
using MPAdapter = Dumux::FluidMatrix::MPAdapter<PcKrSwCurve, 2>;
using NonwettingSolidInterfacialArea = FluidMatrix::InterfacialArea<Scalar, using NonwettingSolidInterfacialArea = FluidMatrix::InterfacialArea<Scalar,
FluidMatrix::InterfacialAreaExponentialCubic, FluidMatrix::InterfacialAreaExponentialCubic,
...@@ -248,9 +247,9 @@ public: ...@@ -248,9 +247,9 @@ public:
auto fluidMatrixInteractionAtPos(const GlobalPosition &globalPos) const auto fluidMatrixInteractionAtPos(const GlobalPosition &globalPos) const
{ {
if (inFF_(globalPos)) if (inFF_(globalPos))
return makeFluidMatrixInteraction(MPAdapter(*pcKrSwCurveFF_), *aNsFreeFlow_, *aNwFreeFlow_, *aWs_); return makeFluidMatrixInteraction(FluidMatrix::MPAdapter(*pcKrSwCurveFF_), *aNsFreeFlow_, *aNwFreeFlow_, *aWs_);
else if (inPM_(globalPos)) else if (inPM_(globalPos))
return makeFluidMatrixInteraction(MPAdapter(*pcKrSwCurvePM_), *aNs_, *aNw_, *aWs_); return makeFluidMatrixInteraction(FluidMatrix::MPAdapter(*pcKrSwCurvePM_), *aNs_, *aNw_, *aWs_);
else DUNE_THROW(Dune::InvalidStateException, "You should not be here: x=" << globalPos[0] << " y= "<< globalPos[dimWorld-1]); else DUNE_THROW(Dune::InvalidStateException, "You should not be here: x=" << globalPos[0] << " y= "<< globalPos[dimWorld-1]);
} }
......
...@@ -54,7 +54,6 @@ class ObstacleSpatialParams ...@@ -54,7 +54,6 @@ class ObstacleSpatialParams
using GlobalPosition = typename SubControlVolume::GlobalPosition; using GlobalPosition = typename SubControlVolume::GlobalPosition;
using PcKrSwCurve = FluidMatrix::SmoothedLinearLaw<Scalar>; using PcKrSwCurve = FluidMatrix::SmoothedLinearLaw<Scalar>;
using MPAdapter = Dumux::FluidMatrix::MPAdapter<PcKrSwCurve, 2>;
public: public:
//! Export the type used for the permeability //! Export the type used for the permeability
...@@ -93,7 +92,7 @@ public: ...@@ -93,7 +92,7 @@ public:
*/ */
auto fluidMatrixInteractionAtPos(const GlobalPosition &globalPos) const auto fluidMatrixInteractionAtPos(const GlobalPosition &globalPos) const
{ {
return makeFluidMatrixInteraction(MPAdapter(pcKrSwCurve_)); return makeFluidMatrixInteraction(FluidMatrix::MPAdapter(pcKrSwCurve_));
} }
/*! /*!
......
...@@ -58,7 +58,6 @@ class CombustionSpatialParams ...@@ -58,7 +58,6 @@ class CombustionSpatialParams
using GlobalPosition = typename SubControlVolume::GlobalPosition; using GlobalPosition = typename SubControlVolume::GlobalPosition;
using PcKrSwCurve = FluidMatrix::HeatPipeLaw<Scalar>; using PcKrSwCurve = FluidMatrix::HeatPipeLaw<Scalar>;
using MPAdapter = Dumux::FluidMatrix::MPAdapter<PcKrSwCurve, 2>;
public: public:
//! Export the type used for the permeability //! Export the type used for the permeability
...@@ -195,7 +194,7 @@ public: ...@@ -195,7 +194,7 @@ public:
*/ */
auto fluidMatrixInteractionAtPos(const GlobalPosition &globalPos) const auto fluidMatrixInteractionAtPos(const GlobalPosition &globalPos) const
{ {
return makeFluidMatrixInteraction(MPAdapter(*pcKrSwCurve_)); return makeFluidMatrixInteraction(FluidMatrix::MPAdapter(*pcKrSwCurve_));
} }
private: private:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment