2019-03-28 08:33:30 -05:00
|
|
|
/*
|
|
|
|
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 <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2019-05-02 08:01:20 -05:00
|
|
|
#ifndef OPM_IO_ESMRY_HPP
|
|
|
|
#define OPM_IO_ESMRY_HPP
|
2019-03-28 08:33:30 -05:00
|
|
|
|
2020-04-01 03:30:10 -05:00
|
|
|
#include <ostream>
|
2019-03-28 08:33:30 -05:00
|
|
|
#include <string>
|
2020-03-13 05:55:43 -05:00
|
|
|
#include <unordered_map>
|
2019-03-28 08:33:30 -05:00
|
|
|
#include <vector>
|
2020-03-27 02:07:52 -05:00
|
|
|
|
2020-02-12 02:12:29 -06:00
|
|
|
#include <opm/common/utility/FileSystem.hpp>
|
2020-03-27 02:07:52 -05:00
|
|
|
#include <opm/io/eclipse/SummaryNode.hpp>
|
2019-05-02 08:01:20 -05:00
|
|
|
|
2019-05-24 08:26:01 -05:00
|
|
|
namespace Opm { namespace EclIO {
|
2019-03-28 08:33:30 -05:00
|
|
|
|
|
|
|
class ESmry
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2020-03-13 04:39:53 -05:00
|
|
|
// input is smspec (or fsmspec file)
|
2019-10-09 15:39:05 -05:00
|
|
|
explicit ESmry(const std::string& filename, bool loadBaseRunData=false);
|
2020-03-13 04:39:53 -05:00
|
|
|
|
2019-06-21 07:48:23 -05:00
|
|
|
int numberOfVectors() const { return nVect; }
|
2019-03-28 08:33:30 -05:00
|
|
|
|
|
|
|
bool hasKey(const std::string& key) const;
|
|
|
|
|
|
|
|
const std::vector<float>& get(const std::string& name) const;
|
2020-03-27 02:07:52 -05:00
|
|
|
const std::vector<float>& get(const SummaryNode& node) const;
|
2019-06-30 10:08:20 -05:00
|
|
|
|
|
|
|
std::vector<float> get_at_rstep(const std::string& name) const;
|
2020-03-27 02:07:52 -05:00
|
|
|
std::vector<float> get_at_rstep(const SummaryNode& node) const;
|
2019-06-30 10:08:20 -05:00
|
|
|
|
2020-03-18 11:18:51 -05:00
|
|
|
const std::vector<int>& get_startdat() const { return startdat; }
|
|
|
|
|
2020-03-27 02:07:52 -05:00
|
|
|
const std::vector<std::string>& keywordList() const;
|
|
|
|
const std::vector<SummaryNode>& summaryNodeList() const;
|
2019-03-28 08:33:30 -05:00
|
|
|
|
2019-10-11 01:04:23 -05:00
|
|
|
int timestepIdxAtReportstepStart(const int reportStep) const;
|
|
|
|
|
2020-03-18 12:00:33 -05:00
|
|
|
size_t numberOfTimeSteps() const { return param[0].size(); }
|
2020-03-18 11:18:51 -05:00
|
|
|
|
2020-03-13 04:36:49 -05:00
|
|
|
const std::string& get_unit(const std::string& name) const;
|
2020-03-27 02:07:52 -05:00
|
|
|
const std::string& get_unit(const SummaryNode& node) const;
|
2020-03-13 04:36:49 -05:00
|
|
|
|
2020-04-01 03:30:10 -05:00
|
|
|
void write_rsm(std::ostream&) const;
|
|
|
|
void write_rsm_file(std::optional<Opm::filesystem::path> = std::nullopt) const;
|
|
|
|
|
2019-03-28 08:33:30 -05:00
|
|
|
private:
|
2020-04-01 03:30:10 -05:00
|
|
|
Opm::filesystem::path inputFileName;
|
2019-03-28 08:33:30 -05:00
|
|
|
int nVect, nI, nJ, nK;
|
|
|
|
|
2019-06-21 07:48:23 -05:00
|
|
|
void ijk_from_global_index(int glob, int &i, int &j, int &k) const;
|
2019-03-28 08:33:30 -05:00
|
|
|
std::vector<std::vector<float>> param;
|
|
|
|
std::vector<std::string> keyword;
|
2020-03-27 02:07:52 -05:00
|
|
|
std::vector<SummaryNode> summaryNodes;
|
2020-03-13 05:55:43 -05:00
|
|
|
std::unordered_map<std::string, std::string> kwunits;
|
2019-03-28 08:33:30 -05:00
|
|
|
|
|
|
|
std::vector<int> seqIndex;
|
2020-03-18 11:18:51 -05:00
|
|
|
std::vector<int> startdat;
|
|
|
|
|
2020-02-12 02:12:29 -06:00
|
|
|
std::vector<std::string> checkForMultipleResultFiles(const Opm::filesystem::path& rootN, bool formatted) const;
|
2020-03-13 04:39:53 -05:00
|
|
|
|
|
|
|
void getRstString(const std::vector<std::string>& restartArray,
|
2020-02-12 02:12:29 -06:00
|
|
|
Opm::filesystem::path& pathRst,
|
|
|
|
Opm::filesystem::path& rootN) const;
|
2019-10-09 15:39:05 -05:00
|
|
|
|
2020-02-12 02:12:29 -06:00
|
|
|
void updatePathAndRootName(Opm::filesystem::path& dir, Opm::filesystem::path& rootN) const;
|
2019-03-28 08:33:30 -05:00
|
|
|
|
2019-06-21 07:48:23 -05:00
|
|
|
std::string makeKeyString(const std::string& keyword, const std::string& wgname, int num) const;
|
2020-03-27 02:07:52 -05:00
|
|
|
|
|
|
|
std::string unpackNumber(const SummaryNode&) const;
|
|
|
|
std::string lookupKey(const SummaryNode&) const;
|
2020-04-01 03:30:10 -05:00
|
|
|
|
|
|
|
void write_block(std::ostream &, const std::vector<SummaryNode>&) const;
|
2020-04-02 02:35:59 -05:00
|
|
|
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
std::vector<T> rstep_vector(const std::vector<T>& full_vector) const {
|
|
|
|
std::vector<T> rstep_vector;
|
|
|
|
rstep_vector.reserve(seqIndex.size());
|
|
|
|
|
|
|
|
for (const auto& ind : seqIndex){
|
|
|
|
rstep_vector.push_back(full_vector[ind]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rstep_vector;
|
|
|
|
}
|
2019-03-28 08:33:30 -05:00
|
|
|
};
|
|
|
|
|
2019-05-24 08:26:01 -05:00
|
|
|
}} // namespace Opm::EclIO
|
2019-03-28 08:33:30 -05:00
|
|
|
|
2020-04-01 03:30:10 -05:00
|
|
|
inline std::ostream& operator<<(std::ostream& os, const Opm::EclIO::ESmry& smry) {
|
|
|
|
smry.write_rsm(os);
|
|
|
|
|
|
|
|
return os;
|
|
|
|
}
|
|
|
|
|
2019-05-02 08:01:20 -05:00
|
|
|
#endif // OPM_IO_ESMRY_HPP
|