From 65ff9bb75b9331b2a7a48183ab73eb7f4ef6da0b Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Tue, 5 Jan 2016 11:47:20 +0100 Subject: [PATCH 1/3] Removed erroneous test data. --- tests/test_norne_pvt.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/test_norne_pvt.cpp b/tests/test_norne_pvt.cpp index 9905bfd0..3bc92bdd 100644 --- a/tests/test_norne_pvt.cpp +++ b/tests/test_norne_pvt.cpp @@ -76,7 +76,8 @@ void verify_norne_oil_pvt_region2(const TableManager& tableManager) { 61, 61, 70, 70, 80, 80, - 100, 100, 100}; + 100, 100 , + 100}; std::vector P = {114, 148, @@ -86,7 +87,7 @@ void verify_norne_oil_pvt_region2(const TableManager& tableManager) { 194, 228, 214, 248, 234, 268, - 270 , 300, 330}; + 270 }; std::vector mu_expected = {0.00106736588, 0.00113961037, @@ -96,7 +97,7 @@ void verify_norne_oil_pvt_region2(const TableManager& tableManager) { 0.00072883113, 0.00076988665, 0.00068250424, 0.00072040786, 0.00062347677, 0.00064963306, - 0.00065122911, 0.00409946846, 0.00472871311}; + 0.00065122911}; std::vector b_expected = {0.88421444595, 0.88893909117, @@ -106,7 +107,7 @@ void verify_norne_oil_pvt_region2(const TableManager& tableManager) { 0.81904041272, 0.82404719615, 0.80341044483, 0.80845950744, 0.77131381726, 0.77661604334, - 0.77691738473, 0.98268067196, 0.98617572121}; + 0.77691738473}; { std::vector tableIndex(P.size() , 0); From a566ac608dbc1b8c719ba3c73296f612783ca299 Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Tue, 5 Jan 2016 11:48:10 +0100 Subject: [PATCH 2/3] Added TableColumn based overloads. --- opm/core/utility/NonuniformTableLinear.hpp | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/opm/core/utility/NonuniformTableLinear.hpp b/opm/core/utility/NonuniformTableLinear.hpp index 3354daa3..5d7c9276 100644 --- a/opm/core/utility/NonuniformTableLinear.hpp +++ b/opm/core/utility/NonuniformTableLinear.hpp @@ -27,8 +27,10 @@ #include #include +#include #include + namespace Opm { @@ -51,6 +53,12 @@ namespace Opm NonuniformTableLinear(const std::vector& x_values, const std::vector& y_values); + NonuniformTableLinear(const TableColumn& x_column, + const std::vector& y_values); + + NonuniformTableLinear(const TableColumn& x_column, + const TableColumn& y_column); + /// @brief Get the domain. /// @return the domain as a pair of doubles. std::pair domain(); @@ -120,6 +128,32 @@ namespace Opm { } + + template + inline + NonuniformTableLinear + ::NonuniformTableLinear(const TableColumn& x_column, + const TableColumn& y_column) + : x_values_( x_column.begin() , x_column.end()), + y_values_( y_column.begin() , y_column.end()) + { + assert(isNondecreasing(x_values_.begin(), x_values_.end())); + } + + + template + inline + NonuniformTableLinear + ::NonuniformTableLinear(const TableColumn& x_column, + const std::vector& y_values) + : x_values_( x_column.begin() , x_column.end()), + y_values_(y_values) + { + assert(isNondecreasing(x_values_.begin(), x_values_.end())); + } + + + template inline NonuniformTableLinear From a6deb02d047ed2286fa9a3eb09aace492975b85b Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Tue, 5 Jan 2016 12:12:29 +0100 Subject: [PATCH 3/3] Changed to use new table api from opm-parser. --- opm/core/props/pvt/PvtDead.cpp | 12 +++--- opm/core/props/pvt/PvtDeadSpline.cpp | 12 +++--- opm/core/props/pvt/PvtLiveGas.cpp | 42 +++++++++++-------- opm/core/props/pvt/PvtLiveOil.cpp | 40 +++++++++--------- opm/core/props/rock/RockCompressibility.cpp | 10 +++-- opm/core/props/satfunc/RelpermDiagnostics.cpp | 26 ++++++------ opm/core/simulator/initStateEquil.hpp | 12 ++++-- 7 files changed, 85 insertions(+), 69 deletions(-) diff --git a/opm/core/props/pvt/PvtDead.cpp b/opm/core/props/pvt/PvtDead.cpp index e2e42c2a..d7526cae 100644 --- a/opm/core/props/pvt/PvtDead.cpp +++ b/opm/core/props/pvt/PvtDead.cpp @@ -47,9 +47,9 @@ namespace Opm const Opm::PvdoTable& pvdoTable = pvdoTables.getTable(regionIdx); // Copy data - const std::vector& press = pvdoTable.getPressureColumn(); - const std::vector& b_var = pvdoTable.getFormationFactorColumn(); - const std::vector& visc = pvdoTable.getViscosityColumn(); + const auto& press = pvdoTable.getColumn("P"); + const auto& b_var = pvdoTable.getColumn("BO"); + const auto& visc = pvdoTable.getColumn("MUO"); const int sz = b_var.size(); std::vector inverseB(sz); @@ -82,9 +82,9 @@ namespace Opm const Opm::PvdgTable& pvdgTable = pvdgTables.getTable(regionIdx); // Copy data - const std::vector& press = pvdgTable.getPressureColumn(); - const std::vector& b = pvdgTable.getFormationFactorColumn(); - const std::vector& visc = pvdgTable.getViscosityColumn(); + const auto& press = pvdgTable.getColumn("P"); + const auto& b = pvdgTable.getColumn("BG"); + const auto& visc = pvdgTable.getColumn("MUG"); const int sz = b.size(); std::vector inverseB(sz); diff --git a/opm/core/props/pvt/PvtDeadSpline.cpp b/opm/core/props/pvt/PvtDeadSpline.cpp index 65cb3638..35f9d382 100644 --- a/opm/core/props/pvt/PvtDeadSpline.cpp +++ b/opm/core/props/pvt/PvtDeadSpline.cpp @@ -53,9 +53,9 @@ namespace Opm int numRows = pvdoTable.numRows(); // Copy data - const std::vector &press = pvdoTable.getPressureColumn(); - const std::vector &B_var = pvdoTable.getFormationFactorColumn(); - const std::vector &visc = pvdoTable.getViscosityColumn(); + std::vector press = pvdoTable.getColumn("P").vectorCopy(); + std::vector B_var = pvdoTable.getColumn("BO").vectorCopy(); + std::vector visc = pvdoTable.getColumn("MUO").vectorCopy(); std::vector B_inv(numRows); for (int i = 0; i < numRows; ++i) { @@ -82,9 +82,9 @@ namespace Opm int numRows = pvdgTable.numRows(); // Copy data - const std::vector &press = pvdgTable.getPressureColumn(); - const std::vector &B = pvdgTable.getFormationFactorColumn(); - const std::vector &visc = pvdgTable.getViscosityColumn(); + std::vector press = pvdgTable.getColumn("P").vectorCopy(); + std::vector B = pvdgTable.getColumn("BG").vectorCopy(); + std::vector visc = pvdgTable.getColumn("MUG").vectorCopy(); std::vector B_inv(numRows); for (int i = 0; i < numRows; ++i) { diff --git a/opm/core/props/pvt/PvtLiveGas.cpp b/opm/core/props/pvt/PvtLiveGas.cpp index 306f9acb..228d114c 100644 --- a/opm/core/props/pvt/PvtLiveGas.cpp +++ b/opm/core/props/pvt/PvtLiveGas.cpp @@ -55,31 +55,39 @@ namespace Opm for (int pvtTableIdx = 0; pvtTableIdx < numTables; ++pvtTableIdx) { const Opm::PvtgTable& pvtgTable = pvtgTables[pvtTableIdx]; - - // GAS, PVTG + const auto& saturatedPvtg = pvtgTable.getSaturatedTable( ); + // GAS, P // saturated_gas_table_[pvtTableIdx].resize(4); // Adding one extra line to PVTG to store 1./(Bg*mu_g) saturated_gas_table_[pvtTableIdx].resize(5); - saturated_gas_table_[pvtTableIdx][0] = pvtgTable.getOuterTable()->getPressureColumn(); // Pressure - saturated_gas_table_[pvtTableIdx][1] = pvtgTable.getOuterTable()->getGasFormationFactorColumn(); // Bg - saturated_gas_table_[pvtTableIdx][2] = pvtgTable.getOuterTable()->getGasViscosityColumn(); // mu_g - // The number of the columns - int nRows = saturated_gas_table_[pvtTableIdx][2].size(); - saturated_gas_table_[pvtTableIdx][3].resize(nRows); // allocate memory for 1/(Bg*mu_g) - saturated_gas_table_[pvtTableIdx][4] = pvtgTable.getOuterTable()->getOilSolubilityColumn(); // Rv + for (int k=0; k<5; ++k) { + saturated_gas_table_[pvtTableIdx][k].resize(saturatedPvtg.numRows()); + } - int sz = pvtgTable.getOuterTable()->numRows(); + for (size_t row=0; row < saturatedPvtg.numRows(); row++) { + saturated_gas_table_[pvtTableIdx][0][row] = saturatedPvtg.get("PG" , row); // Pressure + saturated_gas_table_[pvtTableIdx][1][row] = saturatedPvtg.get("BG" , row); // Bg + saturated_gas_table_[pvtTableIdx][2][row] = saturatedPvtg.get("MUG" , row); // mu_g + // 1/Bg will go in [3] + saturated_gas_table_[pvtTableIdx][4][row] = saturatedPvtg.get("RV" , row); // Rv + } + + + int sz = saturatedPvtg.numRows(); undersat_gas_tables_[pvtTableIdx].resize(sz); for (int i=0; i 1/Bg diff --git a/opm/core/props/pvt/PvtLiveOil.cpp b/opm/core/props/pvt/PvtLiveOil.cpp index a8d4f4ea..42340664 100644 --- a/opm/core/props/pvt/PvtLiveOil.cpp +++ b/opm/core/props/pvt/PvtLiveOil.cpp @@ -41,46 +41,46 @@ namespace Opm undersat_oil_tables_.resize(numTables); for (int pvtTableIdx = 0; pvtTableIdx < numTables; ++pvtTableIdx) { - Opm::PvtoTable pvtoTable = pvtoTables[pvtTableIdx]; + const Opm::PvtoTable& pvtoTable = pvtoTables[pvtTableIdx]; - const auto saturatedPvto = pvtoTable.getOuterTable(); + const auto& saturatedPvto = pvtoTable.getSaturatedTable(); // OIL, PVTO // saturated_oil_table_[pvtTableIdx].resize(4); // adding a extra colummn to the PVTO to store 1/(B*mu) saturated_oil_table_[pvtTableIdx].resize(5); - const int sz = saturatedPvto->numRows(); + const int sz = saturatedPvto.numRows(); // for (int k=0; k<4; ++k) { for (int k=0; k<5; ++k) { saturated_oil_table_[pvtTableIdx][k].resize(sz); } for (int i=0; igetPressureColumn()[i]; // p - saturated_oil_table_[pvtTableIdx][1][i] = 1.0/saturatedPvto->getOilFormationFactorColumn()[i]; // 1/Bo - saturated_oil_table_[pvtTableIdx][2][i] = saturatedPvto->getOilViscosityColumn()[i]; // mu_o - saturated_oil_table_[pvtTableIdx][3][i] = 1.0 / (saturatedPvto->getOilFormationFactorColumn()[i] - * saturatedPvto->getOilViscosityColumn()[i]); // 1/(Bo*mu_o) - saturated_oil_table_[pvtTableIdx][4][i] = saturatedPvto->getGasSolubilityColumn()[i]; // Rs + saturated_oil_table_[pvtTableIdx][0][i] = saturatedPvto.get("P" , i); // P + saturated_oil_table_[pvtTableIdx][1][i] = 1.0/saturatedPvto.get("BO" , i); // BO + saturated_oil_table_[pvtTableIdx][2][i] = saturatedPvto.get("MU" , i); // MU + saturated_oil_table_[pvtTableIdx][3][i] = 1.0 / (saturatedPvto.get("BO" , i) + * saturatedPvto.get("MU" , i));; // 1/(Bo*mu_o) + saturated_oil_table_[pvtTableIdx][4][i] = saturatedPvto.get("RS" , i); // RS } undersat_oil_tables_[pvtTableIdx].resize(sz); for (int i=0; inumRows(); + int tsize = undersaturatedPvto.numRows(); undersat_oil_tables_[pvtTableIdx][i][0].resize(tsize); undersat_oil_tables_[pvtTableIdx][i][1].resize(tsize); undersat_oil_tables_[pvtTableIdx][i][2].resize(tsize); undersat_oil_tables_[pvtTableIdx][i][3].resize(tsize); for (int j=0; jgetPressureColumn()[j]; // p - undersat_oil_tables_[pvtTableIdx][i][1][j] = 1.0/undersaturatedPvto->getOilFormationFactorColumn()[j]; // 1/Bo - undersat_oil_tables_[pvtTableIdx][i][2][j] = undersaturatedPvto->getOilViscosityColumn()[j]; // mu_o - undersat_oil_tables_[pvtTableIdx][i][3][j] = 1.0 / (undersaturatedPvto->getOilFormationFactorColumn()[j] * - undersaturatedPvto->getOilViscosityColumn()[j]); // 1/(Bo*mu_o) + undersat_oil_tables_[pvtTableIdx][i][0][j] = undersaturatedPvto.get("P" , j); // P + undersat_oil_tables_[pvtTableIdx][i][1][j] = 1.0/undersaturatedPvto.get("BO" , j); // BO + undersat_oil_tables_[pvtTableIdx][i][2][j] = undersaturatedPvto.get("MU" , j); // MU + undersat_oil_tables_[pvtTableIdx][i][3][j] = 1.0 / (undersaturatedPvto.get("BO", j)* + undersaturatedPvto.get("MU", j)); // 1/(Bo*mu_o) } } @@ -125,10 +125,12 @@ namespace Opm } } } + /// Destructor. PvtLiveOil::~PvtLiveOil() { + } @@ -137,8 +139,8 @@ namespace Opm const int* pvtTableIdx, const double* p, const double* /*T*/, - const double* z, - double* output_mu) const + const double* z, + double* output_mu) const { // #pragma omp parallel for for (int i = 0; i < n; ++i) { @@ -147,7 +149,7 @@ namespace Opm double inverseB = miscible_oil(p[i], z + num_phases_*i, tableIdx, 1, false); double inverseBMu = miscible_oil(p[i], z + num_phases_*i, tableIdx, 3, false); - output_mu[i] = inverseB / inverseBMu; + output_mu[i] = inverseB / inverseBMu; } } diff --git a/opm/core/props/rock/RockCompressibility.cpp b/opm/core/props/rock/RockCompressibility.cpp index af84c809..8ee859d6 100644 --- a/opm/core/props/rock/RockCompressibility.cpp +++ b/opm/core/props/rock/RockCompressibility.cpp @@ -50,9 +50,13 @@ namespace Opm if (rocktabTables.size() != 1) OPM_THROW(std::runtime_error, "Can only handle a single region in ROCKTAB."); - p_ = rocktabTable.getPressureColumn(); - poromult_ = rocktabTable.getPoreVolumeMultiplierColumn(); - transmult_ = rocktabTable.getTransmissibilityMultiplierColumn(); + p_ = rocktabTable.getColumn("PO").vectorCopy( ); + poromult_ = rocktabTable.getColumn("PV_MULT").vectorCopy(); + if (rocktabTable.hasColumn("PV_MULT_TRAN")) { + transmult_ = rocktabTable.getColumn("PV_MULT_TRAN").vectorCopy(); + } else { + transmult_ = rocktabTable.getColumn("PV_MULT_TRANX").vectorCopy(); + } } else if (deck->hasKeyword("ROCK")) { Opm::DeckKeywordConstPtr rockKeyword = deck->getKeyword("ROCK"); if (rockKeyword->size() != 1) { diff --git a/opm/core/props/satfunc/RelpermDiagnostics.cpp b/opm/core/props/satfunc/RelpermDiagnostics.cpp index c886fc4d..073bd7bc 100644 --- a/opm/core/props/satfunc/RelpermDiagnostics.cpp +++ b/opm/core/props/satfunc/RelpermDiagnostics.cpp @@ -541,27 +541,25 @@ namespace Opm{ if (fluidSystem_ == FluidSystem::BlackOil) { if (satFamily_ == SaturationFunctionFamily::FamilyI) { if (!sgofTables.empty()) { - auto sg = sgofTables.getTable(satnumIdx).getSgColumn(); - auto krog = sgofTables.getTable(satnumIdx).getKrogColumn(); - krog_value=Opm::linearInterpolation(sg, krog,unscaledEpsInfo_[satnumIdx].Sgl); + const auto& table = sgofTables.getTable(satnumIdx); + krog_value = table.evaluate( "KROG" , unscaledEpsInfo_[satnumIdx].Sgl ); } else { assert(!slgofTables.empty()); - auto sl = slgofTables.getTable(satnumIdx).getSlColumn(); - auto krog = slgofTables.getTable(satnumIdx).getKrogColumn(); - krog_value=Opm::linearInterpolation(sl, krog, unscaledEpsInfo_[satnumIdx].Sgl); + const auto& table = slgofTables.getTable(satnumIdx); + krog_value = table.evaluate( "KROG" , unscaledEpsInfo_[satnumIdx].Sgl ); + } + { + const auto& table = swofTables.getTable(satnumIdx); + krow_value = table.evaluate("KROW" , unscaledEpsInfo_[satnumIdx].Swl); } - auto sw = swofTables.getTable(satnumIdx).getSwColumn(); - auto krow = swofTables.getTable(satnumIdx).getKrowColumn(); - krow_value = Opm::linearInterpolation(sw, krow,unscaledEpsInfo_[satnumIdx].Swl); } if (satFamily_ == SaturationFunctionFamily::FamilyII) { assert(!sof3Tables.empty()); + const auto& table = sof3Tables.getTable(satnumIdx); const double Sou = 1.- unscaledEpsInfo_[satnumIdx].Swl - unscaledEpsInfo_[satnumIdx].Sgl; - auto so = sof3Tables.getTable(satnumIdx).getSoColumn(); - auto krow = sof3Tables.getTable(satnumIdx).getKrowColumn(); - auto krog = sof3Tables.getTable(satnumIdx).getKrogColumn(); - krow_value = Opm::linearInterpolation(so, krow, Sou); - krog_value = Opm::linearInterpolation(so, krog, Sou); + + krow_value = table.evaluate("KROW" , Sou); + krog_value = table.evaluate("KROG" , Sou); } if (krow_value != krog_value) { std::string msg = "Warning: Krow(sSomax) should equal Krog(Somax)."; diff --git a/opm/core/simulator/initStateEquil.hpp b/opm/core/simulator/initStateEquil.hpp index 6ce7f96b..e439d080 100644 --- a/opm/core/simulator/initStateEquil.hpp +++ b/opm/core/simulator/initStateEquil.hpp @@ -294,10 +294,11 @@ namespace Opm 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(i); + std::vector depthColumn = rsvdTable.getColumn("DEPTH").vectorCopy(); + std::vector rsColumn = rsvdTable.getColumn("RS").vectorCopy(); rs_func_.push_back(std::make_shared(props, cell, - rsvdTable.getDepthColumn(), - rsvdTable.getRsColumn())); + depthColumn , rsColumn)); } else { OPM_THROW(std::runtime_error, "Cannot initialise: RSVD table " << (rec[i].live_oil_table_index) << " not available."); } @@ -327,10 +328,13 @@ namespace Opm 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(i); + std::vector depthColumn = rvvdTable.getColumn("DEPTH").vectorCopy(); + std::vector rvColumn = rvvdTable.getColumn("RV").vectorCopy(); + rv_func_.push_back(std::make_shared(props, cell, - rvvdTable.getDepthColumn(), - rvvdTable.getRvColumn())); + depthColumn , rvColumn)); + } else { OPM_THROW(std::runtime_error, "Cannot initialise: RVVD table " << (rec[i].wet_gas_table_index) << " not available."); }