Merge pull request #378 from akva2/noecl_flush

Serialization preparation
This commit is contained in:
Bård Skaflestad 2019-12-19 13:57:58 +01:00 committed by GitHub
commit d63c127d52
9 changed files with 370 additions and 9 deletions

View File

@ -129,6 +129,29 @@ public:
Scalar yMax() const
{ return yPos_.back(); }
const std::vector<Scalar>& xPos() const
{ return xPos_; }
const std::vector<Scalar>& yPos() const
{ return yPos_; }
const std::vector<std::vector<Scalar>>& samples() const
{ return samples_; }
bool xExtrapolate() const
{ return xExtrapolate_; }
bool yExtrapolate() const
{ return yExtrapolate_; }
bool operator==(const IntervalTabulated2DFunction<Scalar>& data) const {
return this->xPos() == data.xPos() &&
this->yPos() == data.yPos() &&
this->samples() == data.samples() &&
this->xExtrapolate() == data.xExtrapolate() &&
this->yExtrapolate() == data.yExtrapolate();
}
/*!
* \brief Returns the value of a sampling point.
*/

View File

@ -225,6 +225,12 @@ public:
Scalar xAt(size_t i) const
{ return xValues_[i]; }
const std::vector<Scalar>& xValues() const
{ return xValues_; }
const std::vector<Scalar>& yValues() const
{ return yValues_; }
/*!
* \brief Return the value of the a sample point with a given index.
*/
@ -437,6 +443,11 @@ public:
}
}
bool operator==(const Tabulated1DFunction<Scalar>& data) const {
return xValues_ == data.xValues_ &&
yValues_ == data.yValues_;
}
private:
template <class Evaluation>
size_t findSegmentIndex_(const Evaluation& x, bool extrapolate = false) const

View File

@ -238,6 +238,18 @@ public:
samples_[j*m_ + i] = value;
}
bool operator==(const UniformTabulated2DFunction<Scalar>& data) const
{
return samples_ == data.samples_ &&
m_ == data.m_ &&
n_ == data.n_ &&
xMin_ == data.xMin_ &&
xMax_ == data.xMax_ &&
yMin_ == data.yMin_ &&
yMax_ == data.yMax_;
}
private:
// the vector which contains the values of the sample points
// f(x_i, y_j). don't use this directly, use getSamplePoint(i,j)

View File

@ -52,9 +52,8 @@ namespace Opm {
template <class Scalar>
class UniformXTabulated2DFunction
{
typedef std::tuple</*x=*/Scalar, /*y=*/Scalar, /*value=*/Scalar> SamplePoint;
public:
typedef std::tuple</*x=*/Scalar, /*y=*/Scalar, /*value=*/Scalar> SamplePoint;
/*!
* \brief Indicates how interpolation will be performed.
@ -76,6 +75,16 @@ public:
: interpolationGuide_(interpolationGuide)
{ }
UniformXTabulated2DFunction(const std::vector<Scalar>& xPos,
const std::vector<Scalar>& yPos,
const std::vector<std::vector<SamplePoint>>& samples,
InterpolationPolicy interpolationGuide)
: samples_(samples)
, xPos_(xPos)
, yPos_(yPos)
, interpolationGuide_(interpolationGuide)
{ }
/*!
* \brief Returns the minimum of the X coordinate of the sampling points.
*/
@ -140,6 +149,26 @@ public:
return xPos_.at(i);
}
const std::vector<std::vector<SamplePoint>>& samples() const
{
return samples_;
}
const std::vector<Scalar>& xPos() const
{
return xPos_;
}
const std::vector<Scalar>& yPos() const
{
return yPos_;
}
InterpolationPolicy interpolationGuide() const
{
return interpolationGuide_;
}
/*!
* \brief Return the position on the y-axis of the j-th interval.
*/
@ -436,6 +465,13 @@ public:
}
}
bool operator==(const UniformXTabulated2DFunction<Scalar>& data) const {
return this->xPos() == data.xPos() &&
this->yPos() == data.yPos() &&
this->samples() == data.samples() &&
this->interpolationGuide() == data.interpolationGuide();
}
private:
// the vector which contains the values of the sample points
// f(x_i, y_j). don't use this directly, use getSamplePoint(i,j)

