added: ERft class for reading RFT simulation data from ECL files
This commit is contained in:
parent
181eeffbdb
commit
24a8efb2e3
@ -165,6 +165,7 @@ if(ENABLE_ECL_INPUT)
|
||||
examples/test_util/EclOutput.cpp
|
||||
examples/test_util/EclUtil.cpp
|
||||
examples/test_util/EGrid.cpp
|
||||
examples/test_util/ERft.cpp
|
||||
examples/test_util/summaryComparator.cpp
|
||||
examples/test_util/summaryIntegrationTest.cpp
|
||||
examples/test_util/summaryRegressionTest.cpp)
|
||||
@ -176,7 +177,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_EGrid test_ERft)
|
||||
opm_add_test(${test} CONDITION ENABLE_ECL_INPUT
|
||||
LIBRARIES ${_libs}
|
||||
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/tests)
|
||||
|
@ -322,6 +322,7 @@ if(ENABLE_ECL_INPUT)
|
||||
tests/ECLFILE.INIT
|
||||
tests/ECLFILE.FINIT
|
||||
tests/SPE1CASE1.EGRID
|
||||
tests/SPE1CASE1.RFT
|
||||
)
|
||||
list (APPEND EXAMPLE_SOURCE_FILES
|
||||
examples/opmi.cpp
|
||||
|
310
examples/test_util/ERft.cpp
Normal file
310
examples/test_util/ERft.cpp
Normal file
@ -0,0 +1,310 @@
|
||||
/*
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "ERft.hpp"
|
||||
|
||||
#include <opm/common/ErrorMacros.hpp>
|
||||
#include <string>
|
||||
#include <string.h>
|
||||
#include <sstream>
|
||||
#include <iterator>
|
||||
#include <iomanip>
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
ERft::ERft(const std::string &filename) : EclFile(filename)
|
||||
{
|
||||
loadData();
|
||||
std::vector<int> first;
|
||||
std::vector<int> second;
|
||||
|
||||
std::vector<std::string> wellName;
|
||||
std::vector<RftDate> dates;
|
||||
|
||||
auto listOfArrays = getList();
|
||||
|
||||
for (size_t i = 0; i < listOfArrays.size(); i++) {
|
||||
std::string name = std::get<0>(listOfArrays[i]);
|
||||
|
||||
if (name == "TIME") {
|
||||
first.push_back(i);
|
||||
auto vect1 = get<float>(i);
|
||||
timeList.push_back(vect1[0]);
|
||||
}
|
||||
|
||||
if (name == "DATE") {
|
||||
auto vect1 = get<int>(i);
|
||||
RftDate date(vect1[2],vect1[1],vect1[0]);
|
||||
dateList.insert(date);
|
||||
dates.push_back(date);
|
||||
}
|
||||
|
||||
if (name == "WELLETC"){
|
||||
auto vect1 = get<std::string>(i);
|
||||
wellList.insert(vect1[1]);
|
||||
wellName.push_back(vect1[1]);
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < first.size(); i++) {
|
||||
std::pair<int,int> range;
|
||||
range.first = first[i];
|
||||
|
||||
if (i == first.size() - 1) {
|
||||
range.second = listOfArrays.size();
|
||||
} else {
|
||||
range.second = first[i+1];
|
||||
}
|
||||
|
||||
arrIndexRange[i] = range;
|
||||
}
|
||||
|
||||
numReports = first.size();
|
||||
|
||||
for (size_t i = 0; i < wellName.size(); i++) {
|
||||
std::pair<std::string,RftDate> wellDatePair(wellName[i],dates[i]);
|
||||
reportIndex[wellDatePair] = i;
|
||||
rftReportList.push_back(wellDatePair);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool ERft::hasRft(const std::string& wellName, const RftDate& date) const
|
||||
{
|
||||
return reportIndex.find({wellName, date}) != reportIndex.end();
|
||||
}
|
||||
|
||||
|
||||
bool ERft::hasRft(const std::string& wellName, int year, int month, int day) const
|
||||
{
|
||||
RftDate date(year, month, day);
|
||||
return reportIndex.find({wellName,date}) != reportIndex.end();
|
||||
}
|
||||
|
||||
|
||||
int ERft::getReportIndex(const std::string& wellName, const RftDate& date) const
|
||||
{
|
||||
std::pair<std::string,std::tuple<int,int,int>> wellDatePair(wellName,date);
|
||||
auto rIndIt = reportIndex.find(wellDatePair);
|
||||
|
||||
if (rIndIt == reportIndex.end()) {
|
||||
int y = std::get<0>(date);
|
||||
int m = std::get<1>(date);
|
||||
int d = std::get<2>(date);
|
||||
|
||||
std::string dateStr=std::to_string(y) + "/" + std::to_string(m) + "/" + std::to_string(d);
|
||||
std::string message="RFT data not found for well " + wellName + " at date: " + dateStr;
|
||||
OPM_THROW(std::invalid_argument, message);
|
||||
}
|
||||
|
||||
return rIndIt->second;
|
||||
}
|
||||
|
||||
|
||||
bool ERft::hasArray(const std::string& arrayName, const std::string& wellName,
|
||||
const RftDate& date) const
|
||||
{
|
||||
int reportInd = getReportIndex(wellName, date);
|
||||
|
||||
auto searchInd = arrIndexRange.find(reportInd);
|
||||
|
||||
int fromInd = searchInd->second.first;
|
||||
int toInd = searchInd->second.second;
|
||||
|
||||
auto it = std::find(array_name.begin()+fromInd,array_name.begin()+toInd,arrayName);
|
||||
return it != array_name.begin() + toInd;
|
||||
}
|
||||
|
||||
|
||||
int ERft::getArrayIndex(const std::string& name, const std::string& wellName,
|
||||
const RftDate& date) const
|
||||
{
|
||||
int rInd= getReportIndex(wellName, date);
|
||||
|
||||
auto searchInd = arrIndexRange.find(rInd);
|
||||
|
||||
int fromInd =searchInd->second.first;
|
||||
int toInd = searchInd->second.second;
|
||||
auto it=std::find(array_name.begin()+fromInd,array_name.begin()+toInd,name);
|
||||
|
||||
if (std::distance(array_name.begin(),it) == toInd) {
|
||||
int y = std::get<0>(date);
|
||||
int m = std::get<1>(date);
|
||||
int d = std::get<2>(date);
|
||||
|
||||
std::string dateStr = std::to_string(y) + "/" + std::to_string(m) + "/" + std::to_string(d);
|
||||
std::string message = "Array " + name + " not found for RFT, well: " + wellName + " date: " + dateStr;
|
||||
OPM_THROW(std::invalid_argument, message);
|
||||
}
|
||||
|
||||
return std::distance(array_name.begin(),it);
|
||||
}
|
||||
|
||||
|
||||
template<> const std::vector<float>&
|
||||
ERft::getRft<float>(const std::string& name, const std::string &wellName,
|
||||
const RftDate& date) const
|
||||
{
|
||||
int arrInd = getArrayIndex(name, wellName, date);
|
||||
|
||||
if (array_type[arrInd] != EIOD::REAL) {
|
||||
std::string message = "Array " + name + " found in RFT file for selected date and well, but called with wrong type";
|
||||
OPM_THROW(std::runtime_error, message);
|
||||
}
|
||||
|
||||
auto search_array = real_array.find(arrInd);
|
||||
return search_array->second;
|
||||
}
|
||||
|
||||
|
||||
template<> const std::vector<double>&
|
||||
ERft::getRft<double>(const std::string& name, const std::string& wellName,
|
||||
const RftDate& date) const
|
||||
{
|
||||
int arrInd = getArrayIndex(name, wellName, date);
|
||||
|
||||
if (array_type[arrInd] != EIOD::DOUB) {
|
||||
std::string message = "Array " + name + " found in RFT file for selected date and well, but called with wrong type";
|
||||
OPM_THROW(std::runtime_error, message);
|
||||
}
|
||||
|
||||
auto search_array = doub_array.find(arrInd);
|
||||
return search_array->second;
|
||||
}
|
||||
|
||||
|
||||
template<> const std::vector<int>&
|
||||
ERft::getRft<int>(const std::string& name, const std::string& wellName,
|
||||
const RftDate& date) const
|
||||
{
|
||||
int arrInd = getArrayIndex(name, wellName, date);
|
||||
|
||||
if (array_type[arrInd] != EIOD::INTE) {
|
||||
std::string message = "Array " + name + " found in RFT file for selected date and well, but called with wrong type";
|
||||
OPM_THROW(std::runtime_error, message);
|
||||
}
|
||||
|
||||
auto search_array = inte_array.find(arrInd);
|
||||
return search_array->second;
|
||||
}
|
||||
|
||||
|
||||
template<> const std::vector<bool>&
|
||||
ERft::getRft<bool>(const std::string& name, const std::string& wellName,
|
||||
const RftDate& date) const
|
||||
{
|
||||
int arrInd = getArrayIndex(name, wellName, date);
|
||||
|
||||
if (array_type[arrInd] != EIOD::LOGI) {
|
||||
std::string message = "Array " + name + " found in RFT file for selected date and well, but called with wrong type";
|
||||
OPM_THROW(std::runtime_error, message);
|
||||
}
|
||||
|
||||
auto search_array = logi_array.find(arrInd);
|
||||
return search_array->second;
|
||||
}
|
||||
|
||||
|
||||
template<> const std::vector<std::string>&
|
||||
ERft::getRft<std::string>(const std::string& name, const std::string& wellName,
|
||||
const RftDate& date) const
|
||||
{
|
||||
int arrInd = getArrayIndex(name, wellName, date);
|
||||
|
||||
if (array_type[arrInd] != EIOD::CHAR) {
|
||||
std::string message = "Array " + name + " found in RFT file for selected date and well, but called with wrong type";
|
||||
OPM_THROW(std::runtime_error, message);
|
||||
}
|
||||
|
||||
auto search_array = char_array.find(arrInd);
|
||||
return search_array->second;
|
||||
}
|
||||
|
||||
|
||||
template<> const std::vector<int>&
|
||||
ERft::getRft<int>(const std::string& name, const std::string& wellName,
|
||||
int year, int month, int day) const
|
||||
{
|
||||
return getRft<int>(name, wellName, RftDate{year, month, day});
|
||||
}
|
||||
|
||||
|
||||
template<> const std::vector<float>&
|
||||
ERft::getRft<float>(const std::string& name, const std::string& wellName,
|
||||
int year, int month, int day) const
|
||||
{
|
||||
return getRft<float>(name, wellName, RftDate{year, month, day});
|
||||
}
|
||||
|
||||
|
||||
template<> const std::vector<double>&
|
||||
ERft::getRft<double>(const std::string& name, const std::string& wellName,
|
||||
int year, int month, int day) const
|
||||
{
|
||||
return getRft<double>(name, wellName, RftDate{year, month, day});
|
||||
}
|
||||
|
||||
|
||||
template<> const std::vector<std::string>&
|
||||
ERft::getRft<std::string>(const std::string& name, const std::string& wellName,
|
||||
int year, int month, int day) const
|
||||
{
|
||||
return getRft<std::string>(name, wellName, RftDate{year, month, day});
|
||||
}
|
||||
|
||||
|
||||
template<> const std::vector<bool>&
|
||||
ERft::getRft<bool>(const std::string& name, const std::string& wellName,
|
||||
int year, int month, int day) const
|
||||
{
|
||||
return getRft<bool>(name, wellName, RftDate{year, month, day});
|
||||
}
|
||||
|
||||
|
||||
std::vector<EclFile::EclEntry> ERft::listOfRftArrays(const std::string& wellName,
|
||||
const RftDate& date) const
|
||||
{
|
||||
std::vector<EclEntry> list;
|
||||
int rInd = getReportIndex(wellName, date);
|
||||
|
||||
auto searchInd = arrIndexRange.find(rInd);
|
||||
for (int i = searchInd->second.first; i < searchInd->second.second; i++) {
|
||||
list.emplace_back(array_name[i], array_type[i], array_size[i]);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
std::vector<EclFile::EclEntry> ERft::listOfRftArrays(const std::string& wellName,
|
||||
int year, int month, int day) const
|
||||
{
|
||||
return listOfRftArrays(wellName, RftDate{year, month, day});
|
||||
}
|
||||
|
||||
|
||||
std::vector<std::string> ERft::listOfWells() const
|
||||
{
|
||||
return { this->wellList.begin(), this->wellList.end() };
|
||||
}
|
||||
|
||||
|
||||
std::vector<ERft::RftDate> ERft::listOfdates() const
|
||||
{
|
||||
return { this->dateList.begin(), this->dateList.end() };
|
||||
}
|
83
examples/test_util/ERft.hpp
Normal file
83
examples/test_util/ERft.hpp
Normal file
@ -0,0 +1,83 @@
|
||||
/*
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef ERFT_HPP
|
||||
#define ERFT_HPP
|
||||
|
||||
|
||||
#include "EclFile.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
#include <ctime>
|
||||
#include <map>
|
||||
#include <set>
|
||||
|
||||
|
||||
class ERft : public EclFile
|
||||
{
|
||||
public:
|
||||
explicit ERft(const std::string &filename);
|
||||
|
||||
using RftDate = std::tuple<int,int,int>;
|
||||
template <typename T>
|
||||
const std::vector<T>& getRft(const std::string& name, const std::string& wellName,
|
||||
const RftDate& date) const;
|
||||
|
||||
template <typename T>
|
||||
const std::vector<T>& getRft(const std::string& name, const std::string& wellName,
|
||||
int year, int month, int day) const;
|
||||
|
||||
std::vector<std::string> listOfWells() const;
|
||||
std::vector<RftDate> listOfdates() const;
|
||||
|
||||
using RftReportList = std::vector<std::pair<std::string, RftDate>>;
|
||||
const RftReportList& listOfRftReports() const { return rftReportList; }
|
||||
|
||||
bool hasRft(const std::string& wellName, const RftDate& date) const;
|
||||
bool hasRft(const std::string& wellName, int year, int month, int day) const;
|
||||
|
||||
std::vector<EclEntry> listOfRftArrays(const std::string& wellName,
|
||||
const RftDate& date) const;
|
||||
|
||||
std::vector<EclEntry> listOfRftArrays(const std::string& wellName,
|
||||
int year, int month, int day) const;
|
||||
|
||||
bool hasArray(const std::string& arrayName, const std::string& wellName,
|
||||
const RftDate& date) const;
|
||||
|
||||
private:
|
||||
std::map<int, std::pair<int,int>> arrIndexRange;
|
||||
int numReports;
|
||||
std::vector<float> timeList;
|
||||
|
||||
std::set<std::string> wellList;
|
||||
std::set<RftDate> dateList;
|
||||
RftReportList rftReportList;
|
||||
|
||||
std::map<std::pair<std::string,RftDate>,int> reportIndex; // mapping report index to wellName and date (tupe)
|
||||
|
||||
int getReportIndex(const std::string& wellName, const RftDate& date) const;
|
||||
int getArrayIndex(const std::string& name, const std::string& wellName,
|
||||
const RftDate& date) const;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
BIN
tests/SPE1CASE1.RFT
Normal file
BIN
tests/SPE1CASE1.RFT
Normal file
Binary file not shown.
202
tests/test_ERft.cpp
Normal file
202
tests/test_ERft.cpp
Normal file
@ -0,0 +1,202 @@
|
||||
/*
|
||||
+ 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 <http://www.gnu.org/licenses/>.
|
||||
+ */
|
||||
|
||||
|
||||
#include "config.h"
|
||||
#include <iostream>
|
||||
#include <stdio.h>
|
||||
#include <iomanip>
|
||||
#include <math.h>
|
||||
#include <algorithm>
|
||||
#include <stdexcept>
|
||||
#include <tuple>
|
||||
|
||||
#include <examples/test_util/ERft.hpp>
|
||||
#include <examples/test_util/EclOutput.hpp>
|
||||
|
||||
#define BOOST_TEST_MODULE Test EGrid
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
template<typename InputIterator1, typename InputIterator2>
|
||||
bool
|
||||
range_equal(InputIterator1 first1, InputIterator1 last1,
|
||||
InputIterator2 first2, InputIterator2 last2)
|
||||
{
|
||||
while(first1 != last1 && first2 != last2)
|
||||
{
|
||||
if(*first1 != *first2) return false;
|
||||
++first1;
|
||||
++first2;
|
||||
}
|
||||
return (first1 == last1) && (first2 == last2);
|
||||
}
|
||||
|
||||
bool compare_files(const std::string& filename1, const std::string& filename2)
|
||||
{
|
||||
std::ifstream file1(filename1);
|
||||
std::ifstream file2(filename2);
|
||||
|
||||
std::istreambuf_iterator<char> begin1(file1);
|
||||
std::istreambuf_iterator<char> begin2(file2);
|
||||
|
||||
std::istreambuf_iterator<char> end;
|
||||
|
||||
return range_equal(begin1, end, begin2, end);
|
||||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
bool operator==(const std::vector<T> & t1, const std::vector<T> & t2)
|
||||
{
|
||||
return std::equal(t1.begin(), t1.end(), t2.begin(), t2.end());
|
||||
}
|
||||
|
||||
// test is using SPE1CASE1, with minor modifications in order to test API for EGrid class
|
||||
// -> 6 cells made inactive, box: 5 7 5 6 1 1
|
||||
|
||||
// first pilar at x=0.0, y=0.0 and z=0.0
|
||||
// dx = 1000 ft, dy = 1000 ft. dz = 20 ft for layer 1, 30 ft for layer 2 and 50 ft for layer 3.
|
||||
// size of grid is 10x10x3
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(TestERft_1) {
|
||||
using Date = std::tuple<int, int, int>;
|
||||
|
||||
std::vector<std::string> ref_wellList= {"A-1H", "B-2H", "INJ", "PROD"};
|
||||
std::vector<Date> ref_dates= {
|
||||
Date{2015,1, 1},
|
||||
Date{2015,9, 1},
|
||||
Date{2016,5,31},
|
||||
Date{2017,7,31},
|
||||
};
|
||||
|
||||
const std::vector<std::pair<std::string,Date>> ref_rftList = {
|
||||
{"PROD", Date{2015,1, 1}},
|
||||
{"INJ" , Date{2015,1, 1}},
|
||||
{"A-1H", Date{2015,9, 1}},
|
||||
{"B-2H", Date{2016,5,31}},
|
||||
{"PROD", Date{2017,7,31}}
|
||||
};
|
||||
|
||||
std::string testFile="SPE1CASE1.RFT";
|
||||
|
||||
ERft rft1(testFile);
|
||||
|
||||
std::vector<std::string> wellList = rft1.listOfWells();
|
||||
std::vector<Date> rftDates = rft1.listOfdates();
|
||||
std::vector<std::pair<std::string,Date>> rftList = rft1.listOfRftReports();
|
||||
|
||||
BOOST_CHECK_EQUAL(wellList==ref_wellList, true);
|
||||
BOOST_CHECK_EQUAL(rftDates==ref_dates, true);
|
||||
|
||||
BOOST_CHECK_EQUAL(rftList==ref_rftList, true);
|
||||
|
||||
BOOST_CHECK_EQUAL(rft1.hasRft("PROD", Date{2015,1,1}), true);
|
||||
BOOST_CHECK_EQUAL(rft1.hasRft("PROD",2015,1,1), true);
|
||||
|
||||
BOOST_CHECK_EQUAL(rft1.hasRft("PROD", Date{2015,10,1}), false);
|
||||
BOOST_CHECK_EQUAL(rft1.hasRft("XXXX", Date{2015,1,1}), false);
|
||||
BOOST_CHECK_EQUAL(rft1.hasRft("PROD",2015,10,1), false);
|
||||
BOOST_CHECK_EQUAL(rft1.hasRft("XXXX",2015,1,1), false);
|
||||
|
||||
// test member function hasArray
|
||||
|
||||
BOOST_CHECK_EQUAL(rft1.hasArray("SGAS","B-2H", Date{2016,5,31}), true);
|
||||
BOOST_CHECK_EQUAL(rft1.hasArray("XXXX","B-2H", Date{2016,5,31}), false);
|
||||
|
||||
BOOST_CHECK_THROW(rft1.hasArray("SGAS","C-2H", Date{2016,5,31}),std::invalid_argument);
|
||||
BOOST_CHECK_THROW(rft1.hasArray("SGAS","B-2H", Date{2016,5,30}),std::invalid_argument);
|
||||
BOOST_CHECK_THROW(rft1.hasArray("SGAS","C-2H", Date{2016,5,30}),std::invalid_argument);
|
||||
BOOST_CHECK_THROW(rft1.hasArray("XXXX","C-2H", Date{2016,5,30}),std::invalid_argument);
|
||||
|
||||
// test member function getRft
|
||||
|
||||
std::vector<int> vect1=rft1.getRft<int>("CONIPOS","B-2H", Date{2016,5,31});
|
||||
std::vector<float> vect2=rft1.getRft<float>("PRESSURE","B-2H", Date{2016,5,31});
|
||||
std::vector<std::string> vect3=rft1.getRft<std::string>("WELLETC","B-2H", Date{2016,5,31});
|
||||
|
||||
BOOST_CHECK_EQUAL(vect1.size(), 3);
|
||||
BOOST_CHECK_EQUAL(vect2.size(), 3);
|
||||
BOOST_CHECK_EQUAL(vect3.size(), 16);
|
||||
|
||||
// called with invalid argument, array not existing, wrong well name or wrong date
|
||||
BOOST_CHECK_THROW(std::vector<int> vect1=rft1.getRft<int>("CONIPOS","C-2H", Date{2016,5,31}),std::invalid_argument);
|
||||
BOOST_CHECK_THROW(std::vector<int> vect1=rft1.getRft<int>("CONIPOS","B-2H", Date{2016,5,30}),std::invalid_argument);
|
||||
BOOST_CHECK_THROW(std::vector<int> vect1=rft1.getRft<int>("XXXXXXX","B-2H", Date{2016,5,31}),std::invalid_argument);
|
||||
|
||||
// called with wrong type
|
||||
BOOST_CHECK_THROW(std::vector<int> vect1=rft1.getRft<int>("SGAS","B-2H", Date{2016,5,31}),std::runtime_error);
|
||||
BOOST_CHECK_THROW(std::vector<float> vect1=rft1.getRft<float>("CONIPOS","B-2H", Date{2016,5,31}),std::runtime_error);
|
||||
BOOST_CHECK_THROW(std::vector<std::string> vect1=rft1.getRft<std::string>("CONIPOS","B-2H", Date{2016,5,31}), std::runtime_error);
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(TestERft_2) {
|
||||
|
||||
std::string testFile="SPE1CASE1.RFT";
|
||||
|
||||
std::string outFile="TEST.RFT";
|
||||
|
||||
{
|
||||
EclOutput eclTest(outFile, false);
|
||||
|
||||
ERft rft1(testFile);
|
||||
|
||||
auto rftList = rft1.listOfRftReports();
|
||||
|
||||
for (auto& rft : rftList) {
|
||||
std::string wellName = std::get<0>(rft);
|
||||
auto date = std::get<1>(rft);
|
||||
|
||||
auto arrayList = rft1.listOfRftArrays(wellName, date);
|
||||
|
||||
for (auto& array : arrayList) {
|
||||
std::string arrName = std::get<0>(array);
|
||||
EIOD::eclArrType arrType = std::get<1>(array);
|
||||
|
||||
if (arrType == EIOD::INTE) {
|
||||
std::vector<int> vect = rft1.getRft<int>(arrName, wellName, date);
|
||||
eclTest.write(arrName, vect);
|
||||
} else if (arrType == EIOD::REAL) {
|
||||
std::vector<float> vect = rft1.getRft<float>(arrName, wellName, date);
|
||||
eclTest.write(arrName, vect);
|
||||
} else if (arrType == EIOD::DOUB) {
|
||||
std::vector<double> vect = rft1.getRft<double>(arrName, wellName, date);
|
||||
eclTest.write(arrName, vect);
|
||||
} else if (arrType == EIOD::LOGI) {
|
||||
std::vector<bool> vect = rft1.getRft<bool>(arrName, wellName, date);
|
||||
eclTest.write(arrName, vect);
|
||||
} else if (arrType == EIOD::CHAR) {
|
||||
std::vector<std::string> vect = rft1.getRft<std::string>(arrName, wellName, date);
|
||||
eclTest.write(arrName, vect);
|
||||
} else if (arrType == EIOD::MESS) {
|
||||
eclTest.write(arrName, std::vector<char>());
|
||||
} else {
|
||||
std::cout << "unknown type " << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_CHECK_EQUAL(compare_files(testFile, outFile), true);
|
||||
|
||||
if (remove(outFile.c_str())==-1) {
|
||||
std::cout << " > Warning! temporary file was not deleted" << std::endl;
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue
Block a user