diff --git a/CMakeLists.txt b/CMakeLists.txt
index f7952244d..879cef5b3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -166,6 +166,7 @@ if(ENABLE_ECL_INPUT)
examples/test_util/EclUtil.cpp
examples/test_util/EGrid.cpp
examples/test_util/ERft.cpp
+ examples/test_util/ERst.cpp
examples/test_util/summaryComparator.cpp
examples/test_util/summaryIntegrationTest.cpp
examples/test_util/summaryRegressionTest.cpp)
@@ -177,7 +178,7 @@ if(ENABLE_ECL_INPUT)
set(_libs testutil opmcommon
${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
foreach(test test_compareSummary test_EclFilesComparator test_EclIO
- test_EGrid test_ERft)
+ test_EGrid test_ERft test_ERst)
opm_add_test(${test} CONDITION ENABLE_ECL_INPUT
LIBRARIES ${_libs}
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/tests)
diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake
index ac7c340f6..cf37c1911 100644
--- a/CMakeLists_files.cmake
+++ b/CMakeLists_files.cmake
@@ -323,6 +323,8 @@ if(ENABLE_ECL_INPUT)
tests/ECLFILE.FINIT
tests/SPE1CASE1.EGRID
tests/SPE1CASE1.RFT
+ tests/SPE1_TESTCASE.UNRST
+ tests/SPE1_TESTCASE.FUNRST
)
list (APPEND EXAMPLE_SOURCE_FILES
examples/opmi.cpp
diff --git a/examples/test_util/ERst.cpp b/examples/test_util/ERst.cpp
new file mode 100644
index 000000000..5d809041e
--- /dev/null
+++ b/examples/test_util/ERst.cpp
@@ -0,0 +1,178 @@
+/*
+ Copyright 2019 Equinor ASA.
+
+ 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 .
+ */
+
+#include "ERst.hpp"
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+
+ERst::ERst(const std::string& filename) : EclFile(filename)
+{
+ loadData("SEQNUM");
+
+ std::vector firstIndex;
+
+ for (size_t i = 0; i < array_name.size(); i++) {
+ if (array_name[i] == "SEQNUM") {
+ auto seqn = get(i);
+ seqnum.push_back(seqn[0]);
+ firstIndex.push_back(i);
+ }
+ }
+
+
+ for (size_t i = 0; i < seqnum.size(); i++) {
+ std::pair range;
+ range.first = firstIndex[i];
+
+ if (i != seqnum.size() - 1) {
+ range.second = firstIndex[i+1];
+ } else {
+ range.second = array_name.size();
+ }
+
+ arrIndexRange[seqnum[i]] = range;
+ }
+
+ nReports = seqnum.size();
+
+ for (int i = 0; i < nReports; i++) {
+ reportLoaded[seqnum[i]] = false;
+ }
+};
+
+
+bool ERst::hasReportStepNumber(int number) const
+{
+ auto search = arrIndexRange.find(number);
+ return search != arrIndexRange.end();
+}
+
+
+void ERst::loadReportStepNumber(int number)
+{
+ if (!hasReportStepNumber(number)) {
+ std::string message="Trying to load non existing report step number " + std::to_string(number);
+ OPM_THROW(std::invalid_argument, message);
+ }
+
+ std::vector arrayIndexList;
+ arrayIndexList.reserve(arrIndexRange[number].second - arrIndexRange[number].first + 1);
+
+ for (int i = arrIndexRange[number].first; i < arrIndexRange[number].second; i++) {
+ arrayIndexList.push_back(i);
+ }
+
+ loadData(arrayIndexList);
+
+ reportLoaded[number] = true;
+}
+
+
+std::vector ERst::listOfRstArrays(int reportStepNumber)
+{
+ std::vector list;
+
+ if (!hasReportStepNumber(reportStepNumber)) {
+ std::string message = "Trying to get list of arrays from non existing report step number " + std::to_string(reportStepNumber);
+ OPM_THROW(std::invalid_argument, message);
+ }
+
+ const auto& rng = this->arrIndexRange[reportStepNumber];
+ list.reserve(rng.second - rng.first);
+
+ for (int i = rng.first; i < rng.second; i++) {
+ list.emplace_back(array_name[i], array_type[i], array_size[i]);
+ }
+
+ return list;
+}
+
+
+int ERst::getArrayIndex(const std::string& name, int number) const
+{
+ if (!hasReportStepNumber(number)) {
+ std::string message = "Trying to get vector " + name + " from non existing sequence " + std::to_string(number);
+ OPM_THROW(std::invalid_argument, message);
+ }
+
+ auto search = reportLoaded.find(number);
+
+ if (!search->second) {
+ std::string message = "Data not loaded for sequence " + std::to_string(number);
+ OPM_THROW(std::runtime_error, message);
+ }
+
+ auto range_it = arrIndexRange.find(number);
+
+ std::pair indexRange = range_it->second;
+
+ auto it = std::find(array_name.begin() + indexRange.first,
+ 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);
+ }
+
+ return std::distance(array_name.begin(), it);
+}
+
+
+template<>
+const std::vector& ERst::getRst(const std::string& name, int reportStepNumber)
+{
+ int ind = getArrayIndex(name, reportStepNumber);
+ return getImpl(ind, EIOD::INTE, inte_array, "integer");
+}
+
+
+template<>
+const std::vector& ERst::getRst(const std::string& name, int reportStepNumber)
+{
+ int ind = getArrayIndex(name, reportStepNumber);
+ return getImpl(ind, EIOD::REAL, real_array, "float");
+}
+
+
+template<>
+const std::vector& ERst::getRst(const std::string& name, int reportStepNumber)
+{
+ int ind = getArrayIndex(name, reportStepNumber);
+ return getImpl(ind, EIOD::DOUB, doub_array, "double");
+}
+
+
+template<>
+const std::vector& ERst::getRst(const std::string& name, int reportStepNumber)
+{
+ int ind = getArrayIndex(name, reportStepNumber);
+ return getImpl(ind, EIOD::LOGI, logi_array, "bool");
+}
+
+template<>
+const std::vector& ERst::getRst(const std::string& name, int reportStepNumber)
+{
+ int ind = getArrayIndex(name, reportStepNumber);
+ return getImpl(ind, EIOD::CHAR, char_array, "string");
+}
diff --git a/examples/test_util/ERst.hpp b/examples/test_util/ERst.hpp
new file mode 100644
index 000000000..20e82cb64
--- /dev/null
+++ b/examples/test_util/ERst.hpp
@@ -0,0 +1,57 @@
+/*
+ Copyright 2019 Equinor ASA.
+
+ 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 .
+ */
+
+#ifndef ERST_HPP
+#define ERST_HPP
+
+
+#include "EclFile.hpp"
+
+#include
+#include
+#include
+#include
+#include
+#include