add class for simple tables
This is intended for keywords like SWOF which currently is a big
vector of doubles but one needs to use the data in a column oriented
way.
This class is intended to be used like this:
Opm::DeckKeywordConstPtr swofKeyword = newParserDeck->getKeyword("SWOF");
Opm::SimpleTable swofTable(swofKeyword,
/*columns=*/std::vector<std::string>{"SW", "KRW", "KROW", "PCOW"},
/*recordIdx=*/table_num);
const std::vector<double>& sw = swofTable.getColumn(0);
// ...
what might be useful is to move the column names into the JSON
description of the keywords, but I could not find a way to go back to
the parser from the deck/keyword. maybe this is not even desireable as
decks might also be created by other means...
Also, a multi-record variant of the class is available. That one is
intended for keywords like PVTO where the first few items of each
record form a table (in the case of PVTO: Rs, pressure, Bo, and
viscosity for staturated oil) and the next entries constitute another
table (in the case of PVTO: pressure, Bo and viscosity for
undersaturated oil with the same RS factor as the first entry).
The second kind of tables can be constructed using the item-based
variant of SimpleTable.
2013-12-16 13:45:02 +01:00
|
|
|
/*
|
|
|
|
|
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/>.
|
|
|
|
|
*/
|
2015-09-06 22:47:48 +02:00
|
|
|
#ifndef OPM_PARSER_SIMPLE_TABLE_HPP
|
|
|
|
|
#define OPM_PARSER_SIMPLE_TABLE_HPP
|
add class for simple tables
This is intended for keywords like SWOF which currently is a big
vector of doubles but one needs to use the data in a column oriented
way.
This class is intended to be used like this:
Opm::DeckKeywordConstPtr swofKeyword = newParserDeck->getKeyword("SWOF");
Opm::SimpleTable swofTable(swofKeyword,
/*columns=*/std::vector<std::string>{"SW", "KRW", "KROW", "PCOW"},
/*recordIdx=*/table_num);
const std::vector<double>& sw = swofTable.getColumn(0);
// ...
what might be useful is to move the column names into the JSON
description of the keywords, but I could not find a way to go back to
the parser from the deck/keyword. maybe this is not even desireable as
decks might also be created by other means...
Also, a multi-record variant of the class is available. That one is
intended for keywords like PVTO where the first few items of each
record form a table (in the case of PVTO: Rs, pressure, Bo, and
viscosity for staturated oil) and the next entries constitute another
table (in the case of PVTO: pressure, Bo and viscosity for
undersaturated oil with the same RS factor as the first entry).
The second kind of tables can be constructed using the item-based
variant of SimpleTable.
2013-12-16 13:45:02 +01:00
|
|
|
|
|
|
|
|
#include <opm/parser/eclipse/Deck/DeckKeyword.hpp>
|
|
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
|
#include <memory>
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <vector>
|
|
|
|
|
#include <cassert>
|
|
|
|
|
|
|
|
|
|
namespace Opm {
|
2015-04-24 17:19:05 +02:00
|
|
|
class PlyshlogTable;
|
2015-09-06 22:47:48 +02:00
|
|
|
class SimpleTable {
|
2015-04-24 17:19:05 +02:00
|
|
|
friend class PlyshlogTable;
|
2014-09-17 14:41:37 +02:00
|
|
|
protected:
|
2015-09-06 22:47:48 +02:00
|
|
|
SimpleTable(const SimpleTable&) = default;
|
2014-04-24 18:33:51 +02:00
|
|
|
|
add class for simple tables
This is intended for keywords like SWOF which currently is a big
vector of doubles but one needs to use the data in a column oriented
way.
This class is intended to be used like this:
Opm::DeckKeywordConstPtr swofKeyword = newParserDeck->getKeyword("SWOF");
Opm::SimpleTable swofTable(swofKeyword,
/*columns=*/std::vector<std::string>{"SW", "KRW", "KROW", "PCOW"},
/*recordIdx=*/table_num);
const std::vector<double>& sw = swofTable.getColumn(0);
// ...
what might be useful is to move the column names into the JSON
description of the keywords, but I could not find a way to go back to
the parser from the deck/keyword. maybe this is not even desireable as
decks might also be created by other means...
Also, a multi-record variant of the class is available. That one is
intended for keywords like PVTO where the first few items of each
record form a table (in the case of PVTO: Rs, pressure, Bo, and
viscosity for staturated oil) and the next entries constitute another
table (in the case of PVTO: pressure, Bo and viscosity for
undersaturated oil with the same RS factor as the first entry).
The second kind of tables can be constructed using the item-based
variant of SimpleTable.
2013-12-16 13:45:02 +01:00
|
|
|
/*!
|
|
|
|
|
* \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.
|
|
|
|
|
*/
|
2015-09-14 16:22:15 +02:00
|
|
|
void init(Opm::DeckItemConstPtr deckItem,
|
|
|
|
|
const std::vector<std::string> &columnNames);
|
add class for simple tables
This is intended for keywords like SWOF which currently is a big
vector of doubles but one needs to use the data in a column oriented
way.
This class is intended to be used like this:
Opm::DeckKeywordConstPtr swofKeyword = newParserDeck->getKeyword("SWOF");
Opm::SimpleTable swofTable(swofKeyword,
/*columns=*/std::vector<std::string>{"SW", "KRW", "KROW", "PCOW"},
/*recordIdx=*/table_num);
const std::vector<double>& sw = swofTable.getColumn(0);
// ...
what might be useful is to move the column names into the JSON
description of the keywords, but I could not find a way to go back to
the parser from the deck/keyword. maybe this is not even desireable as
decks might also be created by other means...
Also, a multi-record variant of the class is available. That one is
intended for keywords like PVTO where the first few items of each
record form a table (in the case of PVTO: Rs, pressure, Bo, and
viscosity for staturated oil) and the next entries constitute another
table (in the case of PVTO: pressure, Bo and viscosity for
undersaturated oil with the same RS factor as the first entry).
The second kind of tables can be constructed using the item-based
variant of SimpleTable.
2013-12-16 13:45:02 +01:00
|
|
|
|
2014-09-17 14:41:37 +02:00
|
|
|
public:
|
2015-09-06 22:47:48 +02:00
|
|
|
SimpleTable() = default;
|
2014-09-17 14:41:37 +02:00
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* \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);
|
|
|
|
|
|
|
|
|
|
#ifdef BOOST_TEST_MODULE
|
|
|
|
|
// DO NOT TRY TO CALL THIS METHOD! it is only for the unit tests!
|
2015-09-14 16:22:15 +02:00
|
|
|
void initFORUNITTESTONLY(Opm::DeckItemConstPtr item,
|
|
|
|
|
const std::vector<std::string> &columnNames)
|
|
|
|
|
{ init(item , columnNames ); }
|
2014-09-17 14:41:37 +02:00
|
|
|
#endif
|
|
|
|
|
|
2014-09-16 13:58:13 +02:00
|
|
|
size_t numColumns() const;
|
|
|
|
|
size_t numRows() const;
|
|
|
|
|
const std::vector<double> &getColumn(const std::string &name) const;
|
|
|
|
|
const std::vector<double> &getColumn(size_t colIdx) const;
|
add class for simple tables
This is intended for keywords like SWOF which currently is a big
vector of doubles but one needs to use the data in a column oriented
way.
This class is intended to be used like this:
Opm::DeckKeywordConstPtr swofKeyword = newParserDeck->getKeyword("SWOF");
Opm::SimpleTable swofTable(swofKeyword,
/*columns=*/std::vector<std::string>{"SW", "KRW", "KROW", "PCOW"},
/*recordIdx=*/table_num);
const std::vector<double>& sw = swofTable.getColumn(0);
// ...
what might be useful is to move the column names into the JSON
description of the keywords, but I could not find a way to go back to
the parser from the deck/keyword. maybe this is not even desireable as
decks might also be created by other means...
Also, a multi-record variant of the class is available. That one is
intended for keywords like PVTO where the first few items of each
record form a table (in the case of PVTO: Rs, pressure, Bo, and
viscosity for staturated oil) and the next entries constitute another
table (in the case of PVTO: pressure, Bo and viscosity for
undersaturated oil with the same RS factor as the first entry).
The second kind of tables can be constructed using the item-based
variant of SimpleTable.
2013-12-16 13:45:02 +01:00
|
|
|
|
2014-09-16 17:15:29 +02:00
|
|
|
/*!
|
|
|
|
|
* \brief Evaluate a column of the table at a given position.
|
|
|
|
|
*
|
|
|
|
|
* This method uses linear interpolation and always uses the first column as the
|
|
|
|
|
* X coordinate.
|
|
|
|
|
*/
|
|
|
|
|
double evaluate(const std::string& columnName, double xPos) const;
|
2015-01-30 14:24:01 +01:00
|
|
|
|
add class for simple tables
This is intended for keywords like SWOF which currently is a big
vector of doubles but one needs to use the data in a column oriented
way.
This class is intended to be used like this:
Opm::DeckKeywordConstPtr swofKeyword = newParserDeck->getKeyword("SWOF");
Opm::SimpleTable swofTable(swofKeyword,
/*columns=*/std::vector<std::string>{"SW", "KRW", "KROW", "PCOW"},
/*recordIdx=*/table_num);
const std::vector<double>& sw = swofTable.getColumn(0);
// ...
what might be useful is to move the column names into the JSON
description of the keywords, but I could not find a way to go back to
the parser from the deck/keyword. maybe this is not even desireable as
decks might also be created by other means...
Also, a multi-record variant of the class is available. That one is
intended for keywords like PVTO where the first few items of each
record form a table (in the case of PVTO: Rs, pressure, Bo, and
viscosity for staturated oil) and the next entries constitute another
table (in the case of PVTO: pressure, Bo and viscosity for
undersaturated oil with the same RS factor as the first entry).
The second kind of tables can be constructed using the item-based
variant of SimpleTable.
2013-12-16 13:45:02 +01:00
|
|
|
protected:
|
2014-09-16 16:03:57 +02:00
|
|
|
void checkNonDefaultable(const std::string& columnName);
|
|
|
|
|
void checkMonotonic(const std::string& columnName,
|
|
|
|
|
bool isAscending,
|
|
|
|
|
bool isStrictlyMonotonic = true);
|
|
|
|
|
void applyDefaultsConstant(const std::string& columnName, double value);
|
|
|
|
|
void applyDefaultsLinear(const std::string& columnName);
|
2014-09-17 22:56:25 +02:00
|
|
|
void createColumns(const std::vector<std::string> &columnNames);
|
add class for simple tables
This is intended for keywords like SWOF which currently is a big
vector of doubles but one needs to use the data in a column oriented
way.
This class is intended to be used like this:
Opm::DeckKeywordConstPtr swofKeyword = newParserDeck->getKeyword("SWOF");
Opm::SimpleTable swofTable(swofKeyword,
/*columns=*/std::vector<std::string>{"SW", "KRW", "KROW", "PCOW"},
/*recordIdx=*/table_num);
const std::vector<double>& sw = swofTable.getColumn(0);
// ...
what might be useful is to move the column names into the JSON
description of the keywords, but I could not find a way to go back to
the parser from the deck/keyword. maybe this is not even desireable as
decks might also be created by other means...
Also, a multi-record variant of the class is available. That one is
intended for keywords like PVTO where the first few items of each
record form a table (in the case of PVTO: Rs, pressure, Bo, and
viscosity for staturated oil) and the next entries constitute another
table (in the case of PVTO: pressure, Bo and viscosity for
undersaturated oil with the same RS factor as the first entry).
The second kind of tables can be constructed using the item-based
variant of SimpleTable.
2013-12-16 13:45:02 +01:00
|
|
|
|
2014-01-17 08:13:08 +01:00
|
|
|
std::map<std::string, size_t> m_columnNames;
|
add class for simple tables
This is intended for keywords like SWOF which currently is a big
vector of doubles but one needs to use the data in a column oriented
way.
This class is intended to be used like this:
Opm::DeckKeywordConstPtr swofKeyword = newParserDeck->getKeyword("SWOF");
Opm::SimpleTable swofTable(swofKeyword,
/*columns=*/std::vector<std::string>{"SW", "KRW", "KROW", "PCOW"},
/*recordIdx=*/table_num);
const std::vector<double>& sw = swofTable.getColumn(0);
// ...
what might be useful is to move the column names into the JSON
description of the keywords, but I could not find a way to go back to
the parser from the deck/keyword. maybe this is not even desireable as
decks might also be created by other means...
Also, a multi-record variant of the class is available. That one is
intended for keywords like PVTO where the first few items of each
record form a table (in the case of PVTO: Rs, pressure, Bo, and
viscosity for staturated oil) and the next entries constitute another
table (in the case of PVTO: pressure, Bo and viscosity for
undersaturated oil with the same RS factor as the first entry).
The second kind of tables can be constructed using the item-based
variant of SimpleTable.
2013-12-16 13:45:02 +01:00
|
|
|
std::vector<std::vector<double> > m_columns;
|
2014-09-16 13:58:13 +02:00
|
|
|
std::vector<std::vector<bool> > m_valueDefaulted;
|
add class for simple tables
This is intended for keywords like SWOF which currently is a big
vector of doubles but one needs to use the data in a column oriented
way.
This class is intended to be used like this:
Opm::DeckKeywordConstPtr swofKeyword = newParserDeck->getKeyword("SWOF");
Opm::SimpleTable swofTable(swofKeyword,
/*columns=*/std::vector<std::string>{"SW", "KRW", "KROW", "PCOW"},
/*recordIdx=*/table_num);
const std::vector<double>& sw = swofTable.getColumn(0);
// ...
what might be useful is to move the column names into the JSON
description of the keywords, but I could not find a way to go back to
the parser from the deck/keyword. maybe this is not even desireable as
decks might also be created by other means...
Also, a multi-record variant of the class is available. That one is
intended for keywords like PVTO where the first few items of each
record form a table (in the case of PVTO: Rs, pressure, Bo, and
viscosity for staturated oil) and the next entries constitute another
table (in the case of PVTO: pressure, Bo and viscosity for
undersaturated oil with the same RS factor as the first entry).
The second kind of tables can be constructed using the item-based
variant of SimpleTable.
2013-12-16 13:45:02 +01:00
|
|
|
};
|
|
|
|
|
|
2015-09-06 22:47:48 +02:00
|
|
|
typedef std::shared_ptr<SimpleTable> SimpleTablePtr;
|
|
|
|
|
typedef std::shared_ptr<const SimpleTable> SimpleTableConstPtr;
|
add class for simple tables
This is intended for keywords like SWOF which currently is a big
vector of doubles but one needs to use the data in a column oriented
way.
This class is intended to be used like this:
Opm::DeckKeywordConstPtr swofKeyword = newParserDeck->getKeyword("SWOF");
Opm::SimpleTable swofTable(swofKeyword,
/*columns=*/std::vector<std::string>{"SW", "KRW", "KROW", "PCOW"},
/*recordIdx=*/table_num);
const std::vector<double>& sw = swofTable.getColumn(0);
// ...
what might be useful is to move the column names into the JSON
description of the keywords, but I could not find a way to go back to
the parser from the deck/keyword. maybe this is not even desireable as
decks might also be created by other means...
Also, a multi-record variant of the class is available. That one is
intended for keywords like PVTO where the first few items of each
record form a table (in the case of PVTO: Rs, pressure, Bo, and
viscosity for staturated oil) and the next entries constitute another
table (in the case of PVTO: pressure, Bo and viscosity for
undersaturated oil with the same RS factor as the first entry).
The second kind of tables can be constructed using the item-based
variant of SimpleTable.
2013-12-16 13:45:02 +01:00
|
|
|
}
|
|
|
|
|
|
2014-09-16 13:58:13 +02:00
|
|
|
#endif
|