View File

@ -50,10 +50,22 @@ namespace Opm {
template <class Scalar>
class DryGasPvt
{
typedef Opm::Tabulated1DFunction<Scalar> TabulatedOneDFunction;
typedef std::vector<std::pair<Scalar, Scalar> > SamplingPoints;
public:
typedef Opm::Tabulated1DFunction<Scalar> TabulatedOneDFunction;
explicit DryGasPvt() = default;
DryGasPvt(const std::vector<Scalar>& gasReferenceDensity,
const std::vector<TabulatedOneDFunction>& inverseGasB,
const std::vector<TabulatedOneDFunction>& gasMu,
const std::vector<TabulatedOneDFunction>& inverseGasBMu)
: gasReferenceDensity_(gasReferenceDensity)
, inverseGasB_(inverseGasB)
, gasMu_(gasMu)
, inverseGasBMu_(inverseGasBMu)
{
}
#if HAVE_ECL_INPUT
/*!
* \brief Initialize the parameters for dry gas using an ECL deck.
@ -278,6 +290,26 @@ public:
const Evaluation& /*pressure*/) const
{ return 0.0; /* this is dry gas! */ }
const std::vector<Scalar>& gasReferenceDensity() const
{ return gasReferenceDensity_; }
const std::vector<TabulatedOneDFunction>& inverseGasB() const
{ return inverseGasB_; }
const std::vector<TabulatedOneDFunction>& gasMu() const
{ return gasMu_; }
const std::vector<TabulatedOneDFunction> inverseGasBMu() const
{ return inverseGasBMu_; }
bool operator==(const DryGasPvt<Scalar>& data) const
{
return gasReferenceDensity_ == data.gasReferenceDensity_ &&
inverseGasB_ == data.inverseGasB_ &&
gasMu_ == data.gasMu_ &&
inverseGasBMu_ == data.inverseGasBMu_;
}
private:
std::vector<Scalar> gasReferenceDensity_;
std::vector<TabulatedOneDFunction> inverseGasB_;

View File

@ -87,6 +87,17 @@ public:
GasPvtMultiplexer()
{
gasPvtApproach_ = NoGasPvt;
realGasPvt_ = nullptr;
}
GasPvtMultiplexer(GasPvtApproach approach, void* realGasPvt)
: gasPvtApproach_(approach)
, realGasPvt_(realGasPvt)
{ }
GasPvtMultiplexer(const GasPvtMultiplexer<Scalar,enableThermal>& data)
{
*this = data;
}
~GasPvtMultiplexer()
@ -296,6 +307,48 @@ public:
return *static_cast<const Opm::GasPvtThermal<Scalar>* >(realGasPvt_);
}
const void* realGasPvt() const { return realGasPvt_; }
bool operator==(const GasPvtMultiplexer<Scalar,enableThermal>& data) const
{
if (this->gasPvtApproach() != data.gasPvtApproach())
return false;
switch (gasPvtApproach_) {
case DryGasPvt:
return *static_cast<const Opm::DryGasPvt<Scalar>*>(realGasPvt_) ==
*static_cast<const Opm::DryGasPvt<Scalar>*>(data.realGasPvt_);
case WetGasPvt:
return *static_cast<const Opm::WetGasPvt<Scalar>*>(realGasPvt_) ==
*static_cast<const Opm::WetGasPvt<Scalar>*>(data.realGasPvt_);
case ThermalGasPvt:
return *static_cast<const Opm::GasPvtThermal<Scalar>*>(realGasPvt_) ==
*static_cast<const Opm::GasPvtThermal<Scalar>*>(data.realGasPvt_);
default:
return true;
}
}
GasPvtMultiplexer<Scalar,enableThermal>& operator=(const GasPvtMultiplexer<Scalar,enableThermal>& data)
{
gasPvtApproach_ = data.gasPvtApproach_;
switch (gasPvtApproach_) {
case DryGasPvt:
realGasPvt_ = new Opm::DryGasPvt<Scalar>(*static_cast<const Opm::DryGasPvt<Scalar>*>(data.realGasPvt_));
break;
case WetGasPvt:
realGasPvt_ = new Opm::WetGasPvt<Scalar>(*static_cast<const Opm::WetGasPvt<Scalar>*>(data.realGasPvt_));
break;
case ThermalGasPvt:
realGasPvt_ = new Opm::GasPvtThermal<Scalar>(*static_cast<const Opm::GasPvtThermal<Scalar>*>(data.realGasPvt_));
break;
default:
break;
}
return *this;
}
private:
GasPvtApproach gasPvtApproach_;
void* realGasPvt_;

