From c6f8a41c43b4040322fda811778fb5cf2e21290d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torbj=C3=B8rn=20Skille?= Date: Sun, 3 Nov 2019 19:34:25 +0100 Subject: [PATCH] updates of ERst api, supports multiple occurrences of array names --- opm/io/eclipse/ERst.hpp | 16 +++- src/opm/io/eclipse/ERst.cpp | 66 ++++++++++---- src/opm/output/eclipse/LoadRestart.cpp | 2 +- test_util/EclRegressionTest.cpp | 20 ++--- test_util/convertECL.cpp | 42 +++++++-- tests/msim/test_msim.cpp | 4 +- tests/test_ERst.cpp | 114 ++++++++++++------------- tests/test_EclipseIO.cpp | 10 +-- tests/test_OutputStream.cpp | 30 +++---- tests/test_Restart.cpp | 2 +- 10 files changed, 189 insertions(+), 117 deletions(-) diff --git a/opm/io/eclipse/ERst.hpp b/opm/io/eclipse/ERst.hpp index 0b91c147c..eeb45ddd6 100644 --- a/opm/io/eclipse/ERst.hpp +++ b/opm/io/eclipse/ERst.hpp @@ -42,10 +42,18 @@ public: void loadReportStepNumber(int number); template - const std::vector& getRst(const std::string& name, int reportStepNumber); + const std::vector& getRst(const std::string& name, int reportStepNumber, int occurrence); + + template + const std::vector& getRst(int index, int reportStepNumber){ + auto indRange = this->getIndexRange(reportStepNumber); + return this->get(index + std::get<0>(indRange)); + } + + int count(const std::string& name, int reportStepNumber) const; const std::vector& listOfReportStepNumbers() const { return seqnum; } - + std::vector listOfRstArrays(int reportStepNumber); friend class OutputStream::Restart; @@ -59,10 +67,12 @@ private: void initUnified(); void initSeparate(const int number); - int getArrayIndex(const std::string& name, int seqnum) const; + int getArrayIndex(const std::string& name, int seqnum, int occurrence) const; + std::tuple getIndexRange(int reportStepNumber) const; std::streampos restartStepWritePosition(const int seqnumValue) const; + }; }} // namespace Opm::EclIO diff --git a/src/opm/io/eclipse/ERst.cpp b/src/opm/io/eclipse/ERst.cpp index 1eab5d1bd..b4aed75bc 100644 --- a/src/opm/io/eclipse/ERst.cpp +++ b/src/opm/io/eclipse/ERst.cpp @@ -63,7 +63,7 @@ ERst::ERst(const std::string& filename) this->initUnified(); } else { - this->initSeparate(seqnumFromSeparateFilename(filename)); + this->initSeparate(seqnumFromSeparateFilename(filename)); } } @@ -114,6 +114,29 @@ std::vector ERst::listOfRstArrays(int reportStepNumber) return list; } +int ERst::count(const std::string& name, int reportStepNumber) const +{ + + if (!hasReportStepNumber(reportStepNumber)) { + std::string message = "Trying to count vectors of name " + name + " from non existing sequence " + std::to_string(reportStepNumber); + OPM_THROW(std::invalid_argument, message); + } + + int count = 0; + + auto range_it = arrIndexRange.find(reportStepNumber); + + std::pair indexRange = range_it->second; + + for (int i=std::get<0>(indexRange); i(indexRange);i++){ + if (array_name[i] == name){ + count++; + } + } + + return count; +} + void ERst::initUnified() { loadData("SEQNUM"); @@ -160,7 +183,19 @@ void ERst::initSeparate(const int number) this->reportLoaded[number] = false; } -int ERst::getArrayIndex(const std::string& name, int number) const +std::tuple ERst::getIndexRange(int reportStepNumber) const { + + if (!hasReportStepNumber(reportStepNumber)) { + std::string message = "Trying to get index range for non existing sequence " + std::to_string(reportStepNumber); + OPM_THROW(std::invalid_argument, message); + } + + auto range_it = arrIndexRange.find(reportStepNumber); + + return range_it->second; +} + +int ERst::getArrayIndex(const std::string& name, int number, int occurrenc) const { if (!hasReportStepNumber(number)) { std::string message = "Trying to get vector " + name + " from non existing sequence " + std::to_string(number); @@ -174,6 +209,10 @@ int ERst::getArrayIndex(const std::string& name, int number) const auto it = std::find(array_name.begin() + indexRange.first, array_name.begin() + indexRange.second, name); + for (int t = 0; t < occurrenc; t++){ + it = std::find(it + 1 , array_name.begin() + indexRange.second, name); + } + if (std::distance(array_name.begin(),it) == indexRange.second) { std::string message = "Array " + name + " not found in sequence " + std::to_string(number); OPM_THROW(std::runtime_error, message); @@ -193,40 +232,37 @@ ERst::restartStepWritePosition(const int seqnumValue) const } template<> -const std::vector& ERst::getRst(const std::string& name, int reportStepNumber) +const std::vector& ERst::getRst(const std::string& name, int reportStepNumber, int occurrence) { - int ind = getArrayIndex(name, reportStepNumber); + int ind = getArrayIndex(name, reportStepNumber, occurrence); return getImpl(ind, INTE, inte_array, "integer"); } - template<> -const std::vector& ERst::getRst(const std::string& name, int reportStepNumber) +const std::vector& ERst::getRst(const std::string& name, int reportStepNumber, int occurrence) { - int ind = getArrayIndex(name, reportStepNumber); + int ind = getArrayIndex(name, reportStepNumber, occurrence); return getImpl(ind, REAL, real_array, "float"); } - template<> -const std::vector& ERst::getRst(const std::string& name, int reportStepNumber) +const std::vector& ERst::getRst(const std::string& name, int reportStepNumber, int occurrence) { - int ind = getArrayIndex(name, reportStepNumber); + int ind = getArrayIndex(name, reportStepNumber, occurrence); return getImpl(ind, DOUB, doub_array, "double"); } - template<> -const std::vector& ERst::getRst(const std::string& name, int reportStepNumber) +const std::vector& ERst::getRst(const std::string& name, int reportStepNumber, int occurrence) { - int ind = getArrayIndex(name, reportStepNumber); + int ind = getArrayIndex(name, reportStepNumber, occurrence); return getImpl(ind, LOGI, logi_array, "bool"); } template<> -const std::vector& ERst::getRst(const std::string& name, int reportStepNumber) +const std::vector& ERst::getRst(const std::string& name, int reportStepNumber, int occurrence) { - int ind = getArrayIndex(name, reportStepNumber); + int ind = getArrayIndex(name, reportStepNumber, occurrence); return getImpl(ind, CHAR, char_array, "string"); } diff --git a/src/opm/output/eclipse/LoadRestart.cpp b/src/opm/output/eclipse/LoadRestart.cpp index 3e5478b72..23fd4eea8 100644 --- a/src/opm/output/eclipse/LoadRestart.cpp +++ b/src/opm/output/eclipse/LoadRestart.cpp @@ -126,7 +126,7 @@ public: const std::vector& getKeyword(const std::string& vector) { - return this->rst_file_->getRst(vector, this->report_step_); + return this->rst_file_->getRst(vector, this->report_step_, 0); } const std::vector& intehead() diff --git a/test_util/EclRegressionTest.cpp b/test_util/EclRegressionTest.cpp index 9579e9b92..9ac853f3a 100644 --- a/test_util/EclRegressionTest.cpp +++ b/test_util/EclRegressionTest.cpp @@ -776,24 +776,24 @@ void ECLRegressionTest::results_rst() std::cout << "Comparing " << keywords1[i] << " ... "; if (arrayType1[i] == INTE) { - auto vect1 = rst1.getRst(keywords1[i], seqn); - auto vect2 = rst2.getRst(keywords2[ind2], seqn); + auto vect1 = rst1.getRst(keywords1[i], seqn, 0); + auto vect2 = rst2.getRst(keywords2[ind2], seqn, 0); compareVectors(vect1, vect2, keywords1[i], reference); } else if (arrayType1[i] == REAL) { - auto vect1 = rst1.getRst(keywords1[i], seqn); - auto vect2 = rst2.getRst(keywords2[ind2], seqn); + auto vect1 = rst1.getRst(keywords1[i], seqn, 0); + auto vect2 = rst2.getRst(keywords2[ind2], seqn, 0); compareFloatingPointVectors(vect1, vect2, keywords1[i], reference); } else if (arrayType1[i] == DOUB) { - auto vect1 = rst1.getRst(keywords1[i], seqn); - auto vect2 = rst2.getRst(keywords2[ind2], seqn); + auto vect1 = rst1.getRst(keywords1[i], seqn, 0); + auto vect2 = rst2.getRst(keywords2[ind2], seqn, 0); compareFloatingPointVectors(vect1, vect2, keywords1[i], reference); } else if (arrayType1[i] == LOGI) { - auto vect1 = rst1.getRst(keywords1[i], seqn); - auto vect2 = rst2.getRst(keywords2[ind2], seqn); + auto vect1 = rst1.getRst(keywords1[i], seqn, 0); + auto vect2 = rst2.getRst(keywords2[ind2], seqn, 0); compareVectors(vect1, vect2, keywords1[i], reference); } else if (arrayType1[i] == CHAR) { - auto vect1 = rst1.getRst(keywords1[i], seqn); - auto vect2 = rst2.getRst(keywords2[ind2], seqn); + auto vect1 = rst1.getRst(keywords1[i], seqn, 0); + auto vect2 = rst2.getRst(keywords2[ind2], seqn, 0); compareVectors(vect1, vect2, keywords1[i], reference); } else if (arrayType1[i] == MESS) { // shold not be any associated data diff --git a/test_util/convertECL.cpp b/test_util/convertECL.cpp index fc3e089d5..424679664 100644 --- a/test_util/convertECL.cpp +++ b/test_util/convertECL.cpp @@ -22,13 +22,21 @@ void write(EclOutput& outFile, EclFile& file1, template void write(EclOutput& outFile, ERst& file1, - const std::string& name, int reportStepNumber) + const std::string& name, int index, int reportStepNumber) { - - auto vect = file1.getRst(name, reportStepNumber); + auto vect = file1.getRst(index, reportStepNumber); outFile.write(name, vect); } +template +void write(EclOutput& outFile, ERst& file1, + const std::string& name, int index) +{ + auto vect = file1.get(index); + outFile.write(name, vect); +} + + template void writeArray(std::string name, eclArrType arrType, T& file1, int index, EclOutput& outFile) { @@ -50,24 +58,42 @@ void writeArray(std::string name, eclArrType arrType, T& file1, int index, EclOu } } +template +void writeArray(std::string name, eclArrType arrType, T& file1, int index, int reportStepNumber, EclOutput& outFile) { + + if (arrType == INTE) { + write(outFile, file1, name, index, reportStepNumber); + } else if (arrType == REAL) { + write(outFile, file1, name, index, reportStepNumber); + } else if (arrType == DOUB) { + write(outFile, file1, name, index, reportStepNumber); + } else if (arrType == LOGI) { + write(outFile, file1, name, index, reportStepNumber); + } else if (arrType == CHAR) { + write(outFile, file1, name, index, reportStepNumber); + } else if (arrType == MESS) { + outFile.message(name); + } else { + std::cout << "unknown array type " << std::endl; + exit(1); + } +} + void writeArrayList(std::vector& arrayList, EclFile file1, EclOutput& outFile) { for (size_t index = 0; index < arrayList.size(); index++) { std::string name = std::get<0>(arrayList[index]); eclArrType arrType = std::get<1>(arrayList[index]); - writeArray(name, arrType, file1, index, outFile); } } - void writeArrayList(std::vector& arrayList, ERst file1, int reportStepNumber, EclOutput& outFile) { for (size_t index = 0; index < arrayList.size(); index++) { std::string name = std::get<0>(arrayList[index]); eclArrType arrType = std::get<1>(arrayList[index]); - - writeArray(name, arrType, file1, reportStepNumber, outFile); + writeArray(name, arrType, file1, index , reportStepNumber, outFile); } } @@ -131,7 +157,7 @@ int main(int argc, char **argv) { for (auto seqn : reportStepList) { - std::vector inteh = rst1.getRst("INTEHEAD", seqn); + std::vector inteh = rst1.getRst("INTEHEAD", seqn, 0); std::cout << "Report step number: " << std::setfill(' ') << std::setw(4) << seqn << " Date: " << inteh[66] << "/" diff --git a/tests/msim/test_msim.cpp b/tests/msim/test_msim.cpp index e1cc39708..e898b943c 100644 --- a/tests/msim/test_msim.cpp +++ b/tests/msim/test_msim.cpp @@ -101,8 +101,8 @@ BOOST_AUTO_TEST_CASE(RUN) { auto rst = EclIO::ERst("SPE1CASE1.UNRST"); for (const auto& step : rst.listOfReportStepNumbers()) { - const auto& dh = rst.getRst("DOUBHEAD", step); - const auto& press = rst.getRst("PRESSURE", step); + const auto& dh = rst.getRst("DOUBHEAD", step, 0); + const auto& press = rst.getRst("PRESSURE", step, 0); // DOUBHEAD[0] is elapsed time in days since start of simulation. BOOST_CHECK_CLOSE( press[0], dh[0] * 86400, 1e-3 ); diff --git a/tests/test_ERst.cpp b/tests/test_ERst.cpp index f155feb29..4061f2342 100644 --- a/tests/test_ERst.cpp +++ b/tests/test_ERst.cpp @@ -127,28 +127,28 @@ BOOST_AUTO_TEST_CASE(TestERst_1) { // non exising report step number, should throw exception - BOOST_CHECK_THROW(std::vector vect1=rst1.getRst("ICON",0) , std::invalid_argument ); - BOOST_CHECK_THROW(std::vector vect2=rst1.getRst("PRESSURE",0) , std::invalid_argument ); - BOOST_CHECK_THROW(std::vector vect3=rst1.getRst("XGRP",0) , std::invalid_argument ); - BOOST_CHECK_THROW(std::vector vect4=rst1.getRst("LOGIHEAD",0) , std::invalid_argument ); - BOOST_CHECK_THROW(std::vector vect4=rst1.getRst("ZWEL",0) , std::invalid_argument ); + BOOST_CHECK_THROW(std::vector vect1=rst1.getRst("ICON",0, 0) , std::invalid_argument ); + BOOST_CHECK_THROW(std::vector vect2=rst1.getRst("PRESSURE",0, 0) , std::invalid_argument ); + BOOST_CHECK_THROW(std::vector vect3=rst1.getRst("XGRP",0, 0) , std::invalid_argument ); + BOOST_CHECK_THROW(std::vector vect4=rst1.getRst("LOGIHEAD",0, 0) , std::invalid_argument ); + BOOST_CHECK_THROW(std::vector vect4=rst1.getRst("ZWEL",0, 0) , std::invalid_argument ); // calling getRst member function with wrong type, should throw exception - BOOST_CHECK_THROW(std::vector vect1=rst1.getRst("ICON",5) , std::runtime_error ); - BOOST_CHECK_THROW(std::vector vect2=rst1.getRst("PRESSURE",5), std::runtime_error ); - BOOST_CHECK_THROW(std::vector vect3=rst1.getRst("XGRP",5), std::runtime_error ); - BOOST_CHECK_THROW(std::vector vect4=rst1.getRst("LOGIHEAD",5), std::runtime_error ); - BOOST_CHECK_THROW(std::vector vect5=rst1.getRst("ZWEL",5), std::runtime_error ); + BOOST_CHECK_THROW(std::vector vect1=rst1.getRst("ICON",5, 0) , std::runtime_error ); + BOOST_CHECK_THROW(std::vector vect2=rst1.getRst("PRESSURE",5, 0), std::runtime_error ); + BOOST_CHECK_THROW(std::vector vect3=rst1.getRst("XGRP",5, 0), std::runtime_error ); + BOOST_CHECK_THROW(std::vector vect4=rst1.getRst("LOGIHEAD",5, 0), std::runtime_error ); + BOOST_CHECK_THROW(std::vector vect5=rst1.getRst("ZWEL",5, 0), std::runtime_error ); // report step number exists, but data is not loaded. Vector should in this case // be loaded on demand. Hence not throwing an exception - std::vector vect1=rst1.getRst("ICON",10); - std::vector vect2=rst1.getRst("PRESSURE",10); - std::vector vect3=rst1.getRst("XGRP",10); - std::vector vect4=rst1.getRst("LOGIHEAD",10); - std::vector vect5=rst1.getRst("ZWEL",10); + std::vector vect1=rst1.getRst("ICON",10, 0); + std::vector vect2=rst1.getRst("PRESSURE",10, 0); + std::vector vect3=rst1.getRst("XGRP",10, 0); + std::vector vect4=rst1.getRst("LOGIHEAD",10, 0); + std::vector vect5=rst1.getRst("ZWEL",10, 0); BOOST_CHECK_EQUAL(ref_icon_10==vect1, true); @@ -163,11 +163,11 @@ BOOST_AUTO_TEST_CASE(TestERst_1) { rst1.loadReportStepNumber(25); - vect1 = rst1.getRst("ICON",25); - vect2 = rst1.getRst("PRESSURE",25); - vect3 = rst1.getRst("XGRP",25); - vect4 = rst1.getRst("LOGIHEAD",25); - vect5 = rst1.getRst("ZWEL",25); + vect1 = rst1.getRst("ICON",25, 0); + vect2 = rst1.getRst("PRESSURE",25, 0); + vect3 = rst1.getRst("XGRP",25, 0); + vect4 = rst1.getRst("LOGIHEAD",25, 0); + vect5 = rst1.getRst("ZWEL",25, 0); BOOST_CHECK_EQUAL(ref_icon_25==vect1, true); @@ -187,19 +187,19 @@ static void readAndWrite(EclOutput& eclTest, ERst& rst1, eclArrType arrType) { if (arrType == INTE) { - std::vector vect = rst1.getRst(name, seqnum); + std::vector vect = rst1.getRst(name, seqnum, 0); eclTest.write(name, vect); } else if (arrType == REAL) { - std::vector vect = rst1.getRst(name, seqnum); + std::vector vect = rst1.getRst(name, seqnum, 0); eclTest.write(name, vect); } else if (arrType == DOUB) { - std::vector vect = rst1.getRst(name, seqnum); + std::vector vect = rst1.getRst(name, seqnum, 0); eclTest.write(name, vect); } else if (arrType == LOGI) { - std::vector vect = rst1.getRst(name, seqnum); + std::vector vect = rst1.getRst(name, seqnum, 0); eclTest.write(name, vect); } else if (arrType == CHAR) { - std::vector vect = rst1.getRst(name, seqnum); + std::vector vect = rst1.getRst(name, seqnum, 0); eclTest.write(name, vect); } else if (arrType == MESS) { eclTest.write(name, std::vector()); @@ -301,9 +301,9 @@ BOOST_AUTO_TEST_CASE(TestERst_4) { BOOST_CHECK_EQUAL(rst3.hasReportStepNumber(4), false); BOOST_CHECK_EQUAL(rst3.hasReportStepNumber(25), true); - std::vector pres1 = rst1.getRst("PRESSURE",25); - std::vector pres2 = rst2.getRst("PRESSURE",25); - std::vector pres3 = rst3.getRst("PRESSURE",25); + std::vector pres1 = rst1.getRst("PRESSURE",25, 0); + std::vector pres2 = rst2.getRst("PRESSURE",25, 0); + std::vector pres3 = rst3.getRst("PRESSURE",25, 0); BOOST_CHECK_EQUAL(pres1==pres2, true); BOOST_CHECK_EQUAL(pres1==pres3, true); @@ -443,7 +443,7 @@ BOOST_AUTO_TEST_CASE(Unformatted) rst.loadReportStepNumber(1); { - const auto& I = rst.getRst("I", 1); + const auto& I = rst.getRst("I", 1, 0); const auto expect_I = std::vector{ 1, 7, 2, 9 }; BOOST_CHECK_EQUAL_COLLECTIONS(I.begin(), I.end(), expect_I.begin(), @@ -451,7 +451,7 @@ BOOST_AUTO_TEST_CASE(Unformatted) } { - const auto& L = rst.getRst("L", 1); + const auto& L = rst.getRst("L", 1, 0); const auto expect_L = std::vector { true, false, false, true, }; @@ -462,7 +462,7 @@ BOOST_AUTO_TEST_CASE(Unformatted) } { - const auto& S = rst.getRst("S", 1); + const auto& S = rst.getRst("S", 1, 0); const auto expect_S = std::vector{ 3.1f, 4.1f, 59.265f, }; @@ -471,7 +471,7 @@ BOOST_AUTO_TEST_CASE(Unformatted) } { - const auto& D = rst.getRst("D", 1); + const auto& D = rst.getRst("D", 1, 0); const auto expect_D = std::vector{ 2.71, 8.21, }; @@ -480,7 +480,7 @@ BOOST_AUTO_TEST_CASE(Unformatted) } { - const auto& Z = rst.getRst("Z", 1); + const auto& Z = rst.getRst("Z", 1, 0); const auto expect_Z = std::vector{ "W1", "W2", // ERst trims trailing blanks }; @@ -541,7 +541,7 @@ BOOST_AUTO_TEST_CASE(Unformatted) rst.loadReportStepNumber(5); { - const auto& I = rst.getRst("I", 5); + const auto& I = rst.getRst("I", 5, 0); const auto expect_I = std::vector{ 1, 2, 3, 4 }; BOOST_CHECK_EQUAL_COLLECTIONS(I.begin(), I.end(), expect_I.begin(), @@ -549,7 +549,7 @@ BOOST_AUTO_TEST_CASE(Unformatted) } { - const auto& L = rst.getRst("L", 5); + const auto& L = rst.getRst("L", 5, 0); const auto expect_L = std::vector { false, false, false, true, }; @@ -560,7 +560,7 @@ BOOST_AUTO_TEST_CASE(Unformatted) } { - const auto& S = rst.getRst("S", 5); + const auto& S = rst.getRst("S", 5, 0); const auto expect_S = std::vector{ 1.23e-04f, 1.234e5f, -5.4321e-9f, }; @@ -569,7 +569,7 @@ BOOST_AUTO_TEST_CASE(Unformatted) } { - const auto& D = rst.getRst("D", 5); + const auto& D = rst.getRst("D", 5, 0); const auto expect_D = std::vector{ 0.6931, 1.6180, }; @@ -578,7 +578,7 @@ BOOST_AUTO_TEST_CASE(Unformatted) } { - const auto& Z = rst.getRst("Z", 5); + const auto& Z = rst.getRst("Z", 5, 0); const auto expect_Z = std::vector{ "HELLO", ",", "WORLD", // ERst trims trailing blanks }; @@ -639,7 +639,7 @@ BOOST_AUTO_TEST_CASE(Unformatted) rst.loadReportStepNumber(13); { - const auto& I = rst.getRst("I", 13); + const auto& I = rst.getRst("I", 13, 0); const auto expect_I = std::vector{ 35, 51, 13}; BOOST_CHECK_EQUAL_COLLECTIONS(I.begin(), I.end(), expect_I.begin(), @@ -647,7 +647,7 @@ BOOST_AUTO_TEST_CASE(Unformatted) } { - const auto& L = rst.getRst("L", 13); + const auto& L = rst.getRst("L", 13, 0); const auto expect_L = std::vector { true, true, true, false, }; @@ -658,7 +658,7 @@ BOOST_AUTO_TEST_CASE(Unformatted) } { - const auto& S = rst.getRst("S", 13); + const auto& S = rst.getRst("S", 13, 0); const auto expect_S = std::vector{ 17.29e-02f, 1.4142f, }; @@ -667,7 +667,7 @@ BOOST_AUTO_TEST_CASE(Unformatted) } { - const auto& D = rst.getRst("D", 13); + const auto& D = rst.getRst("D", 13, 0); const auto expect_D = std::vector{ 0.6931, 1.6180, 123.45e6, }; @@ -676,7 +676,7 @@ BOOST_AUTO_TEST_CASE(Unformatted) } { - const auto& Z = rst.getRst("Z", 13); + const auto& Z = rst.getRst("Z", 13, 0); const auto expect_Z = std::vector{ "G1", "FIELD", // ERst trims trailing blanks }; @@ -747,7 +747,7 @@ BOOST_AUTO_TEST_CASE(Formatted) rst.loadReportStepNumber(13); { - const auto& I = rst.getRst("I", 13); + const auto& I = rst.getRst("I", 13, 0); const auto expect_I = std::vector{ 35, 51, 13 }; BOOST_CHECK_EQUAL_COLLECTIONS(I.begin(), I.end(), expect_I.begin(), @@ -755,7 +755,7 @@ BOOST_AUTO_TEST_CASE(Formatted) } { - const auto& L = rst.getRst("L", 13); + const auto& L = rst.getRst("L", 13, 0); const auto expect_L = std::vector { true, true, true, false, }; @@ -766,7 +766,7 @@ BOOST_AUTO_TEST_CASE(Formatted) } { - const auto& S = rst.getRst("S", 13); + const auto& S = rst.getRst("S", 13, 0); const auto expect_S = std::vector{ 17.29e-02f, 1.4142f, }; @@ -775,7 +775,7 @@ BOOST_AUTO_TEST_CASE(Formatted) } { - const auto& D = rst.getRst("D", 13); + const auto& D = rst.getRst("D", 13, 0); const auto expect_D = std::vector{ 0.6931, 1.6180, 123.45e6, }; @@ -784,7 +784,7 @@ BOOST_AUTO_TEST_CASE(Formatted) } { - const auto& Z = rst.getRst("Z", 13); + const auto& Z = rst.getRst("Z", 13, 0); const auto expect_Z = std::vector{ "G1", "FIELD", // ERst trims trailing blanks }; @@ -836,7 +836,7 @@ BOOST_AUTO_TEST_CASE(Formatted) rst.loadReportStepNumber(5); { - const auto& I = rst.getRst("I", 5); + const auto& I = rst.getRst("I", 5, 0); const auto expect_I = std::vector{ 1, 2, 3, 4 }; BOOST_CHECK_EQUAL_COLLECTIONS(I.begin(), I.end(), expect_I.begin(), @@ -855,7 +855,7 @@ BOOST_AUTO_TEST_CASE(Formatted) } { - const auto& S = rst.getRst("S", 5); + const auto& S = rst.getRst("S", 5, 0); const auto expect_S = std::vector{ 1.23e-04f, 1.234e5f, -5.4321e-9f, }; @@ -864,7 +864,7 @@ BOOST_AUTO_TEST_CASE(Formatted) } { - const auto& D = rst.getRst("D", 5); + const auto& D = rst.getRst("D", 5, 0); const auto expect_D = std::vector{ 0.6931, 1.6180, }; @@ -873,7 +873,7 @@ BOOST_AUTO_TEST_CASE(Formatted) } { - const auto& Z = rst.getRst("Z", 5); + const auto& Z = rst.getRst("Z", 5, 0); const auto expect_Z = std::vector{ "HELLO", ",", "WORLD", // ERst trims trailing blanks }; @@ -917,7 +917,7 @@ BOOST_AUTO_TEST_CASE(Formatted) rst.loadReportStepNumber(13); { - const auto& I = rst.getRst("I", 13); + const auto& I = rst.getRst("I", 13, 0); const auto expect_I = std::vector{ 35, 51, 13 }; BOOST_CHECK_EQUAL_COLLECTIONS(I.begin(), I.end(), expect_I.begin(), @@ -925,7 +925,7 @@ BOOST_AUTO_TEST_CASE(Formatted) } { - const auto& L = rst.getRst("L", 13); + const auto& L = rst.getRst("L", 13, 0); const auto expect_L = std::vector { true, true, true, false, }; @@ -936,7 +936,7 @@ BOOST_AUTO_TEST_CASE(Formatted) } { - const auto& S = rst.getRst("S", 13); + const auto& S = rst.getRst("S", 13, 0); const auto expect_S = std::vector{ 17.29e-02f, 1.4142f, }; @@ -945,7 +945,7 @@ BOOST_AUTO_TEST_CASE(Formatted) } { - const auto& D = rst.getRst("D", 13); + const auto& D = rst.getRst("D", 13, 0); const auto expect_D = std::vector{ 0.6931, 1.6180, 123.45e6, }; @@ -954,7 +954,7 @@ BOOST_AUTO_TEST_CASE(Formatted) } { - const auto& Z = rst.getRst("Z", 13); + const auto& Z = rst.getRst("Z", 13, 0); const auto expect_Z = std::vector{ "G1", "FIELD", // ERst trims trailing blanks }; diff --git a/tests/test_EclipseIO.cpp b/tests/test_EclipseIO.cpp index c94e46558..b1ec23f05 100644 --- a/tests/test_EclipseIO.cpp +++ b/tests/test_EclipseIO.cpp @@ -195,7 +195,7 @@ void checkRestartFile( int timeStepIdx ) { const auto& knownVec = rstFile.listOfRstArrays(i); if (keywordExists(knownVec, "PRESSURE")) { - const auto& press = rstFile.getRst("PRESSURE", i); + const auto& press = rstFile.getRst("PRESSURE", i, 0); for( auto& x : sol.data("PRESSURE") ) x /= Metric::Pressure; @@ -203,22 +203,22 @@ void checkRestartFile( int timeStepIdx ) { } if (keywordExists(knownVec, "SWAT")) { - const auto& swat = rstFile.getRst("SWAT", i); + const auto& swat = rstFile.getRst("SWAT", i, 0); compareErtData( sol.data("SWAT"), swat, 1e-4 ); } if (keywordExists(knownVec, "SGAS")) { - const auto& sgas = rstFile.getRst("SGAS", i); + const auto& sgas = rstFile.getRst("SGAS", i, 0); compareErtData( sol.data("SGAS"), sgas, 1e-4 ); } if (keywordExists(knownVec, "KRO")) { - const auto& kro = rstFile.getRst("KRO", i); + const auto& kro = rstFile.getRst("KRO", i, 0); BOOST_CHECK_CLOSE(1.0 * i * kro.size(), sum(kro), 1.0e-8); } if (keywordExists(knownVec, "KRG")) { - const auto& krg = rstFile.getRst("KRG", i); + const auto& krg = rstFile.getRst("KRG", i, 0); BOOST_CHECK_CLOSE(10.0 * i * krg.size(), sum(krg), 1.0e-8); } } diff --git a/tests/test_OutputStream.cpp b/tests/test_OutputStream.cpp index 0c303113f..c41835079 100644 --- a/tests/test_OutputStream.cpp +++ b/tests/test_OutputStream.cpp @@ -564,7 +564,7 @@ BOOST_AUTO_TEST_CASE(Unformatted_Unified) rst.loadReportStepNumber(13); { - const auto& I = rst.getRst("I", 13); + const auto& I = rst.getRst("I", 13, 0); const auto expect_I = std::vector{ 35, 51, 13}; BOOST_CHECK_EQUAL_COLLECTIONS(I.begin(), I.end(), expect_I.begin(), @@ -572,7 +572,7 @@ BOOST_AUTO_TEST_CASE(Unformatted_Unified) } { - const auto& L = rst.getRst("L", 13); + const auto& L = rst.getRst("L", 13, 0); const auto expect_L = std::vector { true, true, true, false, }; @@ -583,7 +583,7 @@ BOOST_AUTO_TEST_CASE(Unformatted_Unified) } { - const auto& S = rst.getRst("S", 13); + const auto& S = rst.getRst("S", 13, 0); const auto expect_S = std::vector{ 17.29e-02f, 1.4142f, }; @@ -592,7 +592,7 @@ BOOST_AUTO_TEST_CASE(Unformatted_Unified) } { - const auto& D = rst.getRst("D", 13); + const auto& D = rst.getRst("D", 13, 0); const auto expect_D = std::vector{ 0.6931, 1.6180, 123.45e6, }; @@ -601,7 +601,7 @@ BOOST_AUTO_TEST_CASE(Unformatted_Unified) } { - const auto& Z = rst.getRst("Z", 13); + const auto& Z = rst.getRst("Z", 13, 0); const auto expect_Z = std::vector{ "G1", "FIELD", // ERst trims trailing blanks }; @@ -663,7 +663,7 @@ BOOST_AUTO_TEST_CASE(Unformatted_Unified) rst.loadReportStepNumber(5); { - const auto& I = rst.getRst("I", 5); + const auto& I = rst.getRst("I", 5, 0); const auto expect_I = std::vector{ 1, 2, 3, 4 }; BOOST_CHECK_EQUAL_COLLECTIONS(I.begin(), I.end(), expect_I.begin(), @@ -671,7 +671,7 @@ BOOST_AUTO_TEST_CASE(Unformatted_Unified) } { - const auto& L = rst.getRst("L", 5); + const auto& L = rst.getRst("L", 5, 0); const auto expect_L = std::vector { false, false, false, true, }; @@ -682,7 +682,7 @@ BOOST_AUTO_TEST_CASE(Unformatted_Unified) } { - const auto& S = rst.getRst("S", 5); + const auto& S = rst.getRst("S", 5, 0); const auto expect_S = std::vector{ 1.23e-04f, 1.234e5f, -5.4321e-9f, }; @@ -691,7 +691,7 @@ BOOST_AUTO_TEST_CASE(Unformatted_Unified) } { - const auto& D = rst.getRst("D", 5); + const auto& D = rst.getRst("D", 5, 0); const auto expect_D = std::vector{ 0.6931, 1.6180, }; @@ -700,7 +700,7 @@ BOOST_AUTO_TEST_CASE(Unformatted_Unified) } { - const auto& Z = rst.getRst("Z", 5); + const auto& Z = rst.getRst("Z", 5, 0); const auto expect_Z = std::vector{ "HELLO", ",", "WORLD", // ERst trims trailing blanks }; @@ -762,7 +762,7 @@ BOOST_AUTO_TEST_CASE(Unformatted_Unified) rst.loadReportStepNumber(13); { - const auto& I = rst.getRst("I", 13); + const auto& I = rst.getRst("I", 13, 0); const auto expect_I = std::vector{ 35, 51, 13}; BOOST_CHECK_EQUAL_COLLECTIONS(I.begin(), I.end(), expect_I.begin(), @@ -770,7 +770,7 @@ BOOST_AUTO_TEST_CASE(Unformatted_Unified) } { - const auto& L = rst.getRst("L", 13); + const auto& L = rst.getRst("L", 13, 0); const auto expect_L = std::vector { true, true, true, false, }; @@ -781,7 +781,7 @@ BOOST_AUTO_TEST_CASE(Unformatted_Unified) } { - const auto& S = rst.getRst("S", 13); + const auto& S = rst.getRst("S", 13, 0); const auto expect_S = std::vector{ 17.29e-02f, 1.4142f, }; @@ -790,7 +790,7 @@ BOOST_AUTO_TEST_CASE(Unformatted_Unified) } { - const auto& D = rst.getRst("D", 13); + const auto& D = rst.getRst("D", 13, 0); const auto expect_D = std::vector{ 0.6931, 1.6180, 123.45e6, }; @@ -799,7 +799,7 @@ BOOST_AUTO_TEST_CASE(Unformatted_Unified) } { - const auto& Z = rst.getRst("Z", 13); + const auto& Z = rst.getRst("Z", 13, 0); const auto expect_Z = std::vector{ "G1", "FIELD", // ERst trims trailing blanks }; diff --git a/tests/test_Restart.cpp b/tests/test_Restart.cpp index 4fbf0a474..655c76e9d 100644 --- a/tests/test_Restart.cpp +++ b/tests/test_Restart.cpp @@ -806,7 +806,7 @@ BOOST_AUTO_TEST_CASE(ExtraData_content) { EclIO::ERst rst{ rstFile }; BOOST_CHECK_MESSAGE( rst.hasKey("EXTRA"), "Restart file is expexted to have EXTRA vector"); - const auto& ex = rst.getRst("EXTRA", 1); + const auto& ex = rst.getRst("EXTRA", 1, 0); BOOST_CHECK_CLOSE( 10 , units.to_si( UnitSystem::measure::pressure, ex[0] ), 0.00001); BOOST_CHECK_CLOSE( units.from_si( UnitSystem::measure::pressure, 3), ex[3], 0.00001); }