From ea30ed22b79607458c83888f4441dce4bfd133a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Mon, 27 Nov 2017 10:25:48 +0100 Subject: [PATCH] Table Output: Switch Naming Convention for Data Members Mostly to remove trailing underscores. The internal 'tabdims' vector in Opm::Tables has been renamed to 'm_tabdims' to avoid conflicting with the member function named 'tabdims'. --- opm/output/eclipse/LinearisedOutputTable.cpp | 28 ++--- opm/output/eclipse/LinearisedOutputTable.hpp | 10 +- opm/output/eclipse/Tables.cpp | 102 +++++++++---------- opm/output/eclipse/Tables.hpp | 17 ++-- 4 files changed, 81 insertions(+), 76 deletions(-) diff --git a/opm/output/eclipse/LinearisedOutputTable.cpp b/opm/output/eclipse/LinearisedOutputTable.cpp index 81a1e63..5f5c4e9 100644 --- a/opm/output/eclipse/LinearisedOutputTable.cpp +++ b/opm/output/eclipse/LinearisedOutputTable.cpp @@ -6,14 +6,14 @@ #include Opm::LinearisedOutputTable:: -LinearisedOutputTable(const std::size_t numTables, - const std::size_t numPrimary, - const std::size_t numRows, - const std::size_t numCols) - : data_ (numTables * numPrimary * numRows * numCols, 1.0e20) - , numTables_ (numTables) - , numPrimary_(numPrimary) - , numRows_ (numRows) +LinearisedOutputTable(const std::size_t numTables0, + const std::size_t numPrimary0, + const std::size_t numRows0, + const std::size_t numCols0) + : data (numTables0 * numPrimary0 * numRows0 * numCols0, 1.0e20) + , numTables (numTables0) + , numPrimary(numPrimary0) + , numRows (numRows0) {} std::vector::iterator @@ -21,27 +21,27 @@ Opm::LinearisedOutputTable::column(const std::size_t tableID, const std::size_t primID, const std::size_t colID) { - // Table format: numRows_ * numPrimary_ * numTables_ values for first + // Table format: numRows * numPrimary * numTables values for first // column (ID == 0), followed by same number of entries for second // column &c. const auto offset = - 0 + this->numRows_*(primID + this->numPrimary_*(tableID + this->numTables_*colID)); + 0 + this->numRows*(primID + this->numPrimary*(tableID + this->numTables*colID)); - assert (offset + this->numRows_ <= this->data_.size()); + assert (offset + this->numRows <= this->data.size()); - return this->data_.begin() + offset; + return this->data.begin() + offset; } const std::vector& Opm::LinearisedOutputTable::getData() const { - return this->data_; + return this->data; } std::vector Opm::LinearisedOutputTable::getDataDestructively() { - return std::move(this->data_); + return std::move(this->data); } // --------------------------------------------------------------------- diff --git a/opm/output/eclipse/LinearisedOutputTable.hpp b/opm/output/eclipse/LinearisedOutputTable.hpp index 1cda47c..3373837 100644 --- a/opm/output/eclipse/LinearisedOutputTable.hpp +++ b/opm/output/eclipse/LinearisedOutputTable.hpp @@ -92,16 +92,16 @@ namespace Opm { private: /// Internal buffer for tabular data. - std::vector data_; + std::vector data; - /// Number of tables managed by \c data_. - std::size_t numTables_; + /// Number of tables managed by \c data. + std::size_t numTables; /// Number of primary look-up keys/sub-tables in \c data_. - std::size_t numPrimary_; + std::size_t numPrimary; /// Number of rows per sub-table in \c data_. - std::size_t numRows_; + std::size_t numRows; }; /// Apply piecewise linear differentiation (i.e., compute slopes) on a diff --git a/opm/output/eclipse/Tables.cpp b/opm/output/eclipse/Tables.cpp index 96da0c0..e827445 100644 --- a/opm/output/eclipse/Tables.cpp +++ b/opm/output/eclipse/Tables.cpp @@ -1008,24 +1008,24 @@ namespace { namespace SatFunc { namespace Opm { - Tables::Tables(const UnitSystem& units) - : units_ (units) - , tabdims_(TABDIMS_SIZE, 0) + Tables::Tables(const UnitSystem& units0) + : units (units0) + , m_tabdims(TABDIMS_SIZE, 0) { // Initialize subset of base pointers and dimensions to 1 to honour // requirements of TABDIMS protocol. The magic constant 59 is // derived from the file-formats documentation. - std::fill_n(std::begin(this->tabdims_), 59, 1); + std::fill_n(std::begin(this->m_tabdims), 59, 1); } void Tables::addData(const std::size_t offset_index, const std::vector& new_data) { - this->tabdims_[ offset_index ] = this->data_.size() + 1; + this->m_tabdims[ offset_index ] = this->data.size() + 1; - this->data_.insert(this->data_.end(), new_data.begin(), new_data.end()); + this->data.insert(this->data.end(), new_data.begin(), new_data.end()); - this->tabdims_[ TABDIMS_TAB_SIZE_ITEM ] = this->data_.size(); + this->m_tabdims[ TABDIMS_TAB_SIZE_ITEM ] = this->data.size(); } @@ -1060,9 +1060,9 @@ namespace Opm { { const double default_value = 2e20; PvtxDims dims = tableDims( pvtoTables ); - this->tabdims_[ TABDIMS_NTPVTO_ITEM ] = dims.num_tables; - this->tabdims_[ TABDIMS_NRPVTO_ITEM ] = dims.outer_size; - this->tabdims_[ TABDIMS_NPPVTO_ITEM ] = dims.inner_size; + 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 ); @@ -1082,9 +1082,9 @@ namespace Opm { 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 ] = 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]; + pvtoData[ data_index + 2*column_stride] = this->units.from_si( UnitSystem::measure::viscosity , mu[row]) / bo[row]; } composition_index++; } @@ -1111,9 +1111,9 @@ namespace Opm { void Tables::addPVTG( const std::vector& pvtgTables) { const double default_value = -2e20; PvtxDims dims = tableDims( pvtgTables ); - this->tabdims_[ TABDIMS_NTPVTG_ITEM ] = dims.num_tables; - this->tabdims_[ TABDIMS_NRPVTG_ITEM ] = dims.outer_size; - this->tabdims_[ TABDIMS_NPPVTG_ITEM ] = dims.inner_size; + 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 ); @@ -1133,9 +1133,9 @@ namespace Opm { 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]); + 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++; @@ -1146,7 +1146,7 @@ namespace Opm { 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]); + this->units.from_si( UnitSystem::measure::pressure , p[index]); } table_index++; @@ -1164,13 +1164,13 @@ namespace Opm { const size_t num_columns = pvtwTable[0].size; std::vector pvtwData( pvtwTable.size() * num_columns , default_value); - this->tabdims_[ TABDIMS_NTPVTW_ITEM ] = pvtwTable.size(); + 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 ] = 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); + 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 @@ -1191,12 +1191,12 @@ namespace Opm { const size_t num_columns = density[0].size; std::vector densityData( density.size() * num_columns , default_value); - this->tabdims_[ TABDIMS_NTDENS_ITEM ] = density.size(); + this->m_tabdims[ TABDIMS_NTDENS_ITEM ] = density.size(); for (size_t table_num = 0; table_num < density.size(); table_num++) { const auto& record = density[table_num]; - densityData[ table_num * num_columns ] = this->units_.from_si( UnitSystem::measure::density , record.oil); - densityData[ table_num * num_columns + 1] = this->units_.from_si( UnitSystem::measure::density , record.water); - densityData[ table_num * num_columns + 2] = this->units_.from_si( UnitSystem::measure::density , record.gas); + densityData[ table_num * num_columns ] = this->units.from_si( UnitSystem::measure::density , record.oil); + densityData[ table_num * num_columns + 1] = this->units.from_si( UnitSystem::measure::density , record.water); + densityData[ table_num * num_columns + 2] = this->units.from_si( UnitSystem::measure::density , record.gas); } this->addData( TABDIMS_IBDENS_OFFSET_ITEM , densityData ); } @@ -1236,12 +1236,12 @@ namespace Opm { const std::vector& Tables::tabdims() const { - return this->tabdims_; + return this->m_tabdims; } const std::vector& Tables::tab() const { - return this->data_; + return this->data; } void Tables::addSatFunc_FamilyOne(const EclipseState& es, @@ -1257,11 +1257,11 @@ namespace Opm { const auto& tables = tabMgr.getSgofTables(); const auto sgfn = - SatFunc::Gas::fromSGOF(nssfun, this->units_, tables); + SatFunc::Gas::fromSGOF(nssfun, this->units, tables); this->addData(TABDIMS_IBSGFN_OFFSET_ITEM, sgfn); - this->tabdims_[TABDIMS_NSSGFN_ITEM] = nssfun; - this->tabdims_[TABDIMS_NTSGFN_ITEM] = tables.size(); + this->m_tabdims[TABDIMS_NSSGFN_ITEM] = nssfun; + this->m_tabdims[TABDIMS_NTSGFN_ITEM] = tables.size(); } if (oil) { @@ -1272,8 +1272,8 @@ namespace Opm { SatFunc::Oil::TwoPhase::fromSGOF(nssfun, tables); this->addData(TABDIMS_IBSOFN_OFFSET_ITEM, sofn); - this->tabdims_[TABDIMS_NSSOFN_ITEM] = nssfun; - this->tabdims_[TABDIMS_NTSOFN_ITEM] = tables.size(); + this->m_tabdims[TABDIMS_NSSOFN_ITEM] = nssfun; + this->m_tabdims[TABDIMS_NTSOFN_ITEM] = tables.size(); } else if (wat && !gas) { // 2p O/W System const auto& tables = tabMgr.getSwofTables(); @@ -1282,8 +1282,8 @@ namespace Opm { SatFunc::Oil::TwoPhase::fromSWOF(nssfun, tables); this->addData(TABDIMS_IBSOFN_OFFSET_ITEM, sofn); - this->tabdims_[TABDIMS_NSSOFN_ITEM] = nssfun; - this->tabdims_[TABDIMS_NTSOFN_ITEM] = tables.size(); + this->m_tabdims[TABDIMS_NSSOFN_ITEM] = nssfun; + this->m_tabdims[TABDIMS_NTSOFN_ITEM] = tables.size(); } else { // 3p G/O/W System const auto& sgof = tabMgr.getSgofTables(); @@ -1297,8 +1297,8 @@ namespace Opm { fromSGOFandSWOF(numRows, sgof, swof); this->addData(TABDIMS_IBSOFN_OFFSET_ITEM, sofn); - this->tabdims_[TABDIMS_NSSOFN_ITEM] = numRows; - this->tabdims_[TABDIMS_NTSOFN_ITEM] = sgof.size(); + this->m_tabdims[TABDIMS_NSSOFN_ITEM] = numRows; + this->m_tabdims[TABDIMS_NTSOFN_ITEM] = sgof.size(); } } @@ -1306,11 +1306,11 @@ namespace Opm { const auto& tables = tabMgr.getSwofTables(); const auto swfn = - SatFunc::Water::fromSWOF(nssfun, this->units_, tables); + SatFunc::Water::fromSWOF(nssfun, this->units, tables); this->addData(TABDIMS_IBSWFN_OFFSET_ITEM, swfn); - this->tabdims_[TABDIMS_NSSWFN_ITEM] = nssfun; - this->tabdims_[TABDIMS_NTSWFN_ITEM] = tables.size(); + this->m_tabdims[TABDIMS_NSSWFN_ITEM] = nssfun; + this->m_tabdims[TABDIMS_NTSWFN_ITEM] = tables.size(); } } @@ -1327,11 +1327,11 @@ namespace Opm { const auto& tables = tabMgr.getSgfnTables(); const auto sgfn = - SatFunc::Gas::fromSGFN(nssfun, this->units_, tables); + SatFunc::Gas::fromSGFN(nssfun, this->units, tables); this->addData(TABDIMS_IBSGFN_OFFSET_ITEM, sgfn); - this->tabdims_[TABDIMS_NSSGFN_ITEM] = nssfun; - this->tabdims_[TABDIMS_NTSGFN_ITEM] = tables.size(); + this->m_tabdims[TABDIMS_NSSGFN_ITEM] = nssfun; + this->m_tabdims[TABDIMS_NTSGFN_ITEM] = tables.size(); } if (oil) { @@ -1342,8 +1342,8 @@ namespace Opm { SatFunc::Oil::TwoPhase::fromSOF2(nssfun, tables); this->addData(TABDIMS_IBSOFN_OFFSET_ITEM, sofn); - this->tabdims_[TABDIMS_NSSOFN_ITEM] = nssfun; - this->tabdims_[TABDIMS_NTSOFN_ITEM] = tables.size(); + this->m_tabdims[TABDIMS_NSSOFN_ITEM] = nssfun; + this->m_tabdims[TABDIMS_NTSOFN_ITEM] = tables.size(); } else { // 3p G/O/W System const auto& tables = tabMgr.getSof3Tables(); @@ -1352,8 +1352,8 @@ namespace Opm { SatFunc::Oil::ThreePhase::fromSOF3(nssfun, tables); this->addData(TABDIMS_IBSOFN_OFFSET_ITEM, sofn); - this->tabdims_[TABDIMS_NSSOFN_ITEM] = nssfun; - this->tabdims_[TABDIMS_NTSOFN_ITEM] = tables.size(); + this->m_tabdims[TABDIMS_NSSOFN_ITEM] = nssfun; + this->m_tabdims[TABDIMS_NTSOFN_ITEM] = tables.size(); } } @@ -1361,11 +1361,11 @@ namespace Opm { const auto& tables = tabMgr.getSwfnTables(); const auto swfn = - SatFunc::Water::fromSWFN(nssfun, this->units_, tables); + SatFunc::Water::fromSWFN(nssfun, this->units, tables); this->addData(TABDIMS_IBSWFN_OFFSET_ITEM, swfn); - this->tabdims_[TABDIMS_NSSWFN_ITEM] = nssfun; - this->tabdims_[TABDIMS_NTSWFN_ITEM] = tables.size(); + this->m_tabdims[TABDIMS_NSSWFN_ITEM] = nssfun; + this->m_tabdims[TABDIMS_NTSWFN_ITEM] = tables.size(); } } diff --git a/opm/output/eclipse/Tables.hpp b/opm/output/eclipse/Tables.hpp index af14a66..18052af 100644 --- a/opm/output/eclipse/Tables.hpp +++ b/opm/output/eclipse/Tables.hpp @@ -56,9 +56,14 @@ namespace Opm { const std::vector& tab() const; private: - const UnitSystem& units_; - std::vector tabdims_; - std::vector data_; + /// Convention for units of measure of the result set. + const UnitSystem& units; + + /// Offset and size information for the tabular data. + std::vector m_tabdims; + + /// Linearised tabular data of PVT and saturation functions. + std::vector data; void addData(const std::size_t offset_index, const std::vector& new_data); @@ -101,13 +106,13 @@ namespace Opm { /// Emit normalised tabular information (TABDIMS and TAB vectors) to /// ECL-like result set file (typically INIT file). /// - /// \param[in,out] fortio ECL-like result set file. Typically - /// corresponds to a preopened stream attached to the 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); }