updates of ESmry and ExtESmry
* add function for returning root name * add function for returning io (opening and loading) * rename member function LoadData() to loadData()
This commit is contained in:
parent
2851c1d4e2
commit
5306fb1db8
@ -56,8 +56,8 @@ public:
|
||||
std::vector<float> get_at_rstep(const SummaryNode& node) const;
|
||||
std::vector<time_point> dates_at_rstep() const;
|
||||
|
||||
void LoadData(const std::vector<std::string>& vectList) const;
|
||||
void LoadData() const;
|
||||
void loadData(const std::vector<std::string>& vectList) const;
|
||||
void loadData() const;
|
||||
|
||||
bool make_esmry_file();
|
||||
|
||||
@ -78,6 +78,8 @@ public:
|
||||
void write_rsm_file(std::optional<std::filesystem::path> = std::nullopt) const;
|
||||
|
||||
bool all_steps_available();
|
||||
std::string rootname() { return inputFileName.stem(); }
|
||||
std::tuple<double, double> get_io_elapsed() const;
|
||||
|
||||
private:
|
||||
std::filesystem::path inputFileName;
|
||||
@ -110,6 +112,9 @@ private:
|
||||
|
||||
time_point startdat;
|
||||
|
||||
mutable double m_io_opening;
|
||||
mutable double m_io_loading;
|
||||
|
||||
std::vector<std::string> checkForMultipleResultFiles(const std::filesystem::path& rootN, bool formatted) const;
|
||||
|
||||
void getRstString(const std::vector<std::string>& restartArray,
|
||||
|
@ -67,6 +67,8 @@ public:
|
||||
std::vector<time_point> dates();
|
||||
|
||||
bool all_steps_available();
|
||||
std::string rootname() { return m_inputFileName.stem(); }
|
||||
std::tuple<double, double> get_io_elapsed() const;
|
||||
|
||||
private:
|
||||
std::filesystem::path m_inputFileName;
|
||||
@ -94,6 +96,9 @@ private:
|
||||
|
||||
time_point m_startdat;
|
||||
|
||||
double m_io_opening;
|
||||
double m_io_loading;
|
||||
|
||||
uint64_t open_esmry(std::filesystem::path& inputFileName, LodsmryHeadType& lodsmry_head);
|
||||
|
||||
void updatePathAndRootName(std::filesystem::path& dir, std::filesystem::path& rootN);
|
||||
|
@ -96,6 +96,11 @@ ESmry::ESmry(const std::string &filename, bool loadBaseRunData) :
|
||||
inputFileName { filename },
|
||||
summaryNodes { }
|
||||
{
|
||||
m_io_opening = 0.0;
|
||||
m_io_loading = 0.0;
|
||||
|
||||
auto start = std::chrono::system_clock::now();
|
||||
|
||||
fromSingleRun = !loadBaseRunData;
|
||||
|
||||
std::filesystem::path rootName = inputFileName.parent_path() / inputFileName.stem();
|
||||
@ -577,6 +582,9 @@ ESmry::ESmry(const std::string &filename, bool loadBaseRunData) :
|
||||
|
||||
nTstep = timeStepList.size();
|
||||
}
|
||||
|
||||
std::chrono::duration<double> elapsed_seconds = std::chrono::system_clock::now() - start;
|
||||
m_io_opening += elapsed_seconds.count();
|
||||
}
|
||||
|
||||
void ESmry::read_ministeps_from_disk()
|
||||
@ -660,8 +668,9 @@ std::string ESmry::read_string_from_disk(std::fstream& fileH, uint64_t size) con
|
||||
}
|
||||
|
||||
|
||||
void ESmry::LoadData(const std::vector<std::string>& vectList) const
|
||||
void ESmry::loadData(const std::vector<std::string>& vectList) const
|
||||
{
|
||||
auto start = std::chrono::system_clock::now();
|
||||
size_t nvect = vectList.size();
|
||||
|
||||
std::vector<int> keywIndVect;
|
||||
@ -758,6 +767,9 @@ void ESmry::LoadData(const std::vector<std::string>& vectList) const
|
||||
|
||||
for (const auto& ind : keywIndVect)
|
||||
vectorLoaded[ind] = true;
|
||||
|
||||
std::chrono::duration<double> elapsed_seconds = std::chrono::system_clock::now() - start;
|
||||
m_io_loading += elapsed_seconds.count();
|
||||
}
|
||||
|
||||
std::vector<int> ESmry::makeKeywPosVector(int specInd) const
|
||||
@ -782,7 +794,7 @@ std::vector<int> ESmry::makeKeywPosVector(int specInd) const
|
||||
return keywpos;
|
||||
}
|
||||
|
||||
void ESmry::LoadData() const
|
||||
void ESmry::loadData() const
|
||||
{
|
||||
std::fstream fileH;
|
||||
|
||||
@ -1021,7 +1033,7 @@ bool ESmry::make_esmry_file()
|
||||
else
|
||||
is_rstep.push_back(0);
|
||||
|
||||
this->LoadData();
|
||||
this->loadData();
|
||||
|
||||
{
|
||||
Opm::TimeStampUTC ts( std::chrono::system_clock::to_time_t( startdat ));
|
||||
@ -1286,7 +1298,7 @@ const std::vector<float>& ESmry::get(const std::string& name) const
|
||||
int ind = std::distance(keyword.begin(), it);
|
||||
|
||||
if (!vectorLoaded[ind]){
|
||||
LoadData({name});
|
||||
loadData({name});
|
||||
vectorLoaded[ind]=true;
|
||||
}
|
||||
|
||||
@ -1353,4 +1365,12 @@ std::vector<time_point> ESmry::dates_at_rstep() const {
|
||||
const auto& full_vector = this->dates();
|
||||
return this->rstep_vector(full_vector);
|
||||
}
|
||||
|
||||
std::tuple<double, double> ESmry::get_io_elapsed() const
|
||||
{
|
||||
std::tuple<double, double> duration = std::make_tuple(m_io_opening, m_io_loading);
|
||||
return duration;
|
||||
}
|
||||
|
||||
|
||||
}} // namespace Opm::EclIO
|
||||
|
@ -245,7 +245,7 @@ void ESmry::write_rsm(std::ostream& os) const {
|
||||
data_vector_blocks.emplace_back(data_vectors.begin() + i, data_vectors.begin() + last);
|
||||
}
|
||||
|
||||
this->LoadData();
|
||||
this->loadData();
|
||||
std::vector<std::string> time_column;
|
||||
if (this->hasKey("DAY") && this->hasKey("MONTH") && this->hasKey("YEAR")) {
|
||||
write_dates = true;
|
||||
|
@ -93,6 +93,11 @@ ExtESmry::ExtESmry(const std::string &filename, bool loadBaseRunData) :
|
||||
m_inputFileName { filename },
|
||||
m_loadBaseRun(loadBaseRunData)
|
||||
{
|
||||
m_io_opening = 0.0;
|
||||
m_io_loading = 0.0;
|
||||
|
||||
auto start = std::chrono::system_clock::now();
|
||||
|
||||
if (m_inputFileName.extension()=="")
|
||||
m_inputFileName+=".ESMRY";
|
||||
|
||||
@ -222,6 +227,9 @@ ExtESmry::ExtESmry(const std::string &filename, bool loadBaseRunData) :
|
||||
for (size_t m = 0; m < m_rstep.size(); m++)
|
||||
if (m_rstep[m] == 1)
|
||||
m_seqIndex.push_back(m);
|
||||
|
||||
std::chrono::duration<double> elapsed_seconds = std::chrono::system_clock::now() - start;
|
||||
m_io_opening += elapsed_seconds.count();
|
||||
}
|
||||
|
||||
|
||||
@ -357,6 +365,8 @@ void ExtESmry::updatePathAndRootName(std::filesystem::path& dir, std::filesystem
|
||||
|
||||
void ExtESmry::loadData(const std::vector<std::string>& stringVect)
|
||||
{
|
||||
auto start = std::chrono::system_clock::now();
|
||||
|
||||
std::vector<int> keyIndexVect;
|
||||
|
||||
for (const auto& key: stringVect)
|
||||
@ -419,6 +429,9 @@ void ExtESmry::loadData(const std::vector<std::string>& stringVect)
|
||||
|
||||
for (auto kind : keyIndexVect)
|
||||
m_vectorLoaded[kind] = true;
|
||||
|
||||
std::chrono::duration<double> elapsed_seconds = std::chrono::system_clock::now() - start;
|
||||
m_io_loading += elapsed_seconds.count();
|
||||
}
|
||||
|
||||
void ExtESmry::loadData()
|
||||
@ -466,6 +479,12 @@ bool ExtESmry::hasKey(const std::string &key) const
|
||||
return std::find(m_keyword.begin(), m_keyword.end(), key) != m_keyword.end();
|
||||
}
|
||||
|
||||
std::tuple<double, double> ExtESmry::get_io_elapsed() const
|
||||
{
|
||||
std::tuple<double, double> duration = std::make_tuple(m_io_opening, m_io_loading);
|
||||
return duration;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}} // namespace Opm::ecl
|
||||
|
@ -883,11 +883,11 @@ void ECLRegressionTest::results_smry()
|
||||
|
||||
if (foundSmspec1 && foundSmspec2) {
|
||||
ESmry smry1(fileName1, loadBaseRunData);
|
||||
smry1.LoadData();
|
||||
smry1.loadData();
|
||||
std::cout << "\nLoading summary file " << fileName1 << " .... done" << std::endl;
|
||||
|
||||
ESmry smry2(fileName2, loadBaseRunData);
|
||||
smry2.LoadData();
|
||||
smry2.loadData();
|
||||
std::cout << "\nLoading summary file " << fileName2 << " .... done" << std::endl;
|
||||
|
||||
deviations.clear();
|
||||
|
@ -155,7 +155,7 @@ BOOST_AUTO_TEST_CASE(TestESmry_1) {
|
||||
getRefSmryVect(time_ref, wgpr_prod_ref, wbhp_prod_ref, wbhp_inj_ref,fgor_ref, bpr_111_ref, bpr_10103_ref);
|
||||
|
||||
ESmry smry1("SPE1CASE1.SMSPEC");
|
||||
smry1.LoadData();
|
||||
smry1.loadData();
|
||||
|
||||
std::vector<float> smryVect = smry1.get("TIME");
|
||||
BOOST_CHECK_EQUAL(smryVect==time_ref, true);
|
||||
@ -232,7 +232,7 @@ BOOST_AUTO_TEST_CASE(TestESmry_2) {
|
||||
// will be loaded. No data from base run (SPE1CASE1 in this case)
|
||||
|
||||
ESmry smry1("SPE1CASE1_RST60.SMSPEC"); // equivalent to smry1("SPE1CASE1_RST60.SMSPEC",false)
|
||||
smry1.LoadData();
|
||||
smry1.loadData();
|
||||
|
||||
std::vector<float> smryVect = smry1.get("TIME");
|
||||
std::vector<float> time_ref_rst60 = getFrom(time_ref,63);
|
||||
@ -310,7 +310,7 @@ BOOST_AUTO_TEST_CASE(TestESmry_3) {
|
||||
// vectors should be equal to reference vectors (from SPE1CASE1)
|
||||
|
||||
ESmry smry1("SPE1CASE1_RST60.SMSPEC",true);
|
||||
smry1.LoadData();
|
||||
smry1.loadData();
|
||||
|
||||
std::vector<float> smryVect = smry1.get("TIME");
|
||||
BOOST_CHECK_EQUAL(smryVect==time_ref, true);
|
||||
@ -357,7 +357,7 @@ BOOST_AUTO_TEST_CASE(TestESmry_4) {
|
||||
std::vector<float> time_ref = {31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365, 396, 424, 455, 485, 516, 546, 577, 608, 638, 669, 699, 730, 761, 789, 820, 850, 881, 911, 942, 973, 1003, 1034, 1064, 1095, 1126, 1154, 1185, 1215, 1246, 1276, 1307, 1338, 1368, 1399, 1429, 1460, 1491, 1519, 1550, 1580, 1611, 1641, 1672, 1703, 1733, 1764, 1794, 1825, 1856, 1884, 1915, 1945, 1976, 2006, 2037, 2068, 2098, 2129, 2159, 2190, 2221, 2249, 2280, 2310, 2341, 2371, 2402, 2433, 2463, 2494, 2524, 2555, 2586, 2614, 2645, 2675, 2706, 2736, 2767, 2798, 2828, 2859, 2889, 2920, 2951, 2979, 3010, 3040, 3071, 3101, 3132, 3163, 3193, 3224, 3254, 3285, 3316, 3344, 3375, 3405, 3436, 3466, 3497, 3528, 3558, 3589, 3619, 3650};
|
||||
|
||||
ESmry smry1("SPE1CASE1.SMSPEC");
|
||||
smry1.LoadData();
|
||||
smry1.loadData();
|
||||
|
||||
std::vector<float> smryVect = smry1.get("TIME");
|
||||
std::vector<float> smryVect_rstep = smry1.get_at_rstep("TIME");
|
||||
@ -377,7 +377,7 @@ BOOST_AUTO_TEST_CASE(TestESmry_5) {
|
||||
// array NAMES (of type C0NN) in IX smspec files
|
||||
|
||||
ESmry smry1("MODEL1_IX.SMSPEC");
|
||||
smry1.LoadData();
|
||||
smry1.loadData();
|
||||
|
||||
std::vector<float> report_timesteps = {31.0, 60.0, 91.0, 121.0, 152.0, 182.0, 213.0, 244.0, 274.0, 305.0, 335.0, 364.0};
|
||||
|
||||
@ -400,7 +400,7 @@ BOOST_AUTO_TEST_CASE(TestESmry_5) {
|
||||
namespace fs = std::filesystem;
|
||||
BOOST_AUTO_TEST_CASE(TestCreateRSM) {
|
||||
ESmry smry1("SPE1CASE1.SMSPEC");
|
||||
smry1.LoadData();
|
||||
smry1.loadData();
|
||||
|
||||
{
|
||||
WorkArea work;
|
||||
@ -414,7 +414,7 @@ BOOST_AUTO_TEST_CASE(TestCreateRSM) {
|
||||
|
||||
BOOST_AUTO_TEST_CASE(TestUnits) {
|
||||
ESmry smry("SPE1CASE1.SMSPEC");
|
||||
smry.LoadData();
|
||||
smry.loadData();
|
||||
|
||||
BOOST_CHECK_THROW( smry.get_unit("NO_SUCH_KEY"), std::out_of_range);
|
||||
BOOST_CHECK_EQUAL( smry.get_unit("TIME"), "DAYS");
|
||||
|
Loading…
Reference in New Issue
Block a user