Updating class ERst
- rename member function from getRst -> getRestartData - adding support for parsing and reading data for LGRs - a number of member functions made const - updated python bindings for this class
This commit is contained in:
parent
a7314ab5a0
commit
a8461fd121
@ -481,6 +481,8 @@ if(ENABLE_ECL_INPUT)
|
||||
tests/ECLFILE.FINIT
|
||||
tests/LGR_TESTMOD.EGRID
|
||||
tests/LGR_TESTMOD.INIT
|
||||
tests/LGR_TESTMOD.UNRST
|
||||
tests/LGR_TESTMOD.X0002
|
||||
tests/MODEL1_IX.INIT
|
||||
tests/MODEL1_IX.SMSPEC
|
||||
tests/MODEL1_IX.UNSMRY
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace Opm { namespace EclIO { namespace OutputStream {
|
||||
class Restart;
|
||||
}}}
|
||||
@ -37,43 +38,73 @@ class ERst : public EclFile
|
||||
{
|
||||
public:
|
||||
explicit ERst(const std::string& filename);
|
||||
|
||||
bool hasReportStepNumber(int number) const;
|
||||
bool hasLGR(const std::string& gridname, int reportStepNumber) const;
|
||||
|
||||
void loadReportStepNumber(int number);
|
||||
|
||||
template <typename T>
|
||||
const std::vector<T>& getRst(const std::string& name, int reportStepNumber, int occurrence);
|
||||
const std::vector<T>& getRestartData(const std::string& name, int reportStepNumber)
|
||||
{
|
||||
return getRestartData<T>(name,reportStepNumber, 0);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
const std::vector<T>& getRst(int index, int reportStepNumber){
|
||||
const std::vector<T>& getRestartData(const std::string& name, int reportStepNumber, int occurrence);
|
||||
|
||||
template <typename T>
|
||||
const std::vector<T>& getRestartData(const std::string& name, int reportStepNumber, const std::string& lgr_name);
|
||||
|
||||
template <typename T>
|
||||
const std::vector<T>& getRestartData(int index, int reportStepNumber)
|
||||
{
|
||||
auto indRange = this->getIndexRange(reportStepNumber);
|
||||
return this->get<T>(index + std::get<0>(indRange));
|
||||
}
|
||||
|
||||
int count(const std::string& name, int reportStepNumber) const;
|
||||
template <typename T>
|
||||
const std::vector<T>& getRestartData(int index, int reportStepNumber, const std::string& lgr_name)
|
||||
{
|
||||
auto indRange = this->getIndexRange(reportStepNumber);
|
||||
|
||||
if ((std::get<0>(indRange) + index) > std::get<1>(indRange))
|
||||
OPM_THROW(std::invalid_argument, "getRestartData, index out of range");
|
||||
|
||||
int start_ind = get_start_index_lgrname(reportStepNumber, lgr_name);
|
||||
return this->get<T>(index + start_ind);
|
||||
}
|
||||
|
||||
int occurrence_count(const std::string& name, int reportStepNumber) const;
|
||||
size_t numberOfReportSteps() const { return seqnum.size(); };
|
||||
|
||||
const std::vector<int>& listOfReportStepNumbers() const { return seqnum; }
|
||||
|
||||
|
||||
std::vector<EclEntry> listOfRstArrays(int reportStepNumber);
|
||||
std::vector<EclEntry> listOfRstArrays(int reportStepNumber, const std::string& lgr_name);
|
||||
|
||||
friend class OutputStream::Restart;
|
||||
|
||||
private:
|
||||
int nReports;
|
||||
std::vector<int> seqnum; // report step numbers, from SEQNUM array in restart file
|
||||
std::unordered_map<int,bool> reportLoaded;
|
||||
mutable std::unordered_map<int,bool> reportLoaded;
|
||||
std::map<int, std::pair<int,int>> arrIndexRange; // mapping report step number to array indeces (start and end)
|
||||
std::vector<std::vector<std::string>> lgr_names; // report step numbers, from SEQNUM array in restart file
|
||||
|
||||
void initUnified();
|
||||
void initSeparate(const int number);
|
||||
|
||||
int getArrayIndex(const std::string& name, int seqnum, int occurrence) const;
|
||||
std::tuple<int,int> getIndexRange(int reportStepNumber) const;
|
||||
int get_start_index_lgrname(int number, const std::string& lgr_name);
|
||||
|
||||
int getArrayIndex(const std::string& name, int seqnum, int occurrence);
|
||||
int getArrayIndex(const std::string& name, int number, const std::string& lgr_name);
|
||||
|
||||
std::tuple<int,int> getIndexRange(int reportStepNumber) const;
|
||||
|
||||
std::streampos
|
||||
restartStepWritePosition(const int seqnumValue) const;
|
||||
|
||||
|
||||
};
|
||||
|
||||
}} // namespace Opm::EclIO
|
||||
|
@ -121,7 +121,7 @@ npArray get_vector_occurrence(Opm::EclIO::EclFile * file_ptr, const std::string&
|
||||
|
||||
bool erst_contains(Opm::EclIO::ERst * file_ptr, std::tuple<std::string, int> keyword)
|
||||
{
|
||||
bool hasKeyAtReport = file_ptr->count(std::get<0>(keyword), std::get<1>(keyword)) > 0 ? true : false;
|
||||
bool hasKeyAtReport = file_ptr->occurrence_count(std::get<0>(keyword), std::get<1>(keyword)) > 0 ? true : false;
|
||||
return hasKeyAtReport;
|
||||
}
|
||||
|
||||
@ -135,19 +135,19 @@ npArray get_erst_by_index(Opm::EclIO::ERst * file_ptr, size_t index, size_t rste
|
||||
auto array_type = std::get<1>(arrList[index]);
|
||||
|
||||
if (array_type == Opm::EclIO::INTE)
|
||||
return std::make_tuple (convert::numpy_array( file_ptr->getRst<int>(index, rstep)), array_type);
|
||||
return std::make_tuple (convert::numpy_array( file_ptr->getRestartData<int>(index, rstep)), array_type);
|
||||
|
||||
if (array_type == Opm::EclIO::REAL)
|
||||
return std::make_tuple (convert::numpy_array( file_ptr->getRst<float>(index, rstep)), array_type);
|
||||
return std::make_tuple (convert::numpy_array( file_ptr->getRestartData<float>(index, rstep)), array_type);
|
||||
|
||||
if (array_type == Opm::EclIO::DOUB)
|
||||
return std::make_tuple (convert::numpy_array( file_ptr->getRst<double>(index, rstep)), array_type);
|
||||
return std::make_tuple (convert::numpy_array( file_ptr->getRestartData<double>(index, rstep)), array_type);
|
||||
|
||||
if (array_type == Opm::EclIO::LOGI)
|
||||
return std::make_tuple (convert::numpy_array( file_ptr->getRst<bool>(index, rstep)), array_type);
|
||||
return std::make_tuple (convert::numpy_array( file_ptr->getRestartData<bool>(index, rstep)), array_type);
|
||||
|
||||
if (array_type == Opm::EclIO::CHAR)
|
||||
return std::make_tuple (convert::numpy_string_array( file_ptr->getRst<std::string>(index, rstep)), array_type);
|
||||
return std::make_tuple (convert::numpy_string_array( file_ptr->getRestartData<std::string>(index, rstep)), array_type);
|
||||
|
||||
throw std::logic_error("Data type not supported");
|
||||
}
|
||||
@ -155,7 +155,7 @@ npArray get_erst_by_index(Opm::EclIO::ERst * file_ptr, size_t index, size_t rste
|
||||
|
||||
npArray get_erst_vector(Opm::EclIO::ERst * file_ptr, const std::string& key, size_t rstep, size_t occurrence)
|
||||
{
|
||||
if (occurrence >= static_cast<size_t>(file_ptr->count(key, rstep)))
|
||||
if (occurrence >= static_cast<size_t>(file_ptr->occurrence_count(key, rstep)))
|
||||
throw std::out_of_range("file have less than " + std::to_string(occurrence + 1) + " arrays in selected report step");
|
||||
|
||||
auto array_list = file_ptr->listOfRstArrays(rstep);
|
||||
@ -331,9 +331,12 @@ void python::common::export_IO(py::module& m) {
|
||||
.def("load_report_step", &Opm::EclIO::ERst::loadReportStepNumber)
|
||||
.def_property_readonly("report_steps", &Opm::EclIO::ERst::listOfReportStepNumbers)
|
||||
.def("__len__", &Opm::EclIO::ERst::numberOfReportSteps)
|
||||
.def("count", &Opm::EclIO::ERst::count)
|
||||
.def("count", &Opm::EclIO::ERst::occurrence_count)
|
||||
.def("__contains", &erst_contains)
|
||||
.def("__get_list_of_arrays", &Opm::EclIO::ERst::listOfRstArrays)
|
||||
.def("__get_list_of_arrays", (std::vector< std::tuple<std::string, Opm::EclIO::eclArrType, int64_t> >
|
||||
(Opm::EclIO::ERst::*)(int) ) &Opm::EclIO::ERst::listOfRstArrays)
|
||||
.def("__get_list_of_arrays", (std::vector< std::tuple<std::string, Opm::EclIO::eclArrType, int64_t> >
|
||||
(Opm::EclIO::ERst::*)(int, const std::string&) ) &Opm::EclIO::ERst::listOfRstArrays)
|
||||
.def("__get_data", &get_erst_by_index)
|
||||
.def("__get_data", &get_erst_vector);
|
||||
|
||||
|
@ -28,8 +28,6 @@
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
|
||||
namespace {
|
||||
int seqnumFromSeparateFilename(const std::string& filename)
|
||||
@ -80,9 +78,9 @@ void ERst::loadReportStepNumber(int number)
|
||||
}
|
||||
|
||||
std::vector<int> arrayIndexList;
|
||||
arrayIndexList.reserve(arrIndexRange[number].second - arrIndexRange[number].first + 1);
|
||||
arrayIndexList.reserve(arrIndexRange.at(number).second - arrIndexRange.at(number).first + 1);
|
||||
|
||||
for (int i = arrIndexRange[number].first; i < arrIndexRange[number].second; i++) {
|
||||
for (int i = arrIndexRange.at(number).first; i < arrIndexRange.at(number).second; i++) {
|
||||
arrayIndexList.push_back(i);
|
||||
}
|
||||
|
||||
@ -93,6 +91,12 @@ void ERst::loadReportStepNumber(int number)
|
||||
|
||||
|
||||
std::vector<EclFile::EclEntry> ERst::listOfRstArrays(int reportStepNumber)
|
||||
{
|
||||
return this->listOfRstArrays(reportStepNumber, "global");
|
||||
}
|
||||
|
||||
|
||||
std::vector<EclFile::EclEntry> ERst::listOfRstArrays(int reportStepNumber, const std::string& lgr_name)
|
||||
{
|
||||
std::vector<EclEntry> list;
|
||||
|
||||
@ -101,36 +105,66 @@ std::vector<EclFile::EclEntry> ERst::listOfRstArrays(int 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]);
|
||||
if ((lgr_name != "global") && (!this->hasLGR(lgr_name, reportStepNumber))) {
|
||||
std::string message = "Trying to get list of arrays from non existing LGR " + lgr_name;
|
||||
OPM_THROW(std::invalid_argument, message);
|
||||
}
|
||||
|
||||
std::string lgr_name_upper = lgr_name;
|
||||
std::transform(lgr_name_upper.begin(), lgr_name_upper.end(),lgr_name_upper.begin(), ::toupper);
|
||||
|
||||
int start_ind_lgr;
|
||||
std::string last_array_name;
|
||||
|
||||
if ((lgr_name == "") or (lgr_name_upper == "GLOBAL")){
|
||||
auto rng = this->arrIndexRange.at(reportStepNumber);
|
||||
start_ind_lgr = std::get<0>(rng);
|
||||
|
||||
// if keyword LGR not found, loop will be stopped with keyword SEQNUM (next report step)
|
||||
// or last array (end of file)
|
||||
// Opm flow can have extra keywords after ENDSOL, which maks ENDSOL
|
||||
// not usable for a global arrays end signal.
|
||||
|
||||
last_array_name = "LGR";
|
||||
} else {
|
||||
start_ind_lgr = get_start_index_lgrname(reportStepNumber, lgr_name);
|
||||
last_array_name = "ENDLGR";
|
||||
}
|
||||
|
||||
int n = start_ind_lgr;
|
||||
list.emplace_back(array_name[n], array_type[n], array_size[n]);
|
||||
|
||||
do {
|
||||
n++;
|
||||
|
||||
if ((array_name[n] != "SEQNUM") && (array_name[n] != "LGR"))
|
||||
list.emplace_back(array_name[n], array_type[n], array_size[n]);
|
||||
|
||||
} while ((array_name[n] != "SEQNUM") && (array_name[n] != last_array_name) && (n < static_cast<int>(array_name.size()) -1 ));
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
int ERst::count(const std::string& name, int reportStepNumber) const
|
||||
{
|
||||
|
||||
int ERst::occurrence_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<int,int> indexRange = range_it->second;
|
||||
|
||||
|
||||
for (int i=std::get<0>(indexRange); i<std::get<1>(indexRange);i++){
|
||||
if (array_name[i] == name){
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
@ -145,10 +179,15 @@ void ERst::initUnified()
|
||||
auto seqn = get<int>(i);
|
||||
seqnum.push_back(seqn[0]);
|
||||
firstIndex.push_back(i);
|
||||
lgr_names.push_back({});
|
||||
}
|
||||
|
||||
if (array_name[i] == "LGRNAMES") {
|
||||
auto names = getImpl(i, CHAR, char_array, "string");
|
||||
lgr_names[seqnum.size() -1 ] = names;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (size_t i = 0; i < seqnum.size(); i++) {
|
||||
std::pair<int,int> range;
|
||||
range.first = firstIndex[i];
|
||||
@ -169,6 +208,21 @@ void ERst::initUnified()
|
||||
}
|
||||
}
|
||||
|
||||
bool ERst::hasLGR(const std::string& gridname, int reportStepNumber) const
|
||||
{
|
||||
if (!hasReportStepNumber(reportStepNumber)) {
|
||||
std::string message = "Checking for LGR name in non existing sequence " + std::to_string(reportStepNumber);
|
||||
OPM_THROW(std::invalid_argument, message);
|
||||
}
|
||||
|
||||
auto it_seqnum = std::find(seqnum.begin(), seqnum.end(), reportStepNumber);
|
||||
int report_index = std::distance(seqnum.begin(), it_seqnum);
|
||||
auto it_lgrname = std::find(lgr_names[report_index].begin(), lgr_names[report_index].end(), gridname);
|
||||
|
||||
return (it_lgrname != lgr_names[report_index].end());
|
||||
}
|
||||
|
||||
|
||||
void ERst::initSeparate(const int number)
|
||||
{
|
||||
auto& range = this->arrIndexRange[number];
|
||||
@ -178,6 +232,41 @@ void ERst::initSeparate(const int number)
|
||||
this->seqnum.assign(1, number);
|
||||
this->nReports = 1;
|
||||
this->reportLoaded[number] = false;
|
||||
this->lgr_names.push_back({});
|
||||
|
||||
for (int i = range.first; i < range.second; i++) {
|
||||
if (array_name[i] == "LGRNAMES") {
|
||||
auto names = getImpl(i, CHAR, char_array, "string");
|
||||
lgr_names[0] = names;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int ERst::get_start_index_lgrname(int number, const std::string& lgr_name)
|
||||
{
|
||||
if (!hasReportStepNumber(number)) {
|
||||
std::string message = "Trying to get a restart vector from non report step " + std::to_string(number);
|
||||
OPM_THROW(std::invalid_argument, message);
|
||||
}
|
||||
|
||||
auto range_it = arrIndexRange.find(number);
|
||||
std::pair<int,int> indexRange = range_it->second;
|
||||
int start_ind_lgr = -1;
|
||||
|
||||
for (int n = indexRange.first; n < indexRange.second; n++) {
|
||||
if (array_name[n] == "LGR") {
|
||||
auto arr = getImpl(n, CHAR, char_array, "string");
|
||||
if (arr[0] == lgr_name)
|
||||
start_ind_lgr = n;
|
||||
}
|
||||
}
|
||||
|
||||
if (start_ind_lgr == -1){
|
||||
std::string message = "LGR '" + lgr_name + "'not found in restart file";
|
||||
OPM_THROW(std::runtime_error, message);
|
||||
}
|
||||
|
||||
return start_ind_lgr;
|
||||
}
|
||||
|
||||
std::tuple<int,int> ERst::getIndexRange(int reportStepNumber) const {
|
||||
@ -186,19 +275,20 @@ std::tuple<int,int> ERst::getIndexRange(int reportStepNumber) const {
|
||||
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
|
||||
int ERst::getArrayIndex(const std::string& name, int number, int occurrenc)
|
||||
{
|
||||
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 range_it = arrIndexRange.find(number);
|
||||
|
||||
std::pair<int,int> indexRange = range_it->second;
|
||||
@ -209,7 +299,7 @@ int ERst::getArrayIndex(const std::string& name, int number, int occurrenc) cons
|
||||
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);
|
||||
@ -218,6 +308,25 @@ int ERst::getArrayIndex(const std::string& name, int number, int occurrenc) cons
|
||||
return std::distance(array_name.begin(), it);
|
||||
}
|
||||
|
||||
int ERst::getArrayIndex(const std::string& name, int number, const std::string& lgr_name)
|
||||
{
|
||||
auto range_it = arrIndexRange.find(number);
|
||||
std::pair<int,int> indexRange = range_it->second;
|
||||
|
||||
int start_ind_lgr = get_start_index_lgrname(number, lgr_name);
|
||||
|
||||
auto it = std::find(array_name.begin() + start_ind_lgr,
|
||||
array_name.begin() + indexRange.second, name);
|
||||
|
||||
if (std::distance(array_name.begin(),it) == indexRange.second) {
|
||||
std::string message = "Array " + name + " not found for " + lgr_name;
|
||||
OPM_THROW(std::runtime_error, message);
|
||||
}
|
||||
|
||||
return std::distance(array_name.begin(), it);
|
||||
}
|
||||
|
||||
|
||||
std::streampos
|
||||
ERst::restartStepWritePosition(const int seqnumValue) const
|
||||
{
|
||||
@ -229,38 +338,74 @@ ERst::restartStepWritePosition(const int seqnumValue) const
|
||||
}
|
||||
|
||||
template<>
|
||||
const std::vector<int>& ERst::getRst<int>(const std::string& name, int reportStepNumber, int occurrence)
|
||||
const std::vector<int>& ERst::getRestartData<int>(const std::string& name, int reportStepNumber, int occurrence)
|
||||
{
|
||||
int ind = getArrayIndex(name, reportStepNumber, occurrence);
|
||||
return getImpl(ind, INTE, inte_array, "integer");
|
||||
}
|
||||
|
||||
template<>
|
||||
const std::vector<float>& ERst::getRst<float>(const std::string& name, int reportStepNumber, int occurrence)
|
||||
const std::vector<float>& ERst::getRestartData<float>(const std::string& name, int reportStepNumber, int occurrence)
|
||||
{
|
||||
int ind = getArrayIndex(name, reportStepNumber, occurrence);
|
||||
return getImpl(ind, REAL, real_array, "float");
|
||||
}
|
||||
|
||||
template<>
|
||||
const std::vector<double>& ERst::getRst<double>(const std::string& name, int reportStepNumber, int occurrence)
|
||||
const std::vector<double>& ERst::getRestartData<double>(const std::string& name, int reportStepNumber, int occurrence)
|
||||
{
|
||||
int ind = getArrayIndex(name, reportStepNumber, occurrence);
|
||||
return getImpl(ind, DOUB, doub_array, "double");
|
||||
}
|
||||
|
||||
template<>
|
||||
const std::vector<bool>& ERst::getRst<bool>(const std::string& name, int reportStepNumber, int occurrence)
|
||||
const std::vector<bool>& ERst::getRestartData<bool>(const std::string& name, int reportStepNumber, int occurrence)
|
||||
{
|
||||
int ind = getArrayIndex(name, reportStepNumber, occurrence);
|
||||
return getImpl(ind, LOGI, logi_array, "bool");
|
||||
}
|
||||
|
||||
template<>
|
||||
const std::vector<std::string>& ERst::getRst<std::string>(const std::string& name, int reportStepNumber, int occurrence)
|
||||
const std::vector<std::string>& ERst::getRestartData<std::string>(const std::string& name, int reportStepNumber, int occurrence)
|
||||
{
|
||||
int ind = getArrayIndex(name, reportStepNumber, occurrence);
|
||||
return getImpl(ind, CHAR, char_array, "string");
|
||||
}
|
||||
|
||||
template<>
|
||||
const std::vector<float>& ERst::getRestartData<float>(const std::string& name, int reportStepNumber,const std::string& lgr_name)
|
||||
{
|
||||
int ind = getArrayIndex(name, reportStepNumber, lgr_name);
|
||||
return getImpl(ind, REAL, real_array, "float");
|
||||
}
|
||||
|
||||
template<>
|
||||
const std::vector<double>& ERst::getRestartData<double>(const std::string& name, int reportStepNumber,const std::string& lgr_name)
|
||||
{
|
||||
int ind = getArrayIndex(name, reportStepNumber, lgr_name);
|
||||
return getImpl(ind, DOUB, doub_array, "double");
|
||||
}
|
||||
|
||||
template<>
|
||||
const std::vector<int>& ERst::getRestartData<int>(const std::string& name, int reportStepNumber,const std::string& lgr_name)
|
||||
{
|
||||
int ind = getArrayIndex(name, reportStepNumber, lgr_name);
|
||||
return getImpl(ind, INTE, inte_array, "int");
|
||||
}
|
||||
|
||||
template<>
|
||||
const std::vector<bool>& ERst::getRestartData<bool>(const std::string& name, int reportStepNumber,const std::string& lgr_name)
|
||||
{
|
||||
int ind = getArrayIndex(name, reportStepNumber, lgr_name);
|
||||
return getImpl(ind, LOGI, logi_array, "bool");
|
||||
}
|
||||
|
||||
template<>
|
||||
const std::vector<std::string>& ERst::getRestartData<std::string>(const std::string& name, int reportStepNumber,const std::string& lgr_name)
|
||||
{
|
||||
int ind = getArrayIndex(name, reportStepNumber, lgr_name);
|
||||
return getImpl(ind, CHAR, char_array, "char");
|
||||
}
|
||||
|
||||
|
||||
}} // namespace Opm::ecl
|
||||
|
@ -209,32 +209,32 @@ const RstWell& RstState::get_well(const std::string& wname) const {
|
||||
|
||||
RstState RstState::load(EclIO::ERst& rst_file, int report_step) {
|
||||
rst_file.loadReportStepNumber(report_step);
|
||||
const auto& intehead = rst_file.getRst<int>("INTEHEAD", report_step, 0);
|
||||
const auto& logihead = rst_file.getRst<bool>("LOGIHEAD", report_step, 0);
|
||||
const auto& doubhead = rst_file.getRst<double>("DOUBHEAD", report_step, 0);
|
||||
const auto& intehead = rst_file.getRestartData<int>("INTEHEAD", report_step, 0);
|
||||
const auto& logihead = rst_file.getRestartData<bool>("LOGIHEAD", report_step, 0);
|
||||
const auto& doubhead = rst_file.getRestartData<double>("DOUBHEAD", report_step, 0);
|
||||
|
||||
auto unit_id = intehead[VI::intehead::UNIT];
|
||||
::Opm::UnitSystem unit_system(unit_id);
|
||||
|
||||
if (intehead[VI::intehead::NWELLS] != 0) {
|
||||
const auto& zgrp = rst_file.getRst<std::string>("ZGRP", report_step, 0);
|
||||
const auto& igrp = rst_file.getRst<int>("IGRP", report_step, 0);
|
||||
const auto& sgrp = rst_file.getRst<float>("SGRP", report_step, 0);
|
||||
const auto& xgrp = rst_file.getRst<double>("XGRP", report_step, 0);
|
||||
const auto& zgrp = rst_file.getRestartData<std::string>("ZGRP", report_step, 0);
|
||||
const auto& igrp = rst_file.getRestartData<int>("IGRP", report_step, 0);
|
||||
const auto& sgrp = rst_file.getRestartData<float>("SGRP", report_step, 0);
|
||||
const auto& xgrp = rst_file.getRestartData<double>("XGRP", report_step, 0);
|
||||
|
||||
const auto& zwel = rst_file.getRst<std::string>("ZWEL", report_step, 0);
|
||||
const auto& iwel = rst_file.getRst<int>("IWEL", report_step, 0);
|
||||
const auto& swel = rst_file.getRst<float>("SWEL", report_step, 0);
|
||||
const auto& xwel = rst_file.getRst<double>("XWEL", report_step, 0);
|
||||
const auto& zwel = rst_file.getRestartData<std::string>("ZWEL", report_step, 0);
|
||||
const auto& iwel = rst_file.getRestartData<int>("IWEL", report_step, 0);
|
||||
const auto& swel = rst_file.getRestartData<float>("SWEL", report_step, 0);
|
||||
const auto& xwel = rst_file.getRestartData<double>("XWEL", report_step, 0);
|
||||
|
||||
const auto& icon = rst_file.getRst<int>("ICON", report_step, 0);
|
||||
const auto& scon = rst_file.getRst<float>("SCON", report_step, 0);
|
||||
const auto& xcon = rst_file.getRst<double>("XCON", report_step, 0);
|
||||
const auto& icon = rst_file.getRestartData<int>("ICON", report_step, 0);
|
||||
const auto& scon = rst_file.getRestartData<float>("SCON", report_step, 0);
|
||||
const auto& xcon = rst_file.getRestartData<double>("XCON", report_step, 0);
|
||||
|
||||
|
||||
if (rst_file.hasKey("ISEG")) {
|
||||
const auto& iseg = rst_file.getRst<int>("ISEG", report_step, 0);
|
||||
const auto& rseg = rst_file.getRst<double>("RSEG", report_step, 0);
|
||||
const auto& iseg = rst_file.getRestartData<int>("ISEG", report_step, 0);
|
||||
const auto& rseg = rst_file.getRestartData<double>("RSEG", report_step, 0);
|
||||
|
||||
return RstState(unit_system,
|
||||
intehead, logihead, doubhead,
|
||||
|
@ -148,7 +148,7 @@ public:
|
||||
const std::vector<ElmType>&
|
||||
getKeyword(const std::string& vector)
|
||||
{
|
||||
return this->rst_file_->getRst<ElmType>(vector, this->report_step_, 0);
|
||||
return this->rst_file_->getRestartData<ElmType>(vector, this->report_step_, 0);
|
||||
}
|
||||
|
||||
const std::vector<int>& intehead()
|
||||
|
@ -856,16 +856,16 @@ void ECLRegressionTest::results_rst()
|
||||
std::cout << "Comparing " << keywords1[i] << " ... ";
|
||||
|
||||
if (arrayType1[i] == INTE) {
|
||||
auto vect1 = rst1.getRst<int>(keywords1[i], seqn, 0);
|
||||
auto vect2 = rst2.getRst<int>(keywords2[ind2], seqn, 0);
|
||||
auto vect1 = rst1.getRestartData<int>(keywords1[i], seqn, 0);
|
||||
auto vect2 = rst2.getRestartData<int>(keywords2[ind2], seqn, 0);
|
||||
compareVectors(vect1, vect2, keywords1[i], reference);
|
||||
} else if (arrayType1[i] == REAL) {
|
||||
auto vect1 = rst1.getRst<float>(keywords1[i], seqn, 0);
|
||||
auto vect2 = rst2.getRst<float>(keywords2[ind2], seqn, 0);
|
||||
auto vect1 = rst1.getRestartData<float>(keywords1[i], seqn, 0);
|
||||
auto vect2 = rst2.getRestartData<float>(keywords2[ind2], seqn, 0);
|
||||
compareFloatingPointVectors(vect1, vect2, keywords1[i], reference);
|
||||
} else if (arrayType1[i] == DOUB) {
|
||||
auto vect1 = rst1.getRst<double>(keywords1[i], seqn, 0);
|
||||
auto vect2 = rst2.getRst<double>(keywords2[ind2], seqn, 0);
|
||||
auto vect1 = rst1.getRestartData<double>(keywords1[i], seqn, 0);
|
||||
auto vect2 = rst2.getRestartData<double>(keywords2[ind2], seqn, 0);
|
||||
|
||||
// hack in order to not test doubhead[1], dependent on simulation results
|
||||
// All ohter items in DOUBHEAD are tested with strict tolerances
|
||||
@ -874,12 +874,12 @@ void ECLRegressionTest::results_rst()
|
||||
}
|
||||
compareFloatingPointVectors(vect1, vect2, keywords1[i], reference);
|
||||
} else if (arrayType1[i] == LOGI) {
|
||||
auto vect1 = rst1.getRst<bool>(keywords1[i], seqn, 0);
|
||||
auto vect2 = rst2.getRst<bool>(keywords2[ind2], seqn, 0);
|
||||
auto vect1 = rst1.getRestartData<bool>(keywords1[i], seqn, 0);
|
||||
auto vect2 = rst2.getRestartData<bool>(keywords2[ind2], seqn, 0);
|
||||
compareVectors(vect1, vect2, keywords1[i], reference);
|
||||
} else if (arrayType1[i] == CHAR) {
|
||||
auto vect1 = rst1.getRst<std::string>(keywords1[i], seqn, 0);
|
||||
auto vect2 = rst2.getRst<std::string>(keywords2[ind2], seqn, 0);
|
||||
auto vect1 = rst1.getRestartData<std::string>(keywords1[i], seqn, 0);
|
||||
auto vect2 = rst2.getRestartData<std::string>(keywords2[ind2], seqn, 0);
|
||||
compareVectors(vect1, vect2, keywords1[i], reference);
|
||||
} else if (arrayType1[i] == MESS) {
|
||||
// shold not be any associated data
|
||||
|
@ -24,7 +24,7 @@ template<typename T>
|
||||
void write(EclOutput& outFile, ERst& file1,
|
||||
const std::string& name, int index, int reportStepNumber)
|
||||
{
|
||||
auto vect = file1.getRst<T>(index, reportStepNumber);
|
||||
auto vect = file1.getRestartData<T>(index, reportStepNumber);
|
||||
outFile.write(name, vect);
|
||||
}
|
||||
|
||||
@ -177,7 +177,7 @@ int main(int argc, char **argv) {
|
||||
|
||||
for (auto seqn : reportStepList) {
|
||||
|
||||
std::vector<int> inteh = rst1.getRst<int>("INTEHEAD", seqn, 0);
|
||||
std::vector<int> inteh = rst1.getRestartData<int>("INTEHEAD", seqn, 0);
|
||||
|
||||
std::cout << "Report step number: "
|
||||
<< std::setfill(' ') << std::setw(4) << seqn << " Date: " << inteh[66] << "/"
|
||||
|
BIN
tests/LGR_TESTMOD.UNRST
Normal file
BIN
tests/LGR_TESTMOD.UNRST
Normal file
Binary file not shown.
BIN
tests/LGR_TESTMOD.X0002
Normal file
BIN
tests/LGR_TESTMOD.X0002
Normal file
Binary file not shown.
@ -147,8 +147,8 @@ BOOST_AUTO_TEST_CASE(RUN) {
|
||||
auto rst = EclIO::ERst("SPE1CASE1.UNRST");
|
||||
|
||||
for (const auto& step : rst.listOfReportStepNumbers()) {
|
||||
const auto& dh = rst.getRst<double>("DOUBHEAD", step, 0);
|
||||
const auto& press = rst.getRst<float>("PRESSURE", step, 0);
|
||||
const auto& dh = rst.getRestartData<double>("DOUBHEAD", step, 0);
|
||||
const auto& press = rst.getRestartData<float>("PRESSURE", step, 0);
|
||||
|
||||
// DOUBHEAD[0] is elapsed time in days since start of simulation.
|
||||
BOOST_CHECK_CLOSE( press[0], dh[0] * 86400, 1e-3 );
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "config.h"
|
||||
|
||||
#include <opm/io/eclipse/ERst.hpp>
|
||||
#include <opm/io/eclipse/EclFile.hpp>
|
||||
|
||||
#define BOOST_TEST_MODULE Test EclIO
|
||||
#include <boost/test/unit_test.hpp>
|
||||
@ -36,7 +37,7 @@
|
||||
#include <stdio.h>
|
||||
#include <tuple>
|
||||
#include <type_traits>
|
||||
#include<numeric>
|
||||
#include <numeric>
|
||||
|
||||
#include <opm/common/utility/FileSystem.hpp>
|
||||
|
||||
@ -128,28 +129,28 @@ BOOST_AUTO_TEST_CASE(TestERst_1) {
|
||||
|
||||
// non exising report step number, should throw exception
|
||||
|
||||
BOOST_CHECK_THROW(std::vector<int> vect1=rst1.getRst<int>("ICON",0, 0) , std::invalid_argument );
|
||||
BOOST_CHECK_THROW(std::vector<float> vect2=rst1.getRst<float>("PRESSURE",0, 0) , std::invalid_argument );
|
||||
BOOST_CHECK_THROW(std::vector<double> vect3=rst1.getRst<double>("XGRP",0, 0) , std::invalid_argument );
|
||||
BOOST_CHECK_THROW(std::vector<bool> vect4=rst1.getRst<bool>("LOGIHEAD",0, 0) , std::invalid_argument );
|
||||
BOOST_CHECK_THROW(std::vector<std::string> vect4=rst1.getRst<std::string>("ZWEL",0, 0) , std::invalid_argument );
|
||||
BOOST_CHECK_THROW(std::vector<int> vect1=rst1.getRestartData<int>("ICON",0, 0) , std::invalid_argument );
|
||||
BOOST_CHECK_THROW(std::vector<float> vect2=rst1.getRestartData<float>("PRESSURE",0, 0) , std::invalid_argument );
|
||||
BOOST_CHECK_THROW(std::vector<double> vect3=rst1.getRestartData<double>("XGRP",0, 0) , std::invalid_argument );
|
||||
BOOST_CHECK_THROW(std::vector<bool> vect4=rst1.getRestartData<bool>("LOGIHEAD",0, 0) , std::invalid_argument );
|
||||
BOOST_CHECK_THROW(std::vector<std::string> vect4=rst1.getRestartData<std::string>("ZWEL",0, 0) , std::invalid_argument );
|
||||
|
||||
// calling getRst<T> member function with wrong type, should throw exception
|
||||
// calling getRestartData<T> member function with wrong type, should throw exception
|
||||
|
||||
BOOST_CHECK_THROW(std::vector<float> vect1=rst1.getRst<float>("ICON",5, 0) , std::runtime_error );
|
||||
BOOST_CHECK_THROW(std::vector<int> vect2=rst1.getRst<int>("PRESSURE",5, 0), std::runtime_error );
|
||||
BOOST_CHECK_THROW(std::vector<float> vect3=rst1.getRst<float>("XGRP",5, 0), std::runtime_error );
|
||||
BOOST_CHECK_THROW(std::vector<double> vect4=rst1.getRst<double>("LOGIHEAD",5, 0), std::runtime_error );
|
||||
BOOST_CHECK_THROW(std::vector<bool> vect5=rst1.getRst<bool>("ZWEL",5, 0), std::runtime_error );
|
||||
BOOST_CHECK_THROW(std::vector<float> vect1=rst1.getRestartData<float>("ICON",5, 0) , std::runtime_error );
|
||||
BOOST_CHECK_THROW(std::vector<int> vect2=rst1.getRestartData<int>("PRESSURE",5, 0), std::runtime_error );
|
||||
BOOST_CHECK_THROW(std::vector<float> vect3=rst1.getRestartData<float>("XGRP",5, 0), std::runtime_error );
|
||||
BOOST_CHECK_THROW(std::vector<double> vect4=rst1.getRestartData<double>("LOGIHEAD",5, 0), std::runtime_error );
|
||||
BOOST_CHECK_THROW(std::vector<bool> vect5=rst1.getRestartData<bool>("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<int> vect1=rst1.getRst<int>("ICON",10, 0);
|
||||
std::vector<float> vect2=rst1.getRst<float>("PRESSURE",10, 0);
|
||||
std::vector<double> vect3=rst1.getRst<double>("XGRP",10, 0);
|
||||
std::vector<bool> vect4=rst1.getRst<bool>("LOGIHEAD",10, 0);
|
||||
std::vector<std::string> vect5=rst1.getRst<std::string>("ZWEL",10, 0);
|
||||
std::vector<int> vect1=rst1.getRestartData<int>("ICON",10, 0);
|
||||
std::vector<float> vect2=rst1.getRestartData<float>("PRESSURE",10, 0);
|
||||
std::vector<double> vect3=rst1.getRestartData<double>("XGRP",10, 0);
|
||||
std::vector<bool> vect4=rst1.getRestartData<bool>("LOGIHEAD",10, 0);
|
||||
std::vector<std::string> vect5=rst1.getRestartData<std::string>("ZWEL",10, 0);
|
||||
|
||||
BOOST_CHECK_EQUAL(ref_icon_10==vect1, true);
|
||||
|
||||
@ -164,11 +165,11 @@ BOOST_AUTO_TEST_CASE(TestERst_1) {
|
||||
|
||||
rst1.loadReportStepNumber(25);
|
||||
|
||||
vect1 = rst1.getRst<int>("ICON",25, 0);
|
||||
vect2 = rst1.getRst<float>("PRESSURE",25, 0);
|
||||
vect3 = rst1.getRst<double>("XGRP",25, 0);
|
||||
vect4 = rst1.getRst<bool>("LOGIHEAD",25, 0);
|
||||
vect5 = rst1.getRst<std::string>("ZWEL",25, 0);
|
||||
vect1 = rst1.getRestartData<int>("ICON",25, 0);
|
||||
vect2 = rst1.getRestartData<float>("PRESSURE",25, 0);
|
||||
vect3 = rst1.getRestartData<double>("XGRP",25, 0);
|
||||
vect4 = rst1.getRestartData<bool>("LOGIHEAD",25, 0);
|
||||
vect5 = rst1.getRestartData<std::string>("ZWEL",25, 0);
|
||||
|
||||
BOOST_CHECK_EQUAL(ref_icon_25==vect1, true);
|
||||
|
||||
@ -183,24 +184,25 @@ BOOST_AUTO_TEST_CASE(TestERst_1) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
static void readAndWrite(EclOutput& eclTest, ERst& rst1,
|
||||
const std::string& name, int seqnum,
|
||||
eclArrType arrType)
|
||||
{
|
||||
if (arrType == INTE) {
|
||||
std::vector<int> vect = rst1.getRst<int>(name, seqnum, 0);
|
||||
std::vector<int> vect = rst1.getRestartData<int>(name, seqnum, 0);
|
||||
eclTest.write(name, vect);
|
||||
} else if (arrType == REAL) {
|
||||
std::vector<float> vect = rst1.getRst<float>(name, seqnum, 0);
|
||||
std::vector<float> vect = rst1.getRestartData<float>(name, seqnum, 0);
|
||||
eclTest.write(name, vect);
|
||||
} else if (arrType == DOUB) {
|
||||
std::vector<double> vect = rst1.getRst<double>(name, seqnum, 0);
|
||||
std::vector<double> vect = rst1.getRestartData<double>(name, seqnum, 0);
|
||||
eclTest.write(name, vect);
|
||||
} else if (arrType == LOGI) {
|
||||
std::vector<bool> vect = rst1.getRst<bool>(name, seqnum, 0);
|
||||
std::vector<bool> vect = rst1.getRestartData<bool>(name, seqnum, 0);
|
||||
eclTest.write(name, vect);
|
||||
} else if (arrType == CHAR) {
|
||||
std::vector<std::string> vect = rst1.getRst<std::string>(name, seqnum, 0);
|
||||
std::vector<std::string> vect = rst1.getRestartData<std::string>(name, seqnum, 0);
|
||||
eclTest.write(name, vect);
|
||||
} else if (arrType == MESS) {
|
||||
eclTest.write(name, std::vector<char>());
|
||||
@ -246,6 +248,7 @@ BOOST_AUTO_TEST_CASE(TestERst_2) {
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(TestERst_3) {
|
||||
|
||||
std::string testFile="SPE1_TESTCASE.FUNRST";
|
||||
@ -278,6 +281,7 @@ BOOST_AUTO_TEST_CASE(TestERst_3) {
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(TestERst_4) {
|
||||
|
||||
std::string testFile1="./SPE1_TESTCASE.UNRST";
|
||||
@ -302,13 +306,223 @@ BOOST_AUTO_TEST_CASE(TestERst_4) {
|
||||
BOOST_CHECK_EQUAL(rst3.hasReportStepNumber(4), false);
|
||||
BOOST_CHECK_EQUAL(rst3.hasReportStepNumber(25), true);
|
||||
|
||||
std::vector<float> pres1 = rst1.getRst<float>("PRESSURE",25, 0);
|
||||
std::vector<float> pres2 = rst2.getRst<float>("PRESSURE",25, 0);
|
||||
std::vector<float> pres3 = rst3.getRst<float>("PRESSURE",25, 0);
|
||||
std::vector<float> pres1 = rst1.getRestartData<float>("PRESSURE",25, 0);
|
||||
std::vector<float> pres2 = rst2.getRestartData<float>("PRESSURE",25, 0);
|
||||
std::vector<float> pres3 = rst3.getRestartData<float>("PRESSURE",25, 0);
|
||||
|
||||
BOOST_CHECK_EQUAL(pres1==pres2, true);
|
||||
BOOST_CHECK_EQUAL(pres1==pres3, true);
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(TestERst_5a) {
|
||||
|
||||
std::string testRstFile = "LGR_TESTMOD.X0002";
|
||||
|
||||
ERst rst1(testRstFile);
|
||||
|
||||
BOOST_CHECK_EQUAL(rst1.hasReportStepNumber(2), true);
|
||||
BOOST_CHECK_EQUAL(rst1.hasReportStepNumber(0), false);
|
||||
|
||||
// invalied report step number
|
||||
BOOST_CHECK_THROW(rst1.hasLGR("LGR1", 99) , std::invalid_argument );
|
||||
|
||||
BOOST_CHECK_EQUAL(rst1.hasLGR("LGR1", 2), true);
|
||||
BOOST_CHECK_EQUAL(rst1.hasLGR("XXXX", 2), false);
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(TestERst_5b) {
|
||||
|
||||
std::string testRstFile = "LGR_TESTMOD.UNRST";
|
||||
|
||||
std::vector<int> ref_reports = {0, 1, 2, 3};
|
||||
|
||||
std::vector<std::string> ref_names_global = {"SEQNUM", "INTEHEAD", "LOGIHEAD", "DOUBHEAD",
|
||||
"IGRP", "SGRP", "XGRP", "ZGRP", "IWEL", "SWEL", "XWEL", "ZWEL", "ZWLS", "IWLS", "ICON",
|
||||
"SCON", "XCON", "DLYTIM", "HIDDEN", "STARTSOL", "PRESSURE", "SWAT", "SGAS", "RS",
|
||||
"REGDIMS", "FIPFAMNA", "REGRPT", "FIPOIL", "FIPWAT", "FIPGAS", "PBUB", "LGRNAMES",
|
||||
"ENDSOL" };
|
||||
|
||||
std::vector<int> ref_size_global = { 1, 411, 121, 229, 400, 448, 720, 20, 310, 244, 260, 6,
|
||||
3, 3, 1250, 2050, 2900, 30, 58, 0, 30, 30, 30, 30, 40, 1, 304, 30, 30, 30, 30, 2, 0 };
|
||||
|
||||
std::vector<std::string> ref_names_lgr1 = { "LGR", "LGRHEADI", "LGRHEADQ", "LGRHEADD", "INTEHEAD",
|
||||
"LOGIHEAD", "DOUBHEAD", "IGRP", "SGRP", "XGRP", "ZGRP", "IWEL", "SWEL", "XWEL", "ZWEL", "LGWEL",
|
||||
"ZWLS", "IWLS", "ICON", "SCON", "XCON", "DLYTIM", "HIDDEN", "STARTSOL", "PRESSURE", "SWAT",
|
||||
"SGAS", "RS", "PBUB", "ENDSOL", "ENDLGR"};
|
||||
|
||||
std::vector<int> ref_size_lgr1 = {1, 45, 5, 5, 411, 121, 229, 200, 224, 360, 10, 155, 122, 130,
|
||||
3, 1, 1, 1, 625, 1025, 1450, 30, 58, 0, 128, 128, 128, 128, 128, 0, 1 };
|
||||
|
||||
std::vector<std::string> ref_names_lgr2 = {"LGR", "LGRHEADI", "LGRHEADQ", "LGRHEADD", "INTEHEAD",
|
||||
"LOGIHEAD", "DOUBHEAD", "IGRP", "SGRP", "XGRP", "ZGRP", "IWEL", "SWEL", "XWEL", "ZWEL", "LGWEL",
|
||||
"ZWLS", "IWLS", "ICON", "SCON", "XCON", "DLYTIM", "HIDDEN", "STARTSOL", "PRESSURE", "SWAT",
|
||||
"SGAS", "RS", "PBUB", "ENDSOL", "ENDLGR" };
|
||||
|
||||
std::vector<int> ref_size_lgr2 = {1, 45, 5, 5, 411, 121, 229, 200, 224, 360, 10, 155, 122, 130, 3,
|
||||
1, 1, 1, 625, 1025, 1450, 30, 58, 0, 192, 192, 192, 192, 192, 0, 1};
|
||||
|
||||
ERst rst1(testRstFile);
|
||||
|
||||
auto report_list = rst1.listOfReportStepNumbers();
|
||||
|
||||
BOOST_CHECK_EQUAL(report_list==ref_reports, true);
|
||||
|
||||
BOOST_CHECK_EQUAL(rst1.hasReportStepNumber(1), true);
|
||||
BOOST_CHECK_EQUAL(rst1.hasReportStepNumber(5), false);
|
||||
|
||||
// invalied report step number
|
||||
BOOST_CHECK_THROW(rst1.hasLGR("LGR1", 99) , std::invalid_argument );
|
||||
|
||||
BOOST_CHECK_EQUAL(rst1.hasLGR("LGR1", 2), true);
|
||||
|
||||
int rstep = 0;
|
||||
|
||||
auto array_list_1 = rst1.listOfRstArrays(rstep);
|
||||
|
||||
BOOST_CHECK_EQUAL(array_list_1.size(), ref_names_global.size());
|
||||
BOOST_CHECK_EQUAL(array_list_1.size(), ref_size_global.size());
|
||||
|
||||
for (size_t n = 0; n < array_list_1.size(); n++){
|
||||
BOOST_CHECK_EQUAL(std::get<0>(array_list_1[n]), ref_names_global[n]);
|
||||
BOOST_CHECK_EQUAL(std::get<2>(array_list_1[n]), ref_size_global[n]);
|
||||
}
|
||||
|
||||
for (size_t index = 0; index < array_list_1.size(); index++){
|
||||
|
||||
std::string name = std::get<0>(array_list_1[index]);
|
||||
|
||||
if (std::get<1>(array_list_1[index]) == Opm::EclIO::INTE){
|
||||
auto vect1 = rst1.getRestartData<int>(name, rstep);
|
||||
auto vect2 = rst1.getRestartData<int>(index, rstep);
|
||||
BOOST_CHECK_EQUAL(vect1 == vect2, true);
|
||||
}
|
||||
|
||||
if (std::get<1>(array_list_1[index]) == Opm::EclIO::REAL){
|
||||
auto vect1 = rst1.getRestartData<float>(name, rstep);
|
||||
auto vect2 = rst1.getRestartData<float>(index, rstep);
|
||||
BOOST_CHECK_EQUAL(vect1 == vect2, true);
|
||||
}
|
||||
|
||||
if (std::get<1>(array_list_1[index]) == Opm::EclIO::DOUB){
|
||||
auto vect1 = rst1.getRestartData<double>(name, rstep);
|
||||
auto vect2 = rst1.getRestartData<double>(index, rstep);
|
||||
BOOST_CHECK_EQUAL(vect1 == vect2, true);
|
||||
}
|
||||
|
||||
if (std::get<1>(array_list_1[index]) == Opm::EclIO::LOGI){
|
||||
auto vect1 = rst1.getRestartData<bool>(name, rstep);
|
||||
auto vect2 = rst1.getRestartData<bool>(index, rstep);
|
||||
BOOST_CHECK_EQUAL(vect1 == vect2, true);
|
||||
}
|
||||
|
||||
if (std::get<1>(array_list_1[index]) == Opm::EclIO::CHAR){
|
||||
auto vect1 = rst1.getRestartData<std::string>(name, rstep);
|
||||
auto vect2 = rst1.getRestartData<std::string>(index, rstep);
|
||||
BOOST_CHECK_EQUAL(vect1 == vect2, true);
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------
|
||||
|
||||
std::string lgr_name = "LGR1";
|
||||
|
||||
BOOST_CHECK_THROW(rst1.listOfRstArrays(0, "XXXX") , std::invalid_argument );
|
||||
|
||||
auto array_list_2 = rst1.listOfRstArrays(0, lgr_name);
|
||||
|
||||
BOOST_CHECK_EQUAL(array_list_2.size(), ref_names_lgr1.size());
|
||||
BOOST_CHECK_EQUAL(array_list_2.size(), ref_size_lgr1.size());
|
||||
|
||||
for (size_t n = 0; n < array_list_2.size(); n++){
|
||||
BOOST_CHECK_EQUAL(std::get<0>(array_list_2[n]), ref_names_lgr1[n]);
|
||||
BOOST_CHECK_EQUAL(std::get<2>(array_list_2[n]), ref_size_lgr1[n]);
|
||||
}
|
||||
|
||||
for (size_t index = 0; index < array_list_2.size(); index++){
|
||||
|
||||
std::string name = std::get<0>(array_list_2[index]);
|
||||
|
||||
if (std::get<1>(array_list_2[index]) == Opm::EclIO::INTE){
|
||||
auto vect1 = rst1.getRestartData<int>(name, rstep, lgr_name);
|
||||
auto vect2 = rst1.getRestartData<int>(index, rstep, lgr_name);
|
||||
BOOST_CHECK_EQUAL(vect1 == vect2, true);
|
||||
}
|
||||
|
||||
if (std::get<1>(array_list_2[index]) == Opm::EclIO::REAL){
|
||||
auto vect1 = rst1.getRestartData<float>(name, rstep, lgr_name);
|
||||
auto vect2 = rst1.getRestartData<float>(index, rstep, lgr_name);
|
||||
BOOST_CHECK_EQUAL(vect1 == vect2, true);
|
||||
}
|
||||
|
||||
if (std::get<1>(array_list_2[index]) == Opm::EclIO::DOUB){
|
||||
auto vect1 = rst1.getRestartData<double>(name, rstep, lgr_name);
|
||||
auto vect2 = rst1.getRestartData<double>(index, rstep, lgr_name);
|
||||
BOOST_CHECK_EQUAL(vect1 == vect2, true);
|
||||
}
|
||||
|
||||
if (std::get<1>(array_list_2[index]) == Opm::EclIO::LOGI){
|
||||
auto vect1 = rst1.getRestartData<bool>(name, rstep, lgr_name);
|
||||
auto vect2 = rst1.getRestartData<bool>(index, rstep, lgr_name);
|
||||
BOOST_CHECK_EQUAL(vect1 == vect2, true);
|
||||
}
|
||||
|
||||
if (std::get<1>(array_list_2[index]) == Opm::EclIO::CHAR){
|
||||
auto vect1 = rst1.getRestartData<std::string>(name, rstep, lgr_name);
|
||||
auto vect2 = rst1.getRestartData<std::string>(index, rstep, lgr_name);
|
||||
BOOST_CHECK_EQUAL(vect1 == vect2, true);
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------
|
||||
|
||||
lgr_name = "LGR2";
|
||||
|
||||
auto array_list_3 = rst1.listOfRstArrays(0, lgr_name);
|
||||
|
||||
BOOST_CHECK_EQUAL(array_list_3.size(), ref_names_lgr2.size());
|
||||
BOOST_CHECK_EQUAL(array_list_3.size(), ref_size_lgr2.size());
|
||||
|
||||
for (size_t n = 0; n < array_list_2.size(); n++){
|
||||
BOOST_CHECK_EQUAL(std::get<0>(array_list_3[n]), ref_names_lgr2[n]);
|
||||
BOOST_CHECK_EQUAL(std::get<2>(array_list_3[n]), ref_size_lgr2[n]);
|
||||
}
|
||||
|
||||
for (size_t index = 0; index < array_list_3.size(); index++){
|
||||
|
||||
std::string name = std::get<0>(array_list_3[index]);
|
||||
|
||||
if (std::get<1>(array_list_3[index]) == Opm::EclIO::INTE){
|
||||
auto vect1 = rst1.getRestartData<int>(name, rstep, lgr_name);
|
||||
auto vect2 = rst1.getRestartData<int>(index, rstep, lgr_name);
|
||||
BOOST_CHECK_EQUAL(vect1 == vect2, true);
|
||||
}
|
||||
|
||||
if (std::get<1>(array_list_3[index]) == Opm::EclIO::REAL){
|
||||
auto vect1 = rst1.getRestartData<float>(name, rstep, lgr_name);
|
||||
auto vect2 = rst1.getRestartData<float>(index, rstep, lgr_name);
|
||||
BOOST_CHECK_EQUAL(vect1 == vect2, true);
|
||||
}
|
||||
|
||||
if (std::get<1>(array_list_3[index]) == Opm::EclIO::DOUB){
|
||||
auto vect1 = rst1.getRestartData<double>(name, rstep, lgr_name);
|
||||
auto vect2 = rst1.getRestartData<double>(index, rstep, lgr_name);
|
||||
BOOST_CHECK_EQUAL(vect1 == vect2, true);
|
||||
}
|
||||
|
||||
if (std::get<1>(array_list_3[index]) == Opm::EclIO::LOGI){
|
||||
auto vect1 = rst1.getRestartData<bool>(name, rstep, lgr_name);
|
||||
auto vect2 = rst1.getRestartData<bool>(index, rstep, lgr_name);
|
||||
BOOST_CHECK_EQUAL(vect1 == vect2, true);
|
||||
}
|
||||
|
||||
if (std::get<1>(array_list_3[index]) == Opm::EclIO::CHAR){
|
||||
auto vect1 = rst1.getRestartData<std::string>(name, rstep, lgr_name);
|
||||
auto vect2 = rst1.getRestartData<std::string>(index, rstep, lgr_name);
|
||||
BOOST_CHECK_EQUAL(vect1 == vect2, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -443,7 +657,7 @@ BOOST_AUTO_TEST_CASE(Unformatted)
|
||||
rst.loadReportStepNumber(1);
|
||||
|
||||
{
|
||||
const auto& I = rst.getRst<int>("I", 1, 0);
|
||||
const auto& I = rst.getRestartData<int>("I", 1, 0);
|
||||
const auto expect_I = std::vector<int>{ 1, 7, 2, 9 };
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(I.begin(), I.end(),
|
||||
expect_I.begin(),
|
||||
@ -451,7 +665,7 @@ BOOST_AUTO_TEST_CASE(Unformatted)
|
||||
}
|
||||
|
||||
{
|
||||
const auto& L = rst.getRst<bool>("L", 1, 0);
|
||||
const auto& L = rst.getRestartData<bool>("L", 1, 0);
|
||||
const auto expect_L = std::vector<bool> {
|
||||
true, false, false, true,
|
||||
};
|
||||
@ -462,7 +676,7 @@ BOOST_AUTO_TEST_CASE(Unformatted)
|
||||
}
|
||||
|
||||
{
|
||||
const auto& S = rst.getRst<float>("S", 1, 0);
|
||||
const auto& S = rst.getRestartData<float>("S", 1, 0);
|
||||
const auto expect_S = std::vector<float>{
|
||||
3.1f, 4.1f, 59.265f,
|
||||
};
|
||||
@ -471,7 +685,7 @@ BOOST_AUTO_TEST_CASE(Unformatted)
|
||||
}
|
||||
|
||||
{
|
||||
const auto& D = rst.getRst<double>("D", 1, 0);
|
||||
const auto& D = rst.getRestartData<double>("D", 1, 0);
|
||||
const auto expect_D = std::vector<double>{
|
||||
2.71, 8.21,
|
||||
};
|
||||
@ -480,7 +694,7 @@ BOOST_AUTO_TEST_CASE(Unformatted)
|
||||
}
|
||||
|
||||
{
|
||||
const auto& Z = rst.getRst<std::string>("Z", 1, 0);
|
||||
const auto& Z = rst.getRestartData<std::string>("Z", 1, 0);
|
||||
const auto expect_Z = std::vector<std::string>{
|
||||
"W1", "W2", // ERst trims trailing blanks
|
||||
};
|
||||
@ -541,7 +755,7 @@ BOOST_AUTO_TEST_CASE(Unformatted)
|
||||
rst.loadReportStepNumber(5);
|
||||
|
||||
{
|
||||
const auto& I = rst.getRst<int>("I", 5, 0);
|
||||
const auto& I = rst.getRestartData<int>("I", 5, 0);
|
||||
const auto expect_I = std::vector<int>{ 1, 2, 3, 4 };
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(I.begin(), I.end(),
|
||||
expect_I.begin(),
|
||||
@ -549,7 +763,7 @@ BOOST_AUTO_TEST_CASE(Unformatted)
|
||||
}
|
||||
|
||||
{
|
||||
const auto& L = rst.getRst<bool>("L", 5, 0);
|
||||
const auto& L = rst.getRestartData<bool>("L", 5, 0);
|
||||
const auto expect_L = std::vector<bool> {
|
||||
false, false, false, true,
|
||||
};
|
||||
@ -560,7 +774,7 @@ BOOST_AUTO_TEST_CASE(Unformatted)
|
||||
}
|
||||
|
||||
{
|
||||
const auto& S = rst.getRst<float>("S", 5, 0);
|
||||
const auto& S = rst.getRestartData<float>("S", 5, 0);
|
||||
const auto expect_S = std::vector<float>{
|
||||
1.23e-04f, 1.234e5f, -5.4321e-9f,
|
||||
};
|
||||
@ -569,7 +783,7 @@ BOOST_AUTO_TEST_CASE(Unformatted)
|
||||
}
|
||||
|
||||
{
|
||||
const auto& D = rst.getRst<double>("D", 5, 0);
|
||||
const auto& D = rst.getRestartData<double>("D", 5, 0);
|
||||
const auto expect_D = std::vector<double>{
|
||||
0.6931, 1.6180,
|
||||
};
|
||||
@ -578,7 +792,7 @@ BOOST_AUTO_TEST_CASE(Unformatted)
|
||||
}
|
||||
|
||||
{
|
||||
const auto& Z = rst.getRst<std::string>("Z", 5, 0);
|
||||
const auto& Z = rst.getRestartData<std::string>("Z", 5, 0);
|
||||
const auto expect_Z = std::vector<std::string>{
|
||||
"HELLO", ",", "WORLD", // ERst trims trailing blanks
|
||||
};
|
||||
@ -639,7 +853,7 @@ BOOST_AUTO_TEST_CASE(Unformatted)
|
||||
rst.loadReportStepNumber(13);
|
||||
|
||||
{
|
||||
const auto& I = rst.getRst<int>("I", 13, 0);
|
||||
const auto& I = rst.getRestartData<int>("I", 13, 0);
|
||||
const auto expect_I = std::vector<int>{ 35, 51, 13};
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(I.begin(), I.end(),
|
||||
expect_I.begin(),
|
||||
@ -647,7 +861,7 @@ BOOST_AUTO_TEST_CASE(Unformatted)
|
||||
}
|
||||
|
||||
{
|
||||
const auto& L = rst.getRst<bool>("L", 13, 0);
|
||||
const auto& L = rst.getRestartData<bool>("L", 13, 0);
|
||||
const auto expect_L = std::vector<bool> {
|
||||
true, true, true, false,
|
||||
};
|
||||
@ -658,7 +872,7 @@ BOOST_AUTO_TEST_CASE(Unformatted)
|
||||
}
|
||||
|
||||
{
|
||||
const auto& S = rst.getRst<float>("S", 13, 0);
|
||||
const auto& S = rst.getRestartData<float>("S", 13, 0);
|
||||
const auto expect_S = std::vector<float>{
|
||||
17.29e-02f, 1.4142f,
|
||||
};
|
||||
@ -667,7 +881,7 @@ BOOST_AUTO_TEST_CASE(Unformatted)
|
||||
}
|
||||
|
||||
{
|
||||
const auto& D = rst.getRst<double>("D", 13, 0);
|
||||
const auto& D = rst.getRestartData<double>("D", 13, 0);
|
||||
const auto expect_D = std::vector<double>{
|
||||
0.6931, 1.6180, 123.45e6,
|
||||
};
|
||||
@ -676,7 +890,7 @@ BOOST_AUTO_TEST_CASE(Unformatted)
|
||||
}
|
||||
|
||||
{
|
||||
const auto& Z = rst.getRst<std::string>("Z", 13, 0);
|
||||
const auto& Z = rst.getRestartData<std::string>("Z", 13, 0);
|
||||
const auto expect_Z = std::vector<std::string>{
|
||||
"G1", "FIELD", // ERst trims trailing blanks
|
||||
};
|
||||
@ -747,7 +961,7 @@ BOOST_AUTO_TEST_CASE(Formatted)
|
||||
rst.loadReportStepNumber(13);
|
||||
|
||||
{
|
||||
const auto& I = rst.getRst<int>("I", 13, 0);
|
||||
const auto& I = rst.getRestartData<int>("I", 13, 0);
|
||||
const auto expect_I = std::vector<int>{ 35, 51, 13 };
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(I.begin(), I.end(),
|
||||
expect_I.begin(),
|
||||
@ -755,7 +969,7 @@ BOOST_AUTO_TEST_CASE(Formatted)
|
||||
}
|
||||
|
||||
{
|
||||
const auto& L = rst.getRst<bool>("L", 13, 0);
|
||||
const auto& L = rst.getRestartData<bool>("L", 13, 0);
|
||||
const auto expect_L = std::vector<bool> {
|
||||
true, true, true, false,
|
||||
};
|
||||
@ -766,7 +980,7 @@ BOOST_AUTO_TEST_CASE(Formatted)
|
||||
}
|
||||
|
||||
{
|
||||
const auto& S = rst.getRst<float>("S", 13, 0);
|
||||
const auto& S = rst.getRestartData<float>("S", 13, 0);
|
||||
const auto expect_S = std::vector<float>{
|
||||
17.29e-02f, 1.4142f,
|
||||
};
|
||||
@ -775,7 +989,7 @@ BOOST_AUTO_TEST_CASE(Formatted)
|
||||
}
|
||||
|
||||
{
|
||||
const auto& D = rst.getRst<double>("D", 13, 0);
|
||||
const auto& D = rst.getRestartData<double>("D", 13, 0);
|
||||
const auto expect_D = std::vector<double>{
|
||||
0.6931, 1.6180, 123.45e6,
|
||||
};
|
||||
@ -784,7 +998,7 @@ BOOST_AUTO_TEST_CASE(Formatted)
|
||||
}
|
||||
|
||||
{
|
||||
const auto& Z = rst.getRst<std::string>("Z", 13, 0);
|
||||
const auto& Z = rst.getRestartData<std::string>("Z", 13, 0);
|
||||
const auto expect_Z = std::vector<std::string>{
|
||||
"G1", "FIELD", // ERst trims trailing blanks
|
||||
};
|
||||
@ -836,7 +1050,7 @@ BOOST_AUTO_TEST_CASE(Formatted)
|
||||
rst.loadReportStepNumber(5);
|
||||
|
||||
{
|
||||
const auto& I = rst.getRst<int>("I", 5, 0);
|
||||
const auto& I = rst.getRestartData<int>("I", 5, 0);
|
||||
const auto expect_I = std::vector<int>{ 1, 2, 3, 4 };
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(I.begin(), I.end(),
|
||||
expect_I.begin(),
|
||||
@ -855,7 +1069,7 @@ BOOST_AUTO_TEST_CASE(Formatted)
|
||||
}
|
||||
|
||||
{
|
||||
const auto& S = rst.getRst<float>("S", 5, 0);
|
||||
const auto& S = rst.getRestartData<float>("S", 5, 0);
|
||||
const auto expect_S = std::vector<float>{
|
||||
1.23e-04f, 1.234e5f, -5.4321e-9f,
|
||||
};
|
||||
@ -864,7 +1078,7 @@ BOOST_AUTO_TEST_CASE(Formatted)
|
||||
}
|
||||
|
||||
{
|
||||
const auto& D = rst.getRst<double>("D", 5, 0);
|
||||
const auto& D = rst.getRestartData<double>("D", 5, 0);
|
||||
const auto expect_D = std::vector<double>{
|
||||
0.6931, 1.6180,
|
||||
};
|
||||
@ -873,7 +1087,7 @@ BOOST_AUTO_TEST_CASE(Formatted)
|
||||
}
|
||||
|
||||
{
|
||||
const auto& Z = rst.getRst<std::string>("Z", 5, 0);
|
||||
const auto& Z = rst.getRestartData<std::string>("Z", 5, 0);
|
||||
const auto expect_Z = std::vector<std::string>{
|
||||
"HELLO", ",", "WORLD", // ERst trims trailing blanks
|
||||
};
|
||||
@ -917,7 +1131,7 @@ BOOST_AUTO_TEST_CASE(Formatted)
|
||||
rst.loadReportStepNumber(13);
|
||||
|
||||
{
|
||||
const auto& I = rst.getRst<int>("I", 13, 0);
|
||||
const auto& I = rst.getRestartData<int>("I", 13, 0);
|
||||
const auto expect_I = std::vector<int>{ 35, 51, 13 };
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(I.begin(), I.end(),
|
||||
expect_I.begin(),
|
||||
@ -925,7 +1139,7 @@ BOOST_AUTO_TEST_CASE(Formatted)
|
||||
}
|
||||
|
||||
{
|
||||
const auto& L = rst.getRst<bool>("L", 13, 0);
|
||||
const auto& L = rst.getRestartData<bool>("L", 13, 0);
|
||||
const auto expect_L = std::vector<bool> {
|
||||
true, true, true, false,
|
||||
};
|
||||
@ -936,7 +1150,7 @@ BOOST_AUTO_TEST_CASE(Formatted)
|
||||
}
|
||||
|
||||
{
|
||||
const auto& S = rst.getRst<float>("S", 13, 0);
|
||||
const auto& S = rst.getRestartData<float>("S", 13, 0);
|
||||
const auto expect_S = std::vector<float>{
|
||||
17.29e-02f, 1.4142f,
|
||||
};
|
||||
@ -945,7 +1159,7 @@ BOOST_AUTO_TEST_CASE(Formatted)
|
||||
}
|
||||
|
||||
{
|
||||
const auto& D = rst.getRst<double>("D", 13, 0);
|
||||
const auto& D = rst.getRestartData<double>("D", 13, 0);
|
||||
const auto expect_D = std::vector<double>{
|
||||
0.6931, 1.6180, 123.45e6,
|
||||
};
|
||||
@ -954,7 +1168,7 @@ BOOST_AUTO_TEST_CASE(Formatted)
|
||||
}
|
||||
|
||||
{
|
||||
const auto& Z = rst.getRst<std::string>("Z", 13, 0);
|
||||
const auto& Z = rst.getRestartData<std::string>("Z", 13, 0);
|
||||
const auto expect_Z = std::vector<std::string>{
|
||||
"G1", "FIELD", // ERst trims trailing blanks
|
||||
};
|
||||
|
@ -198,7 +198,7 @@ void checkRestartFile( int timeStepIdx ) {
|
||||
const auto& knownVec = rstFile.listOfRstArrays(i);
|
||||
|
||||
if (keywordExists(knownVec, "PRESSURE")) {
|
||||
const auto& press = rstFile.getRst<float>("PRESSURE", i, 0);
|
||||
const auto& press = rstFile.getRestartData<float>("PRESSURE", i, 0);
|
||||
for( auto& x : sol.data("PRESSURE") )
|
||||
x /= Metric::Pressure;
|
||||
|
||||
@ -206,22 +206,22 @@ void checkRestartFile( int timeStepIdx ) {
|
||||
}
|
||||
|
||||
if (keywordExists(knownVec, "SWAT")) {
|
||||
const auto& swat = rstFile.getRst<float>("SWAT", i, 0);
|
||||
const auto& swat = rstFile.getRestartData<float>("SWAT", i, 0);
|
||||
compareErtData( sol.data("SWAT"), swat, 1e-4 );
|
||||
}
|
||||
|
||||
if (keywordExists(knownVec, "SGAS")) {
|
||||
const auto& sgas = rstFile.getRst<float>("SGAS", i, 0);
|
||||
const auto& sgas = rstFile.getRestartData<float>("SGAS", i, 0);
|
||||
compareErtData( sol.data("SGAS"), sgas, 1e-4 );
|
||||
}
|
||||
|
||||
if (keywordExists(knownVec, "KRO")) {
|
||||
const auto& kro = rstFile.getRst<float>("KRO", i, 0);
|
||||
const auto& kro = rstFile.getRestartData<float>("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<float>("KRG", i, 0);
|
||||
const auto& krg = rstFile.getRestartData<float>("KRG", i, 0);
|
||||
BOOST_CHECK_CLOSE(10.0 * i * krg.size(), sum(krg), 1.0e-8);
|
||||
}
|
||||
}
|
||||
|
@ -563,7 +563,7 @@ BOOST_AUTO_TEST_CASE(Unformatted_Unified)
|
||||
rst.loadReportStepNumber(13);
|
||||
|
||||
{
|
||||
const auto& I = rst.getRst<int>("I", 13, 0);
|
||||
const auto& I = rst.getRestartData<int>("I", 13, 0);
|
||||
const auto expect_I = std::vector<int>{ 35, 51, 13};
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(I.begin(), I.end(),
|
||||
expect_I.begin(),
|
||||
@ -571,7 +571,7 @@ BOOST_AUTO_TEST_CASE(Unformatted_Unified)
|
||||
}
|
||||
|
||||
{
|
||||
const auto& L = rst.getRst<bool>("L", 13, 0);
|
||||
const auto& L = rst.getRestartData<bool>("L", 13, 0);
|
||||
const auto expect_L = std::vector<bool> {
|
||||
true, true, true, false,
|
||||
};
|
||||
@ -582,7 +582,7 @@ BOOST_AUTO_TEST_CASE(Unformatted_Unified)
|
||||
}
|
||||
|
||||
{
|
||||
const auto& S = rst.getRst<float>("S", 13, 0);
|
||||
const auto& S = rst.getRestartData<float>("S", 13, 0);
|
||||
const auto expect_S = std::vector<float>{
|
||||
17.29e-02f, 1.4142f,
|
||||
};
|
||||
@ -591,7 +591,7 @@ BOOST_AUTO_TEST_CASE(Unformatted_Unified)
|
||||
}
|
||||
|
||||
{
|
||||
const auto& D = rst.getRst<double>("D", 13, 0);
|
||||
const auto& D = rst.getRestartData<double>("D", 13, 0);
|
||||
const auto expect_D = std::vector<double>{
|
||||
0.6931, 1.6180, 123.45e6,
|
||||
};
|
||||
@ -600,7 +600,7 @@ BOOST_AUTO_TEST_CASE(Unformatted_Unified)
|
||||
}
|
||||
|
||||
{
|
||||
const auto& Z = rst.getRst<std::string>("Z", 13, 0);
|
||||
const auto& Z = rst.getRestartData<std::string>("Z", 13, 0);
|
||||
const auto expect_Z = std::vector<std::string>{
|
||||
"G1", "FIELD", // ERst trims trailing blanks
|
||||
};
|
||||
@ -662,7 +662,7 @@ BOOST_AUTO_TEST_CASE(Unformatted_Unified)
|
||||
rst.loadReportStepNumber(5);
|
||||
|
||||
{
|
||||
const auto& I = rst.getRst<int>("I", 5, 0);
|
||||
const auto& I = rst.getRestartData<int>("I", 5, 0);
|
||||
const auto expect_I = std::vector<int>{ 1, 2, 3, 4 };
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(I.begin(), I.end(),
|
||||
expect_I.begin(),
|
||||
@ -670,7 +670,7 @@ BOOST_AUTO_TEST_CASE(Unformatted_Unified)
|
||||
}
|
||||
|
||||
{
|
||||
const auto& L = rst.getRst<bool>("L", 5, 0);
|
||||
const auto& L = rst.getRestartData<bool>("L", 5, 0);
|
||||
const auto expect_L = std::vector<bool> {
|
||||
false, false, false, true,
|
||||
};
|
||||
@ -681,7 +681,7 @@ BOOST_AUTO_TEST_CASE(Unformatted_Unified)
|
||||
}
|
||||
|
||||
{
|
||||
const auto& S = rst.getRst<float>("S", 5, 0);
|
||||
const auto& S = rst.getRestartData<float>("S", 5, 0);
|
||||
const auto expect_S = std::vector<float>{
|
||||
1.23e-04f, 1.234e5f, -5.4321e-9f,
|
||||
};
|
||||
@ -690,7 +690,7 @@ BOOST_AUTO_TEST_CASE(Unformatted_Unified)
|
||||
}
|
||||
|
||||
{
|
||||
const auto& D = rst.getRst<double>("D", 5, 0);
|
||||
const auto& D = rst.getRestartData<double>("D", 5, 0);
|
||||
const auto expect_D = std::vector<double>{
|
||||
0.6931, 1.6180,
|
||||
};
|
||||
@ -699,7 +699,7 @@ BOOST_AUTO_TEST_CASE(Unformatted_Unified)
|
||||
}
|
||||
|
||||
{
|
||||
const auto& Z = rst.getRst<std::string>("Z", 5, 0);
|
||||
const auto& Z = rst.getRestartData<std::string>("Z", 5, 0);
|
||||
const auto expect_Z = std::vector<std::string>{
|
||||
"HELLO", ",", "WORLD", // ERst trims trailing blanks
|
||||
};
|
||||
@ -761,7 +761,7 @@ BOOST_AUTO_TEST_CASE(Unformatted_Unified)
|
||||
rst.loadReportStepNumber(13);
|
||||
|
||||
{
|
||||
const auto& I = rst.getRst<int>("I", 13, 0);
|
||||
const auto& I = rst.getRestartData<int>("I", 13, 0);
|
||||
const auto expect_I = std::vector<int>{ 35, 51, 13};
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(I.begin(), I.end(),
|
||||
expect_I.begin(),
|
||||
@ -769,7 +769,7 @@ BOOST_AUTO_TEST_CASE(Unformatted_Unified)
|
||||
}
|
||||
|
||||
{
|
||||
const auto& L = rst.getRst<bool>("L", 13, 0);
|
||||
const auto& L = rst.getRestartData<bool>("L", 13, 0);
|
||||
const auto expect_L = std::vector<bool> {
|
||||
true, true, true, false,
|
||||
};
|
||||
@ -780,7 +780,7 @@ BOOST_AUTO_TEST_CASE(Unformatted_Unified)
|
||||
}
|
||||
|
||||
{
|
||||
const auto& S = rst.getRst<float>("S", 13, 0);
|
||||
const auto& S = rst.getRestartData<float>("S", 13, 0);
|
||||
const auto expect_S = std::vector<float>{
|
||||
17.29e-02f, 1.4142f,
|
||||
};
|
||||
@ -789,7 +789,7 @@ BOOST_AUTO_TEST_CASE(Unformatted_Unified)
|
||||
}
|
||||
|
||||
{
|
||||
const auto& D = rst.getRst<double>("D", 13, 0);
|
||||
const auto& D = rst.getRestartData<double>("D", 13, 0);
|
||||
const auto expect_D = std::vector<double>{
|
||||
0.6931, 1.6180, 123.45e6,
|
||||
};
|
||||
@ -798,7 +798,7 @@ BOOST_AUTO_TEST_CASE(Unformatted_Unified)
|
||||
}
|
||||
|
||||
{
|
||||
const auto& Z = rst.getRst<std::string>("Z", 13, 0);
|
||||
const auto& Z = rst.getRestartData<std::string>("Z", 13, 0);
|
||||
const auto expect_Z = std::vector<std::string>{
|
||||
"G1", "FIELD", // ERst trims trailing blanks
|
||||
};
|
||||
|
@ -650,7 +650,7 @@ BOOST_AUTO_TEST_CASE(ExtraData_KEYS) {
|
||||
BOOST_CHECK_THROW( restart_value.addExtra("KEY", {0,1,1}), std::runtime_error);
|
||||
|
||||
/* The keys must be unique across solution and extra_data */
|
||||
BOOST_CHECK_THROW( restart_value.addExtra("PRESSURE", {0,1}), std::runtime_error);
|
||||
BOOST_CHECK_THROW( restart_value.addExtra("PRESSURE", {0,1}), std::runtime_error);
|
||||
|
||||
/* Must avoid using reserved keys like 'LOGIHEAD' */
|
||||
BOOST_CHECK_THROW( restart_value.addExtra("LOGIHEAD", {0,1}), std::runtime_error);
|
||||
@ -705,7 +705,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<double>("EXTRA", 1, 0);
|
||||
const auto& ex = rst.getRestartData<double>("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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user