diff --git a/opm/parser/eclipse/EclipseState/Tables/TableColumn.cpp b/opm/parser/eclipse/EclipseState/Tables/TableColumn.cpp index d18f00ea9..28a2fc49c 100644 --- a/opm/parser/eclipse/EclipseState/Tables/TableColumn.cpp +++ b/opm/parser/eclipse/EclipseState/Tables/TableColumn.cpp @@ -27,7 +27,7 @@ namespace Opm { TableColumn::TableColumn(const ColumnSchema& schema) : - m_schema( &schema ) + m_schema( schema ) { m_defaultCount = 0; } @@ -40,8 +40,8 @@ namespace Opm { void TableColumn::assertOrder(double value1 , double value2) const { - if (!m_schema->validOrder( value1 , value2) ) - throw std::invalid_argument("Incorrect ordering of values in column: " + m_schema->name()); + if (!m_schema.validOrder( value1 , value2) ) + throw std::invalid_argument("Incorrect ordering of values in column: " + m_schema.name()); } @@ -84,10 +84,10 @@ namespace Opm { void TableColumn::addDefault() { - Table::DefaultAction defaultAction = m_schema->getDefaultMode( ); + Table::DefaultAction defaultAction = m_schema.getDefaultMode( ); if (defaultAction == Table::DEFAULT_CONST) - addValue( m_schema->getDefaultValue( )); + addValue( m_schema.getDefaultValue( )); else if (defaultAction == Table::DEFAULT_LINEAR) { m_values.push_back( -1 ); // Should never even be read. m_default.push_back( true ); @@ -155,7 +155,7 @@ namespace Opm { bool TableColumn::inRange( double arg ) const { if (m_values.size( ) >= 2) { - if (!m_schema->lookupValid( )) + if (!m_schema.lookupValid( )) throw std::invalid_argument("Must have an ordered column to check in range."); if ((arg >= min()) && (arg <= max())) @@ -169,7 +169,7 @@ namespace Opm { TableIndex TableColumn::lookup( double argValue ) const { - if (!m_schema->lookupValid( )) + if (!m_schema.lookupValid( )) throw std::invalid_argument("Must have an ordered column to perform table argument lookup."); if (size() < 1) @@ -191,7 +191,7 @@ namespace Opm { } { - bool isDescending = m_schema->isDecreasing( ); + bool isDescending = m_schema.isDecreasing( ); size_t lowIntervalIdx = 0; size_t intervalIdx = (size() - 1)/2; size_t highIntervalIdx = size() - 1; @@ -262,7 +262,7 @@ namespace Opm { void TableColumn::applyDefaults( const TableColumn& argColumn ) { - if (m_schema->getDefaultMode() == Table::DEFAULT_LINEAR) { + if (m_schema.getDefaultMode() == Table::DEFAULT_LINEAR) { if (size() != argColumn.size()) throw std::invalid_argument("Size mismatch with argument column"); @@ -283,7 +283,7 @@ namespace Opm { // switch to extrapolation by a constant at the fringes if (rowBeforeIdx < 0 && rowAfterIdx >= static_cast(size())) - throw std::invalid_argument("Column " + m_schema->name() + " can't be fully defaulted"); + throw std::invalid_argument("Column " + m_schema.name() + " can't be fully defaulted"); else if (rowBeforeIdx < 0) rowBeforeIdx = rowAfterIdx; else if (rowAfterIdx >= static_cast(size())) @@ -307,10 +307,10 @@ namespace Opm { void TableColumn::assertUnitRange() const { if (front() != 0.0) - throw std::invalid_argument("Column " + m_schema->name() + " must span range [0 1]"); + throw std::invalid_argument("Column " + m_schema.name() + " must span range [0 1]"); if (back() != 1.0) - throw std::invalid_argument("Column " + m_schema->name() + " must span range [0 1]"); + throw std::invalid_argument("Column " + m_schema.name() + " must span range [0 1]"); } diff --git a/opm/parser/eclipse/EclipseState/Tables/TableColumn.hpp b/opm/parser/eclipse/EclipseState/Tables/TableColumn.hpp index 5fa75ae4e..5cca49052 100644 --- a/opm/parser/eclipse/EclipseState/Tables/TableColumn.hpp +++ b/opm/parser/eclipse/EclipseState/Tables/TableColumn.hpp @@ -23,14 +23,12 @@ #include #include -#include +#include #include namespace Opm { - class ColumnSchema; - class TableColumn { public: explicit TableColumn( const ColumnSchema& schema ); @@ -67,7 +65,7 @@ namespace Opm { void assertPrevious(size_t index , double value) const; void assertNext(size_t index , double value) const; - const ColumnSchema * m_schema; + ColumnSchema m_schema; std::string m_name; std::vector m_values; std::vector m_default; diff --git a/opm/parser/eclipse/EclipseState/Tables/TableManager.hpp b/opm/parser/eclipse/EclipseState/Tables/TableManager.hpp index baa2b24cc..9a225232b 100644 --- a/opm/parser/eclipse/EclipseState/Tables/TableManager.hpp +++ b/opm/parser/eclipse/EclipseState/Tables/TableManager.hpp @@ -227,7 +227,7 @@ namespace Opm { int numTables = TableType::numTables( tableKeyword ); for (int tableIdx = 0; tableIdx < numTables; ++tableIdx) - tableVector.push_back(TableType(tableKeyword , tableIdx)); + tableVector.emplace_back( tableKeyword , tableIdx ); } std::map m_simpleTables;