View File

@ -54,17 +54,41 @@ class GasPvtMultiplexer;
template <class Scalar>
class GasPvtThermal
{
typedef Opm::Tabulated1DFunction<Scalar> TabulatedOneDFunction;
typedef GasPvtMultiplexer<Scalar, /*enableThermal=*/false> IsothermalPvt;
public:
typedef GasPvtMultiplexer<Scalar, /*enableThermal=*/false> IsothermalPvt;
typedef Opm::Tabulated1DFunction<Scalar> TabulatedOneDFunction;
GasPvtThermal()
{
enableThermalDensity_ = false;
enableThermalViscosity_ = false;
enableInternalEnergy_ = false;
isothermalPvt_ = nullptr;
}
GasPvtThermal(IsothermalPvt* isothermalPvt,
const std::vector<TabulatedOneDFunction>& gasvisctCurves,
const std::vector<Scalar>& gasdentRefTemp,
const std::vector<Scalar>& gasdentCT1,
const std::vector<Scalar>& gasdentCT2,
const std::vector<TabulatedOneDFunction>& internalEnergyCurves,
bool enableThermalDensity,
bool enableThermalViscosity,
bool enableInternalEnergy)
: isothermalPvt_(isothermalPvt)
, gasvisctCurves_(gasvisctCurves)
, gasdentRefTemp_(gasdentRefTemp)
, gasdentCT1_(gasdentCT1)
, gasdentCT2_(gasdentCT2)
, internalEnergyCurves_(internalEnergyCurves)
, enableThermalDensity_(enableThermalDensity)
, enableThermalViscosity_(enableThermalViscosity)
, enableInternalEnergy_(enableInternalEnergy)
{ }
GasPvtThermal(const GasPvtThermal& data)
{ *this = data; }
~GasPvtThermal()
{ delete isothermalPvt_; }
@ -344,6 +368,64 @@ public:
const Evaluation& pressure) const
{ return isothermalPvt_->saturationPressure(regionIdx, temperature, pressure); }
const IsothermalPvt* isoThermalPvt() const
{ return isothermalPvt_; }
const std::vector<TabulatedOneDFunction>& gasvisctCurves() const
{ return gasvisctCurves_; }
const std::vector<Scalar>& gasdentRefTemp() const
{ return gasdentRefTemp_; }
const std::vector<Scalar>& gasdentCT1() const
{ return gasdentCT1_; }
const std::vector<Scalar>& gasdentCT2() const
{ return gasdentCT2_; }
const std::vector<TabulatedOneDFunction>& internalEnergyCurves() const
{ return internalEnergyCurves_; }
bool enableInternalEnergy() const
{ return enableInternalEnergy_; }
bool operator==(const GasPvtThermal<Scalar>& data) const
{
if (isothermalPvt_ && !data.isothermalPvt_)
return false;
if (!isothermalPvt_ && data.isothermalPvt_)
return false;
return (!this->isoThermalPvt() ||
(*this->isoThermalPvt() == *data.isoThermalPvt())) &&
this->gasvisctCurves() == data.gasvisctCurves() &&
this->gasdentRefTemp() == data.gasdentRefTemp() &&
this->gasdentCT1() == data.gasdentCT1() &&
this->gasdentCT2() == data.gasdentCT2() &&
this->internalEnergyCurves() == data.internalEnergyCurves() &&
this->enableThermalDensity() == data.enableThermalDensity() &&
this->enableThermalViscosity() == data.enableThermalViscosity() &&
this->enableInternalEnergy() == data.enableInternalEnergy();
}
GasPvtThermal<Scalar>& operator=(const GasPvtThermal<Scalar>& data)
{
if (data.isothermalPvt_)
isothermalPvt_ = new IsothermalPvt(*data.isothermalPvt_);
else
isothermalPvt_ = nullptr;
gasvisctCurves_ = data.gasvisctCurves_;
gasdentRefTemp_ = data.gasdentRefTemp_;
gasdentCT1_ = data.gasdentCT1_;
gasdentCT2_ = data.gasdentCT2_;
internalEnergyCurves_ = data.internalEnergyCurves_;
enableThermalDensity_ = data.enableThermalDensity_;
enableThermalViscosity_ = data.enableThermalViscosity_;
enableInternalEnergy_ = data.enableInternalEnergy_;
return *this;
}
private:
IsothermalPvt* isothermalPvt_;

