From 8e23316ebaaeb68f495d5886017779a27cb94113 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torbj=C3=B8rn=20Skille?= Date: Wed, 23 Oct 2019 12:32:38 +0200 Subject: [PATCH] fixing severe performance issue with ESmry --- src/opm/io/eclipse/ESmry.cpp | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/src/opm/io/eclipse/ESmry.cpp b/src/opm/io/eclipse/ESmry.cpp index f272beb2c..39ae62235 100644 --- a/src/opm/io/eclipse/ESmry.cpp +++ b/src/opm/io/eclipse/ESmry.cpp @@ -31,6 +31,7 @@ #include #include +#include #include #include @@ -158,7 +159,7 @@ ESmry::ESmry(const std::string &filename, bool loadBaseRunData) getRstString(restartArray, pathRstFile, rstRootN); } - + int nFiles = static_cast(smryArray.size()); // arrayInd should hold indices for each vector and runs @@ -190,7 +191,7 @@ ESmry::ESmry(const std::string &filename, bool loadBaseRunData) std::vector wgnames = smspec.get("WGNAMES"); std::vector nums = smspec.get("NUMS"); - std::vector tmpVect(keywords.size(), -1); + std::vector tmpVect(keywords.size(), -1); arrayInd[n]=tmpVect; std::set::iterator it; @@ -286,12 +287,14 @@ ESmry::ESmry(const std::string &filename, bool loadBaseRunData) // 2 or 3 arrays pr time step. // If timestep is a report step: MINISTEP, PARAMS and SEQHDR // else : MINISTEP and PARAMS - - + size_t i = std::get<0>(arraySourceList[0]) == "SEQHDR" ? 1 : 0 ; + std::string prevFile; + std::unique_ptr pEclFile; + while (i < arraySourceList.size()){ - + if (std::get<0>(arraySourceList[i]) != "MINISTEP"){ std::string message="Reading summary file, expecting keyword MINISTEP, found '" + std::get<0>(arraySourceList[i]) + "'"; throw std::invalid_argument(message); @@ -304,10 +307,16 @@ ESmry::ESmry(const std::string &filename, bool loadBaseRunData) i++; - EclFile resfile(std::get<1>(arraySourceList[i])); + if (std::get<1>(arraySourceList[i]) != prevFile){ + pEclFile = std::make_unique(std::get<1>(arraySourceList[i])); + pEclFile->loadData(); + + prevFile = std::get<1>(arraySourceList[i]); + } + int m = std::get<2>(arraySourceList[i]); - std::vector tmpData = resfile.get(m); + std::vector tmpData = pEclFile->get(m); time = tmpData[0]; @@ -344,7 +353,7 @@ ESmry::ESmry(const std::string &filename, bool loadBaseRunData) param[ind][step] = tmpData[j]; } } - + if (reportStepNumber >= toReportStepNumber) { i = arraySourceList.size(); } @@ -356,9 +365,9 @@ ESmry::ESmry(const std::string &filename, bool loadBaseRunData) n--; } - + nVect = keywList.size(); - + for (auto keyw : keywList){ keyword.push_back(keyw); }