Skip to content

Commit

Permalink
Table Output: Switch Naming Convention for Data Members
Browse files Browse the repository at this point in the history
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'.
  • Loading branch information
bska committed Nov 27, 2017
1 parent baf536a commit ea30ed2
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 76 deletions.
28 changes: 14 additions & 14 deletions opm/output/eclipse/LinearisedOutputTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,42 @@
#include <utility>

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<double>::iterator
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<double>&
Opm::LinearisedOutputTable::getData() const
{
return this->data_;
return this->data;
}

std::vector<double>
Opm::LinearisedOutputTable::getDataDestructively()
{
return std::move(this->data_);
return std::move(this->data);
}

// ---------------------------------------------------------------------
Expand Down
10 changes: 5 additions & 5 deletions opm/output/eclipse/LinearisedOutputTable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,16 @@ namespace Opm {

private:
/// Internal buffer for tabular data.
std::vector<double> data_;
std::vector<double> 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
Expand Down
102 changes: 51 additions & 51 deletions opm/output/eclipse/Tables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<double>& 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();
}


Expand Down Expand Up @@ -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<double> pvtoData( dims.data_size , default_value );
Expand All @@ -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++;
}
Expand All @@ -1111,9 +1111,9 @@ namespace Opm {
void Tables::addPVTG( const std::vector<PvtgTable>& 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<double> pvtgData( dims.data_size , default_value );
Expand All @@ -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++;
Expand All @@ -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++;
Expand All @@ -1164,13 +1164,13 @@ namespace Opm {
const size_t num_columns = pvtwTable[0].size;
std::vector<double> 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
Expand All @@ -1191,12 +1191,12 @@ namespace Opm {
const size_t num_columns = density[0].size;
std::vector<double> 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 );
}
Expand Down Expand Up @@ -1236,12 +1236,12 @@ namespace Opm {

const std::vector<int>& Tables::tabdims() const
{
return this->tabdims_;
return this->m_tabdims;
}

const std::vector<double>& Tables::tab() const
{
return this->data_;
return this->data;
}

void Tables::addSatFunc_FamilyOne(const EclipseState& es,
Expand All @@ -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) {
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -1297,20 +1297,20 @@ 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();
}
}

if (wat) {
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();
}
}

Expand All @@ -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) {
Expand All @@ -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();
Expand All @@ -1352,20 +1352,20 @@ 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();
}
}

if (wat) {
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();
}
}

Expand Down
17 changes: 11 additions & 6 deletions opm/output/eclipse/Tables.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,14 @@ namespace Opm {
const std::vector<double>& tab() const;

private:
const UnitSystem& units_;
std::vector<int> tabdims_;
std::vector<double> data_;
/// Convention for units of measure of the result set.
const UnitSystem& units;

/// Offset and size information for the tabular data.
std::vector<int> m_tabdims;

/// Linearised tabular data of PVT and saturation functions.
std::vector<double> data;

void addData(const std::size_t offset_index,
const std::vector<double>& new_data);
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit ea30ed2

Please sign in to comment.