API change of class ERft and ERst
ERft - return false (not throw an exception) if function hasArray( .. ) is used with an non-existing rftreport. ERst - new memeber function hasArray ( .. )
This commit is contained in:
parent
02167f2c2f
commit
e778960932
@ -40,6 +40,7 @@ public:
|
||||
explicit ERst(const std::string& filename);
|
||||
|
||||
bool hasReportStepNumber(int number) const;
|
||||
bool hasArray(const std::string& name, int number) const;
|
||||
bool hasLGR(const std::string& gridname, int reportStepNumber) const;
|
||||
|
||||
void loadReportStepNumber(int number);
|
||||
|
@ -119,6 +119,9 @@ int ERft::getReportIndex(const std::string& wellName, const RftDate& date) const
|
||||
bool ERft::hasArray(const std::string& arrayName, const std::string& wellName,
|
||||
const RftDate& date) const
|
||||
{
|
||||
if (!hasRft(wellName, date))
|
||||
return false;
|
||||
|
||||
int reportInd = getReportIndex(wellName, date);
|
||||
|
||||
auto searchInd = arrIndexRange.find(reportInd);
|
||||
|
@ -283,6 +283,25 @@ std::tuple<int,int> ERst::getIndexRange(int reportStepNumber) const {
|
||||
return range_it->second;
|
||||
}
|
||||
|
||||
bool ERst::hasArray(const std::string& name, int number) const
|
||||
{
|
||||
if (!hasReportStepNumber(number))
|
||||
return false;
|
||||
|
||||
auto range_it = arrIndexRange.find(number);
|
||||
|
||||
std::pair<int,int> 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)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
int ERst::getArrayIndex(const std::string& name, int number, int occurrenc)
|
||||
{
|
||||
if (!hasReportStepNumber(number)) {
|
||||
|
@ -80,7 +80,7 @@ bool operator==(const std::vector<T> & t1, const std::vector<T> & t2)
|
||||
// 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>;
|
||||
|
||||
@ -126,10 +126,11 @@ BOOST_AUTO_TEST_CASE(TestERft_1) {
|
||||
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);
|
||||
BOOST_CHECK_EQUAL(rft1.hasArray("SGAS","C-2H", Date{2016,5,31}), false);
|
||||
BOOST_CHECK_EQUAL(rft1.hasArray("SGAS","B-2H", Date{2016,5,30}), false);
|
||||
BOOST_CHECK_EQUAL(rft1.hasArray("SGAS","C-2H", Date{2016,5,30}), false);
|
||||
BOOST_CHECK_EQUAL(rft1.hasArray("XXXX","C-2H", Date{2016,5,30}), false);
|
||||
|
||||
|
||||
// // test member function getRft(name, wellName, date)
|
||||
|
||||
|
@ -124,6 +124,10 @@ BOOST_AUTO_TEST_CASE(TestERst_1) {
|
||||
// try loading non-existing report step, should throw exception
|
||||
BOOST_CHECK_THROW(rst1.loadReportStepNumber(4) , std::invalid_argument );
|
||||
|
||||
BOOST_CHECK_EQUAL(rst1.hasArray("XXXX", 5), false);
|
||||
BOOST_CHECK_EQUAL(rst1.hasArray("PRESSURE", 5), true);
|
||||
BOOST_CHECK_EQUAL(rst1.hasArray("PRESSURE", 4), false);
|
||||
|
||||
|
||||
// try to get a list of vectors from non-existing report step, should throw exception
|
||||
std::vector<std::tuple<std::string, eclArrType, int64_t>> rstArrays; // = rst1.listOfRstArrays(4);
|
||||
@ -1178,5 +1182,5 @@ BOOST_AUTO_TEST_CASE(Formatted)
|
||||
}
|
||||
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user