diff --git a/opm/parser/eclipse/CMakeLists.txt b/opm/parser/eclipse/CMakeLists.txt index 536e05c2b..9464bcc7f 100644 --- a/opm/parser/eclipse/CMakeLists.txt +++ b/opm/parser/eclipse/CMakeLists.txt @@ -108,7 +108,6 @@ EclipseState/Schedule/Tuning.cpp EclipseState/Schedule/Events.cpp # EclipseState/Tables/SimpleTable.cpp -EclipseState/Tables/MultiRecordTable.cpp EclipseState/Tables/VFPProdTable.cpp EclipseState/Tables/VFPInjTable.cpp EclipseState/Tables/TableManager.cpp @@ -117,6 +116,7 @@ EclipseState/Tables/TableColumn.cpp EclipseState/Tables/ColumnSchema.cpp EclipseState/Tables/TableSchema.cpp EclipseState/Tables/TableIndex.cpp +EclipseState/Tables/PvtxTable.cpp # EclipseState/Grid/GridProperty.cpp EclipseState/Grid/Box.cpp @@ -239,16 +239,13 @@ EclipseState/Tables/Tabdims.hpp EclipseState/Tables/Eqldims.hpp EclipseState/Tables/Regdims.hpp EclipseState/Tables/PlyadsTable.hpp -EclipseState/Tables/PvtoOuterTable.hpp +EclipseState/Tables/PvtoTable.hpp EclipseState/Tables/RocktabTable.hpp -EclipseState/Tables/PvtgInnerTable.hpp EclipseState/Tables/PvdoTable.hpp -EclipseState/Tables/MultiRecordTable.hpp EclipseState/Tables/PvdgTable.hpp EclipseState/Tables/PvdsTable.hpp EclipseState/Tables/SimpleTable.hpp EclipseState/Tables/PlymaxTable.hpp -EclipseState/Tables/PvtgTable.hpp EclipseState/Tables/PlyrockTable.hpp EclipseState/Tables/SwofTable.hpp EclipseState/Tables/SgwfnTable.hpp @@ -258,7 +255,6 @@ EclipseState/Tables/SsfnTable.hpp EclipseState/Tables/Sof2Table.hpp EclipseState/Tables/Sof3Table.hpp EclipseState/Tables/EnptvdTable.hpp -EclipseState/Tables/FullTable.hpp EclipseState/Tables/PlyviscTable.hpp EclipseState/Tables/PlydhflfTable.hpp EclipseState/Tables/PlyshlogTable.hpp @@ -266,16 +262,15 @@ EclipseState/Tables/EnkrvdTable.hpp EclipseState/Tables/ImkrvdTable.hpp EclipseState/Tables/SgofTable.hpp EclipseState/Tables/SlgofTable.hpp -EclipseState/Tables/PvtoTable.hpp +EclipseState/Tables/PvtxTable.hpp EclipseState/Tables/ImptvdTable.hpp EclipseState/Tables/RsvdTable.hpp -EclipseState/Tables/PvtoInnerTable.hpp EclipseState/Tables/RvvdTable.hpp EclipseState/Tables/RtempvdTable.hpp EclipseState/Tables/OilvisctTable.hpp EclipseState/Tables/GasvisctTable.hpp EclipseState/Tables/WatvisctTable.hpp -EclipseState/Tables/PvtgOuterTable.hpp +EclipseState/Tables/PvtgTable.hpp EclipseState/Tables/VFPProdTable.hpp EclipseState/Tables/VFPInjTable.hpp EclipseState/Tables/TableManager.hpp diff --git a/opm/parser/eclipse/EclipseState/Tables/FullTable.hpp b/opm/parser/eclipse/EclipseState/Tables/FullTable.hpp deleted file mode 100644 index 2b3e41ca2..000000000 --- a/opm/parser/eclipse/EclipseState/Tables/FullTable.hpp +++ /dev/null @@ -1,100 +0,0 @@ -/* - Copyright (C) 2013 by Andreas Lauser - - This file is part of the Open Porous Media project (OPM). - - OPM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OPM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with OPM. If not, see . - */ -#ifndef OPM_PARSER_FULL_TABLE_HPP -#define OPM_PARSER_FULL_TABLE_HPP - -#include -#include -#include - -#include -#include -#include -#include -#include - -namespace Opm { - template - class FullTable - { - typedef FullTable Self; - typedef std::shared_ptr OuterTableConstPtr; - typedef std::shared_ptr InnerTablePtr; - typedef std::shared_ptr InnerTableConstPtr; - - protected: - FullTable(const FullTable&) = default; - - /*! - * \brief Read full tables from keywords like PVTO - * - * The data for these keywords can be considered a 2D table: - * The outer one is a multi-record table for a given state, - * the inner one is a normal table which extends this - * state. For the PVTO keyword, the outer table represents the - * gas dissolution factor, pressure, volume factor and - * viscosity at the oil's saturation point, the inner table is - * the pressure, volume factor and viscosity of untersaturated - * oil with the same gas dissolution factor. - */ - void init(Opm::DeckKeywordConstPtr keyword, size_t tableIdx) - { - OuterTable* outerTable = new OuterTable; - outerTable->init(keyword, tableIdx); - m_outerTable.reset(outerTable); - - for (size_t rowIdx = 0; rowIdx < m_outerTable->numRecords(); ++rowIdx) { - InnerTable *curRow = new InnerTable; - auto record = keyword->getRecord( m_outerTable->firstRecordIndex() + rowIdx ); - auto item = record->getItem( 1 ); - curRow->init(item); - m_innerTables.push_back(std::shared_ptr(curRow)); - } - } - - public: - FullTable() = default; - - typedef std::shared_ptr Pointer; - typedef std::shared_ptr ConstPointer; - - static size_t numTables(Opm::DeckKeywordConstPtr keyword) - { return OuterTable::numTables(keyword); } - - std::shared_ptr getOuterTable() const - { return m_outerTable; } - - std::shared_ptr getInnerTable(size_t rowIdx) const - { - assert(rowIdx < m_innerTables.size()); - return m_innerTables[rowIdx]; - } - - protected: - std::shared_ptr m_outerTable; - std::vector > m_innerTables; - - }; - - typedef FullTable::Pointer FullTablePtr; - typedef FullTable::ConstPointer FullTableConstPtr; -} - -#endif - diff --git a/opm/parser/eclipse/EclipseState/Tables/MultiRecordTable.cpp b/opm/parser/eclipse/EclipseState/Tables/MultiRecordTable.cpp deleted file mode 100644 index 89039b7ff..000000000 --- a/opm/parser/eclipse/EclipseState/Tables/MultiRecordTable.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* - Copyright (C) 2013 by Andreas Lauser - - This file is part of the Open Porous Media project (OPM). - - OPM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OPM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with OPM. If not, see . - */ -#include -#include - -namespace Opm { -/*! - * \brief Returns the number of tables which can be found in a - * given keyword. - */ - -size_t MultiRecordTable::numTables(Opm::DeckKeywordConstPtr keyword) -{ - auto ranges = recordRanges(keyword); - return ranges.size(); -} - - -std::vector > MultiRecordTable::recordRanges(Opm::DeckKeywordConstPtr keyword) { - std::vector > ranges; - size_t startRecord = 0; - size_t recordIndex = 0; - while (recordIndex < keyword->size()) { - auto item = keyword->getRecord(recordIndex)->getItem(0); - if (item->size( ) == 0) { - ranges.push_back( std::make_pair( startRecord , recordIndex ) ); - startRecord = recordIndex + 1; - } - recordIndex++; - } - ranges.push_back( std::make_pair( startRecord , recordIndex ) ); - return ranges; -} - - -// create table from first few items of multiple records -void MultiRecordTable::init(Opm::DeckKeywordConstPtr keyword, - const std::vector &columnNames, - size_t tableIdx) -{ - auto ranges = recordRanges(keyword); - if (tableIdx >= ranges.size()) - throw std::invalid_argument("Asked for table: " + std::to_string( tableIdx ) + " in keyword + " + keyword->name() + " which only has " + std::to_string( ranges.size() ) + " tables"); - - createColumns(columnNames); - m_recordRange = ranges[ tableIdx ]; - for (size_t rowIdx = m_recordRange.first; rowIdx < m_recordRange.second; rowIdx++) { - Opm::DeckRecordConstPtr deckRecord = keyword->getRecord(rowIdx); - Opm::DeckItemConstPtr indexItem = deckRecord->getItem(0); - Opm::DeckItemConstPtr dataItem = deckRecord->getItem(1); - - m_columns[0].push_back(indexItem->getSIDouble(0)); - m_valueDefaulted[0].push_back(indexItem->defaultApplied(0)); - for (size_t colIdx = 1; colIdx < numColumns(); ++colIdx) { - m_columns[colIdx].push_back(dataItem->getSIDouble(colIdx - 1)); - m_valueDefaulted[colIdx].push_back(dataItem->defaultApplied(colIdx - 1)); - } - } -} - -size_t MultiRecordTable::firstRecordIndex() const -{ - return m_recordRange.first; -} - -size_t MultiRecordTable::numRecords() const -{ - return m_recordRange.second - m_recordRange.first; -} - - -} diff --git a/opm/parser/eclipse/EclipseState/Tables/MultiRecordTable.hpp b/opm/parser/eclipse/EclipseState/Tables/MultiRecordTable.hpp deleted file mode 100644 index 3e50af39c..000000000 --- a/opm/parser/eclipse/EclipseState/Tables/MultiRecordTable.hpp +++ /dev/null @@ -1,88 +0,0 @@ -/* - Copyright (C) 2013 by Andreas Lauser - - This file is part of the Open Porous Media project (OPM). - - OPM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OPM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with OPM. If not, see . - */ -#ifndef OPM_PARSER_MULTI_RECORD_TABLE_HPP -#define OPM_PARSER_MULTI_RECORD_TABLE_HPP - -#include - -#include - -#include -#include -#include -#include -#include - -namespace Opm { - // forward declaration - class EclipseState; - - // create table from first few items of multiple records (i.e. getSIDoubleData() throws an exception) - class MultiRecordTable : public SimpleTable { - protected: - /*! - * \brief Read simple tables from multi-item keywords like PVTW - * - * This creates a table out of the first N items of each of - * the keyword's records. (N is the number of columns.) - */ - void init(Opm::DeckKeywordConstPtr keyword, - const std::vector &columnNames, - size_t tableIndex); - - public: - MultiRecordTable() = default; - -#ifdef BOOST_TEST_MODULE - // DO NOT TRY TO CALL THIS METHOD! it is only for the unit tests! - void initFORUNITTESTONLY(Opm::DeckKeywordConstPtr keyword, - const std::vector &columnNames, - size_t tableIndex) - { init(keyword, columnNames, tableIndex); } -#endif - - /*! - * \brief Returns the number of tables which can be found in a - * given keyword. - */ - static size_t numTables(Opm::DeckKeywordConstPtr keyword); - static std::vector > recordRanges(Opm::DeckKeywordConstPtr keyword); - /*! - * \brief Return the index of the first record which applies - * for this table object. - */ - size_t firstRecordIndex() const; - - /*! - * \brief Return the number of records which are used by this - * this table object. - */ - size_t numRecords() const; - - private: - std::pair m_recordRange; - }; - - typedef std::shared_ptr MultiRecordTablePtr; - typedef std::shared_ptr MultiRecordTableConstPtr; - -} - -#endif - diff --git a/opm/parser/eclipse/EclipseState/Tables/PvtgInnerTable.hpp b/opm/parser/eclipse/EclipseState/Tables/PvtgInnerTable.hpp deleted file mode 100644 index 5efe5096e..000000000 --- a/opm/parser/eclipse/EclipseState/Tables/PvtgInnerTable.hpp +++ /dev/null @@ -1,73 +0,0 @@ -/* - Copyright (C) 2014 by Andreas Lauser - - This file is part of the Open Porous Media project (OPM). - - OPM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OPM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with OPM. If not, see . - */ -#ifndef OPM_PARSER_PVTG_INNER_TABLE_HPP -#define OPM_PARSER_PVTG_INNER_TABLE_HPP - -#include "SimpleTable.hpp" - -namespace Opm { - // forward declarations - template - class FullTable; - class PvtgTable; - class PvtgOuterTable; - class PvtgInnerTable; - - class PvtgInnerTable : protected MultiRecordTable { - - - friend class PvtgTable; - friend class FullTable; - PvtgInnerTable() = default; - - /*! - * \brief Read the per record table of the PVTG keyword and - * provide some convenience methods for it. - * - * The first value of the record (-> Rv) is skipped. - */ - void init(Opm::DeckItemConstPtr item) - { - SimpleTable::init(item, - std::vector{"RV", "BG", "MUG"}); - - SimpleTable::checkNonDefaultable("RV"); - SimpleTable::checkMonotonic("RV", /*isAscending=*/false); - SimpleTable::applyDefaultsLinear("BG"); - SimpleTable::applyDefaultsLinear("MUG"); - } - - public: - using SimpleTable::numTables; - using SimpleTable::numRows; - using SimpleTable::numColumns; - using SimpleTable::evaluate; - - const std::vector &getOilSolubilityColumn() const - { return SimpleTable::getColumn(0); } - - const std::vector &getGasFormationFactorColumn() const - { return SimpleTable::getColumn(1); } - - const std::vector &getGasViscosityColumn() const - { return SimpleTable::getColumn(2); } - }; -} - -#endif diff --git a/opm/parser/eclipse/EclipseState/Tables/PvtgOuterTable.hpp b/opm/parser/eclipse/EclipseState/Tables/PvtgOuterTable.hpp deleted file mode 100644 index c9e9e0962..000000000 --- a/opm/parser/eclipse/EclipseState/Tables/PvtgOuterTable.hpp +++ /dev/null @@ -1,76 +0,0 @@ -/* - Copyright (C) 2014 by Andreas Lauser - - This file is part of the Open Porous Media project (OPM). - - OPM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OPM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with OPM. If not, see . - */ -#ifndef OPM_PARSER_PVTG_OUTER_TABLE_HPP -#define OPM_PARSER_PVTG_OUTER_TABLE_HPP - -#include "MultiRecordTable.hpp" - -namespace Opm { - // forward declarations - template - class FullTable; - class PvtgTable; - class PvtgOuterTable; - class PvtgInnerTable; - - class PvtgOuterTable : protected MultiRecordTable { - friend class PvtgTable; - friend class FullTable; - PvtgOuterTable() = default; - - /*! - * \brief Read the per record table of the PVTG keyword and - * provide some convenience methods for it. - */ - void init(Opm::DeckKeywordConstPtr keyword, size_t tableIdx) - { - MultiRecordTable::init(keyword, - std::vector{"P", "RV", "BG", "MUG"}, - tableIdx); - - MultiRecordTable::checkNonDefaultable("P"); - MultiRecordTable::checkMonotonic("P", /*isAscending=*/true); - MultiRecordTable::applyDefaultsLinear("RV"); - MultiRecordTable::applyDefaultsLinear("BG"); - MultiRecordTable::applyDefaultsLinear("MUG"); - } - - public: - using MultiRecordTable::numTables; - using MultiRecordTable::numRows; - using MultiRecordTable::numColumns; - using MultiRecordTable::evaluate; - using MultiRecordTable::firstRecordIndex; - using MultiRecordTable::numRecords; - - const std::vector &getPressureColumn() const - { return MultiRecordTable::getColumn(0); } - - const std::vector &getOilSolubilityColumn() const - { return MultiRecordTable::getColumn(1); } - - const std::vector &getGasFormationFactorColumn() const - { return MultiRecordTable::getColumn(2); } - - const std::vector &getGasViscosityColumn() const - { return MultiRecordTable::getColumn(3); } - }; -} - -#endif diff --git a/opm/parser/eclipse/EclipseState/Tables/PvtgTable.hpp b/opm/parser/eclipse/EclipseState/Tables/PvtgTable.hpp index 2c77a0176..91b2d9371 100644 --- a/opm/parser/eclipse/EclipseState/Tables/PvtgTable.hpp +++ b/opm/parser/eclipse/EclipseState/Tables/PvtgTable.hpp @@ -19,37 +19,31 @@ #ifndef OPM_PARSER_PVTG_TABLE_HPP #define OPM_PARSER_PVTG_TABLE_HPP -#include "FullTable.hpp" -#include "PvtgInnerTable.hpp" -#include "PvtgOuterTable.hpp" +#include namespace Opm { - // forward declaration - class TableManager; - - /*! - * \brief Read the table for the PVTG and provide convenient access to it. - */ - class PvtgTable : public Opm::FullTable - { - typedef Opm::FullTable ParentType; - - friend class TableManager; - - using ParentType::init; + class PvtgTable : public PvtxTable { public: - PvtgTable() = default; -#ifdef BOOST_TEST_MODULE - // DO NOT TRY TO CALL THIS METHOD! it is only for the unit tests! - void initFORUNITTESTONLY(Opm::DeckKeywordConstPtr keyword, size_t tableIdx) - { init(keyword, tableIdx); } -#endif + PvtgTable(Opm::DeckKeywordConstPtr keyword , size_t tableIdx) : PvtxTable("P") + { + m_underSaturatedSchema = std::make_shared( ); + m_underSaturatedSchema->addColumn( ColumnSchema( "RV" , Table::STRICTLY_DECREASING , Table::DEFAULT_NONE )); + m_underSaturatedSchema->addColumn( ColumnSchema( "BG" , Table::RANDOM , Table::DEFAULT_LINEAR )); + m_underSaturatedSchema->addColumn( ColumnSchema( "MUG" , Table::RANDOM , Table::DEFAULT_LINEAR )); + + + m_saturatedSchema = std::make_shared( ); + m_saturatedSchema->addColumn( ColumnSchema( "PG" , Table::STRICTLY_INCREASING , Table::DEFAULT_NONE )); + m_saturatedSchema->addColumn( ColumnSchema( "RV" , Table::RANDOM , Table::DEFAULT_NONE )); + m_saturatedSchema->addColumn( ColumnSchema( "BG" , Table::RANDOM , Table::DEFAULT_LINEAR )); + m_saturatedSchema->addColumn( ColumnSchema( "MUG" , Table::RANDOM , Table::DEFAULT_LINEAR )); + + PvtxTable::init(keyword , tableIdx); + } + }; - - typedef std::shared_ptr PvtgTablePtr; - typedef std::shared_ptr PvtgConstTablePtr; } #endif diff --git a/opm/parser/eclipse/EclipseState/Tables/PvtoInnerTable.hpp b/opm/parser/eclipse/EclipseState/Tables/PvtoInnerTable.hpp deleted file mode 100644 index 2ac5a05fa..000000000 --- a/opm/parser/eclipse/EclipseState/Tables/PvtoInnerTable.hpp +++ /dev/null @@ -1,72 +0,0 @@ -/* - Copyright (C) 2014 by Andreas Lauser - - This file is part of the Open Porous Media project (OPM). - - OPM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OPM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with OPM. If not, see . - */ -#ifndef OPM_PARSER_PVTO_INNER_TABLE_HPP -#define OPM_PARSER_PVTO_INNER_TABLE_HPP - -#include "SimpleTable.hpp" - -namespace Opm { - // forward declarations - template - class FullTable; - class PvtoTable; - class PvtoOuterTable; - class PvtoInnerTable; - - class PvtoInnerTable : protected MultiRecordTable { - - friend class PvtoTable; - friend class FullTable; - PvtoInnerTable() = default; - - /*! - * \brief Read the per record table of the PVTO keyword and - * provide some convenience methods for it. - * - * The first value of the record (-> Rs) is skipped. - */ - void init(Opm::DeckItemConstPtr item) - { - SimpleTable::init(item, - std::vector{"P", "BO", "MU"}); - - SimpleTable::checkNonDefaultable("P"); - SimpleTable::checkMonotonic("P", /*isAscending=*/true); - SimpleTable::applyDefaultsLinear("BO"); - SimpleTable::applyDefaultsLinear("MU"); - } - - public: - using SimpleTable::numTables; - using SimpleTable::numRows; - using SimpleTable::numColumns; - using SimpleTable::evaluate; - - const std::vector &getPressureColumn() const - { return SimpleTable::getColumn(0); } - - const std::vector &getOilFormationFactorColumn() const - { return SimpleTable::getColumn(1); } - - const std::vector &getOilViscosityColumn() const - { return SimpleTable::getColumn(2); } - }; -} - -#endif diff --git a/opm/parser/eclipse/EclipseState/Tables/PvtoOuterTable.hpp b/opm/parser/eclipse/EclipseState/Tables/PvtoOuterTable.hpp deleted file mode 100644 index 8ea7772d1..000000000 --- a/opm/parser/eclipse/EclipseState/Tables/PvtoOuterTable.hpp +++ /dev/null @@ -1,77 +0,0 @@ -/* - Copyright (C) 2014 by Andreas Lauser - - This file is part of the Open Porous Media project (OPM). - - OPM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OPM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with OPM. If not, see . - */ -#ifndef OPM_PARSER_PVTO_OUTER_TABLE_HPP -#define OPM_PARSER_PVTO_OUTER_TABLE_HPP - -#include "MultiRecordTable.hpp" - -namespace Opm { - // forward declaration - template - class FullTable; - class PvtoTable; - class PvtoOuterTable; - class PvtoInnerTable; - - class PvtoOuterTable : protected MultiRecordTable { - friend class PvtoTable; - friend class FullTable; - PvtoOuterTable() = default; - - /*! - * \brief Read the per record table of the PVTO keyword and - * provide some convenience methods for it. - */ - void init(Opm::DeckKeywordConstPtr keyword, int tableIdx) - { - MultiRecordTable::init(keyword, - std::vector{"RS", "P", "BO", "MU"}, - tableIdx); - - - MultiRecordTable::checkNonDefaultable("RS"); - MultiRecordTable::checkMonotonic("RS", /*isAscending=*/true); - MultiRecordTable::applyDefaultsLinear("P"); - MultiRecordTable::applyDefaultsLinear("BO"); - MultiRecordTable::applyDefaultsLinear("MU"); - } - - public: - using MultiRecordTable::numTables; - using MultiRecordTable::numRows; - using MultiRecordTable::numColumns; - using MultiRecordTable::evaluate; - using MultiRecordTable::firstRecordIndex; - using MultiRecordTable::numRecords; - - const std::vector &getGasSolubilityColumn() const - { return MultiRecordTable::getColumn(0); } - - const std::vector &getPressureColumn() const - { return MultiRecordTable::getColumn(1); } - - const std::vector &getOilFormationFactorColumn() const - { return MultiRecordTable::getColumn(2); } - - const std::vector &getOilViscosityColumn() const - { return MultiRecordTable::getColumn(3); } - }; -} - -#endif diff --git a/opm/parser/eclipse/EclipseState/Tables/PvtoTable.hpp b/opm/parser/eclipse/EclipseState/Tables/PvtoTable.hpp index 7bee11d54..f04d58ee2 100644 --- a/opm/parser/eclipse/EclipseState/Tables/PvtoTable.hpp +++ b/opm/parser/eclipse/EclipseState/Tables/PvtoTable.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 by Andreas Lauser + Copyright (C) 2014 by Andreas Lauser This file is part of the Open Porous Media project (OPM). @@ -19,36 +19,32 @@ #ifndef OPM_PARSER_PVTO_TABLE_HPP #define OPM_PARSER_PVTO_TABLE_HPP -#include "FullTable.hpp" -#include "PvtoInnerTable.hpp" -#include "PvtoOuterTable.hpp" +#include namespace Opm { - // forward declaration - class TableManager; - - /*! - * \brief Read the table for the PVTO and provide convenient access to it. - */ - class PvtoTable : public Opm::FullTable - { - typedef Opm::FullTable ParentType; - friend class TableManager; - using ParentType::init; - + class PvtoTable : public PvtxTable { public: - PvtoTable() = default; -#ifdef BOOST_TEST_MODULE - // DO NOT TRY TO CALL THIS METHOD! it is only for the unit tests! - void initFORUNITTESTONLY(Opm::DeckKeywordConstPtr keyword, size_t tableIdx) - { init(keyword, tableIdx); } -#endif + PvtoTable(Opm::DeckKeywordConstPtr keyword , size_t tableIdx) : PvtxTable("RS") + { + m_underSaturatedSchema = std::make_shared( ); + + m_underSaturatedSchema->addColumn( ColumnSchema( "P" , Table::STRICTLY_INCREASING , Table::DEFAULT_NONE )); + m_underSaturatedSchema->addColumn( ColumnSchema( "BO" , Table::RANDOM , Table::DEFAULT_LINEAR )); + m_underSaturatedSchema->addColumn( ColumnSchema( "MU" , Table::RANDOM , Table::DEFAULT_LINEAR )); + + + + m_saturatedSchema = std::make_shared( ); + m_saturatedSchema->addColumn( ColumnSchema( "RS" , Table::STRICTLY_INCREASING , Table::DEFAULT_NONE )); + m_saturatedSchema->addColumn( ColumnSchema( "P" , Table::RANDOM , Table::DEFAULT_NONE )); + m_saturatedSchema->addColumn( ColumnSchema( "BO" , Table::RANDOM , Table::DEFAULT_LINEAR )); + m_saturatedSchema->addColumn( ColumnSchema( "MU" , Table::RANDOM , Table::DEFAULT_LINEAR )); + + PvtxTable::init(keyword , tableIdx); + } }; - - typedef std::shared_ptr PvtoTablePtr; - typedef std::shared_ptr PvtoConstTablePtr; } #endif diff --git a/opm/parser/eclipse/EclipseState/Tables/PvtxTable.cpp b/opm/parser/eclipse/EclipseState/Tables/PvtxTable.cpp new file mode 100644 index 000000000..cc56a9ad5 --- /dev/null +++ b/opm/parser/eclipse/EclipseState/Tables/PvtxTable.cpp @@ -0,0 +1,142 @@ +/* + Copyright 2015 Statoil ASA. + + This file is part of the Open Porous Media project (OPM). + + OPM is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OPM is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with OPM. If not, see . + */ + +#include + +namespace Opm { + + PvtxTable::PvtxTable(const std::string& columnName) : + m_outerColumnSchema( columnName , Table::STRICTLY_INCREASING , Table::DEFAULT_NONE ), + m_outerColumn( m_outerColumnSchema ) + { + + } + + + + /* + The Schema pointers m_saturatedSchema and m_underSaturatedSchema must + have been explicitly set before calling this method. + */ + + void PvtxTable::init(Opm::DeckKeywordConstPtr keyword , size_t tableIdx) { + auto ranges = recordRanges( keyword ); + if (tableIdx >= ranges.size()) + throw std::invalid_argument("Asked for table: " + std::to_string( tableIdx ) + " in keyword + " + keyword->name() + " which only has " + std::to_string( ranges.size() ) + " tables"); + + { + auto range = ranges[ tableIdx ]; + for (size_t rowIdx = range.first; rowIdx < range.second; rowIdx++) { + Opm::DeckRecordConstPtr deckRecord = keyword->getRecord(rowIdx); + { + Opm::DeckItemConstPtr indexItem = deckRecord->getItem(0); + m_outerColumn.addValue( indexItem->getSIDouble( 0 )); + } + { + Opm::DeckItemConstPtr dataItem = deckRecord->getItem(1); + std::shared_ptr underSaturatedTable = std::make_shared(m_underSaturatedSchema , dataItem); + m_underSaturatedTables.push_back( underSaturatedTable ); + } + } + + + m_saturatedTable = std::make_shared(m_saturatedSchema); + for (size_t sat_index = 0; sat_index < size(); sat_index++) { + const auto& underSaturatedTable = getUnderSaturatedTable( sat_index ); + std::vector row(4); + row[0] = m_outerColumn[sat_index]; + for (size_t col_index = 0; col_index < m_underSaturatedSchema->size(); col_index++) + row[col_index + 1] = underSaturatedTable.get( col_index , 0 ); + + m_saturatedTable->addRow( row ); + } + } + } + + + double PvtxTable::evaluate(const std::string& column, double outerArg, double innerArg) const + { + TableIndex outerIndex = m_outerColumn.lookup( outerArg ); + const auto& underSaturatedTable1 = getUnderSaturatedTable( outerIndex.getIndex1( ) ); + double weight1 = outerIndex.getWeight1( ); + double value = weight1 * underSaturatedTable1.evaluate( column , innerArg ); + + if (weight1 < 1) { + const auto& underSaturatedTable2 = getUnderSaturatedTable( outerIndex.getIndex2( ) ); + double weight2 = outerIndex.getWeight2( ); + + value += weight2 * underSaturatedTable2.evaluate( column , innerArg ); + } + + return value; + } + + + const SimpleTable& PvtxTable::getSaturatedTable() const { + return *m_saturatedTable; + } + + + + const SimpleTable& PvtxTable::getUnderSaturatedTable(size_t tableNumber) const { + if (tableNumber >= size()) + throw std::invalid_argument("Invalid table number: " + std::to_string( tableNumber) + " max: " + std::to_string( size() - 1 )); + return *m_underSaturatedTables[ tableNumber ]; + } + + + size_t PvtxTable::size() const + { + return m_outerColumn.size(); + } + + + size_t PvtxTable::numTables(Opm::DeckKeywordConstPtr keyword) + { + auto ranges = recordRanges(keyword); + return ranges.size(); + } + + + std::vector > PvtxTable::recordRanges(Opm::DeckKeywordConstPtr keyword) { + std::vector > ranges; + size_t startRecord = 0; + size_t recordIndex = 0; + while (recordIndex < keyword->size()) { + auto item = keyword->getRecord(recordIndex)->getItem(0); + if (item->size( ) == 0) { + ranges.push_back( std::make_pair( startRecord , recordIndex ) ); + startRecord = recordIndex + 1; + } + recordIndex++; + } + ranges.push_back( std::make_pair( startRecord , recordIndex ) ); + return ranges; + } + + + double PvtxTable::getArgValue(size_t index) const { + if (index < m_outerColumn.size()) + return m_outerColumn[index]; + else + throw std::invalid_argument("Invalid index"); + } + +} + diff --git a/opm/parser/eclipse/EclipseState/Tables/PvtxTable.hpp b/opm/parser/eclipse/EclipseState/Tables/PvtxTable.hpp new file mode 100644 index 000000000..2297813d0 --- /dev/null +++ b/opm/parser/eclipse/EclipseState/Tables/PvtxTable.hpp @@ -0,0 +1,135 @@ +/* + Copyright 2015 Statoil ASA. + + This file is part of the Open Porous Media project (OPM). + + OPM is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OPM is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with OPM. If not, see . + */ +#ifndef OPM_PARSER_PVTX_TABLE_HPP +#define OPM_PARSER_PVTX_TABLE_HPP + +#include +#include + +#include +#include +#include +#include + +/* + This class is a common base class for the PVTG and PVTO tables. The + PVTO and PVTG keywords have a quite complex structure. The structure + consists of alternating records of saturated data and corresponding + undersaturated tables, this structure is again repeated for the + different satnum regions. + + + PVTO + +-- RSO PRESSURE B-OIL VISCOSITY +-- (BAR) (CP) + + [ 20.59 { 50.00 1.10615 1.180 } ] \ + { 75.00 1.10164 1.247 } | + { 100.00 1.09744 1.315 } | + { 125.00 1.09351 1.384 } | + { 150.00 1.08984 1.453 }/ | + | + [ 28.19 { 70.00 1.12522 1.066 } ] | + { 95.00 1.12047 1.124 } | + { 120.00 1.11604 1.182 } |-- Satnum region 1 + { 145.00 1.11191 1.241 } | + { 170.00 1.10804 1.300 }/ | + | + [ 36.01 { 90.00 1.14458 0.964 } ] | + { 115.00 1.13959 1.014 } | + { 140.00 1.13494 1.064 } | + { 165.00 1.13060 1.115 } | + { 190.00 1.12653 1.166 }/ | +/ / + 404.60 594.29 1.97527 0.21564 \ + 619.29 1.96301 0.21981 | + 644.29 1.95143 0.22393 |-- Satnum region 2 + 669.29 1.94046 0.22801 | + 694.29 1.93005 0.23204 / | +/ / + 404.60 594.29 1.97527 0.21564 \ + 619.29 1.96301 0.21981 | + 644.29 1.95143 0.22393 | + 669.29 1.94046 0.22801 | + 694.29 1.93005 0.23204 / |-- Satnum region 3 + 404.60 594.29 1.97527 0.21564 | + 619.29 1.96301 0.21981 | + 644.29 1.95143 0.22393 | + 669.29 1.94046 0.22801 | + 694.29 1.93005 0.23204 / / +/ + + +In satnum region1 the saturated records are marked with [ ... ], and +the corresponding undersaturated tables are marked with { ... }. So +for satnum region1 the table of saturated properties looks like: + + RSO PRESSURE B-OIL VISCOSITY + 20.59 50.00 1.10615 1.180 + 28.19 70.00 1.12522 1.066 + 36.01 90.00 1.14458 0.964 + +In the PvtxTable class this table is available as the method +getSaturatedTable( ). For each RS value there is a table of +undersaturated properties; since the saturated table for region1 has +three rows there are three such tables, these tables are available as +getUnderSaturatedTable( index ). In this particular example the first +undersaturated table looks like: + + PRESSURE B-OIL VISCOSITY + 50.00 1.10615 1.180 + 75.00 1.10164 1.247 + 100.00 1.09744 1.315 + 125.00 1.09351 1.384 + 150.00 1.08984 1.453 + +The first row actually corresponds to saturated values. +*/ + + + namespace Opm { + class PvtxTable + { + + public: + static size_t numTables(Opm::DeckKeywordConstPtr keyword); + static std::vector > recordRanges(Opm::DeckKeywordConstPtr keyword); + + PvtxTable(const std::string& columnName); + const SimpleTable& getUnderSaturatedTable(size_t tableNumber) const; + void init(Opm::DeckKeywordConstPtr keyword , size_t tableIdx); + size_t size() const; + double evaluate(const std::string& column, double outerArg, double innerArg) const; + double getArgValue(size_t index) const; + const SimpleTable& getSaturatedTable() const; + + protected: + ColumnSchema m_outerColumnSchema; + TableColumn m_outerColumn; + + std::shared_ptr m_underSaturatedSchema; + std::shared_ptr m_saturatedSchema; + std::vector > m_underSaturatedTables; + std::shared_ptr m_saturatedTable; + }; + +} + +#endif diff --git a/opm/parser/eclipse/EclipseState/Tables/TableManager.cpp b/opm/parser/eclipse/EclipseState/Tables/TableManager.cpp index d72965784..a95f2ea60 100644 --- a/opm/parser/eclipse/EclipseState/Tables/TableManager.cpp +++ b/opm/parser/eclipse/EclipseState/Tables/TableManager.cpp @@ -156,8 +156,6 @@ namespace Opm { addTables( "SGCWMIS", numMiscibleTables); addTables( "MISC", numMiscibleTables); addTables( "PMISC", numMiscibleTables); - - } { @@ -280,8 +278,7 @@ namespace Opm { const auto tableRecord = tableKeyword->getRecord( tableIdx ); const auto dataItem = tableRecord->getItem( 0 ); if (dataItem->size() > 0) { - std::shared_ptr table = std::make_shared(); - table->init(deck , dataItem ); + std::shared_ptr table = std::make_shared( deck , dataItem ); container.addTable( tableIdx , table ); } } @@ -313,8 +310,7 @@ namespace Opm { const auto dataRecord = tableKeyword->getRecord( tableIdx + 1); const auto dataItem = dataRecord->getItem( 0 ); if (dataItem->size() > 0) { - std::shared_ptr table = std::make_shared(); - table->init(indexRecord , dataRecord); + std::shared_ptr table = std::make_shared(indexRecord , dataRecord); container.addTable( tableIdx , table ); } } @@ -337,8 +333,7 @@ namespace Opm { auto& container = forceGetTables(keywordName , numTables); for (size_t tableIdx = 0; tableIdx < keyword->size(); ++tableIdx) { const auto tableRecord = keyword->getRecord( tableIdx ); - std::shared_ptr table = std::make_shared(); - table->init( tableRecord ); + std::shared_ptr table = std::make_shared(tableRecord); container.addTable( tableIdx , table ); } } @@ -360,8 +355,7 @@ namespace Opm { auto& container = forceGetTables(keywordName , numTables); for (size_t tableIdx = 0; tableIdx < keyword->size(); ++tableIdx) { const auto tableRecord = keyword->getRecord( tableIdx ); - std::shared_ptr table = std::make_shared(); - table->init( tableRecord ); + std::shared_ptr table = std::make_shared( tableRecord ); container.addTable( tableIdx , table ); } } @@ -395,8 +389,7 @@ namespace Opm { const auto tableRecord = rocktabKeyword->getRecord( tableIdx ); const auto dataItem = tableRecord->getItem( 0 ); if (dataItem->size() > 0) { - std::shared_ptr table = std::make_shared(); - table->init(dataItem , isDirectional, useStressOption); + std::shared_ptr table = std::make_shared( dataItem , isDirectional, useStressOption ); container.addTable( tableIdx , table ); } } @@ -474,7 +467,7 @@ namespace Opm { const TableContainer& TableManager::getSgwfnTables() const { return getTables("SGWFN"); } - + const TableContainer& TableManager::getSlgofTables() const { return getTables("SLGOF"); } @@ -590,7 +583,6 @@ namespace Opm { return m_pvtgTables; } - const std::vector& TableManager::getPvtoTables() const { return m_pvtoTables; } diff --git a/opm/parser/eclipse/EclipseState/Tables/TableManager.hpp b/opm/parser/eclipse/EclipseState/Tables/TableManager.hpp index 4918fa147..d3e628dc4 100644 --- a/opm/parser/eclipse/EclipseState/Tables/TableManager.hpp +++ b/opm/parser/eclipse/EclipseState/Tables/TableManager.hpp @@ -26,6 +26,9 @@ #include #include +#include +#include + #include #include #include @@ -55,8 +58,6 @@ #include #include #include -#include -#include #include #include #include @@ -69,6 +70,7 @@ + namespace Opm { class TableManager { @@ -166,8 +168,7 @@ namespace Opm { const auto tableRecord = tableKeyword->getRecord( tableIdx ); const auto dataItem = tableRecord->getItem( 0 ); if (dataItem->size() > 0) { - std::shared_ptr table = std::make_shared(); - table->init(dataItem); + std::shared_ptr table = std::make_shared( dataItem ); container.addTable( tableIdx , table ); } } @@ -229,11 +230,9 @@ namespace Opm { const auto& tableKeyword = deck.getKeyword(keywordName); - int numTables = TableType::numTables(tableKeyword); - for (int tableIdx = 0; tableIdx < numTables; ++tableIdx) { - tableVector.push_back(TableType()); - tableVector[tableIdx].init(tableKeyword, tableIdx); - } + int numTables = TableType::numTables( tableKeyword ); + for (int tableIdx = 0; tableIdx < numTables; ++tableIdx) + tableVector.push_back(TableType(tableKeyword , tableIdx)); } std::map m_simpleTables; diff --git a/opm/parser/eclipse/EclipseState/Tables/tests/CMakeLists.txt b/opm/parser/eclipse/EclipseState/Tables/tests/CMakeLists.txt index b256f54c9..8bd5842a2 100644 --- a/opm/parser/eclipse/EclipseState/Tables/tests/CMakeLists.txt +++ b/opm/parser/eclipse/EclipseState/Tables/tests/CMakeLists.txt @@ -4,7 +4,8 @@ foreach(tapp TableManagerTests SimpleTableTests ColumnSchemaTests TableSchemaTests - TableColumnTests) + TableColumnTests + PvtxTableTests) opm_add_test(run${tapp} SOURCES ${tapp}.cpp LIBRARIES opmparser ${Boost_LIBRARIES}) diff --git a/opm/parser/eclipse/EclipseState/Tables/tests/MultiRecordTableTests.cpp b/opm/parser/eclipse/EclipseState/Tables/tests/PvtxTableTests.cpp similarity index 60% rename from opm/parser/eclipse/EclipseState/Tables/tests/MultiRecordTableTests.cpp rename to opm/parser/eclipse/EclipseState/Tables/tests/PvtxTableTests.cpp index 23fe35b42..b6c9bd4b1 100644 --- a/opm/parser/eclipse/EclipseState/Tables/tests/MultiRecordTableTests.cpp +++ b/opm/parser/eclipse/EclipseState/Tables/tests/PvtxTableTests.cpp @@ -17,7 +17,7 @@ along with OPM. If not, see . */ -#define BOOST_TEST_MODULE MultiRecordTableTests +#define BOOST_TEST_MODULE PvtxTableTests #include #include @@ -30,12 +30,11 @@ // generic table classes #include -#include -#include +#include #include // keyword specific table classes -#include +//#include #include #include #include @@ -51,28 +50,28 @@ using namespace Opm; -BOOST_AUTO_TEST_CASE( MultiRecordNumTables1 ) { +BOOST_AUTO_TEST_CASE( PvtxNumTables1 ) { ParserPtr parser(new Parser()); - boost::filesystem::path deckFile("testdata/integration_tests/TABLES/PVTO1.DATA"); + boost::filesystem::path deckFile("testdata/integration_tests/TABLES/PVTX1.DATA"); ParseMode parseMode; DeckPtr deck = parser->parseFile(deckFile.string(), parseMode); - BOOST_CHECK_EQUAL( MultiRecordTable::numTables( deck->getKeyword()) , 1); + BOOST_CHECK_EQUAL( PvtxTable::numTables( deck->getKeyword()) , 1); - auto ranges = MultiRecordTable::recordRanges( deck->getKeyword() ); + auto ranges = PvtxTable::recordRanges( deck->getKeyword() ); auto range = ranges[0]; BOOST_CHECK_EQUAL( range.first , 0 ); BOOST_CHECK_EQUAL( range.second , 2 ); } -BOOST_AUTO_TEST_CASE( MultiRecordNumTables2 ) { +BOOST_AUTO_TEST_CASE( PvtxNumTables2 ) { ParserPtr parser(new Parser()); boost::filesystem::path deckFile("testdata/integration_tests/TABLES/PVTO2.DATA"); ParseMode parseMode; DeckPtr deck = parser->parseFile(deckFile.string(), parseMode); - BOOST_CHECK_EQUAL( MultiRecordTable::numTables( deck->getKeyword()) , 3); + BOOST_CHECK_EQUAL( PvtxTable::numTables( deck->getKeyword()) , 3); - auto ranges = MultiRecordTable::recordRanges( deck->getKeyword() ); + auto ranges = PvtxTable::recordRanges( deck->getKeyword() ); auto range1 = ranges[0]; BOOST_CHECK_EQUAL( range1.first , 0 ); BOOST_CHECK_EQUAL( range1.second , 41 ); @@ -86,7 +85,7 @@ BOOST_AUTO_TEST_CASE( MultiRecordNumTables2 ) { BOOST_CHECK_EQUAL( range3.second , 46 ); } -BOOST_AUTO_TEST_CASE( MultiRecordNumTables3 ) { +BOOST_AUTO_TEST_CASE( PvtxNumTables3 ) { const char *deckData = "TABDIMS\n" "1 2 /\n" @@ -104,7 +103,7 @@ BOOST_AUTO_TEST_CASE( MultiRecordNumTables3 ) { Opm::ParserPtr parser(new Opm::Parser); Opm::DeckConstPtr deck(parser->parseString(deckData, Opm::ParseMode())); - auto ranges = MultiRecordTable::recordRanges( deck->getKeyword() ); + auto ranges = PvtxTable::recordRanges( deck->getKeyword() ); BOOST_CHECK_EQUAL( 2 ,ranges.size() ); auto range1 = ranges[0]; @@ -115,3 +114,41 @@ BOOST_AUTO_TEST_CASE( MultiRecordNumTables3 ) { BOOST_CHECK_EQUAL( range2.first , 3 ); BOOST_CHECK_EQUAL( range2.second , 5 ); } + + + +BOOST_AUTO_TEST_CASE( PVTOSaturatedTable ) { + ParserPtr parser(new Parser()); + boost::filesystem::path deckFile("testdata/integration_tests/TABLES/PVTX1.DATA"); + ParseMode parseMode; + DeckPtr deck = parser->parseFile(deckFile.string(), parseMode); + Opm::TableManager tables(*deck); + const auto& pvtoTables = tables.getPvtoTables( ); + const auto& pvtoTable = pvtoTables[0]; + + const auto& saturatedTable = pvtoTable.getSaturatedTable( ); + BOOST_CHECK_EQUAL( saturatedTable.numColumns( ) , 4 ); + BOOST_CHECK_EQUAL( saturatedTable.numRows( ) , 2 ); + + BOOST_CHECK_EQUAL( saturatedTable.get(0 , 0) , 20.59 ); + BOOST_CHECK_EQUAL( saturatedTable.get(0 , 1) , 28.19 ); +} + + +BOOST_AUTO_TEST_CASE( PVTGSaturatedTable ) { + ParserPtr parser(new Parser()); + boost::filesystem::path deckFile("testdata/integration_tests/TABLES/PVTX1.DATA"); + ParseMode parseMode; + DeckPtr deck = parser->parseFile(deckFile.string(), parseMode); + Opm::TableManager tables(*deck); + const auto& pvtgTables = tables.getPvtgTables( ); + const auto& pvtgTable = pvtgTables[0]; + + const auto& saturatedTable = pvtgTable.getSaturatedTable( ); + BOOST_CHECK_EQUAL( saturatedTable.numColumns( ) , 4 ); + BOOST_CHECK_EQUAL( saturatedTable.numRows( ) , 2 ); + + BOOST_CHECK_EQUAL( saturatedTable.get(1 , 0) , 0.00002448 ); + BOOST_CHECK_EQUAL( saturatedTable.get(1 , 1) , 0.00000628 ); +} + diff --git a/opm/parser/eclipse/EclipseState/Tables/tests/TableManagerTests.cpp b/opm/parser/eclipse/EclipseState/Tables/tests/TableManagerTests.cpp index f0fab4f64..87d01e95a 100644 --- a/opm/parser/eclipse/EclipseState/Tables/tests/TableManagerTests.cpp +++ b/opm/parser/eclipse/EclipseState/Tables/tests/TableManagerTests.cpp @@ -29,12 +29,9 @@ // generic table classes #include -#include -#include #include // keyword specific table classes -#include #include #include #include @@ -77,78 +74,7 @@ BOOST_AUTO_TEST_CASE( CreateTables ) { /*****************************************************************/ -BOOST_AUTO_TEST_CASE(CreateSimpleTable) { - const char *deckData = - "TABDIMS\n" - " 2 /\n" - "\n" - "SWOF\n" - " 1 2 3 4\n" - " 5 6 7 8 /\n" - " 9 10 11 12 /\n"; - Opm::ParserPtr parser(new Opm::Parser); - Opm::DeckConstPtr deck(parser->parseString(deckData, Opm::ParseMode())); - - std::vector tooFewColumnNames{"A", "B", "C"}; - std::vector justRightColumnNames{"A", "B", "C", "D"}; - std::vector tooManyColumnNames{"A", "B", "C", "D", "E"}; - - BOOST_CHECK_EQUAL(Opm::SimpleTable::numTables(deck->getKeyword("SWOF")), 2); - Opm::SimpleTable tmpTable; - BOOST_CHECK_THROW(tmpTable.initFORUNITTESTONLY(deck->getKeyword("SWOF")->getRecord(0)->getItem(0), - tooFewColumnNames), - std::runtime_error); - - BOOST_CHECK_THROW(tmpTable.initFORUNITTESTONLY(deck->getKeyword("SWOF")->getRecord(0)->getItem(0), - tooManyColumnNames), - std::runtime_error); - - BOOST_CHECK_NO_THROW(tmpTable.initFORUNITTESTONLY(deck->getKeyword("SWOF")->getRecord(0)->getItem(0), - justRightColumnNames)); -} - -BOOST_AUTO_TEST_CASE(CreateMultiTable) { - const char *deckData = - "TABDIMS\n" - "1 2 /\n" - "\n" - "PVTO\n" - " 1 2 3 4" - " 5 6 7/\n" - " 8 9 10 11 /\n" - "/\n" - "12 13 14 15\n" - " 16 17 18/\n" - "19 20 21 22/\n" - "/\n"; - - Opm::ParserPtr parser(new Opm::Parser); - Opm::DeckConstPtr deck(parser->parseString(deckData, Opm::ParseMode())); - - std::vector tooFewColumnNames{"A", "B", "C"}; - std::vector justRightColumnNames{"A", "B", "C", "D"}; - std::vector tooManyColumnNames{"A", "B", "C", "D", "E"}; - - BOOST_CHECK_EQUAL(Opm::MultiRecordTable::numTables(deck->getKeyword("PVTO")), 2); - // this mistake can't be detected as the MultiRecordTable takes - // the first $N items as the column names... - /* - BOOST_CHECK_THROW(Opm::MultiRecordTable(deck->getKeyword("PVTO"), - tooFewColumnNames, - 0), - std::runtime_error); - */ - Opm::MultiRecordTable mrt; - BOOST_CHECK_THROW(mrt.initFORUNITTESTONLY(deck->getKeyword("PVTO"), - tooManyColumnNames, - /*tableIdx=*/0), - std::out_of_range); - - BOOST_CHECK_NO_THROW(mrt.initFORUNITTESTONLY(deck->getKeyword("PVTO"), - justRightColumnNames,0)); - -} BOOST_AUTO_TEST_CASE(SwofTable_Tests) { const char *deckData = @@ -166,13 +92,8 @@ BOOST_AUTO_TEST_CASE(SwofTable_Tests) { Opm::DeckConstPtr deck(parser->parseString(deckData, Opm::ParseMode())); Opm::DeckKeywordConstPtr swofKeyword = deck->getKeyword("SWOF"); - BOOST_CHECK_EQUAL(Opm::SwofTable::numTables(swofKeyword), 2); - - Opm::SwofTable swof1Table; - Opm::SwofTable swof2Table; - - swof1Table.initFORUNITTESTONLY(deck->getKeyword("SWOF")->getRecord(0)->getItem(0)); - swof2Table.initFORUNITTESTONLY(deck->getKeyword("SWOF")->getRecord(1)->getItem(0)); + Opm::SwofTable swof1Table(deck->getKeyword("SWOF")->getRecord(0)->getItem(0)); + Opm::SwofTable swof2Table(deck->getKeyword("SWOF")->getRecord(1)->getItem(0)); BOOST_CHECK_EQUAL(swof1Table.numRows(), 2); BOOST_CHECK_EQUAL(swof2Table.numRows(), 3); @@ -215,13 +136,9 @@ BOOST_AUTO_TEST_CASE(SgwfnTable_Tests) { Opm::DeckConstPtr deck(parser->parseString(deckData, Opm::ParseMode())); Opm::DeckKeywordConstPtr sgwfnKeyword = deck->getKeyword("SGWFN"); - BOOST_CHECK_EQUAL(Opm::SgwfnTable::numTables(sgwfnKeyword), 2); - Opm::SgwfnTable sgwfn1Table; - Opm::SgwfnTable sgwfn2Table; - - sgwfn1Table.initFORUNITTESTONLY(deck->getKeyword("SGWFN")->getRecord(0)->getItem(0)); - sgwfn2Table.initFORUNITTESTONLY(deck->getKeyword("SGWFN")->getRecord(1)->getItem(0)); + Opm::SgwfnTable sgwfn1Table(deck->getKeyword("SGWFN")->getRecord(0)->getItem(0)); + Opm::SgwfnTable sgwfn2Table(deck->getKeyword("SGWFN")->getRecord(1)->getItem(0)); BOOST_CHECK_EQUAL(sgwfn1Table.numRows(), 2); BOOST_CHECK_EQUAL(sgwfn2Table.numRows(), 3); @@ -263,13 +180,8 @@ BOOST_AUTO_TEST_CASE(SgofTable_Tests) { Opm::DeckConstPtr deck(parser->parseString(deckData, Opm::ParseMode())); Opm::DeckKeywordConstPtr sgofKeyword = deck->getKeyword("SGOF"); - BOOST_CHECK_EQUAL(Opm::SgofTable::numTables(sgofKeyword), 2); - - Opm::SgofTable sgof1Table; - Opm::SgofTable sgof2Table; - - sgof1Table.initFORUNITTESTONLY(deck->getKeyword("SGOF")->getRecord(0)->getItem(0)); - sgof2Table.initFORUNITTESTONLY(deck->getKeyword("SGOF")->getRecord(1)->getItem(0)); + Opm::SgofTable sgof1Table(deck->getKeyword("SGOF")->getRecord(0)->getItem(0)); + Opm::SgofTable sgof2Table(deck->getKeyword("SGOF")->getRecord(1)->getItem(0)); BOOST_CHECK_EQUAL(sgof1Table.numRows(), 2); BOOST_CHECK_EQUAL(sgof2Table.numRows(), 3); @@ -314,11 +226,8 @@ BOOST_AUTO_TEST_CASE(PlyadsTable_Tests) { Opm::ParserPtr parser(new Opm::Parser); Opm::DeckConstPtr deck(parser->parseString(correctDeckData, Opm::ParseMode())); Opm::DeckKeywordConstPtr plyadsKeyword = deck->getKeyword("PLYADS"); + Opm::PlyadsTable plyadsTable(plyadsKeyword->getRecord(0)->getItem(0)); - BOOST_CHECK_EQUAL(Opm::PlyadsTable::numTables(plyadsKeyword), 1); - - Opm::PlyadsTable plyadsTable; - plyadsTable.initFORUNITTESTONLY(plyadsKeyword->getRecord(0)->getItem(0)); BOOST_CHECK_CLOSE(plyadsTable.getPolymerConcentrationColumn().front(), 0.0, 1e-6); BOOST_CHECK_CLOSE(plyadsTable.getPolymerConcentrationColumn().back(), 3.0, 1e-6); @@ -347,10 +256,7 @@ BOOST_AUTO_TEST_CASE(PlyadsTable_Tests) { Opm::DeckConstPtr deck(parser->parseString(incorrectDeckData, Opm::ParseMode())); Opm::DeckKeywordConstPtr plyadsKeyword = deck->getKeyword("PLYADS"); - BOOST_CHECK_EQUAL(Opm::PlyadsTable::numTables(plyadsKeyword), 1); - - Opm::PlyadsTable plyadsTable; - BOOST_CHECK_THROW(plyadsTable.initFORUNITTESTONLY(plyadsKeyword->getRecord(0)->getItem(0)), std::invalid_argument); + BOOST_CHECK_THROW(Opm::PlyadsTable(plyadsKeyword->getRecord(0)->getItem(0)), std::invalid_argument); } { @@ -373,67 +279,11 @@ BOOST_AUTO_TEST_CASE(PlyadsTable_Tests) { Opm::DeckConstPtr deck(parser->parseString(incorrectDeckData, Opm::ParseMode())); Opm::DeckKeywordConstPtr plyadsKeyword = deck->getKeyword("PLYADS"); - BOOST_CHECK_EQUAL(Opm::PlyadsTable::numTables(plyadsKeyword), 1); - - Opm::PlyadsTable plyadsTable; - BOOST_CHECK_THROW(plyadsTable.initFORUNITTESTONLY(plyadsKeyword->getRecord(0)->getItem(0)), std::invalid_argument); + BOOST_CHECK_THROW(Opm::PlyadsTable(plyadsKeyword->getRecord(0)->getItem(0)), std::invalid_argument); } } -BOOST_AUTO_TEST_CASE(PvtoTable_Tests) { - const char *deckData = - "TABDIMS\n" - "1 2 /\n" - "\n" - "PVTO\n" - " 1 2 3 4" - " 5 6 7/\n" - " 8 9 10 11 /\n" - "/\n" - "12 13 14 15\n" - " 16 17 18/\n" - "19 20 21 22/\n" - "23 24 25 26/\n" - "/\n"; - Opm::ParserPtr parser(new Opm::Parser); - Opm::DeckConstPtr deck(parser->parseString(deckData, Opm::ParseMode())); - Opm::DeckKeywordConstPtr pvtoKeyword = deck->getKeyword("PVTO"); - - BOOST_CHECK_EQUAL(Opm::PvtoTable::numTables(pvtoKeyword), 2); - - Opm::PvtoTable pvto1Table; - Opm::PvtoTable pvto2Table; - - pvto1Table.initFORUNITTESTONLY(deck->getKeyword("PVTO"), /*tableIdx=*/0); - pvto2Table.initFORUNITTESTONLY(deck->getKeyword("PVTO"), /*tableIdx=*/1); - - const auto pvto1OuterTable = pvto1Table.getOuterTable(); - const auto pvto2OuterTable = pvto2Table.getOuterTable(); - - BOOST_CHECK_EQUAL(pvto1OuterTable->numRows(), 2); - BOOST_CHECK_EQUAL(pvto2OuterTable->numRows(), 3); - - BOOST_CHECK_EQUAL(pvto1OuterTable->numColumns(), 4); - BOOST_CHECK_EQUAL(pvto2OuterTable->numColumns(), 4); - - BOOST_CHECK_EQUAL(pvto1OuterTable->getGasSolubilityColumn().front(), 1.0); - BOOST_CHECK_EQUAL(pvto1OuterTable->getGasSolubilityColumn().back(), 8.0); - - BOOST_CHECK_EQUAL(pvto1OuterTable->getPressureColumn().front(), 2.0e5); - BOOST_CHECK_EQUAL(pvto1OuterTable->getPressureColumn().back(), 9.0e5); - - BOOST_CHECK_EQUAL(pvto1OuterTable->getOilFormationFactorColumn().front(), 3.0); - BOOST_CHECK_EQUAL(pvto1OuterTable->getOilFormationFactorColumn().back(), 10.0); - - BOOST_CHECK_EQUAL(pvto1OuterTable->getOilViscosityColumn().front(), 4.0e-3); - BOOST_CHECK_EQUAL(pvto1OuterTable->getOilViscosityColumn().back(), 11.0e-3); - - // for the second table, we only check the first column and trust - // that everything else is fine... - BOOST_CHECK_EQUAL(pvto2OuterTable->getGasSolubilityColumn().front(), 12.0); - BOOST_CHECK_EQUAL(pvto2OuterTable->getGasSolubilityColumn().back(), 23.0); -} /** diff --git a/opm/parser/eclipse/IntegrationTests/ParseDATAWithDefault.cpp b/opm/parser/eclipse/IntegrationTests/ParseDATAWithDefault.cpp index 798472f4e..768dabf28 100644 --- a/opm/parser/eclipse/IntegrationTests/ParseDATAWithDefault.cpp +++ b/opm/parser/eclipse/IntegrationTests/ParseDATAWithDefault.cpp @@ -23,8 +23,6 @@ #include #include -#include - #include #include diff --git a/opm/parser/eclipse/IntegrationTests/ParsePVTG.cpp b/opm/parser/eclipse/IntegrationTests/ParsePVTG.cpp index 7225f39f7..752580a87 100644 --- a/opm/parser/eclipse/IntegrationTests/ParsePVTG.cpp +++ b/opm/parser/eclipse/IntegrationTests/ParsePVTG.cpp @@ -23,7 +23,6 @@ #include #include -#include #include #include @@ -111,7 +110,7 @@ static void check_parser(ParserPtr parser) { BOOST_CHECK_EQUAL(9U , item4_1->size()); BOOST_CHECK_EQUAL(2U , record4->size()); - + /* { Opm::PvtgTable pvtgTable; pvtgTable.initFORUNITTESTONLY(kw1, 0); @@ -132,6 +131,7 @@ static void check_parser(ParserPtr parser) { BOOST_CHECK_EQUAL(1.299e-5, outerTable.getGasViscosityColumn()[0]); BOOST_CHECK_EQUAL(outerTable.getGasViscosityColumn()[0], innerTable0.getGasViscosityColumn()[0]); } + */ } diff --git a/opm/parser/eclipse/IntegrationTests/ParsePVTO.cpp b/opm/parser/eclipse/IntegrationTests/ParsePVTO.cpp index 5e685d3e1..73914c92e 100644 --- a/opm/parser/eclipse/IntegrationTests/ParsePVTO.cpp +++ b/opm/parser/eclipse/IntegrationTests/ParsePVTO.cpp @@ -105,23 +105,23 @@ static void check_parser(ParserPtr parser) { BOOST_CHECK_EQUAL(9U , item4_1->size()); BOOST_CHECK_EQUAL(2U , record4->size()); - Opm::PvtoTable pvtoTable; - pvtoTable.initFORUNITTESTONLY(kw1, /*tableIdx=*/0); - const auto &outerTable = *pvtoTable.getOuterTable(); - const auto &innerTable0 = *pvtoTable.getInnerTable(0); - BOOST_CHECK_EQUAL(2, outerTable.numRows()); - BOOST_CHECK_EQUAL(4, outerTable.numColumns()); - BOOST_CHECK_EQUAL(3, innerTable0.numRows()); - BOOST_CHECK_EQUAL(3, innerTable0.numColumns()); + Opm::PvtoTable pvtoTable(kw1 , 0); + BOOST_CHECK_EQUAL(2, pvtoTable.size()); + { + const auto &table0 = pvtoTable.getUnderSaturatedTable(0); + const auto& BO = table0.getColumn( "BO" ); - BOOST_CHECK_EQUAL(1e-3, outerTable.getGasSolubilityColumn()[0]); - BOOST_CHECK_EQUAL(1.0e5, outerTable.getPressureColumn()[0]); - BOOST_CHECK_EQUAL(outerTable.getPressureColumn()[0], innerTable0.getPressureColumn()[0]); - BOOST_CHECK_EQUAL(1.01, outerTable.getOilFormationFactorColumn()[0]); - BOOST_CHECK_EQUAL(outerTable.getOilFormationFactorColumn()[0], innerTable0.getOilFormationFactorColumn()[0]); - BOOST_CHECK_EQUAL(1.02e-3, outerTable.getOilViscosityColumn()[0]); - BOOST_CHECK_EQUAL(outerTable.getOilViscosityColumn()[0], innerTable0.getOilViscosityColumn()[0]); + BOOST_CHECK_EQUAL( 3, table0.numRows()); + BOOST_CHECK_EQUAL( 3, table0.numColumns()); + BOOST_CHECK_EQUAL( BO.front( ) , 1.01 ); + BOOST_CHECK_EQUAL( BO.back( ) , 1.20 ); + + BOOST_CHECK_CLOSE(1.15 , table0.evaluate( "BO" , 250*1e5 ) , 1e-6); + } + + BOOST_CHECK_CLOSE( 1.15 , pvtoTable.evaluate( "BO" , 1e-3 , 250*1e5 ) , 1e-6 ); + BOOST_CHECK_CLOSE( 1.15 , pvtoTable.evaluate( "BO" , 0.0 , 250*1e5 ) , 1e-6 ); } diff --git a/testdata/integration_tests/TABLES/PVTO1.DATA b/testdata/integration_tests/TABLES/PVTX1.DATA similarity index 78% rename from testdata/integration_tests/TABLES/PVTO1.DATA rename to testdata/integration_tests/TABLES/PVTX1.DATA index 01e8f531f..afed2008f 100644 --- a/testdata/integration_tests/TABLES/PVTO1.DATA +++ b/testdata/integration_tests/TABLES/PVTX1.DATA @@ -42,3 +42,14 @@ PVTO 170.00 1.10804 1.300 / / + + +PVTG +-- + 20.00 0.00002448 0.061895 0.01299 + 0.00001224 0.061810 0.01300 + 0.00000000 0.061725 0.01300 / + 40.00 0.00000628 0.030252 0.01383 + 0.00000314 0.030249 0.01383 + 0.00000000 0.030245 0.01383 / +/