-
Notifications
You must be signed in to change notification settings - Fork 118
Also output RUNTIMEI to SMSPEC file. #4878
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| /* | ||
| Copyright (c) 2019 Equinor ASA | ||
| Copyright (c) 2026 OPM-OP AS | ||
|
|
||
| This file is part of the Open Porous Media project (OPM). | ||
|
|
||
|
|
@@ -683,6 +684,28 @@ namespace { | |
| }; | ||
| } | ||
|
|
||
| std::vector<int> | ||
| makeRuntimeiDate(const SummarySpecification::StartTime start) | ||
| { | ||
| const auto timepoint = std::chrono::system_clock::to_time_t(start); | ||
| const auto tm = *std::gmtime(&timepoint); | ||
|
|
||
| // { Day, Month, Year, Hour, Minute, Seconds } | ||
|
|
||
| return { | ||
| tm.tm_year + 1900, | ||
|
|
||
| // 1..12 1..32 | ||
| tm.tm_mon + 1, tm.tm_mday, | ||
|
|
||
| // 0..23 0..59 | ||
| tm.tm_hour, tm.tm_min, | ||
|
|
||
| // 0..59 | ||
| std::min(tm.tm_sec, 59) | ||
| }; | ||
| } | ||
|
|
||
| std::vector<int> | ||
| makeDimens(const int nparam, | ||
| const std::array<int, 3>& cartDims, | ||
|
|
@@ -713,12 +736,14 @@ SummarySpecification(const ResultSet& rset, | |
| const UnitConvention uconv, | ||
| const std::array<int,3>& cartDims, | ||
| const RestartSpecification& restart, | ||
| const StartTime start) | ||
| : unit_ (unitConvention(uconv)) | ||
| , restartStep_(makeRestartStep(restart)) | ||
| , cartDims_ (cartDims) | ||
| , startDate_ (start) | ||
| , restart_ (restartRoot(restart)) | ||
| const StartTime start, | ||
| const StartTime computeStart) | ||
| : unit_ (unitConvention(uconv)) | ||
| , restartStep_ (makeRestartStep(restart)) | ||
| , cartDims_ (cartDims) | ||
| , startDate_ (start) | ||
| , computeStart_ (computeStart) | ||
| , restart_ (restartRoot(restart)) | ||
| { | ||
| const auto fname = outputFileName(rset, FileExtension::smspec(fmt.set)); | ||
|
|
||
|
|
@@ -755,7 +780,9 @@ operator=(SummarySpecification&& rhs) | |
|
|
||
| void | ||
| Opm::EclIO::OutputStream:: | ||
| SummarySpecification::write(const Parameters& params) | ||
| SummarySpecification::write(const Parameters& params, | ||
| const bool simulationFinished, const int currentStep, | ||
| const int basic) | ||
| { | ||
| this->rewindStream(); | ||
|
|
||
|
|
@@ -778,6 +805,21 @@ SummarySpecification::write(const Parameters& params) | |
|
|
||
| smspec.write("STARTDAT", makeStartDate(this->startDate_)); | ||
|
|
||
| // Create and write RUNTIMEI | ||
| std::vector<int> runtimei(50, 0); | ||
| runtimei[0] = simulationFinished ? 2 : 1; | ||
| runtimei[1] = (this->restartStep_ == -1)? 1 : this->restartStep_+1; | ||
| runtimei[2] = currentStep + 1; | ||
| const auto computeStart = makeRuntimeiDate(this->computeStart_); | ||
| std::copy(computeStart.begin(), computeStart.end(), runtimei.begin()+3); | ||
|
|
||
| using std::chrono::system_clock; | ||
| const auto now = makeRuntimeiDate(Opm::TimeService::now()); | ||
| std::copy(now.begin(), now.end(), runtimei.begin()+9); | ||
| runtimei[34] = basic; | ||
|
|
||
| smspec.write("RUNTIMEI", runtimei); | ||
|
Comment on lines
+808
to
+821
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please create a helper function for this so that we don't have to have this amount of local state and logic directly in the body of the smspec.write("STARTDAT", makeStartDate(this->startDate_));
smspec.write("RUNTIMEI", makeRuntimeI(...));
this->flushStream(); |
||
|
|
||
| this->flushStream(); | ||
| } | ||
|
|
||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please tag each parameter as |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| /* | ||
| Copyright (c) 2019 Equinor ASA | ||
| Copyroght (c) 2026 OPM-OP AS | ||
|
|
||
| This file is part of the Open Porous Media project (OPM). | ||
|
|
||
|
|
@@ -414,7 +415,8 @@ namespace Opm { namespace EclIO { namespace OutputStream { | |
| const UnitConvention uconv, | ||
| const std::array<int,3>& cartDims, | ||
| const RestartSpecification& restart, | ||
| const StartTime start); | ||
| const StartTime start, | ||
| const StartTime computeStart); | ||
|
|
||
| ~SummarySpecification(); | ||
|
|
||
|
|
@@ -424,13 +426,22 @@ namespace Opm { namespace EclIO { namespace OutputStream { | |
| SummarySpecification& operator=(const SummarySpecification& rhs) = delete; | ||
| SummarySpecification& operator=(SummarySpecification&& rhs); | ||
|
|
||
| void write(const Parameters& params); | ||
| /// \brief wirte SMSPEC file | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tiny nit: "wirte" ➡️ "Write" (with upper case "W"). |
||
| /// | ||
| /// \param simulationFinished whether the simulation has finished (i.e. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Upper case "W" in "Whether". |
||
| /// this is the last written for it) | ||
| /// \param currentStep Index of the current report step | ||
| /// \param basic The value assigned to BASIC in RPRTRST | ||
| void write(const Parameters& params, const bool simulationFinished, | ||
| const int currentStep, const int basic); | ||
|
|
||
| private: | ||
| int unit_; | ||
| int restartStep_; | ||
| std::array<int,3> cartDims_; | ||
| StartTime startDate_; | ||
| /// \brief When the simulation started | ||
| StartTime computeStart_; | ||
| std::vector<PaddedOutputString<8>> restart_; | ||
|
|
||
| /// Summary specification (SMSPEC) file output stream. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,6 @@ | ||
| /* | ||
| Copyright 2021 Equinor ASA. | ||
| Copyright 2019 Equinor ASA. | ||
| Copyright 2016 Statoil ASA. | ||
| Copyright 2016-2021 Equinor ASA. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please only add new copyright statements here. Don't change the original ones. |
||
| Copyright 2026 OPM-OP AS. | ||
|
|
||
| This file is part of the Open Porous Media project (OPM). | ||
|
|
||
|
|
@@ -4950,13 +4949,16 @@ class SMSpecStreamDeferredCreation | |
| { | ||
| return std::make_unique<Spec>(rset, fmt, this->uconv(), | ||
| this->cartDims_, this->restart_, | ||
| this->start_); | ||
| this->start_, | ||
| this->computeStart_); | ||
| } | ||
|
|
||
| private: | ||
| Opm::UnitSystem::UnitType utype_; | ||
| std::array<int,3> cartDims_; | ||
| Spec::StartTime start_; | ||
| /// \brief Time when the simulation started. | ||
| Spec::StartTime computeStart_; | ||
| Spec::RestartSpecification restart_{}; | ||
|
|
||
| Spec::UnitConvention uconv() const; | ||
|
|
@@ -4970,6 +4972,8 @@ SMSpecStreamDeferredCreation(const Opm::InitConfig& initcfg, | |
| : utype_ (utype) | ||
| , cartDims_(grid.getNXYZ()) | ||
| , start_ (Opm::TimeService::from_time_t(start)) | ||
| // This is not exactly when the simulation started, but should make the tools happy enough. | ||
| , computeStart_(Opm::TimeService::now()) | ||
| { | ||
| if (initcfg.restartRequested()) { | ||
| this->restart_.root = initcfg.getRestartRootNameInput(); | ||
|
|
@@ -5278,10 +5282,16 @@ void Opm::out::Summary::SummaryImplementation::write(const bool is_final_summary | |
| return; | ||
| } | ||
|
|
||
| const auto& last = this->lastUnwritten(); | ||
|
|
||
| this->createSMSpecIfNecessary(); | ||
|
|
||
| if (this->prevReportStepID_ < this->lastUnwritten().seq) { | ||
| this->smspec_->write(this->outputParameters_.summarySpecification()); | ||
| if (this->prevReportStepID_ < last.seq) { | ||
|
Comment on lines
5284
to
+5289
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is better written as this->createSMSpecIfNecessary();
if (const auto lastSeq = this->lastUnWritten().seq;
this->prevReportStepID_ < lastSeq)
{
// ...
}That way we won't have to introduce the otherwise unused |
||
| this->smspec_->write(this->outputParameters_.summarySpecification(), | ||
| // pass additional parameters for RUNTIMEI keyword | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This comment is meaningless. Please remove it. |
||
| is_final_summary, last.seq, | ||
| sched_.get()[last.seq].get<RSTConfig>().get() | ||
| .basic.value_or(0)); | ||
| } | ||
|
|
||
| for (auto i = 0*this->numUnwritten_; i < this->numUnwritten_; ++i) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is incorrect. Also, please extract a helper function to form the
tmobject so that we may reuse the logic in bothmakeStartDate()andmakeRuntimeiDate().