View File

@ -50,10 +50,23 @@ namespace Opm {
template <class Scalar>
class SolventPvt
{
typedef Opm::Tabulated1DFunction<Scalar> TabulatedOneDFunction;
typedef std::vector<std::pair<Scalar, Scalar> > SamplingPoints;
public:
typedef Opm::Tabulated1DFunction<Scalar> TabulatedOneDFunction;
explicit SolventPvt() = default;
SolventPvt(const std::vector<Scalar>& solventReferenceDensity,
const std::vector<TabulatedOneDFunction>& inverseSolventB,
const std::vector<TabulatedOneDFunction>& solventMu,
const std::vector<TabulatedOneDFunction>& inverseSolventBMu)
: solventReferenceDensity_(solventReferenceDensity)
, inverseSolventB_(inverseSolventB)
, solventMu_(solventMu)
, inverseSolventBMu_(inverseSolventBMu)
{
}
#if HAVE_ECL_INPUT
/*!
* \brief Initialize the parameters for "solvent gas" using an ECL deck.
@ -193,6 +206,26 @@ public:
const Evaluation& pressure) const
{ return inverseSolventB_[regionIdx].eval(pressure, /*extrapolate=*/true); }
const std::vector<Scalar>& solventReferenceDensity() const
{ return solventReferenceDensity_; }
const std::vector<TabulatedOneDFunction>& inverseSolventB() const
{ return inverseSolventB_; }
const std::vector<TabulatedOneDFunction>& solventMu() const
{ return solventMu_; }
const std::vector<TabulatedOneDFunction>& inverseSolventBMu() const
{ return inverseSolventBMu_; }
bool operator==(const SolventPvt<Scalar>& data) const
{
return solventReferenceDensity_ == data.solventReferenceDensity_ &&
inverseSolventB_ == data.inverseSolventB_ &&
solventMu_ == data.solventMu_ &&
inverseSolventBMu_ == data.inverseSolventBMu_;
}
private:
std::vector<Scalar> solventReferenceDensity_;
std::vector<TabulatedOneDFunction> inverseSolventB_;

View File

