diff --git a/opm/output/eclipse/Tables.hpp b/opm/output/eclipse/Tables.hpp index 12e67ae13..f6bae029f 100644 --- a/opm/output/eclipse/Tables.hpp +++ b/opm/output/eclipse/Tables.hpp @@ -24,11 +24,6 @@ #include -#include -#include - -#include -#include #include namespace Opm { @@ -39,9 +34,6 @@ namespace Opm { public: explicit Tables( const UnitSystem& units); - void addPVTO(const std::vector& pvtoTables); - void addPVTG(const std::vector& pvtgTables); - void addPVTW(const PvtwTable& pvtwTable); void addDensity(const DensityTable& density); /// Add normalised PVT function tables to INIT file's TAB vector. @@ -137,20 +129,6 @@ namespace Opm { /// TableManager sub-object. void addWaterPVTTables(const EclipseState& es); }; - - /// Emit normalised tabular information (TABDIMS and TAB vectors) to - /// ECL-like result set file (typically INIT file). - /// - /// \param[in] tables Collection of normalised tables. Its \code - /// tabdims() \endcode and \code tab() \endcode vectors will be - /// emitted to \p fortio as ECL keywords "TABDIMS" and "TAB", - /// respectively. - /// - /// \param[in,out] fortio ECL-like result set file. Typically - /// corresponds to a preopened stream attached to the INIT file. - void fwrite(const Tables& tables, - ERT::FortIO& fortio); } - -#endif +#endif // OUTPUT_TABLES_HPP diff --git a/src/opm/output/eclipse/Tables.cpp b/src/opm/output/eclipse/Tables.cpp index 487dd69dc..28eb616a5 100644 --- a/src/opm/output/eclipse/Tables.cpp +++ b/src/opm/output/eclipse/Tables.cpp @@ -21,8 +21,6 @@ #include -#include -#include #include #include @@ -1980,162 +1978,6 @@ namespace Opm { this->m_tabdims[ TABDIMS_TAB_SIZE_ITEM ] = this->data.size(); } - - namespace { - struct PvtxDims { - size_t num_tables; - size_t outer_size; - size_t inner_size; - size_t num_columns = 3; - size_t data_size; - }; - - template - PvtxDims tableDims( const std::vector& pvtxTables) { - PvtxDims dims; - - dims.num_tables = pvtxTables.size(); - dims.inner_size = 0; - dims.outer_size = 0; - for (const auto& table : pvtxTables) { - dims.outer_size = std::max( dims.outer_size, table.size()); - for (const auto& underSatTable : table) - dims.inner_size = std::max(dims.inner_size, underSatTable.numRows() ); - } - dims.data_size = dims.num_tables * dims.outer_size * dims.inner_size * dims.num_columns; - - return dims; - } - } - - void Tables::addPVTO( const std::vector& pvtoTables) - { - const double default_value = 2e20; - PvtxDims dims = tableDims( pvtoTables ); - this->m_tabdims[ TABDIMS_NTPVTO_ITEM ] = dims.num_tables; - this->m_tabdims[ TABDIMS_NRPVTO_ITEM ] = dims.outer_size; - this->m_tabdims[ TABDIMS_NPPVTO_ITEM ] = dims.inner_size; - - { - std::vector pvtoData( dims.data_size , default_value ); - std::vector rs_values( dims.num_tables * dims.outer_size , default_value ); - size_t composition_stride = dims.inner_size; - size_t table_stride = dims.outer_size * composition_stride; - size_t column_stride = table_stride * pvtoTables.size(); - - size_t table_index = 0; - for (const auto& table : pvtoTables) { - size_t composition_index = 0; - for (const auto& underSatTable : table) { - const auto& p = underSatTable.getColumn("P"); - const auto& bo = underSatTable.getColumn("BO"); - const auto& mu = underSatTable.getColumn("MU"); - - for (size_t row = 0; row < p.size(); row++) { - size_t data_index = row + composition_stride * composition_index + table_stride * table_index; - - pvtoData[ data_index ] = this->units.from_si( UnitSystem::measure::pressure, p[row]); - pvtoData[ data_index + column_stride ] = 1.0 / bo[row]; - pvtoData[ data_index + 2*column_stride] = this->units.from_si( UnitSystem::measure::viscosity , mu[row]) / bo[row]; - } - composition_index++; - } - - /* - The RS values which apply for one inner table each - are added as a separate data vector to the TABS - array. - */ - { - const auto& sat_table = table.getSaturatedTable(); - const auto& rs = sat_table.getColumn("RS"); - for (size_t index = 0; index < rs.size(); index++) - rs_values[index + table_index * dims.outer_size ] = rs[index]; - } - table_index++; - } - - this->addData( TABDIMS_IBPVTO_OFFSET_ITEM , pvtoData ); - this->addData( TABDIMS_JBPVTO_OFFSET_ITEM , rs_values ); - } - } - - void Tables::addPVTG( const std::vector& pvtgTables) { - const double default_value = -2e20; - PvtxDims dims = tableDims( pvtgTables ); - this->m_tabdims[ TABDIMS_NTPVTG_ITEM ] = dims.num_tables; - this->m_tabdims[ TABDIMS_NRPVTG_ITEM ] = dims.outer_size; - this->m_tabdims[ TABDIMS_NPPVTG_ITEM ] = dims.inner_size; - - { - std::vector pvtgData( dims.data_size , default_value ); - std::vector p_values( dims.num_tables * dims.outer_size , default_value ); - size_t composition_stride = dims.inner_size; - size_t table_stride = dims.outer_size * composition_stride; - size_t column_stride = table_stride * dims.num_tables; - - size_t table_index = 0; - for (const auto& table : pvtgTables) { - size_t composition_index = 0; - for (const auto& underSatTable : table) { - const auto& col0 = underSatTable.getColumn(0); - const auto& col1 = underSatTable.getColumn(1); - const auto& col2 = underSatTable.getColumn(2); - - for (size_t row = 0; row < col0.size(); row++) { - size_t data_index = row + composition_stride * composition_index + table_stride * table_index; - - pvtgData[ data_index ] = this->units.from_si( UnitSystem::measure::gas_oil_ratio, col0[row]); - pvtgData[ data_index + column_stride ] = this->units.from_si( UnitSystem::measure::gas_oil_ratio, col1[row]); - pvtgData[ data_index + 2*column_stride] = this->units.from_si( UnitSystem::measure::viscosity , col2[row]); - } - - composition_index++; - } - - { - const auto& sat_table = table.getSaturatedTable(); - const auto& p = sat_table.getColumn("PG"); - for (size_t index = 0; index < p.size(); index++) - p_values[index + table_index * dims.outer_size ] = - this->units.from_si( UnitSystem::measure::pressure , p[index]); - } - - table_index++; - } - - this->addData( TABDIMS_IBPVTG_OFFSET_ITEM , pvtgData ); - this->addData( TABDIMS_JBPVTG_OFFSET_ITEM , p_values ); - } - } - - void Tables::addPVTW( const PvtwTable& pvtwTable) - { - if (pvtwTable.size() > 0) { - const double default_value = -2e20; - const size_t num_columns = pvtwTable[0].size; - std::vector pvtwData( pvtwTable.size() * num_columns , default_value); - - this->m_tabdims[ TABDIMS_NTPVTW_ITEM ] = pvtwTable.size(); - for (size_t table_num = 0; table_num < pvtwTable.size(); table_num++) { - const auto& record = pvtwTable[table_num]; - pvtwData[ table_num * num_columns ] = this->units.from_si( UnitSystem::measure::pressure , record.reference_pressure); - pvtwData[ table_num * num_columns + 1] = 1.0 / record.volume_factor; - pvtwData[ table_num * num_columns + 2] = this->units.to_si( UnitSystem::measure::pressure, record.compressibility); - pvtwData[ table_num * num_columns + 3] = record.volume_factor / this->units.from_si( UnitSystem::measure::viscosity , record.viscosity); - - - // The last column should contain information about - // the viscosibility, however there is clearly a - // not-yet-identified transformation involved, we - // therefor leave this item defaulted. - - // pvtwData[ table_num * num_columns + 4] = record.viscosibility; - } - this->addData( TABDIMS_IBPVTW_OFFSET_ITEM , pvtwData ); - } - } - void Tables::addDensity( const DensityTable& density) { if (density.size() > 0) { @@ -2464,18 +2306,4 @@ namespace Opm { this->addData(TABDIMS_IBPVTW_OFFSET_ITEM, tableData); this->m_tabdims[TABDIMS_NTPVTW_ITEM] = pvtw.size(); } - - void fwrite(const Tables& tables, - ERT::FortIO& fortio) - { - { - ERT::EclKW tabdims("TABDIMS", tables.tabdims()); - tabdims.fwrite(fortio); - } - - { - ERT::EclKW tab("TAB", tables.tab()); - tab.fwrite(fortio); - } - } } diff --git a/tests/test_Tables.cpp b/tests/test_Tables.cpp index 6349f3ae0..0c91ceac1 100644 --- a/tests/test_Tables.cpp +++ b/tests/test_Tables.cpp @@ -25,48 +25,22 @@ #include -#include - #include #include -#include #include #include #include #include -#include -#include -#include -#include #include -#include -#include #include +#include #include #include - -using namespace Opm; +#include -struct setup { - Deck deck; - EclipseState es; - test_work_area_type * ta; - - setup( const std::string& path) : - deck( Parser().parseFile( path) ), - es( deck ), - ta( test_work_area_alloc( "test_tables")) - { - } - - ~setup() { - test_work_area_free(this->ta); - } - -}; namespace { template @@ -1182,104 +1156,6 @@ END } // SPE9 } -BOOST_AUTO_TEST_SUITE (FileWrite_PVT) - -BOOST_AUTO_TEST_CASE(Test_PVTX) { - setup cfg( "table_deck.DATA"); - Tables tables( cfg.es.getUnits() ); - - tables.addPVTO( cfg.es.getTableManager().getPvtoTables() ); - tables.addPVTG( cfg.es.getTableManager().getPvtgTables() ); - tables.addPVTW( cfg.es.getTableManager().getPvtwTable() ); - tables.addDensity( cfg.es.getTableManager().getDensityTable( ) ); - { - ERT::FortIO f("TEST.INIT" , std::fstream::out); - fwrite(tables, f); - } - - - { - ecl_file_type * f = ecl_file_open("TEST.INIT" , 0 ); - const ecl_kw_type * tabdims = ecl_file_iget_named_kw( f , "TABDIMS" , 0 ); - const ecl_kw_type * tab = ecl_file_iget_named_kw( f , "TAB" , 0 ); - - BOOST_CHECK_EQUAL( ecl_kw_get_size( tab ) , ecl_kw_iget_int( tabdims , TABDIMS_TAB_SIZE_ITEM )); - /* PVTO */ - { - int offset = ecl_kw_iget_int( tabdims , TABDIMS_IBPVTO_OFFSET_ITEM ) - 1; - int rs_offset = ecl_kw_iget_int( tabdims , TABDIMS_JBPVTO_OFFSET_ITEM ) - 1; - int column_stride = ecl_kw_iget_int( tabdims , TABDIMS_NRPVTO_ITEM ) * ecl_kw_iget_int( tabdims , TABDIMS_NPPVTO_ITEM ) * ecl_kw_iget_int( tabdims , TABDIMS_NTPVTO_ITEM ); - - BOOST_CHECK_EQUAL( 2, ecl_kw_iget_int( tabdims , TABDIMS_NRPVTO_ITEM ) ); - BOOST_CHECK_EQUAL( 5, ecl_kw_iget_int( tabdims , TABDIMS_NPPVTO_ITEM ) ); - BOOST_CHECK_EQUAL( 1, ecl_kw_iget_int( tabdims , TABDIMS_NTPVTO_ITEM ) ); - - BOOST_CHECK_CLOSE(50.0 , ecl_kw_iget_double( tab , offset ), 1e-6 ); - BOOST_CHECK_CLOSE(1.0 / 1.10615 , ecl_kw_iget_double( tab , offset + column_stride), 1e-6 ); - BOOST_CHECK_CLOSE(1.18 / 1.10615 , ecl_kw_iget_double( tab , offset + 2*column_stride ), 1e-6 ); - - BOOST_CHECK_CLOSE(150.0 , ecl_kw_iget_double( tab , 4 + offset ), 1e-6 ); - BOOST_CHECK_CLOSE(1.0 / 1.08984 , ecl_kw_iget_double( tab , 4 + offset + column_stride), 1e-6 ); - BOOST_CHECK_CLOSE(1.453 / 1.08984 , ecl_kw_iget_double( tab , 4 + offset + 2*column_stride ), 1e-6 ); - - BOOST_CHECK_CLOSE(20.59 , ecl_kw_iget_double( tab , rs_offset ), 1e-6 ); - BOOST_CHECK_CLOSE(28.19 , ecl_kw_iget_double( tab , rs_offset + 1), 1e-6 ); - } - - - /* PVTG */ - { - int offset = ecl_kw_iget_int( tabdims , TABDIMS_IBPVTG_OFFSET_ITEM ) - 1; - int pg_offset = ecl_kw_iget_int( tabdims , TABDIMS_JBPVTG_OFFSET_ITEM ) - 1; - int column_stride = ecl_kw_iget_int( tabdims , TABDIMS_NRPVTG_ITEM ) * ecl_kw_iget_int( tabdims , TABDIMS_NPPVTG_ITEM ) * ecl_kw_iget_int( tabdims , TABDIMS_NTPVTG_ITEM ); - - BOOST_CHECK_EQUAL( 2, ecl_kw_iget_int( tabdims , TABDIMS_NRPVTG_ITEM ) ); - BOOST_CHECK_EQUAL( 3, ecl_kw_iget_int( tabdims , TABDIMS_NPPVTG_ITEM ) ); - BOOST_CHECK_EQUAL( 1, ecl_kw_iget_int( tabdims , TABDIMS_NTPVTG_ITEM ) ); - - BOOST_CHECK_CLOSE(0.00002448 , ecl_kw_iget_double( tab , offset ), 1e-6 ); - BOOST_CHECK_CLOSE(0.061895 , ecl_kw_iget_double( tab , offset + column_stride), 1e-6 ); - BOOST_CHECK_CLOSE(0.01299 , ecl_kw_iget_double( tab , offset + 2*column_stride ), 1e-6 ); - - BOOST_CHECK_CLOSE(20.0 , ecl_kw_iget_double( tab , pg_offset ), 1e-6 ); - BOOST_CHECK_CLOSE(40.0 , ecl_kw_iget_double( tab , pg_offset + 1), 1e-6 ); - } - - - /* PVTW */ - { - int offset = ecl_kw_iget_int( tabdims , TABDIMS_IBPVTW_OFFSET_ITEM ) - 1; - int column_stride = ecl_kw_iget_int( tabdims , TABDIMS_NTPVTW_ITEM ); - BOOST_CHECK( ecl_kw_get_size( tab ) >= (offset + column_stride * 5 )); - - BOOST_CHECK_CLOSE( 247.7 , ecl_kw_iget_double( tab , offset ) , 1e-6 ); - BOOST_CHECK_CLOSE( 1.0 / 1.03665 , ecl_kw_iget_double( tab , offset + column_stride), 1e-6); - BOOST_CHECK_CLOSE( 0.41726E-04 , ecl_kw_iget_double( tab , offset + 2 * column_stride), 1e-6); - BOOST_CHECK_CLOSE( 1.03665 / 0.29120 , ecl_kw_iget_double( tab , offset + 3 * column_stride), 1e-6); - - // For the last column - WATER_VISCOSIBILITY - there is - // clearly a transform involved; not really clear which - // transform this is. This column is therefor not tested. - - // BOOST_CHECK_CLOSE( f(0.99835E-04) , ecl_kw_iget_double( tab , offset + 4 * column_stride), 1e-6); - } - - // Density - { - int offset = ecl_kw_iget_int( tabdims , TABDIMS_IBDENS_OFFSET_ITEM ) - 1; - int column_stride = ecl_kw_iget_int( tabdims , TABDIMS_NTDENS_ITEM ); - BOOST_CHECK( ecl_kw_get_size( tab ) >= (offset + column_stride * 3 )); - BOOST_CHECK_CLOSE( 859.5 , ecl_kw_iget_double( tab , offset ) , 1e-6 ); - BOOST_CHECK_CLOSE( 1033 , ecl_kw_iget_double( tab , offset + 1 ) , 1e-6 ); - BOOST_CHECK_CLOSE( 0.854 , ecl_kw_iget_double( tab , offset + 2) , 1e-6 ); - } - - ecl_file_close( f ); - } -} - -BOOST_AUTO_TEST_SUITE_END () - // ##################################################################### BOOST_AUTO_TEST_SUITE (Two_Phase)