ESmry: Add Way of Retrieving Ministep Index at Start of Report Step

This commit introduces a new member function

    int ESmry::miniStepIdxAtReportStep(rptStep)

which returns the zero-based ministep corresponding to the start of
the given report step (one-based indexing).  This will simplify
decoupling a few unit tests from libecl.
This commit is contained in:
Bård Skaflestad 2019-10-11 01:04:23 -05:00 committed by Markus Blatt
parent 112e698d0a
commit c69a111e7a
2 changed files with 18 additions and 0 deletions

View File

@ -39,6 +39,8 @@ public:
const std::vector<std::string>& keywordList() const { return keyword; }
int timestepIdxAtReportstepStart(const int reportStep) const;
private:
int nVect, nI, nJ, nK;
std::string path="";

View File

@ -18,6 +18,7 @@
#include <opm/io/eclipse/ESmry.hpp>
#include <exception>
#include <string>
#include <string.h>
#include <sstream>
@ -28,6 +29,7 @@
#include <limits>
#include <limits.h>
#include <set>
#include <stdexcept>
#include <opm/io/eclipse/EclFile.hpp>
@ -442,4 +444,18 @@ std::vector<float> ESmry::get_at_rstep(const std::string& name) const
return rstep_vector;
}
int ESmry::timestepIdxAtReportstepStart(const int reportStep) const
{
const auto nReport = static_cast<int>(seqIndex.size());
if ((reportStep < 1) || (reportStep > nReport)) {
throw std::invalid_argument {
"Report step " + std::to_string(reportStep)
+ " outside valid range 1 .. " + std::to_string(nReport)
};
}
return seqIndex[reportStep - 1];
}
}} // namespace Opm::ecl