Loading...
Searching...
No Matches
EffToAbsLaw.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_EFF_TO_ABS_LAW_HPP
#define OPM_EFF_TO_ABS_LAW_HPP
#include "EffToAbsLawParams.hpp"
#include <opm/material/fluidstates/SaturationOverlayFluidState.hpp>
namespace Opm {
template <class EffLawT, class ParamsT = EffToAbsLawParams<typename EffLawT::Params, EffLawT::numPhases> >
class EffToAbsLaw : public EffLawT::Traits
{
typedef EffLawT EffLaw;
public:
typedef typename EffLaw::Traits Traits;
typedef ParamsT Params;
typedef typename EffLaw::Scalar Scalar;
static const int numPhases = EffLaw::numPhases;
static const bool implementsTwoPhaseApi = EffLaw::implementsTwoPhaseApi;
static const bool implementsTwoPhaseSatApi = EffLaw::implementsTwoPhaseSatApi;
static const bool isSaturationDependent = EffLaw::isSaturationDependent;
static const bool isPressureDependent = EffLaw::isPressureDependent;
static const bool isTemperatureDependent = EffLaw::isTemperatureDependent;
static const bool isCompositionDependent = EffLaw::isCompositionDependent;
template <class Container, class FluidState>
static void capillaryPressures(Container& values, const Params& params, const FluidState& fs)
{
typedef SaturationOverlayFluidState<FluidState> OverlayFluidState;
OverlayFluidState overlayFs(fs);
for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++ phaseIdx) {
overlayFs.setSaturation(phaseIdx,
effectiveSaturation(params,
fs.saturation(phaseIdx),
phaseIdx));
}
EffLaw::template capillaryPressures<Container, OverlayFluidState>(values, params, overlayFs);
}
template <class Container, class FluidState>
static void relativePermeabilities(Container& values, const Params& params, const FluidState& fs)
{
typedef SaturationOverlayFluidState<FluidState> OverlayFluidState;
OverlayFluidState overlayFs(fs);
for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++ phaseIdx) {
overlayFs.setSaturation(phaseIdx,
effectiveSaturation(params,
fs.saturation(phaseIdx),
phaseIdx));
}
EffLaw::template relativePermeabilities<Container, OverlayFluidState>(values, params, overlayFs);
}
template <class FluidState, class Evaluation = typename FluidState::Scalar>
static Evaluation pcnw(const Params& params, const FluidState& fs)
{
typedef SaturationOverlayFluidState<FluidState> OverlayFluidState;
static_assert(FluidState::numPhases == numPhases,
"The fluid state and the material law must exhibit the same "
"number of phases!");
OverlayFluidState overlayFs(fs);
for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++ phaseIdx) {
overlayFs.setSaturation(phaseIdx,
effectiveSaturation(params,
fs.saturation(phaseIdx),
phaseIdx));
}
return EffLaw::template pcnw<OverlayFluidState, Evaluation>(params, overlayFs);
}
template <class Evaluation>
static typename std::enable_if<implementsTwoPhaseSatApi, Evaluation>::type
twoPhaseSatPcnw(const Params& params, const Evaluation& SwAbs)
{
const Evaluation& SwEff = effectiveSaturation(params, SwAbs, Traits::wettingPhaseIdx);
return EffLaw::twoPhaseSatPcnw(params, SwEff);
}
template <class Container, class FluidState>
static void saturations(Container& values, const Params& params, const FluidState& fs)
{
EffLaw::template saturations<Container, FluidState>(values, params, fs);
for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
values[phaseIdx] = absoluteSaturation(params, values[phaseIdx], phaseIdx);
}
}
template <class FluidState, class Evaluation = typename FluidState::Scalar>
static Evaluation Sw(const Params& params, const FluidState& fs)
{
return absoluteSaturation(params,
EffLaw::template Sw<FluidState, Evaluation>(params, fs),
Traits::wettingPhaseIdx);
}
template <class Evaluation>
static typename std::enable_if<implementsTwoPhaseSatApi, Evaluation>::type
twoPhaseSatSw(const Params& params, const Evaluation& Sw)
{ return absoluteSaturation(params,
EffLaw::twoPhaseSatSw(params, Sw),
Traits::wettingPhaseIdx); }
template <class FluidState, class Evaluation = typename FluidState::Scalar>
static Evaluation Sn(const Params& params, const FluidState& fs)
{
return absoluteSaturation(params,
EffLaw::template Sn<FluidState, Evaluation>(params, fs),
Traits::nonWettingPhaseIdx);
}
template <class Evaluation>
static typename std::enable_if<implementsTwoPhaseSatApi, Evaluation>::type
twoPhaseSatSn(const Params& params, const Evaluation& Sw)
{
return absoluteSaturation(params,
EffLaw::twoPhaseSatSn(params, Sw),
Traits::nonWettingPhaseIdx);
}
template <class FluidState, class Evaluation = typename FluidState::Scalar>
static typename std::enable_if< (Traits::numPhases > 2), Evaluation>::type
Sg(const Params& params, const FluidState& fs)
{
return absoluteSaturation(params,
EffLaw::template Sg<FluidState, Evaluation>(params, fs),
Traits::gasPhaseIdx);
}
template <class FluidState, class Evaluation = typename FluidState::Scalar>
static Evaluation krw(const Params& params, const FluidState& fs)
{
typedef SaturationOverlayFluidState<FluidState> OverlayFluidState;
static_assert(FluidState::numPhases == numPhases,
"The fluid state and the material law must exhibit the same "
"number of phases!");
OverlayFluidState overlayFs(fs);
for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++ phaseIdx) {
overlayFs.setSaturation(phaseIdx,
effectiveSaturation(params,
fs.saturation(phaseIdx),
phaseIdx));
}
return EffLaw::template krw<OverlayFluidState, Evaluation>(params, overlayFs);
}
template <class Evaluation>
static typename std::enable_if<implementsTwoPhaseSatApi, Evaluation>::type
twoPhaseSatKrw(const Params& params, const Evaluation& Sw)
{ return EffLaw::twoPhaseSatKrw(params, effectiveSaturation(params, Sw, Traits::wettingPhaseIdx)); }
template <class FluidState, class Evaluation = typename FluidState::Scalar>
static Evaluation krn(const Params& params, const FluidState& fs)
{
typedef SaturationOverlayFluidState<FluidState> OverlayFluidState;
static_assert(FluidState::numPhases == numPhases,
"The fluid state and the material law must exhibit the same "
"number of phases!");
OverlayFluidState overlayFs(fs);
for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++ phaseIdx) {
overlayFs.setSaturation(phaseIdx,
effectiveSaturation(params,
fs.saturation(phaseIdx),
phaseIdx));
}
return EffLaw::template krn<OverlayFluidState, Evaluation>(params, overlayFs);
}
template <class Evaluation>
static typename std::enable_if<implementsTwoPhaseSatApi, Evaluation>::type
twoPhaseSatKrn(const Params& params, const Evaluation& Sw)
{ return EffLaw::twoPhaseSatKrn(params, effectiveSaturation(params, Sw, Traits::wettingPhaseIdx)); }
template <class FluidState, class Evaluation = typename FluidState::Scalar>
static typename std::enable_if< (Traits::numPhases > 2), Evaluation>::type
krg(const Params& params, const FluidState& fs)
{
typedef SaturationOverlayFluidState<FluidState> OverlayFluidState;
static_assert(FluidState::numPhases == numPhases,
"The fluid state and the material law must exhibit the same "
"number of phases!");
OverlayFluidState overlayFs(fs);
for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++ phaseIdx) {
overlayFs.setSaturation(phaseIdx,
effectiveSaturation(params,
fs.saturation(phaseIdx),
phaseIdx));
}
return EffLaw::template krg<OverlayFluidState, Evaluation>(params, overlayFs);
}
template <class Evaluation>
static Evaluation effectiveSaturation(const Params& params, const Evaluation& S, unsigned phaseIdx)
{ return (S - params.residualSaturation(phaseIdx))/(1.0 - params.sumResidualSaturations()); }
template <class Evaluation>
static Evaluation absoluteSaturation(const Params& params, const Evaluation& S, unsigned phaseIdx)
{ return S*(1.0 - params.sumResidualSaturations()) + params.residualSaturation(phaseIdx); }
private:
static Scalar dSeff_dSabs_(const Params& params, int /*phaseIdx*/)
{ return 1.0/(1 - params.sumResidualSaturations()); }
static Scalar dSabs_dSeff_(const Params& params, int /*phaseIdx*/)
{ return 1 - params.sumResidualSaturations(); }
};
} // namespace Opm
#endif
EffToAbsLawParams.hpp
A default implementation of the parameters for the adapter class to convert material laws from effect...
SaturationOverlayFluidState.hpp
This is a fluid state which allows to set the fluid saturations and takes all other quantities from a...
Opm::EffToAbsLaw
This material law takes a material law defined for effective saturations and converts it to a materia...
Definition EffToAbsLaw.hpp:71
Opm::EffToAbsLaw::implementsTwoPhaseApi
static const bool implementsTwoPhaseApi
Specify whether this material law implements the two-phase convenience API.
Definition EffToAbsLaw.hpp:84
Opm::EffToAbsLaw::isPressureDependent
static const bool isPressureDependent
Specify whether the quantities defined by this material law are dependent on the absolute pressure.
Definition EffToAbsLaw.hpp:96
Opm::EffToAbsLaw::isTemperatureDependent
static const bool isTemperatureDependent
Specify whether the quantities defined by this material law are temperature dependent.
Definition EffToAbsLaw.hpp:100
Opm::EffToAbsLaw::capillaryPressures
static void capillaryPressures(Container &values, const Params &params, const FluidState &fs)
The capillary pressure-saturation curves depending on absolute saturations.
Definition EffToAbsLaw.hpp:117
Opm::EffToAbsLaw::isCompositionDependent
static const bool isCompositionDependent
Specify whether the quantities defined by this material law are dependent on the phase composition.
Definition EffToAbsLaw.hpp:104
Opm::EffToAbsLaw::pcnw
static Evaluation pcnw(const Params &params, const FluidState &fs)
The capillary pressure-saturation curve.
Definition EffToAbsLaw.hpp:171
Opm::EffToAbsLaw::krn
static Evaluation krn(const Params &params, const FluidState &fs)
The relative permeability of the non-wetting phase.
Definition EffToAbsLaw.hpp:305
Opm::EffToAbsLaw::Sn
static Evaluation Sn(const Params &params, const FluidState &fs)
Calculate non-wetting liquid phase saturation given that the rest of the fluid state has been initial...
Definition EffToAbsLaw.hpp:235
Opm::EffToAbsLaw::isSaturationDependent
static const bool isSaturationDependent
Specify whether the quantities defined by this material law are saturation dependent.
Definition EffToAbsLaw.hpp:92
Opm::EffToAbsLaw::krw
static Evaluation krw(const Params &params, const FluidState &fs)
The relative permeability for the wetting phase.
Definition EffToAbsLaw.hpp:277
Opm::EffToAbsLaw::Sg
static std::enable_if<(Traits::numPhases >2), Evaluation >::type Sg(const Params &params, const FluidState &fs)
Calculate gas phase saturation given that the rest of the fluid state has been initialized.
Definition EffToAbsLaw.hpp:259
Opm::EffToAbsLaw::implementsTwoPhaseSatApi
static const bool implementsTwoPhaseSatApi
Specify whether this material law implements the two-phase convenience API which only depends on the ...
Definition EffToAbsLaw.hpp:88
Opm::EffToAbsLaw::absoluteSaturation
static Evaluation absoluteSaturation(const Params &params, const Evaluation &S, unsigned phaseIdx)
Convert an effective saturation to an absolute one.
Definition EffToAbsLaw.hpp:366
Opm::EffToAbsLaw::numPhases
static const int numPhases
The number of fluid phases.
Definition EffToAbsLaw.hpp:80
Opm::EffToAbsLaw::krg
static std::enable_if<(Traits::numPhases >2), Evaluation >::type krg(const Params &params, const FluidState &fs)
The relative permability of the gas phase.
Definition EffToAbsLaw.hpp:336
Opm::EffToAbsLaw::Sw
static Evaluation Sw(const Params &params, const FluidState &fs)
Calculate wetting liquid phase saturation given that the rest of the fluid state has been initialized...
Definition EffToAbsLaw.hpp:216
Opm::EffToAbsLaw::effectiveSaturation
static Evaluation effectiveSaturation(const Params &params, const Evaluation &S, unsigned phaseIdx)
Convert an absolute saturation to an effective one.
Definition EffToAbsLaw.hpp:359
Opm::EffToAbsLaw::relativePermeabilities
static void relativePermeabilities(Container &values, const Params &params, const FluidState &fs)
The relative permeability-saturation curves depending on absolute saturations.
Definition EffToAbsLaw.hpp:143
Opm::EffToAbsLaw::saturations
static void saturations(Container &values, const Params &params, const FluidState &fs)
The saturation-capillary pressure curves.
Definition EffToAbsLaw.hpp:203
Opm::SaturationOverlayFluidState
This is a fluid state which allows to set the fluid saturations and takes all other quantities from a...
Definition SaturationOverlayFluidState.hpp:44
Opm
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30