Implements Opm::EclIO::ESmry::get_unit.

This commit is contained in:
Williham Williham Totland 2020-03-13 11:55:43 +01:00
parent af61d58606
commit 7297a9736a
2 changed files with 9 additions and 1 deletions

View File

@ -20,6 +20,7 @@
#define OPM_IO_ESMRY_HPP
#include <string>
#include <unordered_map>
#include <vector>
#include <opm/common/utility/FileSystem.hpp>
@ -52,6 +53,7 @@ private:
void ijk_from_global_index(int glob, int &i, int &j, int &k) const;
std::vector<std::vector<float>> param;
std::vector<std::string> keyword;
std::unordered_map<std::string, std::string> kwunits;
std::vector<int> seqIndex;
std::vector<float> seqTime;

View File

@ -107,10 +107,13 @@ ESmry::ESmry(const std::string &filename, bool loadBaseRunData)
std::vector<std::string> wgnames = smspec1.get<std::string>("WGNAMES");
std::vector<int> nums = smspec1.get<int>("NUMS");
std::vector<std::string> units = smspec1.get<std::string>("UNITS");
for (unsigned int i=0; i<keywords.size(); i++) {
std::string str1 = makeKeyString(keywords[i], wgnames[i], nums[i]);
if (str1.length() > 0) {
keywList.insert(str1);
kwunits[str1] = units[i];
}
}
@ -146,10 +149,13 @@ ESmry::ESmry(const std::string &filename, bool loadBaseRunData)
std::vector<std::string> wgnames = smspec_rst.get<std::string>("WGNAMES");
std::vector<int> nums = smspec_rst.get<int>("NUMS");
std::vector<std::string> units = smspec_rst.get<std::string>("UNITS");
for (size_t i = 0; i < keywords.size(); i++) {
std::string str1 = makeKeyString(keywords[i], wgnames[i], nums[i]);
if (str1.length() > 0) {
keywList.insert(str1);
kwunits[str1] = units[i];
}
}
@ -538,7 +544,7 @@ int ESmry::timestepIdxAtReportstepStart(const int reportStep) const
}
const std::string& ESmry::get_unit(const std::string& name) const {
OPM_THROW(std::out_of_range, "No unit found for key " + name);
return kwunits.at(name);
}
}} // namespace Opm::ecl