Commit bbcd3c65 authored by Timo Koch's avatar Timo Koch Committed by Kilian Weishaupt
Browse files

[deprecated] Implement a wrapper that support old and new material law interfaces

parent 40244ba1
......@@ -26,6 +26,8 @@
#define DUMUX_COMMON_DEPRECATED_HH
#include <dune/common/deprecated.hh>
#include <dumux/common/typetraits/isvalid.hh>
#include <dumux/material/fluidmatrixinteractions/fluidmatrixinteraction.hh>
namespace Dumux {
......@@ -43,9 +45,350 @@ namespace Deprecated {
////////////////////////////////////////////
///////////////////////////////////////////////////////////////
// Deprecation warnings for effective diffusion coefficients //
// Deprecation warnings for the new material law //
///////////////////////////////////////////////////////////////
// support old interface of the effective thermal conductivity laws
template<class E, class SCV, class Sol>
struct HasNewFIAIF
{
template<class S>
auto operator()(S&& sp)
-> decltype(sp.fluidMatrixInteraction(std::declval<const E&>(),
std::declval<const SCV&>(),
std::declval<const Sol&>())) {}
};
template<class Pos>
struct HasNewFIAIFAtPos
{
template<class S>
auto operator()(S&& sp)
-> decltype(sp.fluidMatrixInteractionAtPos(std::declval<const Pos&>())) {}
};
template<class ScalarT, class SpatialParams, class Element, class Scv, class ElemSol>
class PcKrSwHelper : public FluidMatrix::Adapter<PcKrSwHelper<ScalarT, SpatialParams, Element, Scv, ElemSol>, FluidMatrix::PcKrSw>
{
public:
using Scalar = ScalarT;
// pass scalar so template arguments can all be deduced
PcKrSwHelper(const Scalar& scalar,
const SpatialParams& sp,
const Element& element,
const Scv& scv,
const ElemSol& elemSol)
: spatialParams_(sp), element_(element), scv_(scv), elemSol_(elemSol)
{}
Scalar krw(const Scalar sw) const
{
const auto& params = spatialParams_.materialLawParamsDeprecated(element_, scv_, elemSol_);
return SpatialParams::MaterialLaw::krw(params, sw);
}
Scalar krn(const Scalar sw) const
{
const auto& params = spatialParams_.materialLawParamsDeprecated(element_, scv_, elemSol_);
return SpatialParams::MaterialLaw::krn(params, sw);
}
Scalar pc(const Scalar sw) const
{
const auto& params = spatialParams_.materialLawParamsDeprecated(element_, scv_, elemSol_);
return SpatialParams::MaterialLaw::pc(params, sw);
}
Scalar dpc_dsw(const Scalar sw) const
{
const auto& params = spatialParams_.materialLawParamsDeprecated(element_, scv_, elemSol_);
return SpatialParams::MaterialLaw::dpc_dsw(params, sw);
}
Scalar endPointPc() const
{
const auto& params = spatialParams_.materialLawParamsDeprecated(element_, scv_, elemSol_);
return SpatialParams::MaterialLaw::endPointPc(params);
}
Scalar sw(const Scalar pc) const
{
const auto& params = spatialParams_.materialLawParamsDeprecated(element_, scv_, elemSol_);
return SpatialParams::MaterialLaw::sw(params, pc);
}
Scalar dsw_dpc(const Scalar pc) const
{
const auto& params = spatialParams_.materialLawParamsDeprecated(element_, scv_, elemSol_);
return SpatialParams::MaterialLaw::dsw_dpc(params, pc);
}
Scalar dkrw_dsw(const Scalar sw) const
{
const auto& params = spatialParams_.materialLawParamsDeprecated(element_, scv_, elemSol_);
return SpatialParams::MaterialLaw::dkrw_dsw(params, sw);
}
Scalar dkrn_dsw(const Scalar sw) const
{
const auto& params = spatialParams_.materialLawParamsDeprecated(element_, scv_, elemSol_);
return SpatialParams::MaterialLaw::dkrn_dsw(params, sw);
}
private:
const SpatialParams& spatialParams_;
const Element& element_;
const Scv& scv_;
const ElemSol& elemSol_;
};
template<class Scalar, class SpatialParams, class Element, class Scv, class ElemSol>
auto makeDeprecationPcKrSwHelper(const Scalar& scalar,
const SpatialParams& sp,
const Element& element,
const Scv& scv,
const ElemSol& elemSol)
{
using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
constexpr bool hasNew = decltype(isValid(HasNewFIAIF<Element, Scv, ElemSol>()).template check<SpatialParams>())::value;
constexpr bool hasNewAtPos = decltype(isValid(HasNewFIAIFAtPos<GlobalPosition>()).template check<SpatialParams>())::value;
if constexpr (hasNew)
return sp.fluidMatrixInteraction(element, scv, elemSol);
else if constexpr (hasNewAtPos)
return sp.fluidMatrixInteractionAtPos(scv.center());
else
return makeFluidMatrixInteraction(PcKrSwHelper(scalar, sp, element, scv, elemSol));
}
///////////////////////////////////////////////////////////////
// Deprecation warnings for the kinetic surface areas //
///////////////////////////////////////////////////////////////
// support old interface of surface area
template<class E, class SCV, class Sol>
struct HasNewAns
{
template<class S>
auto operator()(S&& sp)
-> decltype(sp.nonwettingSolidInterfacialArea(std::declval<const E&>(),
std::declval<const SCV&>(),
std::declval<const Sol&>())) {}
};
template<class Pos>
struct HasNewAnsAtPos
{
template<class S>
auto operator()(S&& sp)
-> decltype(sp.nonwettingSolidInterfacialAreaAtPos(std::declval<const Pos&>())) {}
};
// support old interface of surface area
template<class E, class SCV, class Sol>
struct HasNewAnw
{
template<class S>
auto operator()(S&& sp)
-> decltype(sp.wettingNonwettingInterfacialArea(std::declval<const E&>(),
std::declval<const SCV&>(),
std::declval<const Sol&>())) {}
};
template<class Pos>
struct HasNewAnwAtPos
{
template<class S>
auto operator()(S&& sp)
-> decltype(sp.wettingNonwettingInterfacialAreaAtPos(std::declval<const Pos&>())) {}
};
// support old interface of surface area
template<class E, class SCV, class Sol>
struct HasNewAws
{
template<class S>
auto operator()(S&& sp)
-> decltype(sp.wettingSolidInterfacialArea(std::declval<const E&>(),
std::declval<const SCV&>(),
std::declval<const Sol&>())) {}
};
template<class Pos>
struct HasNewAwsAtPos
{
template<class S>
auto operator()(S&& sp)
-> decltype(sp.wettingSolidInterfacialAreaAtPos(std::declval<const Pos&>())) {}
};
template<class ScalarT, class SpatialParams, class Element, class Scv, class ElemSol>
class WettingNonwettingInterfacialArea : public FluidMatrix::Adapter<WettingNonwettingInterfacialArea<ScalarT, SpatialParams, Element, Scv, ElemSol>, FluidMatrix::WettingNonwettingInterfacialAreaPcSw>
{
public:
using Scalar = ScalarT;
WettingNonwettingInterfacialArea(const Scalar& scalar,
const SpatialParams& sp,
const Element& element,
const Scv& scv,
const ElemSol& elemSol)
: spatialParams_(sp), element_(element), scv_(scv), elemSol_(elemSol)
{}
const auto& basicParams() const
{
return spatialParams_.aWettingNonWettingSurfaceParams(element_, scv_, elemSol_);
}
Scalar area(const Scalar sw, const Scalar pc) const
{
const auto& surfaceParams = spatialParams_.aWettingNonWettingSurfaceParams(element_, scv_, elemSol_);
const auto& materialParams = spatialParams_.materialLawParams(element_, scv_, elemSol_);
using AwnSurface = typename SpatialParams::AwnSurface;
return AwnSurface::interfacialArea(surfaceParams, materialParams, sw, pc);
}
Scalar darea_dpc(const Scalar sw, const Scalar pc)
{
const auto& surfaceParams = spatialParams_.aWettingNonWettingSurfaceParams(element_, scv_, elemSol_);
using AwnSurface = typename SpatialParams::AwnSurface;
return AwnSurface::dawn_dpc(surfaceParams, sw, pc);
}
Scalar darea_dsw(const Scalar sw, const Scalar pc)
{
const auto& surfaceParams = spatialParams_.aWettingNonWettingSurfaceParams(element_, scv_, elemSol_);
using AwnSurface = typename SpatialParams::AwnSurface;
return AwnSurface::dawn_dsw(surfaceParams, sw, pc);
}
private:
const SpatialParams& spatialParams_;
const Element& element_;
const Scv& scv_;
const ElemSol& elemSol_;
};
template<class ScalarT, class SpatialParams, class Element, class Scv, class ElemSol>
class NonwettingSolidInterfacialArea : public FluidMatrix::Adapter<NonwettingSolidInterfacialArea<ScalarT, SpatialParams, Element, Scv, ElemSol>, FluidMatrix::NonwettingSolidInterfacialAreaPcSw>
{
public:
using Scalar = ScalarT;
NonwettingSolidInterfacialArea(const Scalar& scalar,
const SpatialParams& sp,
const Element& element,
const Scv& scv,
const ElemSol& elemSol)
: spatialParams_(sp), element_(element), scv_(scv), elemSol_(elemSol)
{}
const auto& basicParams() const
{
return spatialParams_.aNonWettingSolidSurfaceParams(element_, scv_, elemSol_);
}
Scalar area(const Scalar sw, const Scalar pc) const
{
const auto& surfaceParams = spatialParams_.aNonWettingSolidSurfaceParams(element_, scv_, elemSol_);
const auto& materialParams = spatialParams_.materialLawParams(element_, scv_, elemSol_);
using AnsSurface = typename SpatialParams::AnsSurface;
return AnsSurface::interfacialArea(surfaceParams, materialParams, sw, pc);
}
Scalar darea_dpc(const Scalar sw, const Scalar pc)
{
const auto& surfaceParams = spatialParams_.aNonWettingSolidSurfaceParams(element_, scv_, elemSol_);
using AnsSurface = typename SpatialParams::AnsSurface;
return AnsSurface::dawn_dpc(surfaceParams, sw, pc);
}
Scalar darea_dsw(const Scalar sw, const Scalar pc)
{
const auto& surfaceParams = spatialParams_.aNonWettingSolidSurfaceParams(element_, scv_, elemSol_);
using AnsSurface = typename SpatialParams::AnsSurface;
return AnsSurface::dawn_dsw(surfaceParams, sw, pc);
}
private:
const SpatialParams& spatialParams_;
const Element& element_;
const Scv& scv_;
const ElemSol& elemSol_;
};
template<class ScalarT, class SpatialParams, class Element, class Scv, class ElemSol>
class WettingSolidInterfacialArea : public FluidMatrix::Adapter<WettingSolidInterfacialArea<ScalarT, SpatialParams, Element, Scv, ElemSol>, FluidMatrix::WettingSolidInterfacialAreaPcSw>
{
public:
using Scalar = ScalarT;
WettingSolidInterfacialArea(const Scalar& scalar,
const SpatialParams& sp,
const Element& element,
const Scv& scv,
const ElemSol& elemSol)
: spatialParams_(sp), element_(element), scv_(scv), elemSol_(elemSol)
{}
const auto& basicParams() const
{
return spatialParams_.aWettingSolidSurfaceParams(element_, scv_, elemSol_);
}
Scalar area(const Scalar sw, const Scalar pc) const
{
const auto& surfaceParams = spatialParams_.aWettingSolidSurfaceParams(element_, scv_, elemSol_);
const auto& materialParams = spatialParams_.materialLawParams(element_, scv_, elemSol_);
using AwsSurface = typename SpatialParams::AwsSurface;
return AwsSurface::interfacialArea(surfaceParams, materialParams, sw, pc);
}
Scalar darea_dpc(const Scalar sw, const Scalar pc)
{
const auto& surfaceParams = spatialParams_.aWettingSolidSurfaceParams(element_, scv_, elemSol_);
using AwsSurface = typename SpatialParams::AwsSurface;
return AwsSurface::dawn_dpc(surfaceParams, sw, pc);
}
Scalar darea_dsw(const Scalar sw, const Scalar pc)
{
const auto& surfaceParams = spatialParams_.aWettingSolidSurfaceParams(element_, scv_, elemSol_);
using AwsSurface = typename SpatialParams::AwsSurface;
return AwsSurface::dawn_dsw(surfaceParams, sw, pc);
}
private:
const SpatialParams& spatialParams_;
const Element& element_;
const Scv& scv_;
const ElemSol& elemSol_;
};
template<class Scalar, class SpatialParams, class Element, class Scv, class ElemSol>
auto makeInterfacialAreaHelper(const Scalar& scalar,
const SpatialParams& sp,
const Element& element,
const Scv& scv,
const ElemSol& elemSol)
{
using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
constexpr bool hasNew = decltype(isValid(HasNewFIAIF<Element, Scv, ElemSol>()).template check<SpatialParams>())::value;
constexpr bool hasNewAtPos = decltype(isValid(HasNewFIAIFAtPos<GlobalPosition>()).template check<SpatialParams>())::value;
if constexpr (hasNew)
return sp.fluidMatrixInteraction(element, scv, elemSol);
else if constexpr (hasNewAtPos)
return sp.fluidMatrixInteractionAtPos(scv.center());
else
return makeFluidMatrixInteraction(WettingNonwettingInterfacialArea(scalar, sp, element, scv, elemSol),
NonwettingSolidInterfacialArea(scalar, sp, element, scv, elemSol),
WettingSolidInterfacialArea(scalar, sp, element, scv, elemSol));
}
} // end namespace Deprecated
#endif
......
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