Loading...
Searching...
No Matches
LinearMaterial.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_LINEAR_MATERIAL_HPP
#define OPM_LINEAR_MATERIAL_HPP
#include "LinearMaterialParams.hpp"
#include <opm/material/common/MathToolbox.hpp>
#include <opm/material/common/Valgrind.hpp>
#include <type_traits>
namespace Opm {
template <class TraitsT, class ParamsT = LinearMaterialParams<TraitsT> >
class LinearMaterial : public TraitsT
{
public:
typedef TraitsT Traits;
typedef ParamsT Params;
typedef typename Traits::Scalar Scalar;
using Traits::numPhases;
static const bool implementsTwoPhaseApi = (numPhases == 2);
static const bool implementsTwoPhaseSatApi = (numPhases == 2);
static const bool isSaturationDependent = true;
static const bool isPressureDependent = false;
static const bool isTemperatureDependent = false;
static const bool isCompositionDependent = false;
template <class ContainerT, class FluidState>
static void capillaryPressures(ContainerT& values,
const Params& params,
const FluidState& state)
{
typedef typename std::remove_reference<decltype(values[0])>::type Evaluation;
for (unsigned phaseIdx = 0; phaseIdx < Traits::numPhases; ++phaseIdx) {
const Evaluation& S =
decay<Evaluation>(state.saturation(phaseIdx));
Valgrind::CheckDefined(S);
values[phaseIdx] =
S*params.pcMaxSat(phaseIdx) +
(1.0 - S)*params.pcMinSat(phaseIdx);
}
}
template <class ContainerT, class FluidState>
static void saturations(ContainerT& /*values*/,
const Params& /*params*/,
const FluidState& /*state*/)
{
throw std::runtime_error("Not implemented: LinearMaterial::saturations()");
}
template <class ContainerT, class FluidState>
static void relativePermeabilities(ContainerT& values,
const Params& /*params*/,
const FluidState& state)
{
typedef typename std::remove_reference<decltype(values[0])>::type Evaluation;
for (unsigned phaseIdx = 0; phaseIdx < Traits::numPhases; ++phaseIdx) {
const Evaluation& S =
decay<Evaluation>(state.saturation(phaseIdx));
Valgrind::CheckDefined(S);
values[phaseIdx] = max(min(S,1.0),0.0);
}
}
template <class FluidState, class Evaluation = typename FluidState::Scalar>
static Evaluation pcnw(const Params& params, const FluidState& fs)
{
const Evaluation& Sw =
decay<Evaluation>(fs.saturation(Traits::wettingPhaseIdx));
Valgrind::CheckDefined(Sw);
const Evaluation& wPhasePressure =
Sw*params.pcMaxSat(Traits::wettingPhaseIdx) +
(1.0 - Sw)*params.pcMinSat(Traits::wettingPhaseIdx);
const Evaluation& Sn =
decay<Evaluation>(fs.saturation(Traits::nonWettingPhaseIdx));
Valgrind::CheckDefined(Sn);
const Evaluation& nPhasePressure =
Sn*params.pcMaxSat(Traits::nonWettingPhaseIdx) +
(1.0 - Sn)*params.pcMinSat(Traits::nonWettingPhaseIdx);
return nPhasePressure - wPhasePressure;
}
template <class Evaluation = Scalar>
static typename std::enable_if<Traits::numPhases == 2, Evaluation>::type
twoPhaseSatPcnw(const Params& params, const Evaluation& Sw)
{
const Evaluation& wPhasePressure =
Sw*params.pcMaxSat(Traits::wettingPhaseIdx) +
(1.0 - Sw)*params.pcMinSat(Traits::wettingPhaseIdx);
const Evaluation& nPhasePressure =
(1.0 - Sw)*params.pcMaxSat(Traits::nonWettingPhaseIdx) +
Sw*params.pcMinSat(Traits::nonWettingPhaseIdx);
return nPhasePressure - wPhasePressure;
}
template <class FluidState, class Evaluation = typename FluidState::Scalar>
static Evaluation Sw(const Params& /*params*/, const FluidState& /*fs*/)
{ throw std::runtime_error("Not implemented: Sw()"); }
template <class Evaluation = Scalar>
static typename std::enable_if<Traits::numPhases == 2, Evaluation>::type
twoPhaseSatSw(const Params& /*params*/, const Evaluation& /*Sw*/)
{ throw std::runtime_error("Not implemented: twoPhaseSatSw()"); }
template <class FluidState, class Evaluation = typename FluidState::Scalar>
static Evaluation Sn(const Params& /*params*/, const FluidState& /*fs*/)
{ throw std::runtime_error("Not implemented: Sn()"); }
template <class Evaluation = Scalar>
static typename std::enable_if<Traits::numPhases == 2, Evaluation>::type
twoPhaseSatSn(const Params& /*params*/, const Evaluation& /*Sw*/)
{ throw std::runtime_error("Not implemented: twoPhaseSatSn()"); }
template <class FluidState, class Evaluation = typename FluidState::Scalar>
static typename std::enable_if<Traits::numPhases == 3, Evaluation>::type
Sg(const Params& /*params*/, const FluidState& /*fs*/)
{ throw std::runtime_error("Not implemented: Sg()"); }
template <class FluidState, class Evaluation = typename FluidState::Scalar>
static Evaluation krw(const Params& /*params*/, const FluidState& fs)
{
const Evaluation& Sw =
decay<Evaluation>(fs.saturation(Traits::wettingPhaseIdx));
return max(0.0, min(1.0, Sw));
}
template <class Evaluation = Scalar>
static typename std::enable_if<Traits::numPhases == 2, Evaluation>::type
twoPhaseSatKrw(const Params& /*params*/, const Evaluation& Sw)
{ return max(0.0, min(1.0, Sw)); }
template <class FluidState, class Evaluation = typename FluidState::Scalar>
static Evaluation krn(const Params& /*params*/, const FluidState& fs)
{
const Evaluation& Sn =
decay<Evaluation>(fs.saturation(Traits::nonWettingPhaseIdx));
return max(0.0, min(1.0, Sn));
}
template <class Evaluation = Scalar>
static typename std::enable_if<Traits::numPhases == 2, Evaluation>::type
twoPhaseSatKrn(const Params& /*params*/, const Evaluation& Sw)
{
return max(0.0, min(1.0, Sw));
}
template <class FluidState, class Evaluation = typename FluidState::Scalar>
static typename std::enable_if<Traits::numPhases == 3, Evaluation>::type
krg(const Params& /*params*/, const FluidState& fs)
{
const Evaluation& Sg =
decay<Evaluation>(fs.saturation(Traits::gasPhaseIdx));
return max(0.0, min(1.0, Sg));
}
template <class FluidState, class Evaluation = Scalar>
static typename std::enable_if<Traits::numPhases == 3, Evaluation>::type
pcgn(const Params& params, const FluidState& fs)
{
const Evaluation& Sn =
decay<Evaluation>(fs.saturation(Traits::nonWettingPhaseIdx));
Valgrind::CheckDefined(Sn);
const Evaluation& nPhasePressure =
Sn*params.pcMaxSat(Traits::nonWettingPhaseIdx) +
(1.0 - Sn)*params.pcMinSat(Traits::nonWettingPhaseIdx);
const Evaluation& Sg =
decay<Evaluation>(fs.saturation(Traits::gasPhaseIdx));
Valgrind::CheckDefined(Sg);
const Evaluation& gPhasePressure =
Sg*params.pcMaxSat(Traits::gasPhaseIdx) +
(1.0 - Sg)*params.pcMinSat(Traits::gasPhaseIdx);
return gPhasePressure - nPhasePressure;
}
};
} // namespace Opm
#endif
LinearMaterialParams.hpp
Reference implementation of params for the linear M-phase material material.
MathToolbox.hpp
A traits class which provides basic mathematical functions for arbitrary scalar floating point values...
Valgrind.hpp
Some templates to wrap the valgrind client request macros.
Opm::LinearMaterial
Implements a linear saturation-capillary pressure relation.
Definition LinearMaterial.hpp:51
Opm::LinearMaterial::pcnw
static Evaluation pcnw(const Params &params, const FluidState &fs)
The difference between the pressures of the non-wetting and wetting phase.
Definition LinearMaterial.hpp:148
Opm::LinearMaterial::krn
static Evaluation krn(const Params &, const FluidState &fs)
The relative permability of the liquid non-wetting phase.
Definition LinearMaterial.hpp:242
Opm::LinearMaterial::relativePermeabilities
static void relativePermeabilities(ContainerT &values, const Params &, const FluidState &state)
The relative permeability of all phases.
Definition LinearMaterial.hpp:129
Opm::LinearMaterial::implementsTwoPhaseSatApi
static const bool implementsTwoPhaseSatApi
Specify whether this material law implements the two-phase convenience API which only depends on the ...
Definition LinearMaterial.hpp:66
Opm::LinearMaterial::isPressureDependent
static const bool isPressureDependent
Specify whether the quantities defined by this material law are dependent on the absolute pressure.
Definition LinearMaterial.hpp:74
Opm::LinearMaterial::pcgn
static std::enable_if< Traits::numPhases==3, Evaluation >::type pcgn(const Params &params, const FluidState &fs)
The difference between the pressures of the gas and the non-wetting phase.
Definition LinearMaterial.hpp:277
Opm::LinearMaterial::isSaturationDependent
static const bool isSaturationDependent
Specify whether the quantities defined by this material law are saturation dependent.
Definition LinearMaterial.hpp:70
Opm::LinearMaterial::Sg
static std::enable_if< Traits::numPhases==3, Evaluation >::type Sg(const Params &, const FluidState &)
Calculate gas phase saturation given that the rest of the fluid state has been initialized.
Definition LinearMaterial.hpp:219
Opm::LinearMaterial::Sw
static Evaluation Sw(const Params &, const FluidState &)
Calculate wetting phase saturation given that the rest of the fluid state has been initialized.
Definition LinearMaterial.hpp:190
Opm::LinearMaterial::Sn
static Evaluation Sn(const Params &, const FluidState &)
Calculate non-wetting liquid phase saturation given that the rest of the fluid state has been initial...
Definition LinearMaterial.hpp:203
Opm::LinearMaterial::isTemperatureDependent
static const bool isTemperatureDependent
Specify whether the quantities defined by this material law are temperature dependent.
Definition LinearMaterial.hpp:78
Opm::LinearMaterial::saturations
static void saturations(ContainerT &, const Params &, const FluidState &)
The inverse of the capillary pressure.
Definition LinearMaterial.hpp:118
Opm::LinearMaterial::isCompositionDependent
static const bool isCompositionDependent
Specify whether the quantities defined by this material law are dependent on the phase composition.
Definition LinearMaterial.hpp:82
Opm::LinearMaterial::implementsTwoPhaseApi
static const bool implementsTwoPhaseApi
Specify whether this material law implements the two-phase convenience API.
Definition LinearMaterial.hpp:62
Opm::LinearMaterial::capillaryPressures
static void capillaryPressures(ContainerT &values, const Params &params, const FluidState &state)
The linear capillary pressure-saturation curve.
Definition LinearMaterial.hpp:97
Opm::LinearMaterial::krg
static std::enable_if< Traits::numPhases==3, Evaluation >::type krg(const Params &, const FluidState &fs)
The relative permability of the gas phase.
Definition LinearMaterial.hpp:263
Opm::LinearMaterial::krw
static Evaluation krw(const Params &, const FluidState &fs)
The relative permability of the wetting phase.
Definition LinearMaterial.hpp:226
Opm
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30