@ -47,16 +47,41 @@ namespace Opm {
template <class Scalar>
class WetGasPvt
{
typedef Opm::UniformXTabulated2DFunction<Scalar> TabulatedTwoDFunction;
typedef Opm::Tabulated1DFunction<Scalar> TabulatedOneDFunction;
typedef std::vector<std::pair<Scalar, Scalar> > SamplingPoints;
public:
typedef Opm::UniformXTabulated2DFunction<Scalar> TabulatedTwoDFunction;
typedef Opm::Tabulated1DFunction<Scalar> TabulatedOneDFunction;
WetGasPvt()
{
vapPar1_ = 0.0;
}
WetGasPvt(const std::vector<Scalar>& gasReferenceDensity,
const std::vector<Scalar>& oilReferenceDensity,
const std::vector<TabulatedTwoDFunction>& inverseGasB,
const std::vector<TabulatedOneDFunction>& inverseSaturatedGasB,
const std::vector<TabulatedTwoDFunction>& gasMu,
const std::vector<TabulatedTwoDFunction>& inverseGasBMu,
const std::vector<TabulatedOneDFunction>& inverseSaturatedGasBMu,
const std::vector<TabulatedOneDFunction>& saturatedOilVaporizationFactorTable,
const std::vector<TabulatedOneDFunction>& saturationPressure,
Scalar vapPar1)
: gasReferenceDensity_(gasReferenceDensity)
, oilReferenceDensity_(oilReferenceDensity)
, inverseGasB_(inverseGasB)
, inverseSaturatedGasB_(inverseSaturatedGasB)
, gasMu_(gasMu)
, inverseGasBMu_(inverseGasBMu)
, inverseSaturatedGasBMu_(inverseSaturatedGasBMu)
, saturatedOilVaporizationFactorTable_(saturatedOilVaporizationFactorTable)
, saturationPressure_(saturationPressure)
, vapPar1_(vapPar1)
{
}
#if HAVE_ECL_INPUT
/*!
* \brief Initialize the parameters for wet gas using an ECL deck.
@ -603,6 +628,60 @@ public:
throw NumericalIssue(errlog.str());
}
const std::vector<Scalar>& gasReferenceDensity() const {
return gasReferenceDensity_;
}
const std::vector<Scalar>& oilReferenceDensity() const {
return oilReferenceDensity_;
}
const std::vector<TabulatedTwoDFunction>& inverseGasB() const {
return inverseGasB_;
}
const std::vector<TabulatedOneDFunction>& inverseSaturatedGasB() const {
return inverseSaturatedGasB_;
}
const std::vector<TabulatedTwoDFunction>& gasMu() const {
return gasMu_;
}
const std::vector<TabulatedTwoDFunction>& inverseGasBMu() const {
return inverseGasBMu_;
}
const std::vector<TabulatedOneDFunction>& inverseSaturatedGasBMu() const {
return inverseSaturatedGasBMu_;
}
const std::vector<TabulatedOneDFunction>& saturatedOilVaporizationFactorTable() const {
return saturatedOilVaporizationFactorTable_;
}
const std::vector<TabulatedOneDFunction>& saturationPressure() const {
return saturationPressure_;
}
Scalar vapPar1() const {
return vapPar1_;
}
bool operator==(const WetGasPvt<Scalar>& data) const
{
return this->gasReferenceDensity() == data.gasReferenceDensity() &&
this->oilReferenceDensity() == data.oilReferenceDensity() &&
this->inverseGasB() == data.inverseGasB() &&
this->inverseSaturatedGasB() == data.inverseSaturatedGasB() &&
this->gasMu() == data.gasMu() &&
this->inverseGasBMu() == data.inverseGasBMu() &&
this->inverseSaturatedGasBMu() == data.inverseSaturatedGasBMu() &&
this->saturatedOilVaporizationFactorTable() == data.saturatedOilVaporizationFactorTable() &&
this->saturationPressure() == data.saturationPressure() &&
this->vapPar1() == data.vapPar1();
}
private:
void updateSaturationPressure_(unsigned regionIdx)
{