Remove Equil + EquilWrapper, replace with upstream

Upstream (opm-parser) now provides a better Equil + EquilRecord, and
simultaneously deprecated EquilWrapper. This patch fixes the resulting
breakage.

One important note: The new Equil does not expose integers for live
oil/wet gas initialization procedure methods, but rather booleans
through constRs/constRv methods. This is how the variable behaves
according to the Eclipse reference manual (EQUIL keyword section).

Code has been updated to reflect this.
This commit is contained in:
Jørgen Kvalsvik 2016-02-29 15:41:08 +01:00 committed by Andreas Lauser
parent 0b797bd972
commit 8b30078339
3 changed files with 49 additions and 127 deletions

View File

@ -26,6 +26,8 @@
#include <opm/core/utility/RegionMapping.hpp>
#include <opm/core/utility/RootFinders.hpp>
#include <opm/parser/eclipse/EclipseState/InitConfig/Equil.hpp>
#include <memory>
@ -34,7 +36,7 @@
namespace Opm
{
namespace Equil {
namespace EQUIL {
template <class Props>
class DensityCalculator;
@ -49,8 +51,6 @@ namespace Opm
class RsSatAtContact;
}
struct EquilRecord;
template <class DensCalc>
class EquilReg;
@ -84,7 +84,7 @@ namespace Opm
* This namespace is intentionally nested to avoid name clashes
* with other parts of OPM.
*/
namespace Equil {
namespace EQUIL {
template <class Props>
@ -546,52 +546,6 @@ namespace Opm
} // namespace Miscibility
/**
* Equilibration record.
*
* Layout and contents inspired by first six items of
* ECLIPSE's 'EQUIL' records. This is the minimum amount of
* input data needed to define phase pressures in an
* equilibration region.
*
* Data consists of three pairs of depth and pressure values:
* 1. main
* - @c depth Main datum depth.
* - @c press Pressure at datum depth.
*
* 2. woc
* - @c depth Depth of water-oil contact
* - @c press water-oil capillary pressure at water-oil contact.
* Capillary pressure defined as "P_oil - P_water".
*
* 3. goc
* - @c depth Depth of gas-oil contact
* - @c press Gas-oil capillary pressure at gas-oil contact.
* Capillary pressure defined as "P_gas - P_oil".
*
* For the time being, items 7-9 of ECLIPSE's 'EQUIL' records are also
* stored here, but might (should?) eventually be moved elsewhere.
*
* - @c live_oil_table_index Indicates type of initialisation for live oil.
* Positive value points to corresponding Rs vs. depth table.
* - @c wet_gas_table_index Indicates type of initialisation for wet gas.
* Positive value points to corresponding Rv vs. depth table.
* - @c N Defines accuracy of initialisation computations. Currently
* only @c N=0 is supported.
*
*/
struct EquilRecord {
struct {
double depth;
double press;
} main, woc, goc;
int live_oil_table_index;
int wet_gas_table_index;
int N;
};
/**
* Aggregate information base of an equilibration region.
*
@ -654,36 +608,36 @@ namespace Opm
/**
* Datum depth in current region
*/
double datum() const { return this->rec_.main.depth; }
double datum() const { return this->rec_.datumDepth(); }
/**
* Pressure at datum depth in current region.
*/
double pressure() const { return this->rec_.main.press; }
double pressure() const { return this->rec_.datumDepthPressure(); }
/**
* Depth of water-oil contact.
*/
double zwoc() const { return this->rec_.woc .depth; }
double zwoc() const { return this->rec_.waterOilContactDepth(); }
/**
* water-oil capillary pressure at water-oil contact.
*
* \return P_o - P_w at WOC.
*/
double pcow_woc() const { return this->rec_.woc .press; }
double pcow_woc() const { return this->rec_.waterOilContactCapillaryPressure(); }
/**
* Depth of gas-oil contact.
*/
double zgoc() const { return this->rec_.goc .depth; }
double zgoc() const { return this->rec_.gasOilContactDepth(); }
/**
* Gas-oil capillary pressure at gas-oil contact.
*
* \return P_g - P_o at GOC.
*/
double pcgo_goc() const { return this->rec_.goc .press; }
double pcgo_goc() const { return this->rec_.gasOilContactCapillaryPressure(); }
/**
* Retrieve phase density calculator of current region.

View File

@ -29,9 +29,10 @@
#include <opm/core/props/BlackoilPhases.hpp>
#include <opm/core/utility/RegionMapping.hpp>
#include <opm/core/utility/Units.hpp>
#include <opm/parser/eclipse/Utility/EquilWrapper.hpp>
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/GridProperty.hpp>
#include <opm/parser/eclipse/EclipseState/InitConfig/Equil.hpp>
#include <opm/parser/eclipse/EclipseState/InitConfig/InitConfig.hpp>
#include <opm/parser/eclipse/EclipseState/Tables/TableContainer.hpp>
#include <opm/parser/eclipse/EclipseState/Tables/TableManager.hpp>
#include <opm/parser/eclipse/EclipseState/Tables/RsvdTable.hpp>
@ -83,7 +84,7 @@ namespace Opm
* This namespace is intentionally nested to avoid name clashes
* with other parts of OPM.
*/
namespace Equil {
namespace EQUIL {
/**
* Compute initial phase pressures by means of equilibration.
@ -196,48 +197,16 @@ namespace Opm
namespace DeckDependent {
inline
std::vector<EquilRecord>
getEquil(const Opm::DeckConstPtr deck)
getEquil(const Opm::EclipseState& state)
{
if (deck->hasKeyword("EQUIL")) {
Opm::EquilWrapper eql(deck->getKeyword("EQUIL"));
const auto& init = *state.getInitConfig();
const int nrec = eql.numRegions();
std::vector<EquilRecord> ret;
ret.reserve(nrec);
for (int r = 0; r < nrec; ++r) {
EquilRecord record =
{
{ eql.datumDepth(r) ,
eql.datumDepthPressure(r) }
,
{ eql.waterOilContactDepth(r) ,
eql.waterOilContactCapillaryPressure(r) }
,
{ eql.gasOilContactDepth(r) ,
eql.gasOilContactCapillaryPressure(r) }
,
eql.liveOilInitProceedure(r)
,
eql.wetGasInitProceedure(r)
,
eql.initializationTargetAccuracy(r)
};
if (record.N != 0) {
OPM_THROW(std::domain_error,
"kw EQUIL, item 9: Only N=0 supported.");
}
ret.push_back(record);
}
return ret;
}
else {
OPM_THROW(std::domain_error,
"Deck does not provide equilibration data.");
if( !init.hasEquil() ) {
OPM_THROW(std::domain_error, "Deck does not provide equilibration data.");
}
const auto& equil = init.getEquil();
return { equil.begin(), equil.end() };
}
template<class Grid>
@ -285,7 +254,7 @@ namespace Opm
rv_(UgGridHelpers::numCells(G))
{
// Get the equilibration records.
const std::vector<EquilRecord> rec = getEquil(deck);
const std::vector<EquilRecord> rec = getEquil(*eclipseState);
std::shared_ptr<const TableManager> tables = eclipseState->getTableManager();
// Create (inverse) region mapping.
const RegionMapping<> eqlmap(equilnum(deck, eclipseState, G));
@ -296,25 +265,24 @@ namespace Opm
const TableContainer& rsvdTables = tables->getRsvdTables();
for (size_t i = 0; i < rec.size(); ++i) {
const int cell = *(eqlmap.cells(i).begin());
if (rec[i].live_oil_table_index > 0) {
if (rsvdTables.size() > 0 && size_t(rec[i].live_oil_table_index) <= rsvdTables.size()) {
const RsvdTable& rsvdTable = rsvdTables.getTable<RsvdTable>(i);
std::vector<double> depthColumn = rsvdTable.getColumn("DEPTH").vectorCopy();
std::vector<double> rsColumn = rsvdTable.getColumn("RS").vectorCopy();
rs_func_.push_back(std::make_shared<Miscibility::RsVD>(props,
cell,
depthColumn , rsColumn));
} else {
OPM_THROW(std::runtime_error, "Cannot initialise: RSVD table " << (rec[i].live_oil_table_index) << " not available.");
if (!rec[i].liveOilInitConstantRs()) {
if (rsvdTables.size() <= 0 ) {
OPM_THROW(std::runtime_error, "Cannot initialise: RSVD table not available.");
}
const RsvdTable& rsvdTable = rsvdTables.getTable<RsvdTable>(i);
std::vector<double> depthColumn = rsvdTable.getColumn("DEPTH").vectorCopy();
std::vector<double> rsColumn = rsvdTable.getColumn("RS").vectorCopy();
rs_func_.push_back(std::make_shared<Miscibility::RsVD>(props,
cell,
depthColumn , rsColumn));
} else {
if (rec[i].goc.depth != rec[i].main.depth) {
if (rec[i].gasOilContactDepth() != rec[i].datumDepth()) {
OPM_THROW(std::runtime_error,
"Cannot initialise: when no explicit RSVD table is given, \n"
"datum depth must be at the gas-oil-contact. "
"In EQUIL region " << (i + 1) << " (counting from 1), this does not hold.");
}
const double p_contact = rec[i].main.press;
const double p_contact = rec[i].datumDepthPressure();
const double T_contact = 273.15 + 20; // standard temperature for now
rs_func_.push_back(std::make_shared<Miscibility::RsSatAtContact>(props, cell, p_contact, T_contact));
}
@ -330,27 +298,27 @@ namespace Opm
const TableContainer& rvvdTables = tables->getRvvdTables();
for (size_t i = 0; i < rec.size(); ++i) {
const int cell = *(eqlmap.cells(i).begin());
if (rec[i].wet_gas_table_index > 0) {
if (rvvdTables.size() > 0 && size_t(rec[i].wet_gas_table_index) <= rvvdTables.size()) {
const RvvdTable& rvvdTable = rvvdTables.getTable<RvvdTable>(i);
std::vector<double> depthColumn = rvvdTable.getColumn("DEPTH").vectorCopy();
std::vector<double> rvColumn = rvvdTable.getColumn("RV").vectorCopy();
rv_func_.push_back(std::make_shared<Miscibility::RvVD>(props,
cell,
depthColumn , rvColumn));
} else {
OPM_THROW(std::runtime_error, "Cannot initialise: RVVD table " << (rec[i].wet_gas_table_index) << " not available.");
if (!rec[i].wetGasInitConstantRv()) {
if (rvvdTables.size() <= 0) {
OPM_THROW(std::runtime_error, "Cannot initialise: RVVD table not available.");
}
const RvvdTable& rvvdTable = rvvdTables.getTable<RvvdTable>(i);
std::vector<double> depthColumn = rvvdTable.getColumn("DEPTH").vectorCopy();
std::vector<double> rvColumn = rvvdTable.getColumn("RV").vectorCopy();
rv_func_.push_back(std::make_shared<Miscibility::RvVD>(props,
cell,
depthColumn , rvColumn));
} else {
if (rec[i].goc.depth != rec[i].main.depth) {
if (rec[i].gasOilContactDepth() != rec[i].datumDepth()) {
OPM_THROW(std::runtime_error,
"Cannot initialise: when no explicit RVVD table is given, \n"
"datum depth must be at the gas-oil-contact. "
"In EQUIL region " << (i + 1) << " (counting from 1), this does not hold.");
}
const double p_contact = rec[i].main.press + rec[i].goc.press;
const double p_contact = rec[i].datumDepthPressure() + rec[i].gasOilContactCapillaryPressure();
const double T_contact = 273.15 + 20; // standard temperature for now
rv_func_.push_back(std::make_shared<Miscibility::RvSatAtContact>(props, cell, p_contact, T_contact));
}
@ -456,7 +424,7 @@ namespace Opm
};
} // namespace DeckDependent
} // namespace Equil
} // namespace EQUIL
} // namespace Opm
#include <opm/core/simulator/initStateEquil_impl.hpp>

View File

@ -583,7 +583,7 @@ namespace Opm
} // namespace Details
namespace Equil {
namespace EQUIL {
template <class Grid,
@ -885,7 +885,7 @@ namespace Opm
const double gravity,
BlackoilState& state)
{
typedef Equil::DeckDependent::InitialStateComputer ISC;
typedef EQUIL::DeckDependent::InitialStateComputer ISC;
ISC isc(props, deck, eclipseState, grid, gravity);
const auto pu = props.phaseUsage();
const int ref_phase = pu.phase_used[BlackoilPhases::Liquid]