Fix bug in ExtESmry
Start date in ESMRY file (format) have 7 elements, last element is milliseconds.
This commit is contained in:
@@ -61,7 +61,8 @@ public:
|
|||||||
|
|
||||||
bool make_esmry_file();
|
bool make_esmry_file();
|
||||||
|
|
||||||
time_point startdate() const { return startdat; }
|
time_point startdate() const { return tp_startdat; }
|
||||||
|
std::vector<int> start_v() const { return start_vect; }
|
||||||
|
|
||||||
const std::vector<std::string>& keywordList() const;
|
const std::vector<std::string>& keywordList() const;
|
||||||
std::vector<std::string> keywordList(const std::string& pattern) const;
|
std::vector<std::string> keywordList(const std::string& pattern) const;
|
||||||
@@ -110,7 +111,8 @@ private:
|
|||||||
std::vector<SummaryNode> summaryNodes;
|
std::vector<SummaryNode> summaryNodes;
|
||||||
std::unordered_map<std::string, std::string> kwunits;
|
std::unordered_map<std::string, std::string> kwunits;
|
||||||
|
|
||||||
time_point startdat;
|
time_point tp_startdat;
|
||||||
|
std::vector<int> start_vect;
|
||||||
|
|
||||||
mutable double m_io_opening;
|
mutable double m_io_opening;
|
||||||
mutable double m_io_loading;
|
mutable double m_io_loading;
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ public:
|
|||||||
void loadData(const std::vector<std::string>& stringVect);
|
void loadData(const std::vector<std::string>& stringVect);
|
||||||
|
|
||||||
time_point startdate() const { return m_startdat; }
|
time_point startdate() const { return m_startdat; }
|
||||||
|
std::vector<int> start_v() const { return m_start_vect; }
|
||||||
|
|
||||||
bool hasKey(const std::string& key) const;
|
bool hasKey(const std::string& key) const;
|
||||||
|
|
||||||
@@ -93,6 +94,7 @@ private:
|
|||||||
std::vector<uint64_t> m_rstep_offset;
|
std::vector<uint64_t> m_rstep_offset;
|
||||||
|
|
||||||
time_point m_startdat;
|
time_point m_startdat;
|
||||||
|
std::vector<int> m_start_vect;
|
||||||
|
|
||||||
double m_io_opening;
|
double m_io_opening;
|
||||||
double m_io_loading;
|
double m_io_loading;
|
||||||
|
|||||||
@@ -180,7 +180,8 @@ ESmry::ESmry(const std::string &filename, bool loadBaseRunData) :
|
|||||||
std::vector<std::string> combindKeyList;
|
std::vector<std::string> combindKeyList;
|
||||||
combindKeyList.reserve(dimens[0]);
|
combindKeyList.reserve(dimens[0]);
|
||||||
|
|
||||||
this->startdat = make_date(smspecList.back().get<int>("STARTDAT"));
|
start_vect = smspecList.back().get<int>("STARTDAT");
|
||||||
|
this->tp_startdat = make_date(start_vect);
|
||||||
|
|
||||||
if ( have_lgr ) {
|
if ( have_lgr ) {
|
||||||
for (unsigned int i=0; i<keywords.size(); i++) {
|
for (unsigned int i=0; i<keywords.size(); i++) {
|
||||||
@@ -312,8 +313,6 @@ ESmry::ESmry(const std::string &filename, bool loadBaseRunData) :
|
|||||||
std::vector<std::string> combindKeyList;
|
std::vector<std::string> combindKeyList;
|
||||||
combindKeyList.reserve(dimens[0]);
|
combindKeyList.reserve(dimens[0]);
|
||||||
|
|
||||||
this->startdat = make_date(smspecList.back().get<int>("STARTDAT"));
|
|
||||||
|
|
||||||
if (have_lgr) {
|
if (have_lgr) {
|
||||||
for (size_t i = 0; i < keywords.size(); i++) {
|
for (size_t i = 0; i < keywords.size(); i++) {
|
||||||
Opm::EclIO::lgr_info lgr { lgrs[i], {numlx[i], numly[i], numlz[i]}};
|
Opm::EclIO::lgr_info lgr { lgrs[i], {numlx[i], numly[i], numlz[i]}};
|
||||||
@@ -375,7 +374,6 @@ ESmry::ESmry(const std::string &filename, bool loadBaseRunData) :
|
|||||||
for (int i = 0; i < nSpecFiles; i++)
|
for (int i = 0; i < nSpecFiles; i++)
|
||||||
arrayPos.push_back({});
|
arrayPos.push_back({});
|
||||||
|
|
||||||
// tskille: testing
|
|
||||||
std::map<std::string, int> keyIndex;
|
std::map<std::string, int> keyIndex;
|
||||||
{
|
{
|
||||||
size_t m = 0;
|
size_t m = 0;
|
||||||
@@ -445,8 +443,6 @@ ESmry::ESmry(const std::string &filename, bool loadBaseRunData) :
|
|||||||
int step = 0;
|
int step = 0;
|
||||||
specInd = nSpecFiles - 1;
|
specInd = nSpecFiles - 1;
|
||||||
|
|
||||||
//nVect = keywList.size();
|
|
||||||
|
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for (const auto& keyw : keywList) {
|
for (const auto& keyw : keywList) {
|
||||||
if (!keyw.empty()) {
|
if (!keyw.empty()) {
|
||||||
@@ -1044,10 +1040,13 @@ bool ESmry::make_esmry_file()
|
|||||||
this->loadData();
|
this->loadData();
|
||||||
|
|
||||||
{
|
{
|
||||||
Opm::TimeStampUTC ts( std::chrono::system_clock::to_time_t( startdat ));
|
std::vector<int> start_date_vect = start_vect;
|
||||||
|
|
||||||
std::vector<int> start_date_vect = {ts.day(), ts.month(), ts.year(), ts.hour(),
|
int sec = start_date_vect[5] / 1000000;
|
||||||
ts.minutes(), ts.seconds(), 0 };
|
int millisec = (start_date_vect[5] % 1000000) / 1000;
|
||||||
|
|
||||||
|
start_date_vect[5] = sec;
|
||||||
|
start_date_vect.push_back(millisec);
|
||||||
|
|
||||||
std::vector<std::string> units;
|
std::vector<std::string> units;
|
||||||
units.reserve(keyword.size());
|
units.reserve(keyword.size());
|
||||||
@@ -1055,6 +1054,7 @@ bool ESmry::make_esmry_file()
|
|||||||
for (auto key : keyword)
|
for (auto key : keyword)
|
||||||
units.push_back(kwunits.at(key));
|
units.push_back(kwunits.at(key));
|
||||||
|
|
||||||
|
|
||||||
Opm::EclIO::EclOutput outFile(smryDataFile, false, std::ios::out);
|
Opm::EclIO::EclOutput outFile(smryDataFile, false, std::ios::out);
|
||||||
|
|
||||||
outFile.write<int>("START", start_date_vect);
|
outFile.write<int>("START", start_date_vect);
|
||||||
@@ -1363,7 +1363,7 @@ std::vector<Opm::time_point> ESmry::dates() const {
|
|||||||
std::vector<Opm::time_point> d;
|
std::vector<Opm::time_point> d;
|
||||||
|
|
||||||
for (const auto& t : this->get("TIME"))
|
for (const auto& t : this->get("TIME"))
|
||||||
d.push_back( this->startdat + std::chrono::duration_cast<std::chrono::seconds>( std::chrono::duration<double, std::chrono::seconds::period>( t * time_unit)));
|
d.push_back( this->tp_startdat + std::chrono::duration_cast<std::chrono::seconds>( std::chrono::duration<double, std::chrono::seconds::period>( t * time_unit)));
|
||||||
|
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ Opm::time_point make_date(const std::vector<int>& datetime) {
|
|||||||
auto minute = 0;
|
auto minute = 0;
|
||||||
auto second = 0;
|
auto second = 0;
|
||||||
|
|
||||||
if (datetime.size() == 6) {
|
if (datetime.size() == 7) {
|
||||||
hour = datetime[3];
|
hour = datetime[3];
|
||||||
minute = datetime[4];
|
minute = datetime[4];
|
||||||
auto total_usec = datetime[5];
|
auto total_usec = datetime[5];
|
||||||
@@ -293,15 +293,15 @@ bool ExtESmry::open_esmry(const std::filesystem::path& inputFileName, ExtSmryHea
|
|||||||
if ((arrName != "START ") or (arrType != Opm::EclIO::INTE))
|
if ((arrName != "START ") or (arrType != Opm::EclIO::INTE))
|
||||||
OPM_THROW(std::invalid_argument, "reading start, invalid esmry file " + inputFileName.string() );
|
OPM_THROW(std::invalid_argument, "reading start, invalid esmry file " + inputFileName.string() );
|
||||||
|
|
||||||
std::vector<int> start_vect;
|
|
||||||
try {
|
try {
|
||||||
start_vect = Opm::EclIO::readBinaryInteArray(fileH, arr_size);
|
m_start_vect = Opm::EclIO::readBinaryInteArray(fileH, arr_size);
|
||||||
} catch (const std::runtime_error& error)
|
} catch (const std::runtime_error& error)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto startdat = make_date(start_vect);
|
auto startdat = make_date(m_start_vect);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Opm::EclIO::readBinaryHeader(fileH, arrName, arr_size, arrType, sizeOfElement);
|
Opm::EclIO::readBinaryHeader(fileH, arrName, arr_size, arrType, sizeOfElement);
|
||||||
|
|||||||
Reference in New Issue
Block a user