/* Copyright 2019 Equinor ASA. This file is part of the Open Porous Media project (OPM). OPM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. OPM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OPM. If not, see . */ #ifndef OPM_IO_ESMRY_HPP #define OPM_IO_ESMRY_HPP #include #include #include #include #include #include namespace Opm { namespace EclIO { class ESmry { public: // input is smspec (or fsmspec file) explicit ESmry(const std::string& filename, bool loadBaseRunData=false); int numberOfVectors() const { return nVect; } bool hasKey(const std::string& key) const; const std::vector& get(const std::string& name) const; const std::vector& get(const SummaryNode& node) const; std::vector get_at_rstep(const std::string& name) const; std::vector get_at_rstep(const SummaryNode& node) const; const std::vector& get_startdat() const { return startdat; } const std::vector& keywordList() const; const std::vector& summaryNodeList() const; int timestepIdxAtReportstepStart(const int reportStep) const; size_t numberOfTimeSteps() const { return param[0].size(); } const std::string& get_unit(const std::string& name) const; const std::string& get_unit(const SummaryNode& node) const; void write_rsm(std::ostream&) const; void write_rsm_file(std::optional = std::nullopt) const; private: Opm::filesystem::path inputFileName; int nVect, nI, nJ, nK; void ijk_from_global_index(int glob, int &i, int &j, int &k) const; std::vector> param; std::vector keyword; std::vector summaryNodes; std::unordered_map kwunits; std::vector seqIndex; std::vector startdat; std::vector checkForMultipleResultFiles(const Opm::filesystem::path& rootN, bool formatted) const; void getRstString(const std::vector& restartArray, Opm::filesystem::path& pathRst, Opm::filesystem::path& rootN) const; void updatePathAndRootName(Opm::filesystem::path& dir, Opm::filesystem::path& rootN) const; std::string makeKeyString(const std::string& keyword, const std::string& wgname, int num) const; std::string unpackNumber(const SummaryNode&) const; std::string lookupKey(const SummaryNode&) const; void write_block(std::ostream &, const std::vector&) const; template std::vector rstep_vector(const std::vector& full_vector) const { std::vector rstep_vector; rstep_vector.reserve(seqIndex.size()); for (const auto& ind : seqIndex){ rstep_vector.push_back(full_vector[ind]); } return rstep_vector; } }; }} // namespace Opm::EclIO inline std::ostream& operator<<(std::ostream& os, const Opm::EclIO::ESmry& smry) { smry.write_rsm(os); return os; } #endif // OPM_IO_ESMRY_HPP