now the data is parsed from a string specified in the source file instead of a separate file, the PvtgTable utility class is tested and the order of the fields in the JSON definition of PVTG is the same as for that of PVTO.
111 lines
4.2 KiB
C++
111 lines
4.2 KiB
C++
#define BOOST_TEST_MODULE ParserIntegrationTests
|
|
#include <math.h>
|
|
|
|
#include <boost/test/unit_test.hpp>
|
|
#include <boost/test/test_tools.hpp>
|
|
|
|
#include <opm/parser/eclipse/Utility/PvtgTable.hpp>
|
|
|
|
#include <opm/parser/eclipse/Deck/Deck.hpp>
|
|
#include <opm/parser/eclipse/Deck/DeckDoubleItem.hpp>
|
|
|
|
#include <opm/parser/eclipse/Parser/Parser.hpp>
|
|
#include <opm/parser/eclipse/Parser/ParserKeyword.hpp>
|
|
#include <opm/parser/eclipse/Parser/ParserRecord.hpp>
|
|
#include <opm/parser/eclipse/Parser/ParserIntItem.hpp>
|
|
#include <opm/parser/eclipse/Parser/ParserDoubleItem.hpp>
|
|
#include <opm/parser/eclipse/Parser/ParserStringItem.hpp>
|
|
#include <opm/parser/eclipse/Parser/ParserEnums.hpp>
|
|
|
|
using namespace Opm;
|
|
|
|
const char *pvtgData = "\n\
|
|
TABDIMS\n\
|
|
-- NTSFUN NTPVT NSSFUN NPPVT NTFIP NRPVT\n\
|
|
1 2 30 24 10 20 /\n\
|
|
\n\
|
|
PVTG\n\
|
|
--\n\
|
|
20.00 0.00002448 0.061895 0.01299\n\
|
|
0.00001224 0.061810 0.01300\n\
|
|
0.00000000 0.061725 0.01300 /\n\
|
|
40.00 0.00000628 0.030252 0.01383\n\
|
|
0.00000314 0.030249 0.01383\n\
|
|
0.00000000 0.030245 0.01383 /\n\
|
|
/\n\
|
|
197.66 0.00006327 0.005820 0.02160\n\
|
|
0.00003164 0.005840 0.02122\n\
|
|
0.00000000 0.005860 0.02086 /\n\
|
|
231.13 0.00010861 0.005042 0.02477\n\
|
|
0.00005431 0.005061 0.02389\n\
|
|
0.00000000 0.005082 0.02306 /\n\
|
|
/\n";
|
|
|
|
|
|
void check_parser(ParserPtr parser) {
|
|
DeckPtr deck = parser->parseString(pvtgData);
|
|
DeckKeywordConstPtr kw1 = deck->getKeyword("PVTG" , 0);
|
|
BOOST_CHECK_EQUAL(5U , kw1->size());
|
|
|
|
DeckRecordConstPtr record0 = kw1->getRecord(0);
|
|
DeckRecordConstPtr record1 = kw1->getRecord(1);
|
|
DeckRecordConstPtr record2 = kw1->getRecord(2);
|
|
DeckRecordConstPtr record3 = kw1->getRecord(3);
|
|
DeckRecordConstPtr record4 = kw1->getRecord(4);
|
|
|
|
DeckItemConstPtr item0_0 = record0->getItem("GAS_PRESSURE");
|
|
DeckItemConstPtr item0_1 = record0->getItem("DATA");
|
|
BOOST_CHECK_EQUAL(1U , item0_0->size());
|
|
BOOST_CHECK_EQUAL(9U , item0_1->size());
|
|
BOOST_CHECK_EQUAL(2U , record0->size());
|
|
|
|
DeckItemConstPtr item1_0 = record1->getItem("GAS_PRESSURE");
|
|
DeckItemConstPtr item1_1 = record1->getItem("DATA");
|
|
BOOST_CHECK_EQUAL(1U , item1_0->size());
|
|
BOOST_CHECK_EQUAL(9U , item1_1->size());
|
|
BOOST_CHECK_EQUAL(2U , record1->size());
|
|
|
|
DeckItemConstPtr item2_0 = record2->getItem("GAS_PRESSURE");
|
|
DeckItemConstPtr item2_1 = record2->getItem("DATA");
|
|
BOOST_CHECK_EQUAL(1U , item2_0->size());
|
|
BOOST_CHECK_EQUAL(0U , item2_1->size());
|
|
BOOST_CHECK_EQUAL(2U , record2->size());
|
|
|
|
|
|
DeckItemConstPtr item3_0 = record3->getItem("GAS_PRESSURE");
|
|
DeckItemConstPtr item3_1 = record3->getItem("DATA");
|
|
BOOST_CHECK_EQUAL(1U , item3_0->size());
|
|
BOOST_CHECK_EQUAL(9U , item3_1->size());
|
|
BOOST_CHECK_EQUAL(2U , record3->size());
|
|
|
|
|
|
DeckItemConstPtr item4_0 = record4->getItem("GAS_PRESSURE");
|
|
DeckItemConstPtr item4_1 = record4->getItem("DATA");
|
|
BOOST_CHECK_EQUAL(1U , item4_0->size());
|
|
BOOST_CHECK_EQUAL(9U , item4_1->size());
|
|
BOOST_CHECK_EQUAL(2U , record4->size());
|
|
|
|
Opm::PvtgTable pvtgTable(kw1, /*tableIdx=*/0);
|
|
const auto &outerTable = *pvtgTable.getOuterTable();
|
|
const auto &innerTable0 = *pvtgTable.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());
|
|
|
|
BOOST_CHECK_EQUAL(20.0e5, outerTable.getPressureColumn()[0]);
|
|
BOOST_CHECK_EQUAL(0.00002448, outerTable.getOilSolubilityColumn()[0]);
|
|
BOOST_CHECK_EQUAL(outerTable.getOilSolubilityColumn()[0], innerTable0.getOilSolubilityColumn()[0]);
|
|
BOOST_CHECK_EQUAL(0.061895, outerTable.getGasFormationFactorColumn()[0]);
|
|
BOOST_CHECK_EQUAL(outerTable.getGasFormationFactorColumn()[0], innerTable0.getGasFormationFactorColumn()[0]);
|
|
BOOST_CHECK_EQUAL(1.299e-5, outerTable.getGasViscosityColumn()[0]);
|
|
BOOST_CHECK_EQUAL(outerTable.getGasViscosityColumn()[0], innerTable0.getGasViscosityColumn()[0]);
|
|
}
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE( parse_PVTG_OK ) {
|
|
ParserPtr parser(new Parser());
|
|
check_parser( parser );
|
|
}
|