TableContainer for SWOF,SGOF,SLGOF,SOF2 ans SOF3.
This commit is contained in:
@@ -25,7 +25,7 @@ namespace Opm {
|
||||
// forward declaration
|
||||
class TableManager;
|
||||
|
||||
class SgofTable : protected SimpleTable {
|
||||
class SgofTable : public SimpleTable {
|
||||
friend class TableManager;
|
||||
|
||||
/*!
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Opm {
|
||||
// forward declaration
|
||||
class TableManager;
|
||||
|
||||
class SlgofTable : protected SimpleTable {
|
||||
class SlgofTable : public SimpleTable {
|
||||
friend class TableManager;
|
||||
|
||||
/*!
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Opm {
|
||||
// forward declaration
|
||||
class TableManager;
|
||||
|
||||
class Sof2Table : protected SimpleTable {
|
||||
class Sof2Table : public SimpleTable {
|
||||
friend class TableManager;
|
||||
|
||||
/*!
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Opm {
|
||||
// forward declaration
|
||||
class TableManager;
|
||||
|
||||
class Sof3Table : protected SimpleTable {
|
||||
class Sof3Table : public SimpleTable {
|
||||
friend class TableManager;
|
||||
|
||||
/*!
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Opm {
|
||||
// forward declaration
|
||||
class TableManager;
|
||||
|
||||
class SwofTable : protected SimpleTable {
|
||||
class SwofTable : public SimpleTable {
|
||||
|
||||
friend class TableManager;
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
#include <opm/parser/eclipse/EclipseState/Tables/TableContainer.hpp>
|
||||
|
||||
@@ -30,6 +31,7 @@ namespace Opm {
|
||||
|
||||
|
||||
bool TableContainer::empty() const {
|
||||
std::cout << "Size: " << m_tables.size() << " empty: " << m_tables.empty() << std::endl;
|
||||
return m_tables.empty();
|
||||
}
|
||||
|
||||
@@ -47,7 +49,7 @@ namespace Opm {
|
||||
}
|
||||
|
||||
|
||||
const SimpleTable& TableContainer::operator[](size_t tableNumber) const {
|
||||
const SimpleTable& TableContainer::getTable(size_t tableNumber) const {
|
||||
if (tableNumber >= m_maxTables)
|
||||
throw std::invalid_argument("TableContainer - invalid tableNumber");
|
||||
|
||||
@@ -56,13 +58,17 @@ namespace Opm {
|
||||
return *(pair->second.get());
|
||||
} else {
|
||||
if (tableNumber > 0)
|
||||
return (*this)[tableNumber - 1];
|
||||
return getTable(tableNumber -1);
|
||||
else
|
||||
throw std::invalid_argument("TableContainer does not have any table in the range 0..." + std::to_string( tableNumber ));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const SimpleTable& TableContainer::operator[](size_t tableNumber) const {
|
||||
return getTable(tableNumber);
|
||||
}
|
||||
|
||||
void TableContainer::addTable(size_t tableNumber , std::shared_ptr<const SimpleTable> table) {
|
||||
if (tableNumber >= m_maxTables)
|
||||
throw std::invalid_argument("TableContainer has max: " + std::to_string( m_maxTables ) + " tables. Table number: " + std::to_string( tableNumber ) + " illegal.");
|
||||
|
||||
@@ -74,7 +74,6 @@ namespace Opm {
|
||||
table N is not implemented use table N - 1 behavior.
|
||||
*/
|
||||
size_t hasTable(size_t tableNumber) const;
|
||||
|
||||
const SimpleTable& getTable(size_t tableNumber) const;
|
||||
const SimpleTable& operator[](size_t tableNumber) const;
|
||||
|
||||
|
||||
@@ -102,6 +102,16 @@ namespace Opm {
|
||||
return pair->second;
|
||||
}
|
||||
|
||||
TableContainer& TableManager::forceGetTables( const std::string& tableName , size_t numTables ) {
|
||||
auto pair = m_simpleTables.find( tableName );
|
||||
if (pair == m_simpleTables.end()) {
|
||||
addTables( tableName , numTables );
|
||||
pair = m_simpleTables.find( tableName );
|
||||
}
|
||||
return pair->second;
|
||||
}
|
||||
|
||||
|
||||
const TableContainer& TableManager::operator[](const std::string& tableName) const {
|
||||
return getTables(tableName);
|
||||
}
|
||||
@@ -156,15 +166,21 @@ namespace Opm {
|
||||
initRTempTables(deck);
|
||||
initGasvisctTables(deck, "GASVISCT", m_gasvisctTables);
|
||||
*/
|
||||
initSimpleTableContainer<SwofTable>(deck, "SWOF" , m_tabdims->getNumSatTables());
|
||||
initSimpleTableContainer<SgofTable>(deck, "SGOF" , m_tabdims->getNumSatTables());
|
||||
initSimpleTableContainer<SlgofTable>(deck, "SLGOF" , m_tabdims->getNumSatTables());
|
||||
initSimpleTableContainer<Sof2Table>(deck, "SOF2" , m_tabdims->getNumSatTables());
|
||||
initSimpleTableContainer<Sof3Table>(deck, "SOF3" , m_tabdims->getNumSatTables());
|
||||
|
||||
|
||||
/*****************************************************************/
|
||||
|
||||
initSimpleTable(deck, "SWOF", m_swofTables);
|
||||
initSimpleTable(deck, "SGOF", m_sgofTables);
|
||||
initSimpleTable(deck, "SLGOF", m_slgofTables);
|
||||
initSimpleTable(deck, "SOF2", m_sof2Tables);
|
||||
initSimpleTable(deck, "SOF3", m_sof3Tables);
|
||||
//initSimpleTable(deck, "SWOF", m_swofTables);
|
||||
//initSimpleTable(deck, "SGOF", m_sgofTables);
|
||||
//initSimpleTable(deck, "SLGOF", m_slgofTables);
|
||||
//initSimpleTable(deck, "SOF2", m_sof2Tables);
|
||||
//initSimpleTable(deck, "SOF3", m_sof3Tables);
|
||||
|
||||
initSimpleTable(deck, "PVDG", m_pvdgTables);
|
||||
initSimpleTable(deck, "PVDO", m_pvdoTables);
|
||||
initSimpleTable(deck, "SWFN", m_swfnTables);
|
||||
@@ -399,26 +415,31 @@ namespace Opm {
|
||||
}
|
||||
|
||||
|
||||
const std::vector<SwofTable>& TableManager::getSwofTables() const {
|
||||
/*
|
||||
const std::vector<SwofTable>& TableManager::getSwofTables() const {
|
||||
return m_swofTables;
|
||||
}
|
||||
*/
|
||||
|
||||
const TableContainer& TableManager::getSwofTables() const {
|
||||
return getTables("SWOF");
|
||||
}
|
||||
|
||||
const TableContainer& TableManager::getSlgofTables() const {
|
||||
return getTables("SLGOF");
|
||||
}
|
||||
|
||||
|
||||
const std::vector<SlgofTable>& TableManager::getSlgofTables() const {
|
||||
return m_slgofTables;
|
||||
const TableContainer& TableManager::getSgofTables() const {
|
||||
return getTables("SGOF");
|
||||
}
|
||||
|
||||
|
||||
const std::vector<SgofTable>& TableManager::getSgofTables() const {
|
||||
return m_sgofTables;
|
||||
const TableContainer& TableManager::getSof2Tables() const {
|
||||
return getTables("SOF2");
|
||||
}
|
||||
|
||||
const std::vector<Sof2Table>& TableManager::getSof2Tables() const {
|
||||
return m_sof2Tables;
|
||||
}
|
||||
|
||||
const std::vector<Sof3Table>& TableManager::getSof3Tables() const {
|
||||
return m_sof3Tables;
|
||||
const TableContainer& TableManager::getSof3Tables() const {
|
||||
return getTables("SOF3");
|
||||
}
|
||||
|
||||
const std::vector<PvdgTable>& TableManager::getPvdgTables() const {
|
||||
|
||||
@@ -73,16 +73,18 @@ namespace Opm {
|
||||
|
||||
std::shared_ptr<const Tabdims> getTabdims() const;
|
||||
|
||||
const TableContainer& getSwofTables() const;
|
||||
const TableContainer& getSof2Tables() const;
|
||||
const TableContainer& getSof3Tables() const;
|
||||
const TableContainer& getSgofTables() const;
|
||||
const TableContainer& getSlgofTables() const;
|
||||
|
||||
|
||||
// the tables used by the deck. If the tables had some defaulted data in the
|
||||
// deck, the objects returned here exhibit the correct values. If the table is
|
||||
// not present in the deck, the corresponding vector is of size zero.
|
||||
const std::vector<PvtgTable>& getPvtgTables() const;
|
||||
const std::vector<PvtoTable>& getPvtoTables() const;
|
||||
const std::vector<Sof2Table>& getSof2Tables() const;
|
||||
const std::vector<Sof3Table>& getSof3Tables() const;
|
||||
const std::vector<SwofTable>& getSwofTables() const;
|
||||
const std::vector<SgofTable>& getSgofTables() const;
|
||||
const std::vector<SlgofTable>& getSlgofTables() const;
|
||||
const std::vector<PvdgTable>& getPvdgTables() const;
|
||||
const std::vector<PvdoTable>& getPvdoTables() const;
|
||||
const std::vector<SwfnTable>& getSwfnTables() const;
|
||||
@@ -110,6 +112,8 @@ namespace Opm {
|
||||
const std::map<int, VFPProdTable>& getVFPProdTables() const;
|
||||
const std::map<int, VFPInjTable>& getVFPInjTables() const;
|
||||
private:
|
||||
TableContainer& forceGetTables( const std::string& tableName , size_t numTables);
|
||||
|
||||
void complainAboutAmbiguousKeyword(const Deck& deck, const std::string& keywordName) const;
|
||||
|
||||
void addTables( const std::string& tableName , size_t numTables);
|
||||
@@ -142,6 +146,33 @@ namespace Opm {
|
||||
const std::string& keywordName,
|
||||
std::vector<PlyshlogTable>& tableVector);
|
||||
|
||||
template <class TableType>
|
||||
void initSimpleTableContainer(const Deck& deck,
|
||||
const std::string& keywordName,
|
||||
size_t numTables) {
|
||||
if (!deck.hasKeyword(keywordName))
|
||||
return; // the table is not featured by the deck...
|
||||
|
||||
auto& container = forceGetTables(keywordName , numTables);
|
||||
|
||||
if (deck.numKeywords(keywordName) > 1) {
|
||||
complainAboutAmbiguousKeyword(deck, keywordName);
|
||||
return;
|
||||
}
|
||||
|
||||
const auto& tableKeyword = deck.getKeyword(keywordName);
|
||||
for (size_t tableIdx = 0; tableIdx < tableKeyword->size(); ++tableIdx) {
|
||||
const auto tableRecord = tableKeyword->getRecord( tableIdx );
|
||||
const auto dataItem = tableRecord->getItem( 0 );
|
||||
if (dataItem->size() > 0) {
|
||||
std::shared_ptr<TableType> table = std::make_shared<TableType>();
|
||||
table->init(dataItem);
|
||||
container.addTable( tableIdx , table );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <class TableType>
|
||||
void initSimpleTable(const Deck& deck,
|
||||
const std::string& keywordName,
|
||||
@@ -208,11 +239,6 @@ namespace Opm {
|
||||
std::vector<SsfnTable> m_ssfnTables;
|
||||
std::vector<PvdgTable> m_pvdgTables;
|
||||
std::vector<PvdoTable> m_pvdoTables;
|
||||
std::vector<Sof2Table> m_sof2Tables;
|
||||
std::vector<Sof3Table> m_sof3Tables;
|
||||
std::vector<SgofTable> m_sgofTables;
|
||||
std::vector<SwofTable> m_swofTables;
|
||||
std::vector<SlgofTable> m_slgofTables;
|
||||
std::vector<PlyadsTable> m_plyadsTables;
|
||||
std::vector<PlymaxTable> m_plymaxTables;
|
||||
std::vector<PlyrockTable> m_plyrockTables;
|
||||
|
||||
Reference in New Issue
Block a user