Loading...
Searching...
No Matches
SatCurveMultiplexer.hpp
Go to the documentation of this file.
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
Consult the COPYING file in the top-level source directory of this
module for the precise wording of the license and the list of
copyright holders.
*/
#ifndef OPM_SAT_CURVE_MULTIPLEXER_HPP
#define OPM_SAT_CURVE_MULTIPLEXER_HPP
#include "SatCurveMultiplexerParams.hpp"
#include <stdexcept>
// The static_assert does not compile with gcc 12 and earlier when placed in the multiplexer calls below.
#if defined(__GNUC__) && (__GNUC__ < 13)
#define STATIC_ASSERT_SATCURVE_MULTIPLEXER_UNLESS_GCC_LT_13 throw std::logic_error("Unhandled SatCurveMultiplexerApproach")
#else
#define STATIC_ASSERT_SATCURVE_MULTIPLEXER_UNLESS_GCC_LT_13 static_assert(false, "Unhandled SatCurveMultiplexerApproach")
#endif
namespace Opm {
template <class TraitsT, class ParamsT = SatCurveMultiplexerParams<TraitsT> >
class SatCurveMultiplexer : public TraitsT
{
public:
using Traits = TraitsT;
using Params = ParamsT;
using Scalar = typename Traits::Scalar;
using LETTwoPhaseLaw = TwoPhaseLETCurves<Traits>;
using PLTwoPhaseLaw = PiecewiseLinearTwoPhaseMaterial<Traits>;
using Traits::numPhases;
static_assert(numPhases == 2,
"The Brooks-Corey capillary pressure law only applies "
"to the case of two fluid phases");
static constexpr bool implementsTwoPhaseApi = true;
static constexpr bool implementsTwoPhaseSatApi = true;
static constexpr bool isSaturationDependent = true;
static constexpr bool isPressureDependent = false;
static constexpr bool isTemperatureDependent = false;
static constexpr bool isCompositionDependent = false;
static_assert(Traits::numPhases == 2,
"The number of fluid phases must be two if you want to use "
"this material law!");
template <class Container, class FluidState>
static void capillaryPressures(Container& values, const Params& params, const FluidState& fluidState)
{
switch (params.approach()) {
case SatCurveMultiplexerApproach::LET:
LETTwoPhaseLaw::capillaryPressures(values,
params.template getRealParams<SatCurveMultiplexerApproach::LET>(),
fluidState);
break;
case SatCurveMultiplexerApproach::PiecewiseLinear:
PLTwoPhaseLaw::capillaryPressures(values,
params.template getRealParams<SatCurveMultiplexerApproach::PiecewiseLinear>(),
fluidState);
break;
}
}
template <class Container, class FluidState>
static void saturations(Container& values, const Params& params, const FluidState& fluidState)
{
switch (params.approach()) {
case SatCurveMultiplexerApproach::LET:
LETTwoPhaseLaw::saturations(values,
params.template getRealParams<SatCurveMultiplexerApproach::LET>(),
fluidState);
break;
case SatCurveMultiplexerApproach::PiecewiseLinear:
PLTwoPhaseLaw::saturations(values,
params.template getRealParams<SatCurveMultiplexerApproach::PiecewiseLinear>(),
fluidState);
break;
}
}
template <class Container, class FluidState>
static void relativePermeabilities(Container& values, const Params& params, const FluidState& fluidState)
{
switch (params.approach()) {
case SatCurveMultiplexerApproach::LET:
LETTwoPhaseLaw::relativePermeabilities(values,
params.template getRealParams<SatCurveMultiplexerApproach::LET>(),
fluidState);
break;
case SatCurveMultiplexerApproach::PiecewiseLinear:
PLTwoPhaseLaw::relativePermeabilities(values,
params.template getRealParams<SatCurveMultiplexerApproach::PiecewiseLinear>(),
fluidState);
break;
}
}
template <class FluidState, class Evaluation = typename FluidState::Scalar>
static Evaluation pcnw(const Params& params, const FluidState& fluidState)
{
switch (params.approach()) {
case SatCurveMultiplexerApproach::LET:
return LETTwoPhaseLaw::pcnw(params.template getRealParams<SatCurveMultiplexerApproach::LET>(),
fluidState);
break;
case SatCurveMultiplexerApproach::PiecewiseLinear:
return PLTwoPhaseLaw::pcnw(params.template getRealParams<SatCurveMultiplexerApproach::PiecewiseLinear>(),
fluidState);
break;
}
return 0.0;
}
template <class Evaluation, class ...Args>
static Evaluation twoPhaseSatPcnw(const Params& params, const Evaluation& Sw)
{
if constexpr (FrontIsSatCurveMultiplexerDispatchV<Args...>) {
return twoPhaseSatPcnwT<Evaluation, Args...>(params, Sw);
}
switch (params.approach()) {
case SatCurveMultiplexerApproach::LET:
return LETTwoPhaseLaw::twoPhaseSatPcnw(params.template getRealParams<SatCurveMultiplexerApproach::LET>(),
Sw);
break;
case SatCurveMultiplexerApproach::PiecewiseLinear:
return PLTwoPhaseLaw::twoPhaseSatPcnw(params.template getRealParams<SatCurveMultiplexerApproach::PiecewiseLinear>(),
Sw);
break;
}
return 0.0;
}
template <class Evaluation, class Head, class ...Args>
static Evaluation twoPhaseSatPcnwT(const Params& params, const Evaluation& Sw)
{
if constexpr (Head::approach == SatCurveMultiplexerApproach::LET) {
return LETTwoPhaseLaw::twoPhaseSatPcnw(params.template getRealParams<SatCurveMultiplexerApproach::LET>(),
Sw);
} else if constexpr (Head::approach == SatCurveMultiplexerApproach::PiecewiseLinear) {
return PLTwoPhaseLaw::twoPhaseSatPcnw(params.template getRealParams<SatCurveMultiplexerApproach::PiecewiseLinear>(),
Sw);
} else {
STATIC_ASSERT_SATCURVE_MULTIPLEXER_UNLESS_GCC_LT_13;
}
}
template <class Evaluation>
static Evaluation twoPhaseSatPcnwInv(const Params&, const Evaluation&)
{
throw std::logic_error("SatCurveMultiplexer::twoPhaseSatPcnwInv"
" not implemented!");
}
template <class FluidState, class Evaluation = typename FluidState::Scalar>
static Evaluation Sw(const Params& params, const FluidState& fluidstate)
{
switch (params.approach()) {
case SatCurveMultiplexerApproach::LET:
return LETTwoPhaseLaw::Sw(params.template getRealParams<SatCurveMultiplexerApproach::LET>(),
fluidstate);
break;
case SatCurveMultiplexerApproach::PiecewiseLinear:
return PLTwoPhaseLaw::Sw(params.template getRealParams<SatCurveMultiplexerApproach::PiecewiseLinear>(),
fluidstate);
break;
}
return 0.0;
}
template <class Evaluation>
static Evaluation twoPhaseSatSw(const Params&, const Evaluation&)
{
throw std::logic_error("SatCurveMultiplexer::twoPhaseSatSw"
" not implemented!");
}
template <class FluidState, class Evaluation = typename FluidState::Scalar>
static Evaluation Sn(const Params& params, const FluidState& fluidstate)
{
switch (params.approach()) {
case SatCurveMultiplexerApproach::LET:
return LETTwoPhaseLaw::Sn(params.template getRealParams<SatCurveMultiplexerApproach::LET>(),
fluidstate);
break;
case SatCurveMultiplexerApproach::PiecewiseLinear:
return PLTwoPhaseLaw::Sn(params.template getRealParams<SatCurveMultiplexerApproach::PiecewiseLinear>(),
fluidstate);
break;
}
return 0.0;
}
template <class Evaluation>
static Evaluation twoPhaseSatSn(const Params& params, const Evaluation& pc)
{
switch (params.approach()) {
case SatCurveMultiplexerApproach::LET:
return LETTwoPhaseLaw::twoPhaseSatSn(params.template getRealParams<SatCurveMultiplexerApproach::LET>(),
pc);
break;
case SatCurveMultiplexerApproach::PiecewiseLinear:
return PLTwoPhaseLaw::twoPhaseSatSn(params.template getRealParams<SatCurveMultiplexerApproach::PiecewiseLinear>(),
pc);
break;
}
return 0.0;
}
template <class FluidState, class Evaluation = typename FluidState::Scalar>
static Evaluation krw(const Params& params, const FluidState& fluidstate)
{
switch (params.approach()) {
case SatCurveMultiplexerApproach::LET:
return LETTwoPhaseLaw::krw(params.template getRealParams<SatCurveMultiplexerApproach::LET>(),
fluidstate);
break;
case SatCurveMultiplexerApproach::PiecewiseLinear:
return PLTwoPhaseLaw::krw(params.template getRealParams<SatCurveMultiplexerApproach::PiecewiseLinear>(),
fluidstate);
break;
}
return 0.0;
}
template <class Evaluation, class ...Args>
static Evaluation twoPhaseSatKrw(const Params& params, const Evaluation& Sw)
{
if constexpr (FrontIsSatCurveMultiplexerDispatchV<Args...>) {
return twoPhaseSatKrwT<Evaluation, Args...>(params, Sw);
}
switch (params.approach()) {
case SatCurveMultiplexerApproach::LET:
return LETTwoPhaseLaw::twoPhaseSatKrw(params.template getRealParams<SatCurveMultiplexerApproach::LET>(),
Sw);
break;
case SatCurveMultiplexerApproach::PiecewiseLinear:
return PLTwoPhaseLaw::twoPhaseSatKrw(params.template getRealParams<SatCurveMultiplexerApproach::PiecewiseLinear>(),
Sw);
break;
}
return 0.0;
}
template <class Evaluation, class Head, class ...Args>
static Evaluation twoPhaseSatKrwT(const Params& params, const Evaluation& Sw)
{
if constexpr (Head::approach == SatCurveMultiplexerApproach::LET) {
return LETTwoPhaseLaw::twoPhaseSatKrw(params.template getRealParams<SatCurveMultiplexerApproach::LET>(),
Sw);
} else if constexpr (Head::approach == SatCurveMultiplexerApproach::PiecewiseLinear) {
return PLTwoPhaseLaw::twoPhaseSatKrw(params.template getRealParams<SatCurveMultiplexerApproach::PiecewiseLinear>(),
Sw);
} else {
STATIC_ASSERT_SATCURVE_MULTIPLEXER_UNLESS_GCC_LT_13;
}
}
template <class Evaluation>
static Evaluation twoPhaseSatKrwInv(const Params& params, const Evaluation& krw)
{
switch (params.approach()) {
case SatCurveMultiplexerApproach::LET:
return LETTwoPhaseLaw::twoPhaseSatKrwInv(params.template getRealParams<SatCurveMultiplexerApproach::LET>(),
krw);
break;
case SatCurveMultiplexerApproach::PiecewiseLinear:
return PLTwoPhaseLaw::twoPhaseSatKrwInv(params.template getRealParams<SatCurveMultiplexerApproach::PiecewiseLinear>(),
krw);
break;
}
return 0.0;
}
template <class FluidState, class Evaluation = typename FluidState::Scalar>
static Evaluation krn(const Params& params, const FluidState& fluidstate)
{
switch (params.approach()) {
case SatCurveMultiplexerApproach::LET:
return LETTwoPhaseLaw::krn(params.template getRealParams<SatCurveMultiplexerApproach::LET>(),
fluidstate);
break;
case SatCurveMultiplexerApproach::PiecewiseLinear:
return PLTwoPhaseLaw::krn(params.template getRealParams<SatCurveMultiplexerApproach::PiecewiseLinear>(),
fluidstate);
break;
}
return 0.0;
}
template <class Evaluation, class ...Args>
static Evaluation twoPhaseSatKrn(const Params& params, const Evaluation& Sw)
{
if constexpr (FrontIsSatCurveMultiplexerDispatchV<Args...>) {
return twoPhaseSatKrnT<Evaluation, Args...>(params, Sw);
}
switch (params.approach()) {
case SatCurveMultiplexerApproach::LET:
return LETTwoPhaseLaw::twoPhaseSatKrn(params.template getRealParams<SatCurveMultiplexerApproach::LET>(),
Sw);
break;
case SatCurveMultiplexerApproach::PiecewiseLinear:
return PLTwoPhaseLaw::twoPhaseSatKrn(params.template getRealParams<SatCurveMultiplexerApproach::PiecewiseLinear>(),
Sw);
break;
}
return 0.0;
}
template <class Evaluation, class Head, class ...Args>
static Evaluation twoPhaseSatKrnT(const Params& params, const Evaluation& Sw)
{
if constexpr (Head::approach == SatCurveMultiplexerApproach::LET) {
return LETTwoPhaseLaw::twoPhaseSatKrn(params.template getRealParams<SatCurveMultiplexerApproach::LET>(),
Sw);
} else if constexpr (Head::approach == SatCurveMultiplexerApproach::PiecewiseLinear) {
return PLTwoPhaseLaw::twoPhaseSatKrn(params.template getRealParams<SatCurveMultiplexerApproach::PiecewiseLinear>(),
Sw);
} else {
STATIC_ASSERT_SATCURVE_MULTIPLEXER_UNLESS_GCC_LT_13;
}
}
template <class Evaluation>
static Evaluation twoPhaseSatKrnInv(const Params& params, const Evaluation& krn)
{
switch (params.approach()) {
case SatCurveMultiplexerApproach::LET:
return LETTwoPhaseLaw::twoPhaseSatKrnInv(params.template getRealParams<SatCurveMultiplexerApproach::LET>(),
krn);
break;
case SatCurveMultiplexerApproach::PiecewiseLinear:
return PLTwoPhaseLaw::twoPhaseSatKrnInv(params.template getRealParams<SatCurveMultiplexerApproach::PiecewiseLinear>(),
krn);
break;
}
return 0.0;
}
};
} // namespace Opm
#endif // OPM_SAT_CURVE_MULTIPLEXER_HPP
SatCurveMultiplexerParams.hpp
Specification of the material parameters for the saturation function multiplexer.
Opm::PiecewiseLinearTwoPhaseMaterial
Implementation of a tabulated, piecewise linear capillary pressure law.
Definition PiecewiseLinearTwoPhaseMaterial.hpp:53
Opm::PiecewiseLinearTwoPhaseMaterial< Traits >::capillaryPressures
static OPM_HOST_DEVICE void capillaryPressures(Container &values, const Params &params, const FluidState &fs)
Definition PiecewiseLinearTwoPhaseMaterial.hpp:100
Opm::PiecewiseLinearTwoPhaseMaterial< Traits >::Sn
static OPM_HOST_DEVICE Evaluation Sn(const Params &params, const FluidState &fs)
Definition PiecewiseLinearTwoPhaseMaterial.hpp:173
Opm::PiecewiseLinearTwoPhaseMaterial< Traits >::relativePermeabilities
static OPM_HOST_DEVICE void relativePermeabilities(Container &values, const Params &params, const FluidState &fs)
Definition PiecewiseLinearTwoPhaseMaterial.hpp:121
Opm::PiecewiseLinearTwoPhaseMaterial< Traits >::twoPhaseSatPcnw
static OPM_HOST_DEVICE Evaluation twoPhaseSatPcnw(const Params &params, const Evaluation &Sw)
Definition PiecewiseLinearTwoPhaseMaterial.hpp:147
Opm::PiecewiseLinearTwoPhaseMaterial< Traits >::krw
static OPM_HOST_DEVICE Evaluation krw(const Params &params, const FluidState &fs)
Definition PiecewiseLinearTwoPhaseMaterial.hpp:185
Opm::PiecewiseLinearTwoPhaseMaterial< Traits >::saturations
static OPM_HOST_DEVICE void saturations(Container &, const Params &, const FluidState &)
Definition PiecewiseLinearTwoPhaseMaterial.hpp:114
Opm::PiecewiseLinearTwoPhaseMaterial< Traits >::krn
static OPM_HOST_DEVICE Evaluation krn(const Params &params, const FluidState &fs)
Definition PiecewiseLinearTwoPhaseMaterial.hpp:213
Opm::PiecewiseLinearTwoPhaseMaterial< Traits >::Sw
static OPM_HOST_DEVICE Evaluation Sw(const Params &, const FluidState &)
Definition PiecewiseLinearTwoPhaseMaterial.hpp:161
Opm::PiecewiseLinearTwoPhaseMaterial< Traits >::pcnw
static OPM_HOST_DEVICE Evaluation pcnw(const Params &params, const FluidState &fs)
Definition PiecewiseLinearTwoPhaseMaterial.hpp:134
Opm::SatCurveMultiplexer
Implements a multiplexer class that provides LET curves and piecewise linear saturation functions.
Definition SatCurveMultiplexer.hpp:52
Opm::SatCurveMultiplexer::Sw
static Evaluation Sw(const Params &params, const FluidState &fluidstate)
The saturation-capillary pressure curve.
Definition SatCurveMultiplexer.hpp:234
Opm::SatCurveMultiplexer::krn
static Evaluation krn(const Params &params, const FluidState &fluidstate)
The relative permeability for the non-wetting phase of the medium.
Definition SatCurveMultiplexer.hpp:379
Opm::SatCurveMultiplexer::krw
static Evaluation krw(const Params &params, const FluidState &fluidstate)
The relative permeability for the wetting phase of the medium.
Definition SatCurveMultiplexer.hpp:303
Opm::SatCurveMultiplexer< GasOilTraits >::isPressureDependent
static constexpr bool isPressureDependent
Definition SatCurveMultiplexer.hpp:81
Opm::SatCurveMultiplexer::saturations
static void saturations(Container &values, const Params &params, const FluidState &fluidState)
Calculate the saturations of the phases starting from their pressure differences.
Definition SatCurveMultiplexer.hpp:121
Opm::SatCurveMultiplexer< GasOilTraits >::implementsTwoPhaseSatApi
static constexpr bool implementsTwoPhaseSatApi
Definition SatCurveMultiplexer.hpp:73
Opm::SatCurveMultiplexer< GasOilTraits >::isTemperatureDependent
static constexpr bool isTemperatureDependent
Definition SatCurveMultiplexer.hpp:85
Opm::SatCurveMultiplexer< GasOilTraits >::isCompositionDependent
static constexpr bool isCompositionDependent
Definition SatCurveMultiplexer.hpp:89
Opm::SatCurveMultiplexer::capillaryPressures
static void capillaryPressures(Container &values, const Params &params, const FluidState &fluidState)
The capillary pressure-saturation curves.
Definition SatCurveMultiplexer.hpp:99
Opm::SatCurveMultiplexer::Sn
static Evaluation Sn(const Params &params, const FluidState &fluidstate)
Calculate the non-wetting phase saturations depending on the phase pressures.
Definition SatCurveMultiplexer.hpp:263
Opm::SatCurveMultiplexer::relativePermeabilities
static void relativePermeabilities(Container &values, const Params &params, const FluidState &fluidState)
The relative permeability-saturation curves.
Definition SatCurveMultiplexer.hpp:149
Opm::SatCurveMultiplexer< GasOilTraits >::implementsTwoPhaseApi
static constexpr bool implementsTwoPhaseApi
Definition SatCurveMultiplexer.hpp:69
Opm::SatCurveMultiplexer< GasOilTraits >::isSaturationDependent
static constexpr bool isSaturationDependent
Definition SatCurveMultiplexer.hpp:77
Opm::SatCurveMultiplexer::pcnw
static Evaluation pcnw(const Params &params, const FluidState &fluidState)
The capillary pressure-saturation curve.
Definition SatCurveMultiplexer.hpp:170
Opm::TwoPhaseLETCurves
Implementation of the LET curve saturation functions.
Definition TwoPhaseLETCurves.hpp:50
Opm::TwoPhaseLETCurves< Traits >::krn
static Evaluation krn(const Params &, const FluidState &)
Definition TwoPhaseLETCurves.hpp:237
Opm::TwoPhaseLETCurves< Traits >::pcnw
static Evaluation pcnw(const Params &, const FluidState &)
Definition TwoPhaseLETCurves.hpp:130
Opm::TwoPhaseLETCurves< Traits >::krw
static Evaluation krw(const Params &, const FluidState &)
Definition TwoPhaseLETCurves.hpp:193
Opm::TwoPhaseLETCurves< Traits >::saturations
static void saturations(Container &, const Params &, const FluidState &)
Definition TwoPhaseLETCurves.hpp:103
Opm::TwoPhaseLETCurves< Traits >::capillaryPressures
static void capillaryPressures(Container &, const Params &, const FluidState &)
Definition TwoPhaseLETCurves.hpp:93
Opm::TwoPhaseLETCurves< Traits >::relativePermeabilities
static void relativePermeabilities(Container &, const Params &, const FluidState &)
Definition TwoPhaseLETCurves.hpp:119
Opm
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30