2014-01-17 08:15:35 +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/>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
#define BOOST_TEST_MODULE ParserIntegrationTests
|
|
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
|
|
#include <boost/test/unit_test.hpp>
|
|
|
|
|
#include <boost/test/test_tools.hpp>
|
|
|
|
|
|
|
|
|
|
#include <opm/parser/eclipse/Deck/Deck.hpp>
|
|
|
|
|
#include <opm/parser/eclipse/Deck/DeckDoubleItem.hpp>
|
|
|
|
|
|
|
|
|
|
#include <opm/parser/eclipse/Parser/Parser.hpp>
|
2015-07-24 15:38:22 +02:00
|
|
|
#include <opm/parser/eclipse/Parser/ParseMode.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/Parser/ParserIntItem.hpp>
|
|
|
|
|
#include <opm/parser/eclipse/Parser/ParserDoubleItem.hpp>
|
|
|
|
|
|
2014-09-18 16:28:36 +02:00
|
|
|
#include <opm/parser/eclipse/EclipseState/Tables/SwofTable.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
|
|
|
|
|
|
|
|
using namespace Opm;
|
|
|
|
|
|
2014-01-09 15:53:35 +01:00
|
|
|
// the data which ought to be parsed
|
|
|
|
|
const char *parserData =
|
|
|
|
|
"TABDIMS\n"
|
|
|
|
|
"-- NTSFUN NTPVT NSSFUN NPPVT NTFIP NRPVT\n"
|
|
|
|
|
" 1 1 30 1 1 1 /\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"-- S_w k_rw k_row p_cow\n"
|
|
|
|
|
"SWOF\n"
|
2014-09-16 16:03:57 +02:00
|
|
|
" 0.1 2* 0.0\n"
|
2014-01-09 15:53:35 +01:00
|
|
|
" 0.2 0.1 1.0 1.0\n"
|
2014-09-16 16:03:57 +02:00
|
|
|
" 0.3 1* 0.9 2.0\n"
|
|
|
|
|
" 0.4 0.3 1* 3.0\n"
|
2014-01-09 15:53:35 +01:00
|
|
|
" 0.5 0.5 0.5 4.0\n"
|
2014-09-16 16:03:57 +02:00
|
|
|
" 0.6 0.6 0.4 1*\n"
|
2014-01-09 15:53:35 +01:00
|
|
|
" 0.7 0.8 0.3 6.0\n"
|
|
|
|
|
" 0.8 0.9 0.2 7.0\n"
|
|
|
|
|
" 0.9 0.5 0.1 8.0\n"
|
2014-09-16 16:03:57 +02:00
|
|
|
" 1.0 1* 0.1 9.0 /\n";
|
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-05-08 16:26:14 +02:00
|
|
|
static void check_parser(ParserPtr parser) {
|
2015-07-24 15:38:22 +02:00
|
|
|
DeckPtr deck = parser->parseString(parserData, ParseMode());
|
2014-01-09 15:53:35 +01:00
|
|
|
DeckKeywordConstPtr kw1 = deck->getKeyword("SWOF");
|
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
|
|
|
BOOST_CHECK_EQUAL(1U , kw1->size());
|
|
|
|
|
|
|
|
|
|
DeckRecordConstPtr record0 = kw1->getRecord(0);
|
|
|
|
|
BOOST_CHECK_EQUAL(1U , record0->size());
|
|
|
|
|
|
|
|
|
|
DeckItemConstPtr item0 = record0->getItem(0);
|
2014-01-17 08:13:08 +01:00
|
|
|
BOOST_CHECK_EQUAL(10U * 4, item0->size());
|
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-05-08 16:26:14 +02:00
|
|
|
static void check_SwofTable(ParserPtr parser) {
|
2015-07-24 15:38:22 +02:00
|
|
|
DeckPtr deck = parser->parseString(parserData, ParseMode());
|
2014-09-16 13:58:13 +02:00
|
|
|
Opm::SwofTable swofTable;
|
2015-09-14 16:22:15 +02:00
|
|
|
swofTable.initFORUNITTESTONLY(deck->getKeyword("SWOF")->getRecord(0)->getItem(0));
|
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
|
|
|
BOOST_CHECK_EQUAL(10U, swofTable.getSwColumn().size());
|
2014-09-16 16:03:57 +02:00
|
|
|
BOOST_CHECK_CLOSE(0.1, swofTable.getSwColumn()[0], 1e-8);
|
|
|
|
|
BOOST_CHECK_CLOSE(1.0, swofTable.getSwColumn().back(), 1e-8);
|
|
|
|
|
|
|
|
|
|
BOOST_CHECK_CLOSE(0.1, swofTable.getKrwColumn()[0], 1e-8);
|
|
|
|
|
BOOST_CHECK_CLOSE(0.1, swofTable.getKrwColumn()[1], 1e-8);
|
|
|
|
|
BOOST_CHECK_CLOSE(0.2, swofTable.getKrwColumn()[2], 1e-8);
|
|
|
|
|
BOOST_CHECK_CLOSE(0.3, swofTable.getKrwColumn()[3], 1e-8);
|
|
|
|
|
BOOST_CHECK_CLOSE(0.5, swofTable.getKrwColumn().back(), 1e-8);
|
|
|
|
|
|
|
|
|
|
BOOST_CHECK_CLOSE(1.0, swofTable.getKrowColumn()[0], 1e-8);
|
|
|
|
|
BOOST_CHECK_CLOSE(0.9, swofTable.getKrowColumn()[2], 1e-8);
|
|
|
|
|
BOOST_CHECK_CLOSE(0.7, swofTable.getKrowColumn()[3], 1e-8);
|
|
|
|
|
BOOST_CHECK_CLOSE(0.5, swofTable.getKrowColumn()[4], 1e-8);
|
|
|
|
|
|
|
|
|
|
BOOST_CHECK_CLOSE(4.0e5, swofTable.getPcowColumn()[4], 1e-8);
|
|
|
|
|
BOOST_CHECK_CLOSE(5.0e5, swofTable.getPcowColumn()[5], 1e-8);
|
|
|
|
|
BOOST_CHECK_CLOSE(6.0e5, swofTable.getPcowColumn()[6], 1e-8);
|
|
|
|
|
|
|
|
|
|
BOOST_CHECK_CLOSE(0.10, swofTable.evaluate("KRW", -0.1), 1e-8);
|
|
|
|
|
BOOST_CHECK_CLOSE(0.15, swofTable.evaluate("KRW", 0.25), 1e-8);
|
|
|
|
|
BOOST_CHECK_CLOSE(0.50, swofTable.evaluate("KRW", 1.1), 1e-8);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE( parse_SWOF_OK ) {
|
2014-01-09 15:53:35 +01:00
|
|
|
ParserPtr parser(new Parser(/*addDefault=*/true));
|
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
|
|
|
|
|
|
|
|
check_parser( parser );
|
2014-01-09 15:53:35 +01:00
|
|
|
check_SwofTable(parser);
|
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
|
|
|
}
|