Merge pull request #201 from andlaus/table_improvements
Table improvements
This commit is contained in:
@@ -77,8 +77,8 @@ EclipseState/Schedule/GroupTree.cpp
|
||||
EclipseState/Grid/EclipseGrid.cpp)
|
||||
|
||||
set (utility_source
|
||||
Utility/SimpleTable.cpp
|
||||
Utility/SimpleMultiRecordTable.cpp)
|
||||
Utility/SingleRecordTable.cpp
|
||||
Utility/MultiRecordTable.cpp)
|
||||
|
||||
set( HEADER_FILES
|
||||
RawDeck/RawConsts.hpp
|
||||
|
||||
@@ -19,13 +19,15 @@
|
||||
#ifndef OPM_PARSER_ENKRVD_TABLE_HPP
|
||||
#define OPM_PARSER_ENKRVD_TABLE_HPP
|
||||
|
||||
#include "SimpleTable.hpp"
|
||||
#include "SingleRecordTable.hpp"
|
||||
|
||||
namespace Opm {
|
||||
class EnkrvdTable : protected SimpleTable {
|
||||
typedef SimpleTable ParentType;
|
||||
class EnkrvdTable : protected SingleRecordTable {
|
||||
typedef SingleRecordTable ParentType;
|
||||
|
||||
public:
|
||||
using ParentType::numTables;
|
||||
|
||||
/*!
|
||||
* \brief Read the ENKRVD keyword and provide some convenience
|
||||
* methods for it.
|
||||
@@ -33,7 +35,7 @@ namespace Opm {
|
||||
EnkrvdTable(Opm::DeckKeywordConstPtr keyword,
|
||||
int recordIdx = 0,
|
||||
int firstEntityOffset = 0)
|
||||
: SimpleTable(keyword,
|
||||
: SingleRecordTable(keyword,
|
||||
std::vector<std::string>{"DEPTH",
|
||||
"KRWMAX",
|
||||
"KRGMAX",
|
||||
|
||||
@@ -19,13 +19,15 @@
|
||||
#ifndef OPM_PARSER_ENPTVD_TABLE_HPP
|
||||
#define OPM_PARSER_ENPTVD_TABLE_HPP
|
||||
|
||||
#include "SimpleTable.hpp"
|
||||
#include "SingleRecordTable.hpp"
|
||||
|
||||
namespace Opm {
|
||||
class EnptvdTable : protected SimpleTable {
|
||||
typedef SimpleTable ParentType;
|
||||
class EnptvdTable : protected SingleRecordTable {
|
||||
typedef SingleRecordTable ParentType;
|
||||
|
||||
public:
|
||||
using ParentType::numTables;
|
||||
|
||||
/*!
|
||||
* \brief Read the ENPTVD keyword and provide some convenience
|
||||
* methods for it.
|
||||
@@ -33,7 +35,7 @@ namespace Opm {
|
||||
EnptvdTable(Opm::DeckKeywordConstPtr keyword,
|
||||
int recordIdx = 0,
|
||||
int firstEntityOffset = 0)
|
||||
: SimpleTable(keyword,
|
||||
: SingleRecordTable(keyword,
|
||||
std::vector<std::string>{"DEPTH",
|
||||
"SWCO",
|
||||
"SWCRIT",
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
#ifndef OPM_PARSER_FULL_TABLE_HPP
|
||||
#define OPM_PARSER_FULL_TABLE_HPP
|
||||
|
||||
#include <opm/parser/eclipse/Utility/SimpleMultiRecordTable.hpp>
|
||||
#include <opm/parser/eclipse/Utility/SimpleTable.hpp>
|
||||
#include <opm/parser/eclipse/Utility/MultiRecordTable.hpp>
|
||||
#include <opm/parser/eclipse/Utility/SingleRecordTable.hpp>
|
||||
#include <opm/parser/eclipse/Deck/DeckKeyword.hpp>
|
||||
|
||||
#include <map>
|
||||
@@ -30,7 +30,7 @@
|
||||
#include <cassert>
|
||||
|
||||
namespace Opm {
|
||||
template <class OuterTable = Opm::SimpleMultiRecordTable, class InnerTable = Opm::SimpleTable>
|
||||
template <class OuterTable = Opm::MultiRecordTable, class InnerTable = Opm::SingleRecordTable>
|
||||
class FullTable
|
||||
{
|
||||
typedef FullTable<OuterTable, InnerTable> Self;
|
||||
@@ -59,6 +59,9 @@ namespace Opm {
|
||||
typedef std::shared_ptr<Self> Pointer;
|
||||
typedef std::shared_ptr<const Self> ConstPointer;
|
||||
|
||||
static size_t numTables(Opm::DeckKeywordConstPtr keyword)
|
||||
{ return OuterTable::numTables(keyword); }
|
||||
|
||||
/*!
|
||||
* \brief Read full tables from keywords like PVTO
|
||||
*
|
||||
@@ -76,11 +79,11 @@ namespace Opm {
|
||||
const std::vector<std::string> &innerColumnNames,
|
||||
size_t tableIdx)
|
||||
{
|
||||
m_outerTable.reset(new SimpleMultiRecordTable(keyword, outerColumnNames, tableIdx));
|
||||
m_outerTable.reset(new MultiRecordTable(keyword, outerColumnNames, tableIdx));
|
||||
|
||||
for (size_t rowIdx = 0; rowIdx < m_outerTable->numRecords(); ++rowIdx) {
|
||||
Opm::SimpleTableConstPtr curRow(
|
||||
new SimpleTable(keyword,
|
||||
Opm::SingleRecordTableConstPtr curRow(
|
||||
new SingleRecordTable(keyword,
|
||||
innerColumnNames,
|
||||
/*recordIdx=*/m_outerTable->firstRecordIndex() + rowIdx,
|
||||
/*firstColumnOffset=*/1));
|
||||
@@ -104,8 +107,8 @@ namespace Opm {
|
||||
|
||||
};
|
||||
|
||||
typedef FullTable<Opm::SimpleMultiRecordTable, Opm::SimpleTable>::Pointer FullTablePtr;
|
||||
typedef FullTable<Opm::SimpleMultiRecordTable, Opm::SimpleTable>::ConstPointer FullTableConstPtr;
|
||||
typedef FullTable<Opm::MultiRecordTable, Opm::SingleRecordTable>::Pointer FullTablePtr;
|
||||
typedef FullTable<Opm::MultiRecordTable, Opm::SingleRecordTable>::ConstPointer FullTableConstPtr;
|
||||
}
|
||||
|
||||
#endif // OPM_PARSER_FULL_TABLE_HPP
|
||||
|
||||
@@ -16,11 +16,37 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <opm/parser/eclipse/Utility/SimpleMultiRecordTable.hpp>
|
||||
#include <opm/parser/eclipse/Utility/MultiRecordTable.hpp>
|
||||
|
||||
namespace Opm {
|
||||
/*!
|
||||
* \brief Returns the number of tables which can be found in a
|
||||
* given keyword.
|
||||
*/
|
||||
size_t MultiRecordTable::numTables(Opm::DeckKeywordConstPtr keyword)
|
||||
{
|
||||
size_t result = 0;
|
||||
|
||||
// first, go to the first record of the specified table. For this,
|
||||
// we need to skip the right number of empty records...
|
||||
for (size_t recordIdx = 0;
|
||||
recordIdx < keyword->size();
|
||||
++ recordIdx)
|
||||
{
|
||||
if (getNumFlatItems_(keyword->getRecord(recordIdx)) == 0)
|
||||
// each table ends with an empty record
|
||||
++ result;
|
||||
}
|
||||
|
||||
// the last empty record of a keyword seems to go MIA for some
|
||||
// strange reason...
|
||||
++result;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// create table from first few items of multiple records (i.e. getSIDoubleData() throws an exception)
|
||||
SimpleMultiRecordTable::SimpleMultiRecordTable(Opm::DeckKeywordConstPtr keyword,
|
||||
MultiRecordTable::MultiRecordTable(Opm::DeckKeywordConstPtr keyword,
|
||||
const std::vector<std::string> &columnNames,
|
||||
size_t tableIdx,
|
||||
size_t firstEntityOffset)
|
||||
@@ -68,7 +94,7 @@ SimpleMultiRecordTable::SimpleMultiRecordTable(Opm::DeckKeywordConstPtr keyword,
|
||||
}
|
||||
}
|
||||
|
||||
size_t SimpleMultiRecordTable::getNumFlatItems_(Opm::DeckRecordConstPtr deckRecord) const
|
||||
size_t MultiRecordTable::getNumFlatItems_(Opm::DeckRecordConstPtr deckRecord)
|
||||
{
|
||||
int result = 0;
|
||||
for (unsigned i = 0; i < deckRecord->size(); ++ i) {
|
||||
@@ -81,7 +107,7 @@ size_t SimpleMultiRecordTable::getNumFlatItems_(Opm::DeckRecordConstPtr deckReco
|
||||
return result;
|
||||
}
|
||||
|
||||
double SimpleMultiRecordTable::getFlatSiDoubleData_(Opm::DeckRecordConstPtr deckRecord, unsigned flatItemIdx) const
|
||||
double MultiRecordTable::getFlatSiDoubleData_(Opm::DeckRecordConstPtr deckRecord, unsigned flatItemIdx) const
|
||||
{
|
||||
unsigned itemFirstFlatIdx = 0;
|
||||
for (unsigned i = 0; i < deckRecord->size(); ++ i) {
|
||||
@@ -16,10 +16,10 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef OPM_PARSER_SIMPLE_MULTI_RECORD_TABLE_HPP
|
||||
#define OPM_PARSER_SIMPLE_MULTI_RECORD_TABLE_HPP
|
||||
#ifndef OPM_PARSER_MULTI_RECORD_TABLE_HPP
|
||||
#define OPM_PARSER_MULTI_RECORD_TABLE_HPP
|
||||
|
||||
#include <opm/parser/eclipse/Utility/SimpleTable.hpp>
|
||||
#include <opm/parser/eclipse/Utility/SingleRecordTable.hpp>
|
||||
|
||||
#include <opm/parser/eclipse/Deck/DeckKeyword.hpp>
|
||||
|
||||
@@ -31,15 +31,21 @@
|
||||
|
||||
namespace Opm {
|
||||
// create table from first few items of multiple records (i.e. getSIDoubleData() throws an exception)
|
||||
class SimpleMultiRecordTable : public SimpleTable {
|
||||
class MultiRecordTable : public SingleRecordTable {
|
||||
public:
|
||||
/*!
|
||||
* \brief Returns the number of tables which can be found in a
|
||||
* given keyword.
|
||||
*/
|
||||
static size_t numTables(Opm::DeckKeywordConstPtr keyword);
|
||||
|
||||
/*!
|
||||
* \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.)
|
||||
*/
|
||||
SimpleMultiRecordTable(Opm::DeckKeywordConstPtr keyword,
|
||||
MultiRecordTable(Opm::DeckKeywordConstPtr keyword,
|
||||
const std::vector<std::string> &columnNames,
|
||||
size_t tableIndex,
|
||||
size_t firstEntityOffset = 0);
|
||||
@@ -59,15 +65,15 @@ namespace Opm {
|
||||
{ return m_numRecords; }
|
||||
|
||||
private:
|
||||
size_t getNumFlatItems_(Opm::DeckRecordConstPtr deckRecord) const;
|
||||
static size_t getNumFlatItems_(Opm::DeckRecordConstPtr deckRecord);
|
||||
double getFlatSiDoubleData_(Opm::DeckRecordConstPtr deckRecord, unsigned flatItemIdx) const;
|
||||
|
||||
size_t m_firstRecordIdx;
|
||||
size_t m_numRecords;
|
||||
};
|
||||
|
||||
typedef std::shared_ptr<SimpleMultiRecordTable> SimpleMultiRecordTablePtr;
|
||||
typedef std::shared_ptr<const SimpleMultiRecordTable> SimpleMultiRecordTableConstPtr;
|
||||
typedef std::shared_ptr<MultiRecordTable> MultiRecordTablePtr;
|
||||
typedef std::shared_ptr<const MultiRecordTable> MultiRecordTableConstPtr;
|
||||
|
||||
}
|
||||
|
||||
@@ -19,13 +19,15 @@
|
||||
#ifndef OPM_PARSER_PLYADS_TABLE_HPP
|
||||
#define OPM_PARSER_PLYADS_TABLE_HPP
|
||||
|
||||
#include "SimpleTable.hpp"
|
||||
#include "SingleRecordTable.hpp"
|
||||
|
||||
namespace Opm {
|
||||
class PlyadsTable : protected SimpleTable {
|
||||
typedef SimpleTable ParentType;
|
||||
class PlyadsTable : protected SingleRecordTable {
|
||||
typedef SingleRecordTable ParentType;
|
||||
|
||||
public:
|
||||
using ParentType::numTables;
|
||||
|
||||
/*!
|
||||
* \brief Read the PLYADS keyword and provide some convenience
|
||||
* methods for it.
|
||||
|
||||
@@ -19,13 +19,15 @@
|
||||
#ifndef OPM_PARSER_PLYMAX_TABLE_HPP
|
||||
#define OPM_PARSER_PLYMAX_TABLE_HPP
|
||||
|
||||
#include "SimpleTable.hpp"
|
||||
#include "SingleRecordTable.hpp"
|
||||
|
||||
namespace Opm {
|
||||
class PlymaxTable : protected SimpleTable {
|
||||
typedef SimpleTable ParentType;
|
||||
class PlymaxTable : protected SingleRecordTable {
|
||||
typedef SingleRecordTable ParentType;
|
||||
|
||||
public:
|
||||
using ParentType::numTables;
|
||||
|
||||
/*!
|
||||
* \brief Read the PLYMAX keyword and provide some convenience
|
||||
* methods for it.
|
||||
|
||||
@@ -19,13 +19,15 @@
|
||||
#ifndef OPM_PARSER_PLYROCK_TABLE_HPP
|
||||
#define OPM_PARSER_PLYROCK_TABLE_HPP
|
||||
|
||||
#include "SimpleTable.hpp"
|
||||
#include "SingleRecordTable.hpp"
|
||||
|
||||
namespace Opm {
|
||||
class PlyrockTable : protected SimpleTable {
|
||||
typedef SimpleTable ParentType;
|
||||
class PlyrockTable : protected SingleRecordTable {
|
||||
typedef SingleRecordTable ParentType;
|
||||
|
||||
public:
|
||||
using ParentType::numTables;
|
||||
|
||||
/*!
|
||||
* \brief Read the PLYROCK keyword and provide some convenience
|
||||
* methods for it.
|
||||
|
||||
@@ -19,13 +19,15 @@
|
||||
#ifndef OPM_PARSER_PLYVISC_TABLE_HPP
|
||||
#define OPM_PARSER_PLYVISC_TABLE_HPP
|
||||
|
||||
#include "SimpleTable.hpp"
|
||||
#include "SingleRecordTable.hpp"
|
||||
|
||||
namespace Opm {
|
||||
class PlyviscTable : protected SimpleTable {
|
||||
typedef SimpleTable ParentType;
|
||||
class PlyviscTable : protected SingleRecordTable {
|
||||
typedef SingleRecordTable ParentType;
|
||||
|
||||
public:
|
||||
using ParentType::numTables;
|
||||
|
||||
/*!
|
||||
* \brief Read the PLYVISC keyword and provide some convenience
|
||||
* methods for it.
|
||||
|
||||
@@ -19,13 +19,15 @@
|
||||
#ifndef OPM_PARSER_PVCDO_TABLE_HPP
|
||||
#define OPM_PARSER_PVCDO_TABLE_HPP
|
||||
|
||||
#include "SimpleTable.hpp"
|
||||
#include "SingleRecordTable.hpp"
|
||||
|
||||
namespace Opm {
|
||||
class PvcdoTable : protected SimpleTable {
|
||||
typedef SimpleTable ParentType;
|
||||
class PvcdoTable : protected SingleRecordTable {
|
||||
typedef SingleRecordTable ParentType;
|
||||
|
||||
public:
|
||||
using ParentType::numTables;
|
||||
|
||||
/*!
|
||||
* \brief Read the PVCDO keyword and provide some convenience
|
||||
* methods for it.
|
||||
@@ -33,7 +35,7 @@ namespace Opm {
|
||||
PvcdoTable(Opm::DeckKeywordConstPtr keyword,
|
||||
int recordIdx = 0,
|
||||
int firstEntityOffset = 0)
|
||||
: SimpleTable(keyword,
|
||||
: SingleRecordTable(keyword,
|
||||
std::vector<std::string>{"P", "BW", "CW", "MUW", "CMUW"},
|
||||
recordIdx, firstEntityOffset)
|
||||
{}
|
||||
|
||||
@@ -19,13 +19,15 @@
|
||||
#ifndef OPM_PARSER_PVDG_TABLE_HPP
|
||||
#define OPM_PARSER_PVDG_TABLE_HPP
|
||||
|
||||
#include "SimpleTable.hpp"
|
||||
#include "SingleRecordTable.hpp"
|
||||
|
||||
namespace Opm {
|
||||
class PvdgTable : protected SimpleTable {
|
||||
typedef SimpleTable ParentType;
|
||||
class PvdgTable : protected SingleRecordTable {
|
||||
typedef SingleRecordTable ParentType;
|
||||
|
||||
public:
|
||||
using ParentType::numTables;
|
||||
|
||||
/*!
|
||||
* \brief Read the PVDG keyword and provide some convenience
|
||||
* methods for it.
|
||||
@@ -33,7 +35,7 @@ namespace Opm {
|
||||
PvdgTable(Opm::DeckKeywordConstPtr keyword,
|
||||
int recordIdx = 0,
|
||||
int firstEntityOffset = 0)
|
||||
: SimpleTable(keyword,
|
||||
: SingleRecordTable(keyword,
|
||||
std::vector<std::string>{"P", "BG", "MUG"},
|
||||
recordIdx, firstEntityOffset)
|
||||
{}
|
||||
|
||||
@@ -19,13 +19,15 @@
|
||||
#ifndef OPM_PARSER_PVDO_TABLE_HPP
|
||||
#define OPM_PARSER_PVDO_TABLE_HPP
|
||||
|
||||
#include "SimpleTable.hpp"
|
||||
#include "SingleRecordTable.hpp"
|
||||
|
||||
namespace Opm {
|
||||
class PvdoTable : protected SimpleTable {
|
||||
typedef SimpleTable ParentType;
|
||||
class PvdoTable : protected SingleRecordTable {
|
||||
typedef SingleRecordTable ParentType;
|
||||
|
||||
public:
|
||||
using ParentType::numTables;
|
||||
|
||||
/*!
|
||||
* \brief Read the PVDO keyword and provide some convenience
|
||||
* methods for it.
|
||||
@@ -33,7 +35,7 @@ namespace Opm {
|
||||
PvdoTable(Opm::DeckKeywordConstPtr keyword,
|
||||
int recordIdx = 0,
|
||||
int firstEntityOffset = 0)
|
||||
: SimpleTable(keyword,
|
||||
: SingleRecordTable(keyword,
|
||||
std::vector<std::string>{"P", "BO", "MUO"},
|
||||
recordIdx, firstEntityOffset)
|
||||
{}
|
||||
|
||||
@@ -19,13 +19,15 @@
|
||||
#ifndef OPM_PARSER_PVTG_INNER_TABLE_HPP
|
||||
#define OPM_PARSER_PVTG_INNER_TABLE_HPP
|
||||
|
||||
#include "SimpleTable.hpp"
|
||||
#include "SingleRecordTable.hpp"
|
||||
|
||||
namespace Opm {
|
||||
class PvtgInnerTable : protected SimpleTable {
|
||||
typedef SimpleTable ParentType;
|
||||
class PvtgInnerTable : protected SingleRecordTable {
|
||||
typedef SingleRecordTable ParentType;
|
||||
|
||||
public:
|
||||
using ParentType::numTables;
|
||||
|
||||
/*!
|
||||
* \brief Read the per record table of the PVTG keyword and
|
||||
* provide some convenience methods for it.
|
||||
@@ -33,7 +35,7 @@ namespace Opm {
|
||||
* The first value of the record (-> Rv) is skipped.
|
||||
*/
|
||||
PvtgInnerTable(Opm::DeckKeywordConstPtr keyword, size_t recordIdx = 0)
|
||||
: SimpleTable(keyword,
|
||||
: SingleRecordTable(keyword,
|
||||
std::vector<std::string>{"RV", "BG", "MUG"},
|
||||
recordIdx, 1U)
|
||||
{}
|
||||
|
||||
@@ -19,13 +19,15 @@
|
||||
#ifndef OPM_PARSER_PVTG_OUTER_TABLE_HPP
|
||||
#define OPM_PARSER_PVTG_OUTER_TABLE_HPP
|
||||
|
||||
#include "SimpleMultiRecordTable.hpp"
|
||||
#include "MultiRecordTable.hpp"
|
||||
|
||||
namespace Opm {
|
||||
class PvtgOuterTable : protected SimpleMultiRecordTable {
|
||||
typedef SimpleMultiRecordTable ParentType;
|
||||
class PvtgOuterTable : protected MultiRecordTable {
|
||||
typedef MultiRecordTable ParentType;
|
||||
|
||||
public:
|
||||
using ParentType::numTables;
|
||||
|
||||
/*!
|
||||
* \brief Read the per record table of the PVTG keyword and
|
||||
* provide some convenience methods for it.
|
||||
|
||||
@@ -32,6 +32,8 @@ namespace Opm {
|
||||
typedef Opm::FullTable<Opm::PvtgOuterTable, Opm::PvtgInnerTable> ParentType;
|
||||
|
||||
public:
|
||||
using ParentType::numTables;
|
||||
|
||||
/*!
|
||||
* \brief Read the table for the PVTG and provide convenient access to it.
|
||||
*/
|
||||
|
||||
@@ -19,13 +19,15 @@
|
||||
#ifndef OPM_PARSER_PVTO_INNER_TABLE_HPP
|
||||
#define OPM_PARSER_PVTO_INNER_TABLE_HPP
|
||||
|
||||
#include "SimpleTable.hpp"
|
||||
#include "SingleRecordTable.hpp"
|
||||
|
||||
namespace Opm {
|
||||
class PvtoInnerTable : protected SimpleTable {
|
||||
typedef SimpleTable ParentType;
|
||||
class PvtoInnerTable : protected SingleRecordTable {
|
||||
typedef SingleRecordTable ParentType;
|
||||
|
||||
public:
|
||||
using ParentType::numTables;
|
||||
|
||||
/*!
|
||||
* \brief Read the per record table of the PVTO keyword and
|
||||
* provide some convenience methods for it.
|
||||
@@ -33,7 +35,7 @@ namespace Opm {
|
||||
* The first value of the record (-> Rs) is skipped.
|
||||
*/
|
||||
PvtoInnerTable(Opm::DeckKeywordConstPtr keyword, int recordIdx = 0)
|
||||
: SimpleTable(keyword,
|
||||
: SingleRecordTable(keyword,
|
||||
std::vector<std::string>{"P", "BO", "MU"},
|
||||
recordIdx, /*firstEntityOffset=*/1)
|
||||
{}
|
||||
|
||||
@@ -19,13 +19,15 @@
|
||||
#ifndef OPM_PARSER_PVTO_OUTER_TABLE_HPP
|
||||
#define OPM_PARSER_PVTO_OUTER_TABLE_HPP
|
||||
|
||||
#include "SimpleMultiRecordTable.hpp"
|
||||
#include "MultiRecordTable.hpp"
|
||||
|
||||
namespace Opm {
|
||||
class PvtoOuterTable : protected SimpleMultiRecordTable {
|
||||
typedef SimpleMultiRecordTable ParentType;
|
||||
class PvtoOuterTable : protected MultiRecordTable {
|
||||
typedef MultiRecordTable ParentType;
|
||||
|
||||
public:
|
||||
using ParentType::numTables;
|
||||
|
||||
/*!
|
||||
* \brief Read the per record table of the PVTO keyword and
|
||||
* provide some convenience methods for it.
|
||||
|
||||
@@ -32,6 +32,8 @@ namespace Opm {
|
||||
typedef Opm::FullTable<Opm::PvtoOuterTable, Opm::PvtoInnerTable> ParentType;
|
||||
|
||||
public:
|
||||
using ParentType::numTables;
|
||||
|
||||
/*!
|
||||
* \brief Read the table for the PVTO and provide convenient access to it.
|
||||
*/
|
||||
|
||||
@@ -19,13 +19,15 @@
|
||||
#ifndef OPM_PARSER_PVTW_TABLE_HPP
|
||||
#define OPM_PARSER_PVTW_TABLE_HPP
|
||||
|
||||
#include "SimpleTable.hpp"
|
||||
#include "SingleRecordTable.hpp"
|
||||
|
||||
namespace Opm {
|
||||
class PvtwTable : protected SimpleTable {
|
||||
typedef SimpleTable ParentType;
|
||||
class PvtwTable : protected SingleRecordTable {
|
||||
typedef SingleRecordTable ParentType;
|
||||
|
||||
public:
|
||||
using ParentType::numTables;
|
||||
|
||||
/*!
|
||||
* \brief Read the PVTW keyword and provide some convenience
|
||||
* methods for it.
|
||||
@@ -33,7 +35,7 @@ namespace Opm {
|
||||
PvtwTable(Opm::DeckKeywordConstPtr keyword,
|
||||
int recordIdx = 0,
|
||||
int firstEntityOffset = 0)
|
||||
: SimpleTable(keyword,
|
||||
: SingleRecordTable(keyword,
|
||||
std::vector<std::string>{"P", "BW", "CW", "MUW", "CMUW"},
|
||||
recordIdx, firstEntityOffset)
|
||||
{}
|
||||
|
||||
@@ -19,13 +19,15 @@
|
||||
#ifndef OPM_PARSER_ROCK_TABLE_HPP
|
||||
#define OPM_PARSER_ROCK_TABLE_HPP
|
||||
|
||||
#include "SimpleTable.hpp"
|
||||
#include "SingleRecordTable.hpp"
|
||||
|
||||
namespace Opm {
|
||||
class RockTable : protected SimpleTable {
|
||||
typedef SimpleTable ParentType;
|
||||
class RockTable : protected SingleRecordTable {
|
||||
typedef SingleRecordTable ParentType;
|
||||
|
||||
public:
|
||||
using ParentType::numTables;
|
||||
|
||||
/*!
|
||||
* \brief Read the ROCK keyword and provide some convenience
|
||||
* methods for it.
|
||||
@@ -33,7 +35,7 @@ namespace Opm {
|
||||
RockTable(Opm::DeckKeywordConstPtr keyword,
|
||||
int recordIdx = 0,
|
||||
int firstEntityOffset = 0)
|
||||
: SimpleTable(keyword,
|
||||
: SingleRecordTable(keyword,
|
||||
std::vector<std::string>{"P_REF", "COMPRESSIBILITY"},
|
||||
recordIdx, firstEntityOffset)
|
||||
{}
|
||||
|
||||
@@ -19,13 +19,15 @@
|
||||
#ifndef OPM_PARSER_ROCKTAB_TABLE_HPP
|
||||
#define OPM_PARSER_ROCKTAB_TABLE_HPP
|
||||
|
||||
#include "SimpleTable.hpp"
|
||||
#include "SingleRecordTable.hpp"
|
||||
|
||||
namespace Opm {
|
||||
class RocktabTable : protected SimpleTable {
|
||||
typedef SimpleTable ParentType;
|
||||
class RocktabTable : protected SingleRecordTable {
|
||||
typedef SingleRecordTable ParentType;
|
||||
|
||||
public:
|
||||
using ParentType::numTables;
|
||||
|
||||
/*!
|
||||
* \brief Read the ROCKTAB keyword and provide some convenience
|
||||
* methods for it.
|
||||
@@ -34,7 +36,7 @@ namespace Opm {
|
||||
bool isDirectional,
|
||||
int recordIdx = 0,
|
||||
int firstEntityOffset = 0)
|
||||
: SimpleTable(keyword,
|
||||
: SingleRecordTable(keyword,
|
||||
isDirectional
|
||||
? std::vector<std::string>{"PO", "PV_MULT", "TRANSMIS_MULT_X", "TRANSMIS_MULT_Y", "TRANSMIS_MULT_Z"}
|
||||
: std::vector<std::string>{"PO", "PV_MULT", "TRANSMIS_MULT"},
|
||||
|
||||
@@ -19,13 +19,15 @@
|
||||
#ifndef OPM_PARSER_SGOF_TABLE_HPP
|
||||
#define OPM_PARSER_SGOF_TABLE_HPP
|
||||
|
||||
#include "SimpleTable.hpp"
|
||||
#include "SingleRecordTable.hpp"
|
||||
|
||||
namespace Opm {
|
||||
class SgofTable : protected SimpleTable {
|
||||
typedef SimpleTable ParentType;
|
||||
class SgofTable : protected SingleRecordTable {
|
||||
typedef SingleRecordTable ParentType;
|
||||
|
||||
public:
|
||||
using ParentType::numTables;
|
||||
|
||||
/*!
|
||||
* \brief Read the SGOF keyword and provide some convenience
|
||||
* methods for it.
|
||||
@@ -33,7 +35,7 @@ namespace Opm {
|
||||
SgofTable(Opm::DeckKeywordConstPtr keyword,
|
||||
int recordIdx = 0,
|
||||
int firstEntityOffset = 0)
|
||||
: SimpleTable(keyword,
|
||||
: SingleRecordTable(keyword,
|
||||
std::vector<std::string>{"SG", "KRG", "KROG", "PCOG"},
|
||||
recordIdx, firstEntityOffset)
|
||||
{}
|
||||
@@ -53,6 +55,10 @@ namespace Opm {
|
||||
const std::vector<double> &getKrogColumn() const
|
||||
{ return ParentType::getColumn(2); }
|
||||
|
||||
// this column is p_g - p_o (non-wetting phase pressure minus
|
||||
// wetting phase pressure for a given gas saturation. the name
|
||||
// is inconsistent, but it is the one used in the Eclipse
|
||||
// manual...)
|
||||
const std::vector<double> &getPcogColumn() const
|
||||
{ return ParentType::getColumn(3); }
|
||||
};
|
||||
|
||||
@@ -16,11 +16,11 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <opm/parser/eclipse/Utility/SimpleTable.hpp>
|
||||
#include <opm/parser/eclipse/Utility/SingleRecordTable.hpp>
|
||||
|
||||
namespace Opm {
|
||||
// create table from single record
|
||||
SimpleTable::SimpleTable(Opm::DeckKeywordConstPtr keyword,
|
||||
SingleRecordTable::SingleRecordTable(Opm::DeckKeywordConstPtr keyword,
|
||||
const std::vector<std::string> &columnNames,
|
||||
size_t recordIdx,
|
||||
size_t firstEntityOffset)
|
||||
@@ -47,7 +47,7 @@ SimpleTable::SimpleTable(Opm::DeckKeywordConstPtr keyword,
|
||||
}
|
||||
}
|
||||
|
||||
void SimpleTable::createColumns_(const std::vector<std::string> &columnNames)
|
||||
void SingleRecordTable::createColumns_(const std::vector<std::string> &columnNames)
|
||||
{
|
||||
// Allocate column names. TODO (?): move the column names into
|
||||
// the json description of the keyword.
|
||||
@@ -60,7 +60,7 @@ void SimpleTable::createColumns_(const std::vector<std::string> &columnNames)
|
||||
m_columns.resize(columnIdx);
|
||||
}
|
||||
|
||||
size_t SimpleTable::getNumFlatItems_(Opm::DeckRecordConstPtr deckRecord) const
|
||||
size_t SingleRecordTable::getNumFlatItems_(Opm::DeckRecordConstPtr deckRecord) const
|
||||
{
|
||||
size_t result = 0;
|
||||
for (size_t i = 0; i < deckRecord->size(); ++ i) {
|
||||
@@ -70,7 +70,7 @@ size_t SimpleTable::getNumFlatItems_(Opm::DeckRecordConstPtr deckRecord) const
|
||||
return result;
|
||||
}
|
||||
|
||||
double SimpleTable::getFlatSiDoubleData_(Opm::DeckRecordConstPtr deckRecord, size_t flatItemIdx) const
|
||||
double SingleRecordTable::getFlatSiDoubleData_(Opm::DeckRecordConstPtr deckRecord, size_t flatItemIdx) const
|
||||
{
|
||||
size_t itemFirstFlatIdx = 0;
|
||||
for (unsigned i = 0; i < deckRecord->size(); ++ i) {
|
||||
@@ -16,8 +16,8 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef OPM_PARSER_SIMPLE_TABLE_HPP
|
||||
#define OPM_PARSER_SIMPLE_TABLE_HPP
|
||||
#ifndef OPM_PARSER_SINGLE_RECORD_TABLE_HPP
|
||||
#define OPM_PARSER_SINGLE_RECORD_TABLE_HPP
|
||||
|
||||
#include <opm/parser/eclipse/Deck/DeckKeyword.hpp>
|
||||
|
||||
@@ -28,25 +28,34 @@
|
||||
#include <cassert>
|
||||
|
||||
namespace Opm {
|
||||
class SimpleTable {
|
||||
class SingleRecordTable {
|
||||
protected:
|
||||
// protected default constructor for the derived classes
|
||||
SimpleTable() {}
|
||||
SingleRecordTable() {}
|
||||
|
||||
public:
|
||||
/*!
|
||||
* \brief Returns the number of tables in a keyword.
|
||||
*
|
||||
* For simple tables, that is identical to the number of
|
||||
* records.
|
||||
*/
|
||||
static size_t numTables(Opm::DeckKeywordConstPtr keyword)
|
||||
{ return keyword->size(); }
|
||||
|
||||
/*!
|
||||
* \brief Read simple tables from keywords like SWOF
|
||||
*
|
||||
* This requires all data to be a list of doubles in the first
|
||||
* item of a given record index.
|
||||
*/
|
||||
SimpleTable(Opm::DeckKeywordConstPtr keyword,
|
||||
SingleRecordTable(Opm::DeckKeywordConstPtr keyword,
|
||||
const std::vector<std::string> &columnNames,
|
||||
size_t recordIdx = 0,
|
||||
size_t firstEntityOffset = 0);
|
||||
|
||||
// constructor to make the base class compatible with specialized table implementations
|
||||
SimpleTable(Opm::DeckKeywordConstPtr /* keyword */,
|
||||
SingleRecordTable(Opm::DeckKeywordConstPtr /* keyword */,
|
||||
size_t /* recordIdx = 0 */,
|
||||
size_t /* firstEntityOffset = 0 */)
|
||||
{
|
||||
@@ -86,8 +95,8 @@ namespace Opm {
|
||||
std::vector<std::vector<double> > m_columns;
|
||||
};
|
||||
|
||||
typedef std::shared_ptr<SimpleTable> SimpleTablePtr;
|
||||
typedef std::shared_ptr<const SimpleTable> SimpleTableConstPtr;
|
||||
typedef std::shared_ptr<SingleRecordTable> SingleRecordTablePtr;
|
||||
typedef std::shared_ptr<const SingleRecordTable> SingleRecordTableConstPtr;
|
||||
}
|
||||
|
||||
#endif // OPM_PARSER_SIMPLE_TABLE_HPP
|
||||
@@ -19,13 +19,15 @@
|
||||
#ifndef OPM_PARSER_SWOF_TABLE_HPP
|
||||
#define OPM_PARSER_SWOF_TABLE_HPP
|
||||
|
||||
#include "SimpleTable.hpp"
|
||||
#include "SingleRecordTable.hpp"
|
||||
|
||||
namespace Opm {
|
||||
class SwofTable : protected SimpleTable {
|
||||
typedef SimpleTable ParentType;
|
||||
class SwofTable : protected SingleRecordTable {
|
||||
typedef SingleRecordTable ParentType;
|
||||
|
||||
public:
|
||||
using ParentType::numTables;
|
||||
|
||||
/*!
|
||||
* \brief Read the SWOF keyword and provide some convenience
|
||||
* methods for it.
|
||||
@@ -33,7 +35,7 @@ namespace Opm {
|
||||
SwofTable(Opm::DeckKeywordConstPtr keyword,
|
||||
int recordIdx = 0,
|
||||
int firstEntityOffset = 0)
|
||||
: SimpleTable(keyword,
|
||||
: SingleRecordTable(keyword,
|
||||
std::vector<std::string>{"SW", "KRW", "KROW", "PCOW"},
|
||||
recordIdx, firstEntityOffset)
|
||||
{}
|
||||
@@ -53,6 +55,8 @@ namespace Opm {
|
||||
const std::vector<double> &getKrowColumn() const
|
||||
{ return ParentType::getColumn(2); }
|
||||
|
||||
// this column is p_o - p_w (non-wetting phase pressure minus
|
||||
// wetting phase pressure for a given water saturation)
|
||||
const std::vector<double> &getPcowColumn() const
|
||||
{ return ParentType::getColumn(3); }
|
||||
};
|
||||
|
||||
@@ -19,13 +19,15 @@
|
||||
#ifndef OPM_PARSER_TLMIXPAR_TABLE_HPP
|
||||
#define OPM_PARSER_TLMIXPAR_TABLE_HPP
|
||||
|
||||
#include "SimpleTable.hpp"
|
||||
#include "SingleRecordTable.hpp"
|
||||
|
||||
namespace Opm {
|
||||
class TlmixparTable : protected SimpleTable {
|
||||
typedef SimpleTable ParentType;
|
||||
class TlmixparTable : protected SingleRecordTable {
|
||||
typedef SingleRecordTable ParentType;
|
||||
|
||||
public:
|
||||
using ParentType::numTables;
|
||||
|
||||
/*!
|
||||
* \brief Read the TLMIXPAR keyword and provide some convenience
|
||||
* methods for it.
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
add_executable(runSimpleTableTests SimpleTableTests.cpp)
|
||||
target_link_libraries(runSimpleTableTests Parser ${Boost_LIBRARIES})
|
||||
add_test(NAME runSimpleTableTests WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} COMMAND ${TEST_MEMCHECK_TOOL} ${EXECUTABLE_OUTPUT_PATH}/runTimeMapTests )
|
||||
add_executable(runTableTests TableTests.cpp)
|
||||
target_link_libraries(runTableTests Parser ${Boost_LIBRARIES})
|
||||
add_test(NAME runTableTests WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} COMMAND ${TEST_MEMCHECK_TOOL} ${EXECUTABLE_OUTPUT_PATH}/runTableTests )
|
||||
|
||||
@@ -1,49 +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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <opm/parser/eclipse/Deck/Deck.hpp>
|
||||
#include <opm/parser/eclipse/Deck/DeckDoubleItem.hpp>
|
||||
#include <opm/parser/eclipse/Utility/SimpleTable.hpp>
|
||||
|
||||
#define BOOST_TEST_MODULE SimpleTableTests
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
#include <stdexcept>
|
||||
#include <iostream>
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(CreateSimpleTable_InvalidDeck) {
|
||||
Opm::DeckKeywordPtr keyword(new Opm::DeckKeyword("SWOF"));
|
||||
Opm::DeckRecordPtr record(new Opm::DeckRecord());
|
||||
Opm::DeckDoubleItemPtr item = Opm::DeckDoubleItemPtr(new Opm::DeckDoubleItem(/*name=*/"foo"));
|
||||
|
||||
item->push_back(1);
|
||||
item->push_back(2);
|
||||
item->push_back(3);
|
||||
|
||||
record->addItem(item);
|
||||
keyword->addRecord(record);
|
||||
|
||||
std::vector<std::string> columnNames{"SW", "KRW", "KROW", "PCOW"};
|
||||
|
||||
BOOST_CHECK_THROW(Opm::SimpleTable(keyword, columnNames, /*recordIdx=*/0) , std::runtime_error);
|
||||
}
|
||||
|
||||
254
opm/parser/eclipse/Utility/tests/TableTests.cpp
Normal file
254
opm/parser/eclipse/Utility/tests/TableTests.cpp
Normal file
@@ -0,0 +1,254 @@
|
||||
/*
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <opm/parser/eclipse/Parser/Parser.hpp>
|
||||
#include <opm/parser/eclipse/Deck/Deck.hpp>
|
||||
|
||||
// generic table classes
|
||||
#include <opm/parser/eclipse/Utility/SingleRecordTable.hpp>
|
||||
#include <opm/parser/eclipse/Utility/MultiRecordTable.hpp>
|
||||
#include <opm/parser/eclipse/Utility/FullTable.hpp>
|
||||
|
||||
// keyword specific table classes
|
||||
#include <opm/parser/eclipse/Utility/PvtoTable.hpp>
|
||||
#include <opm/parser/eclipse/Utility/SwofTable.hpp>
|
||||
#include <opm/parser/eclipse/Utility/SgofTable.hpp>
|
||||
|
||||
#define BOOST_TEST_MODULE SingleRecordTableTests
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
#include <stdexcept>
|
||||
#include <iostream>
|
||||
|
||||
BOOST_AUTO_TEST_CASE(CreateSingleRecordTable) {
|
||||
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));
|
||||
|
||||
std::vector<std::string> tooFewColumnNames{"A", "B", "C"};
|
||||
std::vector<std::string> justRightColumnNames{"A", "B", "C", "D"};
|
||||
std::vector<std::string> tooManyColumnNames{"A", "B", "C", "D", "E"};
|
||||
|
||||
BOOST_CHECK_EQUAL(Opm::SingleRecordTable::numTables(deck->getKeyword("SWOF")), 2);
|
||||
BOOST_CHECK_THROW(Opm::SingleRecordTable(deck->getKeyword("SWOF"),
|
||||
tooFewColumnNames,
|
||||
/*recordIdx=*/0),
|
||||
std::runtime_error);
|
||||
BOOST_CHECK_THROW(Opm::SingleRecordTable(deck->getKeyword("SWOF"),
|
||||
tooManyColumnNames,
|
||||
/*recordIdx=*/0),
|
||||
std::runtime_error);
|
||||
|
||||
Opm::SingleRecordTable foo(deck->getKeyword("SWOF"),
|
||||
justRightColumnNames,
|
||||
/*recordIdx=*/0);
|
||||
}
|
||||
|
||||
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));
|
||||
|
||||
std::vector<std::string> tooFewColumnNames{"A", "B", "C"};
|
||||
std::vector<std::string> justRightColumnNames{"A", "B", "C", "D"};
|
||||
std::vector<std::string> 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);
|
||||
*/
|
||||
BOOST_CHECK_THROW(Opm::MultiRecordTable(deck->getKeyword("PVTO"),
|
||||
tooManyColumnNames,
|
||||
/*tableIdx=*/0),
|
||||
std::runtime_error);
|
||||
|
||||
Opm::MultiRecordTable foo(deck->getKeyword("PVTO"),
|
||||
justRightColumnNames,
|
||||
/*recordIdx=*/0);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(SwofTable_Tests) {
|
||||
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"
|
||||
" 13 14 15 16\n"
|
||||
" 17 18 19 20/\n";
|
||||
|
||||
Opm::ParserPtr parser(new Opm::Parser);
|
||||
Opm::DeckConstPtr deck(parser->parseString(deckData));
|
||||
Opm::DeckKeywordConstPtr swofKeyword = deck->getKeyword("SWOF");
|
||||
|
||||
BOOST_CHECK_EQUAL(Opm::SwofTable::numTables(swofKeyword), 2);
|
||||
|
||||
Opm::SwofTable swof1Table(deck->getKeyword("SWOF"), /*tableIdx=*/0);
|
||||
Opm::SwofTable swof2Table(deck->getKeyword("SWOF"), /*tableIdx=*/1);
|
||||
|
||||
BOOST_CHECK_EQUAL(swof1Table.numRows(), 2);
|
||||
BOOST_CHECK_EQUAL(swof2Table.numRows(), 3);
|
||||
|
||||
BOOST_CHECK_EQUAL(swof1Table.numColumns(), 4);
|
||||
BOOST_CHECK_EQUAL(swof2Table.numColumns(), 4);
|
||||
|
||||
BOOST_CHECK_EQUAL(swof1Table.getSwColumn().front(), 1.0);
|
||||
BOOST_CHECK_EQUAL(swof1Table.getSwColumn().back(), 5.0);
|
||||
|
||||
BOOST_CHECK_EQUAL(swof1Table.getKrwColumn().front(), 2.0);
|
||||
BOOST_CHECK_EQUAL(swof1Table.getKrwColumn().back(), 6.0);
|
||||
|
||||
BOOST_CHECK_EQUAL(swof1Table.getKrowColumn().front(), 3.0);
|
||||
BOOST_CHECK_EQUAL(swof1Table.getKrowColumn().back(), 7.0);
|
||||
|
||||
BOOST_CHECK_EQUAL(swof1Table.getPcowColumn().front(), 4.0e5);
|
||||
BOOST_CHECK_EQUAL(swof1Table.getPcowColumn().back(), 8.0e5);
|
||||
|
||||
// for the second table, we only check the first column and trust
|
||||
// that everything else is fine...
|
||||
BOOST_CHECK_EQUAL(swof2Table.getSwColumn().front(), 9.0);
|
||||
BOOST_CHECK_EQUAL(swof2Table.getSwColumn().back(), 17.0);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(SgofTable_Tests) {
|
||||
const char *deckData =
|
||||
"TABDIMS\n"
|
||||
"2 /\n"
|
||||
"\n"
|
||||
"SGOF\n"
|
||||
" 1 2 3 4\n"
|
||||
" 5 6 7 8/\n"
|
||||
" 9 10 11 12\n"
|
||||
" 13 14 15 16\n"
|
||||
" 17 18 19 20/\n";
|
||||
|
||||
Opm::ParserPtr parser(new Opm::Parser);
|
||||
Opm::DeckConstPtr deck(parser->parseString(deckData));
|
||||
Opm::DeckKeywordConstPtr sgofKeyword = deck->getKeyword("SGOF");
|
||||
|
||||
BOOST_CHECK_EQUAL(Opm::SgofTable::numTables(sgofKeyword), 2);
|
||||
|
||||
Opm::SgofTable sgof1Table(deck->getKeyword("SGOF"), /*tableIdx=*/0);
|
||||
Opm::SgofTable sgof2Table(deck->getKeyword("SGOF"), /*tableIdx=*/1);
|
||||
|
||||
BOOST_CHECK_EQUAL(sgof1Table.numRows(), 2);
|
||||
BOOST_CHECK_EQUAL(sgof2Table.numRows(), 3);
|
||||
|
||||
BOOST_CHECK_EQUAL(sgof1Table.numColumns(), 4);
|
||||
BOOST_CHECK_EQUAL(sgof2Table.numColumns(), 4);
|
||||
|
||||
BOOST_CHECK_EQUAL(sgof1Table.getSgColumn().front(), 1.0);
|
||||
BOOST_CHECK_EQUAL(sgof1Table.getSgColumn().back(), 5.0);
|
||||
|
||||
BOOST_CHECK_EQUAL(sgof1Table.getKrgColumn().front(), 2.0);
|
||||
BOOST_CHECK_EQUAL(sgof1Table.getKrgColumn().back(), 6.0);
|
||||
|
||||
BOOST_CHECK_EQUAL(sgof1Table.getKrogColumn().front(), 3.0);
|
||||
BOOST_CHECK_EQUAL(sgof1Table.getKrogColumn().back(), 7.0);
|
||||
|
||||
BOOST_CHECK_EQUAL(sgof1Table.getPcogColumn().front(), 4.0e5);
|
||||
BOOST_CHECK_EQUAL(sgof1Table.getPcogColumn().back(), 8.0e5);
|
||||
|
||||
// for the second table, we only check the first column and trust
|
||||
// that everything else is fine...
|
||||
BOOST_CHECK_EQUAL(sgof2Table.getSgColumn().front(), 9.0);
|
||||
BOOST_CHECK_EQUAL(sgof2Table.getSgColumn().back(), 17.0);
|
||||
}
|
||||
|
||||
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::DeckKeywordConstPtr pvtoKeyword = deck->getKeyword("PVTO");
|
||||
|
||||
BOOST_CHECK_EQUAL(Opm::PvtoTable::numTables(pvtoKeyword), 2);
|
||||
|
||||
Opm::PvtoTable pvto1Table(deck->getKeyword("PVTO"), /*tableIdx=*/0);
|
||||
Opm::PvtoTable pvto2Table(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);
|
||||
}
|
||||
Reference in New Issue
Block a user