diff --git a/opm/core/props/pvt/BlackoilPvtProperties.cpp b/opm/core/props/pvt/BlackoilPvtProperties.cpp index 0cdc456c..633cef61 100644 --- a/opm/core/props/pvt/BlackoilPvtProperties.cpp +++ b/opm/core/props/pvt/BlackoilPvtProperties.cpp @@ -79,54 +79,58 @@ namespace Opm props_[phase_usage_.phase_pos[Aqua]] = pvtw; } - // Oil PVT - if (phase_usage_.phase_used[Liquid]) { - // for oil, we support the "PVDO", "PVTO" and "PVCDO" - // keywords... - const auto &pvdoTables = eclipseState->getPvdoTables(); - const auto &pvtoTables = eclipseState->getPvtoTables(); - if (pvdoTables.size() > 0) { - if (numSamples > 0) { - auto splinePvt = std::shared_ptr(new PvtDeadSpline); - splinePvt->initFromOil(pvdoTables, numSamples); - props_[phase_usage_.phase_pos[Liquid]] = splinePvt; - } else { - auto deadPvt = std::shared_ptr(new PvtDead); - deadPvt->initFromOil(pvdoTables); - props_[phase_usage_.phase_pos[Liquid]] = deadPvt; - } - } else if (pvtoTables.size() > 0) { - props_[phase_usage_.phase_pos[Liquid]].reset(new PvtLiveOil(pvtoTables)); - } else if (deck->hasKeyword("PVCDO")) { - std::shared_ptr pvcdo(new PvtConstCompr); - pvcdo->initFromOil(deck->getKeyword("PVCDO")); - props_[phase_usage_.phase_pos[Liquid]] = pvcdo; - } else { - OPM_THROW(std::runtime_error, "Input is missing PVDO, PVCDO or PVTO\n"); + { + auto tables = eclipseState->getTableManager(); + // Oil PVT + if (phase_usage_.phase_used[Liquid]) { + // for oil, we support the "PVDO", "PVTO" and "PVCDO" + // keywords... + const auto &pvdoTables = tables->getPvdoTables(); + const auto &pvtoTables = tables->getPvtoTables(); + if (pvdoTables.size() > 0) { + if (numSamples > 0) { + auto splinePvt = std::shared_ptr(new PvtDeadSpline); + splinePvt->initFromOil(pvdoTables, numSamples); + props_[phase_usage_.phase_pos[Liquid]] = splinePvt; + } else { + auto deadPvt = std::shared_ptr(new PvtDead); + deadPvt->initFromOil(pvdoTables); + props_[phase_usage_.phase_pos[Liquid]] = deadPvt; + } + } else if (pvtoTables.size() > 0) { + props_[phase_usage_.phase_pos[Liquid]].reset(new PvtLiveOil(pvtoTables)); + } else if (deck->hasKeyword("PVCDO")) { + std::shared_ptr pvcdo(new PvtConstCompr); + pvcdo->initFromOil(deck->getKeyword("PVCDO")); + + props_[phase_usage_.phase_pos[Liquid]] = pvcdo; + } else { + OPM_THROW(std::runtime_error, "Input is missing PVDO, PVCDO or PVTO\n"); + } } - } - // Gas PVT - if (phase_usage_.phase_used[Vapour]) { - // gas can be specified using the "PVDG" or "PVTG" keywords... - const auto &pvdgTables = eclipseState->getPvdgTables(); - const auto &pvtgTables = eclipseState->getPvtgTables(); - if (pvdgTables.size() > 0) { - if (numSamples > 0) { - std::shared_ptr splinePvt(new PvtDeadSpline); - splinePvt->initFromGas(pvdgTables, numSamples); + // Gas PVT + if (phase_usage_.phase_used[Vapour]) { + // gas can be specified using the "PVDG" or "PVTG" keywords... + const auto &pvdgTables = tables->getPvdgTables(); + const auto &pvtgTables = tables->getPvtgTables(); + if (pvdgTables.size() > 0) { + if (numSamples > 0) { + std::shared_ptr splinePvt(new PvtDeadSpline); + splinePvt->initFromGas(pvdgTables, numSamples); - props_[phase_usage_.phase_pos[Vapour]] = splinePvt; + props_[phase_usage_.phase_pos[Vapour]] = splinePvt; + } else { + std::shared_ptr deadPvt(new PvtDead); + deadPvt->initFromGas(pvdgTables); + + props_[phase_usage_.phase_pos[Vapour]] = deadPvt; + } + } else if (pvtgTables.size() > 0) { + props_[phase_usage_.phase_pos[Vapour]].reset(new PvtLiveGas(pvtgTables)); } else { - std::shared_ptr deadPvt(new PvtDead); - deadPvt->initFromGas(pvdgTables); - - props_[phase_usage_.phase_pos[Vapour]] = deadPvt; + OPM_THROW(std::runtime_error, "Input is missing PVDG or PVTG\n"); } - } else if (pvtgTables.size() > 0) { - props_[phase_usage_.phase_pos[Vapour]].reset(new PvtLiveGas(pvtgTables)); - } else { - OPM_THROW(std::runtime_error, "Input is missing PVDG or PVTG\n"); } } } diff --git a/opm/core/props/pvt/ThermalGasPvtWrapper.hpp b/opm/core/props/pvt/ThermalGasPvtWrapper.hpp index deed6e8d..566ed87c 100644 --- a/opm/core/props/pvt/ThermalGasPvtWrapper.hpp +++ b/opm/core/props/pvt/ThermalGasPvtWrapper.hpp @@ -44,18 +44,18 @@ namespace Opm Opm::EclipseStateConstPtr eclipseState) { isothermalPvt_ = isothermalPvt; - + auto tables = eclipseState->getTableManager(); int numRegions; if (deck->hasKeyword("PVTG")) - numRegions = eclipseState->getPvtgTables().size(); + numRegions = tables->getPvtgTables().size(); else if (deck->hasKeyword("PVDG")) - numRegions = eclipseState->getPvdgTables().size(); + numRegions = tables->getPvdgTables().size(); else OPM_THROW(std::runtime_error, "Gas phase was not initialized using a known way"); // viscosity if (deck->hasKeyword("GASVISCT")) { - gasvisctTables_ = &eclipseState->getGasvisctTables(); + gasvisctTables_ = &tables->getGasvisctTables(); assert(int(gasvisctTables_->size()) == numRegions); gasCompIdx_ = deck->getKeyword("GCOMPIDX")->getRecord(0)->getItem("GAS_COMPONENT_INDEX")->getInt(0) - 1; diff --git a/opm/core/props/pvt/ThermalOilPvtWrapper.hpp b/opm/core/props/pvt/ThermalOilPvtWrapper.hpp index 5cd6d758..4225bbd4 100644 --- a/opm/core/props/pvt/ThermalOilPvtWrapper.hpp +++ b/opm/core/props/pvt/ThermalOilPvtWrapper.hpp @@ -46,10 +46,12 @@ namespace Opm isothermalPvt_ = isothermalPvt; int numRegions; + auto tables = eclipseState->getTableManager(); + if (deck->hasKeyword("PVTO")) - numRegions = eclipseState->getPvtoTables().size(); + numRegions = tables->getPvtoTables().size(); else if (deck->hasKeyword("PVDO")) - numRegions = eclipseState->getPvdoTables().size(); + numRegions = tables->getPvdoTables().size(); else if (deck->hasKeyword("PVCDO")) numRegions = deck->getKeyword("PVCDO")->size(); else @@ -57,7 +59,7 @@ namespace Opm // viscosity if (deck->hasKeyword("VISCREF")) { - oilvisctTables_ = &eclipseState->getOilvisctTables(); + oilvisctTables_ = &tables->getOilvisctTables(); Opm::DeckKeywordConstPtr viscrefKeyword = deck->getKeyword("VISCREF"); assert(int(oilvisctTables_->size()) == numRegions); diff --git a/opm/core/props/pvt/ThermalWaterPvtWrapper.hpp b/opm/core/props/pvt/ThermalWaterPvtWrapper.hpp index 781ccf58..fbc2661f 100644 --- a/opm/core/props/pvt/ThermalWaterPvtWrapper.hpp +++ b/opm/core/props/pvt/ThermalWaterPvtWrapper.hpp @@ -65,7 +65,8 @@ namespace Opm // quantities required for the temperature dependence of the viscosity // (basically we expect well-behaved VISCREF and WATVISCT keywords.) if (deck->hasKeyword("VISCREF")) { - watvisctTables_ = &eclipseState->getWatvisctTables(); + auto tables = eclipseState->getTableManager(); + watvisctTables_ = &tables->getWatvisctTables(); Opm::DeckKeywordConstPtr viscrefKeyword = deck->getKeyword("VISCREF"); assert(int(watvisctTables_->size()) == numRegions); diff --git a/opm/core/props/rock/RockCompressibility.cpp b/opm/core/props/rock/RockCompressibility.cpp index 6c258ae4..e8d932cc 100644 --- a/opm/core/props/rock/RockCompressibility.cpp +++ b/opm/core/props/rock/RockCompressibility.cpp @@ -43,7 +43,8 @@ namespace Opm : pref_(0.0), rock_comp_(0.0) { - const auto& rocktabTables = eclipseState->getRocktabTables(); + const auto tables = eclipseState->getTableManager(); + const auto& rocktabTables = tables->getRocktabTables(); if (rocktabTables.size() > 0) { if (rocktabTables.size() != 1) OPM_THROW(std::runtime_error, "Can only handle a single region in ROCKTAB."); diff --git a/opm/core/props/satfunc/SatFuncBase.hpp b/opm/core/props/satfunc/SatFuncBase.hpp index 775f527d..74e25a6c 100644 --- a/opm/core/props/satfunc/SatFuncBase.hpp +++ b/opm/core/props/satfunc/SatFuncBase.hpp @@ -117,8 +117,7 @@ namespace Opm TableType krow_; TableType pcow_; TableType krg_; - TableType krog_; - TableType pcog_; + TableType krog_; TableType pcog_; double krocw_; // = krow_(s_wc) private: @@ -137,11 +136,12 @@ namespace Opm const PhaseUsage phase_usg, const int samples) { + std::shared_ptr tables = eclipseState->getTableManager(); phase_usage = phase_usg; double swco = 0.0; double swmax = 1.0; if (phase_usage.phase_used[Aqua]) { - const Opm::SwofTable& swof(eclipseState->getSwofTables()[table_num]); + const Opm::SwofTable& swof(tables->getSwofTables()[table_num]); const std::vector& sw = swof.getSwColumn(); const std::vector& krw = swof.getKrwColumn(); const std::vector& krow = swof.getKrowColumn(); @@ -196,7 +196,7 @@ namespace Opm pcwmax_ = pcow.front(); } if (phase_usage.phase_used[Vapour]) { - const Opm::SgofTable& sgof = eclipseState->getSgofTables()[table_num]; + const Opm::SgofTable& sgof = tables->getSgofTables()[table_num]; const std::vector& sg = sgof.getSgColumn(); const std::vector& krg = sgof.getKrgColumn(); const std::vector& krog = sgof.getKrogColumn(); diff --git a/opm/core/props/satfunc/SaturationPropsFromDeck_impl.hpp b/opm/core/props/satfunc/SaturationPropsFromDeck_impl.hpp index 1d324ea5..02663223 100644 --- a/opm/core/props/satfunc/SaturationPropsFromDeck_impl.hpp +++ b/opm/core/props/satfunc/SaturationPropsFromDeck_impl.hpp @@ -594,6 +594,7 @@ namespace Opm std::vector > param_col; std::vector > depth_col; std::vector col_names; + std::shared_ptr tables = eclipseState->getTableManager(); // Active keyword assigned default values for each cell (in case of possible box-wise assignment) if ((keyword[0] == 'S' && (useStateKeyword || hasENPTVD)) || (keyword[1] == 'S' && useStateKeyword) ) { @@ -602,7 +603,7 @@ namespace Opm scaleparam.resize(number_of_cells); } if (!useKeyword && itab > 0) { - const auto& enptvdTables = eclipseState->getEnptvdTables(); + const auto& enptvdTables = tables->getEnptvdTables(); int num_tables = enptvdTables.size(); param_col.resize(num_tables); depth_col.resize(num_tables); @@ -667,7 +668,7 @@ namespace Opm OPM_THROW(std::runtime_error, " -- unknown keyword: '" << keyword << "'"); } if (!useKeyword && itab > 0) { - const auto& enkrvdTables = eclipseState->getEnkrvdTables(); + const auto& enkrvdTables = tables->getEnkrvdTables(); int num_tables = enkrvdTables.size(); param_col.resize(num_tables); depth_col.resize(num_tables); diff --git a/opm/core/simulator/initStateEquil.hpp b/opm/core/simulator/initStateEquil.hpp index 14deaf67..aa518f3d 100644 --- a/opm/core/simulator/initStateEquil.hpp +++ b/opm/core/simulator/initStateEquil.hpp @@ -281,14 +281,14 @@ namespace Opm { // Get the equilibration records. const std::vector rec = getEquil(deck); - + std::shared_ptr tables = eclipseState->getTableManager(); // Create (inverse) region mapping. const RegionMapping<> eqlmap(equilnum(deck, eclipseState, G)); // Create Rs functions. rs_func_.reserve(rec.size()); if (deck->hasKeyword("DISGAS")) { - const std::vector& rsvdTables = eclipseState->getRsvdTables(); + const std::vector& 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) { @@ -320,7 +320,7 @@ namespace Opm rv_func_.reserve(rec.size()); if (deck->hasKeyword("VAPOIL")) { - const std::vector& rvvdTables = eclipseState->getRvvdTables(); + const std::vector& 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) { diff --git a/tests/test_blackoilfluid.cpp b/tests/test_blackoilfluid.cpp index 13be860f..8b4a554a 100644 --- a/tests/test_blackoilfluid.cpp +++ b/tests/test_blackoilfluid.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #if HAVE_DYNAMIC_BOOST_TEST #define BOOST_TEST_DYN_LINK @@ -36,7 +37,7 @@ using namespace std; std::vector > getProps(Opm::DeckConstPtr deck, Opm::EclipseStateConstPtr eclipseState, PhaseUsage phase_usage_){ enum PhaseIndex { Aqua = 0, Liquid = 1, Vapour = 2 }; int samples = 0; - + std::shared_ptr tables = eclipseState->getTableManager(); std::vector > props_; // Set the properties. props_.resize(phase_usage_.num_phases); @@ -56,8 +57,8 @@ std::vector > getProps(Opm::DeckConstPtr deck, Opm // Oil PVT if (phase_usage_.phase_used[Liquid]) { - const auto& pvdoTables = eclipseState->getPvdoTables(); - const auto& pvtoTables = eclipseState->getPvtoTables(); + const auto& pvdoTables = tables->getPvdoTables(); + const auto& pvtoTables = tables->getPvtoTables(); if (!pvdoTables.empty()) { if (samples > 0) { std::shared_ptr splinePvt(new PvtDeadSpline); @@ -81,8 +82,8 @@ std::vector > getProps(Opm::DeckConstPtr deck, Opm } // Gas PVT if (phase_usage_.phase_used[Vapour]) { - const auto& pvdgTables = eclipseState->getPvdgTables(); - const auto& pvtgTables = eclipseState->getPvtgTables(); + const auto& pvdgTables = tables->getPvdgTables(); + const auto& pvtgTables = tables->getPvtgTables(); if (!pvdgTables.empty()) { if (samples > 0) { std::shared_ptr splinePvt(new PvtDeadSpline);