Changed integer type int -> size_t throughout.
This commit is contained in:
@@ -43,14 +43,14 @@ void check_parser(ParserPtr parser) {
|
||||
BOOST_CHECK_EQUAL(1U , record0->size());
|
||||
|
||||
DeckItemConstPtr item0 = record0->getItem(0);
|
||||
BOOST_CHECK_EQUAL(10 * 4, item0->size());
|
||||
BOOST_CHECK_EQUAL(10U * 4, item0->size());
|
||||
}
|
||||
|
||||
void check_SgofTable(ParserPtr parser) {
|
||||
DeckPtr deck = parser->parseString(parserData);
|
||||
Opm::SgofTable sgofTable(deck->getKeyword("SGOF"));
|
||||
|
||||
BOOST_CHECK_EQUAL(10, sgofTable.getSgColumn().size());
|
||||
BOOST_CHECK_EQUAL(10U, sgofTable.getSgColumn().size());
|
||||
BOOST_CHECK_EQUAL(0.1, sgofTable.getSgColumn()[0]);
|
||||
BOOST_CHECK_EQUAL(0.0, sgofTable.getKrgColumn()[0]);
|
||||
BOOST_CHECK_EQUAL(1.0, sgofTable.getKrogColumn()[0]);
|
||||
|
||||
@@ -43,14 +43,14 @@ void check_parser(ParserPtr parser) {
|
||||
BOOST_CHECK_EQUAL(1U , record0->size());
|
||||
|
||||
DeckItemConstPtr item0 = record0->getItem(0);
|
||||
BOOST_CHECK_EQUAL(10 * 4, item0->size());
|
||||
BOOST_CHECK_EQUAL(10U * 4, item0->size());
|
||||
}
|
||||
|
||||
void check_SwofTable(ParserPtr parser) {
|
||||
DeckPtr deck = parser->parseString(parserData);
|
||||
Opm::SwofTable swofTable(deck->getKeyword("SWOF"));
|
||||
|
||||
BOOST_CHECK_EQUAL(10, swofTable.getSwColumn().size());
|
||||
BOOST_CHECK_EQUAL(10U, swofTable.getSwColumn().size());
|
||||
BOOST_CHECK_EQUAL(0.1, swofTable.getSwColumn()[0]);
|
||||
BOOST_CHECK_EQUAL(0.0, swofTable.getKrwColumn()[0]);
|
||||
BOOST_CHECK_EQUAL(1.0, swofTable.getKrowColumn()[0]);
|
||||
|
||||
@@ -16,20 +16,20 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "SimpleMultiRecordTable.hpp"
|
||||
#include <opm/parser/eclipse/Utility/SimpleMultiRecordTable.hpp>
|
||||
|
||||
namespace Opm {
|
||||
// create table from first few items of multiple records (i.e. getSIDoubleData() throws an exception)
|
||||
SimpleMultiRecordTable::SimpleMultiRecordTable(Opm::DeckKeywordConstPtr keyword,
|
||||
const std::vector<std::string> &columnNames,
|
||||
int tableIdx,
|
||||
int firstEntityOffset)
|
||||
size_t tableIdx,
|
||||
size_t firstEntityOffset)
|
||||
{
|
||||
createColumns_(columnNames);
|
||||
|
||||
// first, go to the first record of the specified table. For this,
|
||||
// we need to skip the right number of empty records...
|
||||
int curTableIdx = 0;
|
||||
size_t curTableIdx = 0;
|
||||
for (m_firstRecordIdx = 0;
|
||||
curTableIdx < tableIdx;
|
||||
++ m_firstRecordIdx)
|
||||
@@ -51,7 +51,7 @@ SimpleMultiRecordTable::SimpleMultiRecordTable(Opm::DeckKeywordConstPtr keyword,
|
||||
{
|
||||
}
|
||||
|
||||
for (unsigned rowIdx = m_firstRecordIdx; rowIdx < m_firstRecordIdx + m_numRecords; ++ rowIdx) {
|
||||
for (size_t rowIdx = m_firstRecordIdx; rowIdx < m_firstRecordIdx + m_numRecords; ++ rowIdx) {
|
||||
// extract the actual data from the records of the keyword of
|
||||
// the deck
|
||||
Opm::DeckRecordConstPtr deckRecord =
|
||||
@@ -61,14 +61,14 @@ SimpleMultiRecordTable::SimpleMultiRecordTable(Opm::DeckKeywordConstPtr keyword,
|
||||
throw std::runtime_error("Number of columns in the data file is"
|
||||
"inconsistent with the ones specified");
|
||||
|
||||
for (int colIdx = 0; colIdx < numColumns(); ++colIdx) {
|
||||
int deckItemIdx = colIdx + firstEntityOffset;
|
||||
for (size_t colIdx = 0; colIdx < numColumns(); ++colIdx) {
|
||||
size_t deckItemIdx = colIdx + firstEntityOffset;
|
||||
m_columns[colIdx].push_back(getFlatSiDoubleData_(deckRecord, deckItemIdx));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int SimpleMultiRecordTable::getNumFlatItems_(Opm::DeckRecordConstPtr deckRecord) const
|
||||
size_t SimpleMultiRecordTable::getNumFlatItems_(Opm::DeckRecordConstPtr deckRecord) const
|
||||
{
|
||||
int result = 0;
|
||||
for (unsigned i = 0; i < deckRecord->size(); ++ i) {
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#ifndef OPM_PARSER_SIMPLE_MULTI_RECORD_TABLE_HPP
|
||||
#define OPM_PARSER_SIMPLE_MULTI_RECORD_TABLE_HPP
|
||||
|
||||
#include "SimpleTable.hpp"
|
||||
#include <opm/parser/eclipse/Utility/SimpleTable.hpp>
|
||||
|
||||
#include <opm/parser/eclipse/Deck/DeckKeyword.hpp>
|
||||
|
||||
@@ -41,29 +41,29 @@ namespace Opm {
|
||||
*/
|
||||
SimpleMultiRecordTable(Opm::DeckKeywordConstPtr keyword,
|
||||
const std::vector<std::string> &columnNames,
|
||||
int tableIndex,
|
||||
int firstEntityOffset = 0);
|
||||
size_t tableIndex,
|
||||
size_t firstEntityOffset = 0);
|
||||
|
||||
/*!
|
||||
* \brief Return the index of the first record which applies
|
||||
* for this table object.
|
||||
*/
|
||||
int firstRecordIndex() const
|
||||
size_t firstRecordIndex() const
|
||||
{ return m_firstRecordIdx; }
|
||||
|
||||
/*!
|
||||
* \brief Return the number of records which are used by this
|
||||
* this table object.
|
||||
*/
|
||||
int numRecords() const
|
||||
size_t numRecords() const
|
||||
{ return m_numRecords; }
|
||||
|
||||
private:
|
||||
int getNumFlatItems_(Opm::DeckRecordConstPtr deckRecord) const;
|
||||
size_t getNumFlatItems_(Opm::DeckRecordConstPtr deckRecord) const;
|
||||
double getFlatSiDoubleData_(Opm::DeckRecordConstPtr deckRecord, unsigned flatItemIdx) const;
|
||||
|
||||
int m_firstRecordIdx;
|
||||
int m_numRecords;
|
||||
size_t m_firstRecordIdx;
|
||||
size_t m_numRecords;
|
||||
};
|
||||
|
||||
typedef std::shared_ptr<SimpleMultiRecordTable> SimpleMultiRecordTablePtr;
|
||||
|
||||
@@ -16,14 +16,14 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "SimpleTable.hpp"
|
||||
#include <opm/parser/eclipse/Utility/SimpleTable.hpp>
|
||||
|
||||
namespace Opm {
|
||||
// create table from single record
|
||||
SimpleTable::SimpleTable(Opm::DeckKeywordConstPtr keyword,
|
||||
const std::vector<std::string> &columnNames,
|
||||
int recordIdx,
|
||||
int firstEntityOffset)
|
||||
size_t recordIdx,
|
||||
size_t firstEntityOffset)
|
||||
{
|
||||
createColumns_(columnNames);
|
||||
|
||||
@@ -31,17 +31,17 @@ SimpleTable::SimpleTable(Opm::DeckKeywordConstPtr keyword,
|
||||
Opm::DeckRecordConstPtr deckRecord =
|
||||
keyword->getRecord(recordIdx);
|
||||
|
||||
int numFlatItems = getNumFlatItems_(deckRecord);
|
||||
size_t numFlatItems = getNumFlatItems_(deckRecord);
|
||||
if ( (numFlatItems - firstEntityOffset) % numColumns() != 0)
|
||||
throw std::runtime_error("Number of columns in the data file is"
|
||||
"inconsistent with the ones specified");
|
||||
|
||||
for (int rowIdx = 0;
|
||||
for (size_t rowIdx = 0;
|
||||
rowIdx*numColumns() < numFlatItems - firstEntityOffset;
|
||||
++rowIdx)
|
||||
{
|
||||
for (int colIdx = 0; colIdx < numColumns(); ++colIdx) {
|
||||
int deckItemIdx = rowIdx*numColumns() + firstEntityOffset + colIdx;
|
||||
for (size_t colIdx = 0; colIdx < numColumns(); ++colIdx) {
|
||||
size_t deckItemIdx = rowIdx*numColumns() + firstEntityOffset + colIdx;
|
||||
m_columns[colIdx].push_back(getFlatSiDoubleData_(deckRecord, deckItemIdx));
|
||||
}
|
||||
}
|
||||
@@ -53,26 +53,26 @@ void SimpleTable::createColumns_(const std::vector<std::string> &columnNames)
|
||||
// the json description of the keyword.
|
||||
auto columnNameIt = columnNames.begin();
|
||||
const auto &columnNameEndIt = columnNames.end();
|
||||
int columnIdx = 0;
|
||||
size_t columnIdx = 0;
|
||||
for (; columnNameIt != columnNameEndIt; ++columnNameIt, ++columnIdx) {
|
||||
m_columnNames[*columnNameIt] = columnIdx;
|
||||
}
|
||||
m_columns.resize(columnIdx);
|
||||
}
|
||||
|
||||
int SimpleTable::getNumFlatItems_(Opm::DeckRecordConstPtr deckRecord) const
|
||||
size_t SimpleTable::getNumFlatItems_(Opm::DeckRecordConstPtr deckRecord) const
|
||||
{
|
||||
int result = 0;
|
||||
for (unsigned i = 0; i < deckRecord->size(); ++ i) {
|
||||
size_t result = 0;
|
||||
for (size_t i = 0; i < deckRecord->size(); ++ i) {
|
||||
result += deckRecord->getItem(i)->size();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
double SimpleTable::getFlatSiDoubleData_(Opm::DeckRecordConstPtr deckRecord, unsigned flatItemIdx) const
|
||||
double SimpleTable::getFlatSiDoubleData_(Opm::DeckRecordConstPtr deckRecord, size_t flatItemIdx) const
|
||||
{
|
||||
unsigned itemFirstFlatIdx = 0;
|
||||
size_t itemFirstFlatIdx = 0;
|
||||
for (unsigned i = 0; i < deckRecord->size(); ++ i) {
|
||||
Opm::DeckItemConstPtr item = deckRecord->getItem(i);
|
||||
if (itemFirstFlatIdx + item->size() > flatItemIdx)
|
||||
|
||||
@@ -42,22 +42,22 @@ namespace Opm {
|
||||
*/
|
||||
SimpleTable(Opm::DeckKeywordConstPtr keyword,
|
||||
const std::vector<std::string> &columnNames,
|
||||
int recordIdx = 0,
|
||||
int firstEntityOffset = 0);
|
||||
size_t recordIdx = 0,
|
||||
size_t firstEntityOffset = 0);
|
||||
|
||||
// constructor to make the base class compatible with specialized table implementations
|
||||
SimpleTable(Opm::DeckKeywordConstPtr keyword,
|
||||
int recordIdx = 0,
|
||||
int firstEntityOffset = 0)
|
||||
size_t recordIdx = 0,
|
||||
size_t firstEntityOffset = 0)
|
||||
{
|
||||
throw std::logic_error("The base class of simple tables can't be "
|
||||
"instantiated without specifying columns!");
|
||||
}
|
||||
|
||||
int numColumns() const
|
||||
size_t numColumns() const
|
||||
{ return m_columns.size(); }
|
||||
|
||||
int numRows() const
|
||||
size_t numRows() const
|
||||
{ return m_columns[0].size(); }
|
||||
|
||||
const std::vector<double> &getColumn(const std::string &name) const
|
||||
@@ -70,19 +70,19 @@ namespace Opm {
|
||||
assert(0 <= colIdx && colIdx < static_cast<int>(m_columns.size()));
|
||||
return m_columns[colIdx];
|
||||
}
|
||||
const std::vector<double> &getColumn(int colIdx) const
|
||||
const std::vector<double> &getColumn(size_t colIdx) const
|
||||
{
|
||||
assert(0 <= colIdx && colIdx < static_cast<int>(m_columns.size()));
|
||||
assert(0 <= colIdx && colIdx < static_cast<size_t>(m_columns.size()));
|
||||
return m_columns[colIdx];
|
||||
}
|
||||
|
||||
protected:
|
||||
void createColumns_(const std::vector<std::string> &columnNames);
|
||||
|
||||
int getNumFlatItems_(Opm::DeckRecordConstPtr deckRecord) const;
|
||||
double getFlatSiDoubleData_(Opm::DeckRecordConstPtr deckRecord, unsigned flatItemIdx) const;
|
||||
size_t getNumFlatItems_(Opm::DeckRecordConstPtr deckRecord) const;
|
||||
double getFlatSiDoubleData_(Opm::DeckRecordConstPtr deckRecord, size_t flatItemIdx) const;
|
||||
|
||||
std::map<std::string, int> m_columnNames;
|
||||
std::map<std::string, size_t> m_columnNames;
|
||||
std::vector<std::vector<double> > m_columns;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user