From e4c324dcef7878a49d23fe40da12e1c3041ad049 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torbj=C3=B8rn=20Skille?= Date: Sun, 12 Sep 2021 14:08:21 +0200 Subject: [PATCH] Adding support for LGR related summary vectors --- opm/io/eclipse/ESmry.hpp | 3 +- src/opm/io/eclipse/ESmry.cpp | 87 +++++++++++++++++++++++++++++++++--- 2 files changed, 82 insertions(+), 8 deletions(-) diff --git a/opm/io/eclipse/ESmry.hpp b/opm/io/eclipse/ESmry.hpp index 31dd28203..73b35648b 100644 --- a/opm/io/eclipse/ESmry.hpp +++ b/opm/io/eclipse/ESmry.hpp @@ -119,7 +119,8 @@ private: void updatePathAndRootName(filesystem::path& dir, filesystem::path& rootN) const; - std::string makeKeyString(const std::string& keyword, const std::string& wgname, int num) const; + std::string makeKeyString(const std::string& keyword, const std::string& wgname, int num, + const std::string& lgr = "none", int numlx = -1, int numly = -1, int numlz = -1) const; std::string unpackNumber(const SummaryNode&) const; std::string lookupKey(const SummaryNode&) const; diff --git a/src/opm/io/eclipse/ESmry.cpp b/src/opm/io/eclipse/ESmry.cpp index 815607f10..781a50241 100644 --- a/src/opm/io/eclipse/ESmry.cpp +++ b/src/opm/io/eclipse/ESmry.cpp @@ -166,13 +166,31 @@ ESmry::ESmry(const std::string &filename, bool loadBaseRunData) : const std::vector nums = smspecList.back().get("NUMS"); const std::vector units = smspecList.back().get("UNITS"); + std::vector lgrs; + std::vector numlx; + std::vector numly; + std::vector numlz; + + if (smspecList.back().hasKey("LGRS")){ + lgrs = smspecList.back().get("LGRS"); + numlx = smspecList.back().get("NUMLX"); + numly = smspecList.back().get("NUMLY"); + numlz = smspecList.back().get("NUMLZ"); + } + + const bool have_lgr = !lgrs.empty(); + std::vector combindKeyList; combindKeyList.reserve(dimens[0]); this->startdat = make_date(smspecList.back().get("STARTDAT")); for (unsigned int i=0; i nums = smspecList.back().get("NUMS"); const std::vector units = smspecList.back().get("UNITS"); + std::vector lgrs; + std::vector numlx; + std::vector numly; + std::vector numlz; + + if (smspecList.back().hasKey("LGRS")){ + lgrs = smspecList.back().get("LGRS"); + numlx = smspecList.back().get("NUMLX"); + numly = smspecList.back().get("NUMLY"); + numlz = smspecList.back().get("NUMLZ"); + } + + const bool have_lgr = !lgrs.empty(); + std::vector combindKeyList; combindKeyList.reserve(dimens[0]); this->startdat = make_date(smspecList.back().get("STARTDAT")); for (size_t i = 0; i < keywords.size(); i++) { - const std::string keyString = makeKeyString(keywords[i], wgnames[i], nums[i]); + + const std::string keyString = have_lgr + ? makeKeyString(keywords[i], wgnames[i], nums[i], lgrs[i], numlx[i], numly[i], numlz[i]) + : makeKeyString(keywords[i], wgnames[i], nums[i]); + combindKeyList.push_back(keyString); if (! keyString.empty()) { @@ -288,6 +324,7 @@ ESmry::ESmry(const std::string &filename, bool loadBaseRunData) : getRstString(restartArray, pathRstFile, rstRootN); } + nSpecFiles = static_cast(smryArray.size()); nParamsSpecFile.resize(nSpecFiles, 0); @@ -326,8 +363,25 @@ ESmry::ESmry(const std::string &filename, bool loadBaseRunData) : const std::vector nums = smspecList[specInd].get("NUMS"); + std::vector lgrs; + std::vector numlx; + std::vector numly; + std::vector numlz; + + if (smspecList[specInd].hasKey("LGRS")){ + lgrs = smspecList[specInd].get("LGRS"); + numlx = smspecList[specInd].get("NUMLX"); + numly = smspecList[specInd].get("NUMLY"); + numlz = smspecList[specInd].get("NUMLZ"); + } + + const bool have_lgr = !lgrs.empty(); + for (size_t i=0; i < keywords.size(); i++) { - const std::string keyw = makeKeyString(keywords[i], wgnames[i], nums[i]); + + const std::string keyw = have_lgr + ? makeKeyString(keywords[i], wgnames[i], nums[i], lgrs[i], numlx[i], numly[i], numlz[i]) + : makeKeyString(keywords[i], wgnames[i], nums[i]); if (keywList.find(keyw) != keywList.end()) arrayPos[specInd][keyIndex[keyw]]=i; @@ -1028,7 +1082,8 @@ void ESmry::ijk_from_global_index(int glob, int &i, int &j, int &k) const } -std::string ESmry::makeKeyString(const std::string& keywordArg, const std::string& wgname, int num) const +std::string ESmry::makeKeyString(const std::string& keywordArg, const std::string& wgname, int num, + const std::string& lgr, int numlx, int numly, int numlz) const { const auto no_wgname = std::string_view(":+:+:+:+"); @@ -1072,12 +1127,30 @@ std::string ESmry::makeKeyString(const std::string& keywordArg, const std::strin return fmt::format("{}:{}", keywordArg, wgname); } + if (first == 'L') { + + if ((keywordArg[1] == 'B') || (keywordArg[1] == 'C')) + return fmt::format("{}:{}:{},{},{}", keywordArg, lgr, numlx, numly, numlz); + + if (keywordArg[1] == 'W') + return fmt::format("{}:{}:{}", keywordArg, lgr, wgname); + + return fmt::format("{}", keywordArg); + } + if (first == 'R') { if (num <= 0) { return ""; } - if (keywordArg[1] == 'F') { + std::string str34 = keywordArg.substr(2,2); + std::string str45 = keywordArg.substr(3,2); + + if (keywordArg == "RORFR") // exception, standard region summary keyword + return fmt::format("{}:{}", keywordArg, num); + + if ((str34 == "FR") || (str34 == "FT") || (str45 == "FR") || (str45 == "FT")) { + // NUMS = R1 + 32768*(R2 + 10) const auto r1 = num % (1UL << 15); const auto r2 = (num / (1UL << 15)) - 10;