Loading...
Searching...
No Matches
SplineTwoPhaseMaterial.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 2 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_SPLINE_TWO_PHASE_MATERIAL_HPP
#define OPM_SPLINE_TWO_PHASE_MATERIAL_HPP
#include "SplineTwoPhaseMaterialParams.hpp"
#include <algorithm>
#include <cmath>
#include <cassert>
namespace Opm {
template <class TraitsT, class ParamsT = SplineTwoPhaseMaterialParams<TraitsT> >
class SplineTwoPhaseMaterial : public TraitsT
{
typedef typename ParamsT::SamplePoints SamplePoints;
public:
typedef TraitsT Traits;
typedef ParamsT Params;
typedef typename Traits::Scalar Scalar;
static const int numPhases = Traits::numPhases;
static_assert(numPhases == 2,
"The piecewise linear two-phase capillary pressure law only"
"applies to the case of two fluid phases");
static const bool implementsTwoPhaseApi = true;
static const bool implementsTwoPhaseSatApi = true;
static const bool isSaturationDependent = true;
static const bool isPressureDependent = false;
static const bool isTemperatureDependent = false;
static const bool isCompositionDependent = false;
template <class Container, class FluidState>
static void capillaryPressures(Container& values, const Params& params, const FluidState& fluidState)
{
typedef typename std::remove_reference<decltype(values[0])>::type Evaluation;
values[Traits::wettingPhaseIdx] = 0.0; // reference phase
values[Traits::nonWettingPhaseIdx] = pcnw<FluidState, Evaluation>(params, fluidState);
}
template <class Container, class FluidState>
static void saturations(Container& /*values*/, const Params& /*params*/, const FluidState& /*fluidState*/)
{ throw std::logic_error("Not implemented: saturations()"); }
template <class Container, class FluidState>
static void relativePermeabilities(Container& values, const Params& params, const FluidState& fluidState)
{
typedef typename std::remove_reference<decltype(values[0])>::type Evaluation;
values[Traits::wettingPhaseIdx] = krw<FluidState, Evaluation>(params, fluidState);
values[Traits::nonWettingPhaseIdx] = krn<FluidState, Evaluation>(params, fluidState);
}
template <class FluidState, class Evaluation = typename FluidState::Scalar>
static Evaluation pcnw(const Params& params, const FluidState& fluidState)
{
const Evaluation& Sw =
decay<Evaluation>(fluidState.saturation(Traits::wettingPhaseIdx));
return twoPhaseSatPcnw(params, Sw);
}
template <class Evaluation>
static Evaluation twoPhaseSatPcnw(const Params& params, const Evaluation& Sw)
{
// this assumes that the capillary pressure is monotonically decreasing
const auto& pcnwSpline = params.pcnwSpline();
if (Sw <= pcnwSpline.xAt(0))
return Evaluation(pcnwSpline.valueAt(0));
if (Sw >= pcnwSpline.xAt(pcnwSpline.numSamples() - 1))
return Evaluation(pcnwSpline.valueAt(pcnwSpline.numSamples() - 1));
return pcnwSpline.eval(Sw);
}
template <class Evaluation>
static Evaluation twoPhaseSatPcnwInv(const Params& params, const Evaluation& pcnw)
{
static const Evaluation nil(0.0);
// this assumes that the capillary pressure is monotonically decreasing
const auto& pcnwSpline = params.pcnwSpline();
if (pcnw >= pcnwSpline.valueAt(0))
return Evaluation(pcnwSpline.xAt(0));
if (pcnw <= pcnwSpline.y(pcnwSpline.numSamples() - 1))
return Evaluation(pcnwSpline.xAt(pcnwSpline.numSamples() - 1));
// the intersect() method of splines is a bit slow, but this code path is not too
// time critical...
return pcnwSpline.intersect(/*a=*/nil, /*b=*/nil, /*c=*/nil, /*d=*/pcnw);
}
template <class FluidState, class Evaluation = typename FluidState::Scalar>
static Evaluation Sw(const Params& /*params*/, const FluidState& /*fluidState*/)
{ throw std::logic_error("Not implemented: Sw()"); }
template <class Evaluation>
static Evaluation twoPhaseSatSw(const Params& /*params*/, const Evaluation& /*pC*/)
{ throw std::logic_error("Not implemented: twoPhaseSatSw()"); }
template <class FluidState, class Evaluation = typename FluidState::Scalar>
static Evaluation Sn(const Params& params, const FluidState& fluidState)
{ return 1 - Sw<FluidState, Evaluation>(params, fluidState); }
template <class Evaluation>
static Evaluation twoPhaseSatSn(const Params& params, const Evaluation& pC)
{ return 1 - twoPhaseSatSw(params, pC); }
template <class FluidState, class Evaluation = typename FluidState::Scalar>
static Evaluation krw(const Params& params, const FluidState& fluidState)
{
const Evaluation& Sw =
decay<Evaluation>(fluidState.saturation(Traits::wettingPhaseIdx));
return twoPhaseSatKrw(params, Sw);
}
template <class Evaluation>
static Evaluation twoPhaseSatKrw(const Params& params, const Evaluation& Sw)
{
const auto& krwSpline = params.krwSpline();
if (Sw <= krwSpline.xAt(0))
return Evaluation(krwSpline.valueAt(0));
if (Sw >= krwSpline.xAt(krwSpline.numSamples() - 1))
return Evaluation(krwSpline.valueAt(krwSpline.numSamples() - 1));
return krwSpline.eval(Sw);
}
template <class Evaluation>
static Evaluation twoPhaseSatKrwInv(const Params& params, const Evaluation& krw)
{
static const Evaluation nil(0.0);
const auto& krwSpline = params.krwSpline();
if (krw <= krwSpline.valueAt(0))
return Evaluation(krwSpline.xAt(0));
if (krw >= krwSpline.valueAt(krwSpline.numSamples() - 1))
return Evaluation(krwSpline.xAt(krwSpline.numSamples() - 1));
return krwSpline.intersect(/*a=*/nil, /*b=*/nil, /*c=*/nil, /*d=*/krw);
}
template <class FluidState, class Evaluation = typename FluidState::Scalar>
static Evaluation krn(const Params& params, const FluidState& fluidState)
{
const Evaluation& Sn =
decay<Evaluation>(fluidState.saturation(Traits::nonWettingPhaseIdx));
return twoPhaseSatKrn(params, 1.0 - Sn);
}
template <class Evaluation>
static Evaluation twoPhaseSatKrn(const Params& params, const Evaluation& Sw)
{
const auto& krnSpline = params.krnSpline();
if (Sw <= krnSpline.xAt(0))
return Evaluation(krnSpline.valueAt(0));
if (Sw >= krnSpline.xAt(krnSpline.numSamples() - 1))
return Evaluation(krnSpline.valueAt(krnSpline.numSamples() - 1));
return krnSpline.eval(Sw);
}
template <class Evaluation>
static Evaluation twoPhaseSatKrnInv(const Params& params, const Evaluation& krn)
{
static const Evaluation nil(0.0);
const auto& krnSpline = params.krnSpline();
if (krn >= krnSpline.valueAt(0))
return Evaluation(krnSpline.xAt(0));
if (krn <= krnSpline.valueAt(krnSpline.numSamples() - 1))
return Evaluation(krnSpline.xAt(krnSpline.numSamples() - 1));
return krnSpline.intersect(/*a=*/nil, /*b=*/nil, /*c=*/nil, /*d=*/krn);
}
};
} // namespace Opm
#endif
SplineTwoPhaseMaterialParams.hpp
Specification of the material parameters for a two-phase material law which uses a table and spline-b...
Opm::SplineTwoPhaseMaterial
Implementation of a tabulated capillary pressure and relperm law which uses spline curves as interpol...
Definition SplineTwoPhaseMaterial.hpp:45
Opm::SplineTwoPhaseMaterial::implementsTwoPhaseApi
static const bool implementsTwoPhaseApi
Specify whether this material law implements the two-phase convenience API.
Definition SplineTwoPhaseMaterial.hpp:66
Opm::SplineTwoPhaseMaterial::krw
static Evaluation krw(const Params &params, const FluidState &fluidState)
The relative permeability for the wetting phase of the porous medium.
Definition SplineTwoPhaseMaterial.hpp:193
Opm::SplineTwoPhaseMaterial::isTemperatureDependent
static const bool isTemperatureDependent
Specify whether the quantities defined by this material law are temperature dependent.
Definition SplineTwoPhaseMaterial.hpp:82
Opm::SplineTwoPhaseMaterial::Scalar
Traits::Scalar Scalar
The type of the scalar values for this law.
Definition SplineTwoPhaseMaterial.hpp:56
Opm::SplineTwoPhaseMaterial::capillaryPressures
static void capillaryPressures(Container &values, const Params &params, const FluidState &fluidState)
The capillary pressure-saturation curve.
Definition SplineTwoPhaseMaterial.hpp:92
Opm::SplineTwoPhaseMaterial::Sw
static Evaluation Sw(const Params &, const FluidState &)
The saturation-capillary pressure curve.
Definition SplineTwoPhaseMaterial.hpp:169
Opm::SplineTwoPhaseMaterial::relativePermeabilities
static void relativePermeabilities(Container &values, const Params &params, const FluidState &fluidState)
The relative permeabilities.
Definition SplineTwoPhaseMaterial.hpp:112
Opm::SplineTwoPhaseMaterial::saturations
static void saturations(Container &, const Params &, const FluidState &)
The saturations of the fluid phases starting from their pressure differences.
Definition SplineTwoPhaseMaterial.hpp:105
Opm::SplineTwoPhaseMaterial::krn
static Evaluation krn(const Params &params, const FluidState &fluidState)
The relative permeability for the non-wetting phase of the porous medium.
Definition SplineTwoPhaseMaterial.hpp:232
Opm::SplineTwoPhaseMaterial::implementsTwoPhaseSatApi
static const bool implementsTwoPhaseSatApi
Specify whether this material law implements the two-phase convenience API which only depends on the ...
Definition SplineTwoPhaseMaterial.hpp:70
Opm::SplineTwoPhaseMaterial::isPressureDependent
static const bool isPressureDependent
Specify whether the quantities defined by this material law are dependent on the absolute pressure.
Definition SplineTwoPhaseMaterial.hpp:78
Opm::SplineTwoPhaseMaterial::pcnw
static Evaluation pcnw(const Params &params, const FluidState &fluidState)
The capillary pressure-saturation curve.
Definition SplineTwoPhaseMaterial.hpp:124
Opm::SplineTwoPhaseMaterial::Params
ParamsT Params
The type of the parameter objects for this law.
Definition SplineTwoPhaseMaterial.hpp:53
Opm::SplineTwoPhaseMaterial::Sn
static Evaluation Sn(const Params &params, const FluidState &fluidState)
Calculate the non-wetting phase saturations depending on the phase pressures.
Definition SplineTwoPhaseMaterial.hpp:181
Opm::SplineTwoPhaseMaterial::isCompositionDependent
static const bool isCompositionDependent
Specify whether the quantities defined by this material law are dependent on the phase composition.
Definition SplineTwoPhaseMaterial.hpp:86
Opm::SplineTwoPhaseMaterial::isSaturationDependent
static const bool isSaturationDependent
Specify whether the quantities defined by this material law are saturation dependent.
Definition SplineTwoPhaseMaterial.hpp:74
Opm::SplineTwoPhaseMaterial::Traits
TraitsT Traits
The traits class for this material law.
Definition SplineTwoPhaseMaterial.hpp:50
Opm::SplineTwoPhaseMaterial::numPhases
static const int numPhases
The number of fluid phases.
Definition SplineTwoPhaseMaterial.hpp:59
Opm::SplineTwoPhaseMaterial::twoPhaseSatPcnw
static Evaluation twoPhaseSatPcnw(const Params &params, const Evaluation &Sw)
The saturation-capillary pressure curve.
Definition SplineTwoPhaseMaterial.hpp:136
Opm
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30