From 72892f0c4ba80650d74795161204983edeaad641 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torbj=C3=B8rn=20Skille?= Date: Fri, 15 Dec 2023 12:18:34 +0100 Subject: [PATCH] PRT file updates * Arrays genarated from RPTSOL + FIP is now strictly following Eclipse format * Adding reservoir volume array also for custom FIP regions --- CMakeLists.txt | 4 + ebos/eclgenericoutputblackoilmodule.cc | 85 ++++---- ebos/eclgenericoutputblackoilmodule.hh | 17 +- ebos/eclproblem.hh | 4 +- ebos/eclwriter.hh | 62 ++++-- opm/simulators/flow/LogOutputHelper.cpp | 186 +++++++++++------- opm/simulators/flow/LogOutputHelper.hpp | 7 +- .../SimulatorFullyImplicitBlackoilEbos.hpp | 11 +- .../timestepping/AdaptiveTimeSteppingEbos.hpp | 2 +- tests/test_LogOutputHelper.cpp | 95 +++++---- 10 files changed, 283 insertions(+), 190 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b37211142..7067972e7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -350,6 +350,10 @@ if (HAVE_OPM_TESTS) endif() target_sources(test_outputdir PRIVATE $) +target_sources(test_LogOutputHelper PRIVATE $) +target_sources(test_equil PRIVATE $) +target_sources(test_RestartSerialization PRIVATE $) +target_sources(test_glift1 PRIVATE $) opm_set_test_driver(${CMAKE_CURRENT_SOURCE_DIR}/tests/run-parallel-unitTest.sh "") diff --git a/ebos/eclgenericoutputblackoilmodule.cc b/ebos/eclgenericoutputblackoilmodule.cc index 5765265b0..1a439a171 100644 --- a/ebos/eclgenericoutputblackoilmodule.cc +++ b/ebos/eclgenericoutputblackoilmodule.cc @@ -224,6 +224,13 @@ template EclGenericOutputBlackoilModule:: ~EclGenericOutputBlackoilModule() = default; +template +void EclGenericOutputBlackoilModule:: +outputTimeStamp(const std::string& lbl, double elapsed, int rstep, boost::posix_time::ptime currentDate) +{ + logOutput_.timeStamp(lbl, elapsed, rstep, currentDate); +} + template void EclGenericOutputBlackoilModule:: outputCumLog(std::size_t reportStepNum) @@ -251,15 +258,15 @@ outputInjLog(std::size_t reportStepNum) { return this->isDefunctParallelWell(name); }); } + template Inplace EclGenericOutputBlackoilModule:: -outputFipLog(std::map& miscSummaryData, +calc_inplace(std::map& miscSummaryData, std::map>& regionData, - const std::size_t reportStepNum, - const bool substep, const Parallel::Communication& comm) { auto inplace = this->accumulateRegionSums(comm); + if (comm.rank() != 0) return inplace; @@ -267,6 +274,25 @@ outputFipLog(std::map& miscSummaryData, miscSummaryData, regionData); + + return inplace; +} + + +template +void EclGenericOutputBlackoilModule:: +outputFipAndResvLog(const Inplace& inplace, + const std::size_t reportStepNum, + double elapsed, + boost::posix_time::ptime currentDate, + const bool substep, + const Parallel::Communication& comm) +{ + + if (comm.rank() != 0) + return; + + // For report step 0 we use the RPTSOL config, else derive from RPTSCHED std::unique_ptr fipSched; if (reportStepNum != 0) { @@ -277,53 +303,34 @@ outputFipLog(std::map& miscSummaryData, : *fipSched; if (!substep && !forceDisableFipOutput_ && fipc.output(FIPConfig::OutputField::FIELD)) { - logOutput_.fip(inplace, this->initialInplace(), ""); - if (fipc.output(FIPConfig::OutputField::FIPNUM)) { - logOutput_.fip(inplace, this->initialInplace(), "FIPNUM"); + + logOutput_.timeStamp("BALANCE", elapsed, reportStepNum, currentDate); + + logOutput_.fip(inplace, this->initialInplace(), ""); + + if (fipc.output(FIPConfig::OutputField::FIPNUM)) { + logOutput_.fip(inplace, this->initialInplace(), "FIPNUM"); + + if (fipc.output(FIPConfig::OutputField::RESV)) + logOutput_.fipResv(inplace, "FIPNUM"); } + if (fipc.output(FIPConfig::OutputField::FIP)) { for (const auto& reg : this->regions_) { if (reg.first != "FIPNUM") { + std::ostringstream ss; + ss << "BAL" << reg.first.substr(3); + logOutput_.timeStamp(ss.str(), elapsed, reportStepNum, currentDate); logOutput_.fip(inplace, this->initialInplace(), reg.first); + + if (fipc.output(FIPConfig::OutputField::RESV)) + logOutput_.fipResv(inplace, reg.first); } } } } - - return inplace; } -template -Inplace EclGenericOutputBlackoilModule:: -outputFipresvLog(std::map& miscSummaryData, - std::map>& regionData, - const std::size_t reportStepNum, - const bool substep, - const Parallel::Communication& comm) -{ - auto inplace = this->accumulateRegionSums(comm); - if (comm.rank() != 0) - return inplace; - - updateSummaryRegionValues(inplace, - miscSummaryData, - regionData); - - // For report step 0 we use the RPTSOL config, else derive from RPTSCHED - std::unique_ptr fipSched; - if (reportStepNum != 0) { - const auto& rpt = this->schedule_[reportStepNum].rpt_config.get(); - fipSched = std::make_unique(rpt); - } - const FIPConfig& fipc = reportStepNum == 0 ? this->eclState_.getEclipseConfig().fip() - : *fipSched; - - if (!substep && !forceDisableFipresvOutput_ && fipc.output(FIPConfig::OutputField::RESV)) { - logOutput_.fipResv(inplace); - } - - return inplace; -} template void EclGenericOutputBlackoilModule:: diff --git a/ebos/eclgenericoutputblackoilmodule.hh b/ebos/eclgenericoutputblackoilmodule.hh index db4cdd473..aa1254907 100644 --- a/ebos/eclgenericoutputblackoilmodule.hh +++ b/ebos/eclgenericoutputblackoilmodule.hh @@ -62,6 +62,8 @@ public: return (this->fluidPressure_.size()) ; }; + void outputTimeStamp(const std::string& lbl, double elapsed, int rstep, boost::posix_time::ptime currentDate); + // write cumulative production and injection reports to output void outputCumLog(std::size_t reportStepNum); @@ -71,19 +73,18 @@ public: // write injection report to output void outputInjLog(std::size_t reportStepNum); - // write Fluid In Place to output log - Inplace outputFipLog(std::map& miscSummaryData, + // calculate Fluid In Place + Inplace calc_inplace(std::map& miscSummaryData, std::map>& regionData, + const Parallel::Communication& comm); + + void outputFipAndResvLog(const Inplace& inplace, const std::size_t reportStepNum, + double elapsed, + boost::posix_time::ptime currentDate, const bool substep, const Parallel::Communication& comm); - // write Reservoir Volumes to output log - Inplace outputFipresvLog(std::map& miscSummaryData, - std::map>& regionData, - const std::size_t reportStepNum, - const bool substep, - const Parallel::Communication& comm); void outputErrorLog(const Parallel::Communication& comm) const; diff --git a/ebos/eclproblem.hh b/ebos/eclproblem.hh index b5e2d6488..918f35748 100644 --- a/ebos/eclproblem.hh +++ b/ebos/eclproblem.hh @@ -738,7 +738,7 @@ public: * \brief Write the requested quantities of the current solution into the output * files. */ - void writeOutput(bool verbose = true) + void writeOutput(const SimulatorTimer& timer, bool verbose = true) { OPM_TIMEBLOCK(problemWriteOutput); // use the generic code to prepare the output fields and to @@ -758,7 +758,7 @@ public: } #endif if (enableEclOutput_){ - eclWriter_->writeOutput(std::move(localCellData), isSubStep); + eclWriter_->writeOutput(std::move(localCellData), timer, isSubStep); } } diff --git a/ebos/eclwriter.hh b/ebos/eclwriter.hh index ff3afcd47..548d74feb 100644 --- a/ebos/eclwriter.hh +++ b/ebos/eclwriter.hh @@ -42,7 +42,7 @@ #include #include #include - +#include #include @@ -123,6 +123,7 @@ class EclWriter : public EclGenericWriter enum { enableSolvent = getPropValue() }; public: + static void registerParameters() { EclOutputBlackOilModule::registerParameters(); @@ -176,6 +177,7 @@ public: { OPM_TIMEBLOCK(evalSummaryState); const int reportStepNum = simulator_.episodeIndex() + 1; + /* The summary data is not evaluated for timestep 0, that is implemented with a: @@ -193,6 +195,7 @@ public: "Correct" in this context means unchanged behavior, might very well be more correct to actually remove this if test. */ + if (reportStepNum == 0) return; @@ -245,18 +248,22 @@ public: OPM_END_PARALLEL_TRY_CATCH("Collect to I/O rank: ", this->simulator_.vanguard().grid().comm()); } + std::map miscSummaryData; std::map> regionData; Inplace inplace; + { OPM_TIMEBLOCK(outputFipLogAndFipresvLog); - inplace = eclOutputModule_->outputFipLog(miscSummaryData, regionData, reportStepNum, - isSubStep, simulator_.gridView().comm()); - eclOutputModule_->outputFipresvLog(miscSummaryData, regionData, reportStepNum, - isSubStep, simulator_.gridView().comm()); - } + inplace = eclOutputModule_->calc_inplace(miscSummaryData, regionData, simulator_.gridView().comm()); + + if (this->collectToIORank_.isIORank()){ + inplace_ = inplace; + } + } + // Add TCPU if (totalCpuTime != 0.0) { miscSummaryData["TCPU"] = totalCpuTime; @@ -309,16 +316,6 @@ public: this->summaryState(), this->udqState()); } - - if (! isSubStep) { - OPM_TIMEBLOCK(outputProdInjLogs); - - eclOutputModule_->outputProdLog(reportStepNum); - eclOutputModule_->outputInjLog(reportStepNum); - eclOutputModule_->outputCumLog(reportStepNum); - - OpmLog::note(""); // Blank line after all reports. - } } //! \brief Writes the initial FIP report as configured in RPTSOL. @@ -352,14 +349,21 @@ public: Inplace inplace; { OPM_TIMEBLOCK(outputFipLogAndFipresvLog); - inplace = eclOutputModule_->outputFipLog(miscSummaryData, regionData, 0, + + boost::posix_time::ptime start_time = boost::posix_time::from_time_t(simulator_.vanguard().schedule().getStartTime()); + + inplace = eclOutputModule_->calc_inplace(miscSummaryData, regionData, simulator_.gridView().comm()); + + if (this->collectToIORank_.isIORank()){ + inplace_ = inplace; + + eclOutputModule_->outputFipAndResvLog(inplace_, 0, 0.0, start_time, false, simulator_.gridView().comm()); - eclOutputModule_->outputFipresvLog(miscSummaryData, regionData, 0, - false, simulator_.gridView().comm()); + } } } - void writeOutput(data::Solution&& localCellData, bool isSubStep) + void writeOutput(data::Solution&& localCellData, const SimulatorTimer& timer, bool isSubStep) { OPM_TIMEBLOCK(writeOutput); @@ -384,6 +388,23 @@ public: // data::Solution localCellData = {}; if (! isSubStep) { + auto rstep = timer.reportStepNum(); + + if ((rstep > 0) && (this->collectToIORank_.isIORank())){ + + eclOutputModule_->outputFipAndResvLog(inplace_, rstep, timer.simulationTimeElapsed(), + timer.currentDateTime(), false, simulator_.gridView().comm()); + + + eclOutputModule_->outputTimeStamp("WELLS", timer.simulationTimeElapsed(), rstep, timer.currentDateTime()); + + eclOutputModule_->outputProdLog(reportStepNum); + eclOutputModule_->outputInjLog(reportStepNum); + eclOutputModule_->outputCumLog(reportStepNum); + + OpmLog::note(""); // Blank line after all reports. + } + if (localCellData.empty()) { this->eclOutputModule_->assignToSolution(localCellData); } @@ -675,6 +696,7 @@ private: std::unique_ptr > eclOutputModule_; Scalar restartTimeStepSize_; int rank_ ; + Inplace inplace_; }; } // namespace Opm diff --git a/opm/simulators/flow/LogOutputHelper.cpp b/opm/simulators/flow/LogOutputHelper.cpp index 0d02e8557..054f8b431 100644 --- a/opm/simulators/flow/LogOutputHelper.cpp +++ b/opm/simulators/flow/LogOutputHelper.cpp @@ -18,6 +18,7 @@ */ #include +#include #include #include @@ -28,6 +29,7 @@ #include #include +#include #include @@ -87,7 +89,9 @@ LogOutputHelper::LogOutputHelper(const EclipseState& eclState, : eclState_(eclState) , schedule_(schedule) , summaryState_(summaryState) -{} +{ + flowVersionName_ = moduleVersionName(); +} template void LogOutputHelper:: @@ -306,34 +310,75 @@ fip(const Inplace& inplace, } } + template void LogOutputHelper:: -fipResv(const Inplace& inplace) const +fipResv(const Inplace& inplace, const std::string& name) const { { std::unordered_map current_values; - for (const auto& phase : Inplace::phases()) { + for (const auto& phase : Inplace::phases()) current_values[phase] = inplace.get(phase); - } + + Scalar field_dyn_pv = 0.0; + + + for (auto nreg = inplace.max_region(name), reg = 0*nreg + 1; reg <= nreg; ++reg) + field_dyn_pv = field_dyn_pv + inplace.get(name, Inplace::Phase::DynamicPoreVolume, reg); + + current_values[Inplace::Phase::DynamicPoreVolume] = field_dyn_pv; + this->fipUnitConvert_(current_values); this->outputResvFluidInPlace_(current_values, 0); } - - for (std::size_t reg = 1; reg <= inplace.max_region("FIPNUM"); ++reg) { + + for (auto nreg = inplace.max_region(), reg = 0*nreg + 1; reg <= nreg; ++reg) { std::unordered_map current_values; - + for (const auto& phase : Inplace::phases()) { - current_values[phase] = inplace.get("FIPNUM", phase, reg); + if (reg <= inplace.max_region(name)) + current_values[phase] = inplace.get(name, phase, reg); + else + current_values[phase] = 0.0; } - current_values[Inplace::Phase::DynamicPoreVolume] = - inplace.get("FIPNUM", Inplace::Phase::DynamicPoreVolume, reg); - + + if (reg <= inplace.max_region(name)) + current_values[Inplace::Phase::DynamicPoreVolume] = + inplace.get(name, Inplace::Phase::DynamicPoreVolume, reg); + else + current_values[Inplace::Phase::DynamicPoreVolume] = 0.0; + this->fipUnitConvert_(current_values); this->outputResvFluidInPlace_(current_values, reg); } + + std::ostringstream ss; + ss << " ==========================================================================================="; + OpmLog::note(ss.str()); } + +template +void LogOutputHelper:: +timeStamp(const std::string& lbl, double elapsed, int rstep, boost::posix_time::ptime currentDate) const +{ + + std::ostringstream ss; + boost::posix_time::time_facet* facet = new boost::posix_time::time_facet("%d %b %Y"); + ss.imbue(std::locale(std::locale::classic(), facet)); + + ss << "\n **************************************************************************\n" + << " " << std::left << std::setw(9) << lbl << "AT" << std::right << std::setw(10) + << (double)unit::convert::to(elapsed, unit::day) << " DAYS" << " *" << std::setw(30) << eclState_.getTitle() << " *\n" + << " REPORT " << std::setw(4) << rstep << " " << currentDate + << " * Flow version " << std::setw(11) << flowVersionName_ << " *\n" + << " **************************************************************************\n"; + + OpmLog::note(ss.str()); +} + + template void LogOutputHelper:: injection(const std::size_t reportStepNum, @@ -817,63 +862,62 @@ outputRegionFluidInPlace_(std::unordered_map oip, std::ostringstream ss; ss << '\n'; - if (reg == 0) { - ss << "Field total"; - } else { - ss << name << " report region " << reg; - } - - ss << " pressure dependent pore volume = " - << std::fixed << std::setprecision(0) - << cip[Inplace::Phase::DynamicPoreVolume] << ' ' - << units.name(UnitSystem::measure::volume) << "\n\n"; if (reg == 0) { - ss << " ===================================================\n" - << " : Field Totals :\n"; + ss << " ==================================================\n" + << " : FIELD TOTALS :\n"; } else { - ss << " ===================================================\n" - << " : " << name << " report region " - << std::setw(8 - name.size()) << reg << " :\n"; + ss << " ==================================================\n" + << " : " << name << " REPORT REGION " + << std::setw(8 - name.size()) << reg << " :\n"; } if (units.getType() == UnitSystem::UnitType::UNIT_TYPE_METRIC) { - ss << " : PAV =" << std::setw(14) << pav << " BARSA :\n" + ss << " : PAV = " << std::setw(14) << pav << " BARSA :\n" << std::fixed << std::setprecision(0) - << " : PORV =" << std::setw(14) << cip[Inplace::Phase::PoreVolume] << " RM3 :\n"; + << " : PORV= " << std::setw(14) << cip[Inplace::Phase::PoreVolume] << " RM3 :\n"; if (!reg) { - ss << " : Pressure is weighted by hydrocarbon pore volume :\n" - << " : Porv volumes are taken at reference conditions :\n"; + ss << " : Pressure is weighted by hydrocarbon pore volume:\n" + << " : Porv volumes are taken at reference conditions :\n"; } - ss << " :--------------- Oil SM3 ---------------:-- Wat SM3 --:--------------- Gas SM3 ---------------:\n"; + ss << " :--------------- OIL SM3 ----------------:-- WAT SM3 --:--------------- GAS SM3 ---------------:\n"; } else if (units.getType() == UnitSystem::UnitType::UNIT_TYPE_FIELD) { - ss << " : PAV =" << std::setw(14) << pav << " PSIA :\n" + ss << std::fixed << std::setprecision(0) + << " : PAV =" << std::setw(14) << pav << " PSIA :\n" << std::fixed << std::setprecision(0) - << " : PORV =" << std::setw(14) << cip[Inplace::Phase::PoreVolume] << " RB :\n"; + << " : PORV=" << std::setw(14) << cip[Inplace::Phase::PoreVolume] << " RB :\n"; if (!reg) { - ss << " : Pressure is weighted by hydrocarbon pore volume :\n" - << " : Pore volumes are taken at reference conditions :\n"; + ss << " : Pressure is weighted by hydrocarbon pore volume:\n" + << " : Pore volumes are taken at reference conditions :\n"; } - ss << " :--------------- Oil STB ---------------:-- Wat STB --:--------------- Gas MSCF ---------------:\n"; + ss << " :--------------- OIL STB ----------------:-- WAT STB --:--------------- GAS MSCF ----------------:\n"; } - ss << " : Liquid Vapour Total : Total : Free Dissolved Total :" << "\n" - << ":------------------------:------------------------------------------:----------------:------------------------------------------:" << "\n" - << ":Currently in place :" << std::setw(14) << cip[Inplace::Phase::OilInLiquidPhase] + ss << " : LIQUID VAPOUR TOTAL : TOTAL : FREE DISSOLVED TOTAL :" << "\n" + << " :-------------------------:-------------------------------------------:----------------:-------------------------------------------:" << "\n" + << " :CURRENTLY IN PLACE :" << std::setw(14) << cip[Inplace::Phase::OilInLiquidPhase] << std::setw(14) << cip[Inplace::Phase::OilInGasPhase] - << std::setw(14) << cip[Inplace::Phase::OIL] << ":" - << std::setw(13) << cip[Inplace::Phase::WATER] << " :" + << std::setw(15) << cip[Inplace::Phase::OIL] << ":" + << std::setw(14) << cip[Inplace::Phase::WATER] << " :" << std::setw(14) << (cip[Inplace::Phase::GasInGasPhase]) << std::setw(14) << cip[Inplace::Phase::GasInLiquidPhase] - << std::setw(14) << cip[Inplace::Phase::GAS] << ":\n" - << ":------------------------:------------------------------------------:----------------:------------------------------------------:\n" - << ":Originally in place :" << std::setw(14) << oip[Inplace::Phase::OilInLiquidPhase] + << std::setw(15) << cip[Inplace::Phase::GAS] << ":\n" + << " :-------------------------:-------------------------------------------:----------------:-------------------------------------------:\n" + << " :ORIGINALLY IN PLACE :" << std::setw(14) << oip[Inplace::Phase::OilInLiquidPhase] << std::setw(14) << oip[Inplace::Phase::OilInGasPhase] - << std::setw(14) << oip[Inplace::Phase::OIL] << ":" - << std::setw(13) << oip[Inplace::Phase::WATER] << " :" + << std::setw(15) << oip[Inplace::Phase::OIL] << ":" + << std::setw(14) << oip[Inplace::Phase::WATER] << " :" << std::setw(14) << oip[Inplace::Phase::GasInGasPhase] << std::setw(14) << oip[Inplace::Phase::GasInLiquidPhase] - << std::setw(14) << oip[Inplace::Phase::GAS] << ":\n" - << ":========================:==========================================:================:==========================================:"; + << std::setw(15) << oip[Inplace::Phase::GAS] << ":\n"; + + if (reg == 0){ + ss << " ====================================================================================================================================\n\n"; + + } else { + ss << " :-------------------------:-------------------------------------------:----------------:-------------------------------------------:\n"; + ss << " ====================================================================================================================================\n\n"; + } + OpmLog::note(ss.str()); } @@ -882,37 +926,37 @@ void LogOutputHelper:: outputResvFluidInPlace_(std::unordered_map cipr, const int reg) const { - // don't output FIPNUM report if the region has no porv. - if (cipr[Inplace::Phase::PoreVolume] == 0) { - return; - } - const UnitSystem& units = eclState_.getUnits(); std::ostringstream ss; + if (reg == 0) { ss << "\n ===================================\n"; if (units.getType() == UnitSystem::UnitType::UNIT_TYPE_METRIC) { - ss << " : RESERVOIR VOLUMES M3 :\n"; + ss << " : RESERVOIR VOLUMES RM3 :\n"; } else if (units.getType() == UnitSystem::UnitType::UNIT_TYPE_FIELD) { ss << " : RESERVOIR VOLUMES RB :\n"; } - ss << ":---------:---------------:---------------:---------------:---------------:---------------:\n" - << ": REGION : TOTAL PORE : PORE VOLUME : PORE VOLUME : PORE VOLUME : PORE VOLUME :\n" - << ": : VOLUME : CONTAINING : CONTAINING : CONTAINING : CONTAINING :\n" - << ": : : OIL : WATER : GAS : HYDRO-CARBON :\n" - << ":---------:---------------:---------------:---------------:---------------:---------------"; - } - else { - ss << std::right << std::fixed << std::setprecision(0) << ":" - << std::setw (9) << reg << ":" - << std::setw(15) << cipr[Inplace::Phase::DynamicPoreVolume] << ":" - << std::setw(15) << cipr[Inplace::Phase::OilResVolume] << ":" - << std::setw(15) << cipr[Inplace::Phase::WaterResVolume] << ":" - << std::setw(15) << cipr[Inplace::Phase::GasResVolume] << ":" - << std::setw(15) << cipr[Inplace::Phase::OilResVolume] + - cipr[Inplace::Phase::GasResVolume] << ":\n" - << ":---------:---------------:---------------:---------------:---------------:---------------:"; - } + ss << " :---------:---------------:---------------:---------------:---------------:---------------:\n" + << " : REGION : TOTAL PORE : PORE VOLUME : PORE VOLUME : PORE VOLUME : PORE VOLUME :\n" + << " : : VOLUME : CONTAINING : CONTAINING : CONTAINING : CONTAINING :\n" + << " : : : OIL : WATER : GAS : HYDRO-CARBON :\n" + << " :---------:---------------:---------------:---------------:---------------:---------------\n"; + + ss << std::right << std::fixed << std::setprecision(0) << " :" + << std::setw (8) << "FIELD" << " :"; + + } else { + ss << std::right << std::fixed << std::setprecision(0) << " :" + << std::setw (8) << reg << " :"; + } + + ss << std::setw(15) << cipr[Inplace::Phase::DynamicPoreVolume] << ":" + << std::setw(15) << cipr[Inplace::Phase::OilResVolume] << ":" + << std::setw(15) << cipr[Inplace::Phase::WaterResVolume] << ":" + << std::setw(15) << cipr[Inplace::Phase::GasResVolume] << ":" + << std::setw(15) << cipr[Inplace::Phase::OilResVolume] + + cipr[Inplace::Phase::GasResVolume] << ":"; + OpmLog::note(ss.str()); } diff --git a/opm/simulators/flow/LogOutputHelper.hpp b/opm/simulators/flow/LogOutputHelper.hpp index 7719db05e..4fcc26bf2 100644 --- a/opm/simulators/flow/LogOutputHelper.hpp +++ b/opm/simulators/flow/LogOutputHelper.hpp @@ -29,6 +29,8 @@ #include #include #include +#include + namespace Opm { @@ -58,7 +60,7 @@ public: const std::string& name) const; //! \brief Write fluid-in-place reservoir reports to output. - void fipResv(const Inplace& inplace) const; + void fipResv(const Inplace& inplace, const std::string& name) const; //! \brief Write injection report to output. void injection(const std::size_t reportStepNum, @@ -68,6 +70,8 @@ public: void production(const std::size_t reportStepNum, std::function isDefunct) const; + void timeStamp(const std::string& lbl, double elapsed, int rstep, boost::posix_time::ptime currentDate) const; + private: void beginCumulativeReport_() const; void endCumulativeReport_() const; @@ -167,6 +171,7 @@ private: const EclipseState& eclState_; const Schedule& schedule_; const SummaryState& summaryState_; + std::string flowVersionName_; }; } // namespace Opm diff --git a/opm/simulators/flow/SimulatorFullyImplicitBlackoilEbos.hpp b/opm/simulators/flow/SimulatorFullyImplicitBlackoilEbos.hpp index c59a36ff7..9fdf1e951 100644 --- a/opm/simulators/flow/SimulatorFullyImplicitBlackoilEbos.hpp +++ b/opm/simulators/flow/SimulatorFullyImplicitBlackoilEbos.hpp @@ -362,7 +362,7 @@ public: ebosSimulator_.setEpisodeLength(0.0); ebosSimulator_.setTimeStepSize(0.0); wellModel_().beginReportStep(timer.currentStepNum()); - ebosSimulator_.problem().writeOutput(); + ebosSimulator_.problem().writeOutput(timer); report_.success.output_write_time += perfTimer.stop(); } @@ -432,7 +432,7 @@ public: perfTimer.start(); const double nextstep = adaptiveTimeStepping_ ? adaptiveTimeStepping_->suggestedNextStep() : -1.0; ebosSimulator_.problem().setNextTimeStepSize(nextstep); - ebosSimulator_.problem().writeOutput(); + ebosSimulator_.problem().writeOutput(timer); report_.success.output_write_time += perfTimer.stop(); solver_->model().endReportStep(); @@ -452,13 +452,8 @@ public: // Increment timer, remember well state. ++timer; - + if (terminalOutput_) { - if (!timer.initialStep()) { - const std::string version = moduleVersionName(); - outputTimestampFIP(timer, eclState().getTitle(), version); - } - std::string msg = "Time step took " + std::to_string(solverTimer_->secsSinceStart()) + " seconds; " "total solver time " + std::to_string(report_.success.solver_time) + " seconds."; diff --git a/opm/simulators/timestepping/AdaptiveTimeSteppingEbos.hpp b/opm/simulators/timestepping/AdaptiveTimeSteppingEbos.hpp index 505d6a11f..9ca8ee680 100644 --- a/opm/simulators/timestepping/AdaptiveTimeSteppingEbos.hpp +++ b/opm/simulators/timestepping/AdaptiveTimeSteppingEbos.hpp @@ -497,7 +497,7 @@ std::set consistentlyFailingWells(const std::vector& sr time::StopWatch perfTimer; perfTimer.start(); - ebosProblem.writeOutput(); + ebosProblem.writeOutput(simulatorTimer); report.success.output_write_time += perfTimer.secsSinceStart(); } diff --git a/tests/test_LogOutputHelper.cpp b/tests/test_LogOutputHelper.cpp index b602bf633..457bbe3bf 100644 --- a/tests/test_LogOutputHelper.cpp +++ b/tests/test_LogOutputHelper.cpp @@ -72,6 +72,8 @@ WCONINJE 'INJ' 'GAS' 'OPEN' 'RATE' 100000 1* 9014 / /)"; + + std::string trimStream(std::stringstream& str) { char buffer[1024]; @@ -89,6 +91,7 @@ std::string trimStream(std::stringstream& str) return data; } + } BOOST_AUTO_TEST_CASE(Cumulative) @@ -169,6 +172,7 @@ BOOST_AUTO_TEST_CASE(Cumulative) BOOST_CHECK_EQUAL(data, reference); } + BOOST_AUTO_TEST_CASE(Error) { const std::string reference = R"(Finding the bubble point pressure failed for 3 cells [(2,1,1), (1,3,1), (1,4,1)] @@ -200,34 +204,40 @@ Finding the dew point pressure failed for 3 cells [(5,1,1), (6,1,1), (7,1,1)] BOOST_AUTO_TEST_CASE(Fip) { - const std::string reference = R"(Field total pressure dependent pore volume = 50 RB -=================================================== -: Field Totals : -: PAV = 0 PSIA : -: PORV = 157 RB : -: Pressure is weighted by hydrocarbon pore volume : -: Pore volumes are taken at reference conditions : -:--------------- Oil STB ---------------:-- Wat STB --:--------------- Gas MSCF ---------------: -: Liquid Vapour Total : Total : Free Dissolved Total : -:------------------------:------------------------------------------:----------------:------------------------------------------: -:Currently in place : 132 138 120: 113 : 1 1 1: -:------------------------:------------------------------------------:----------------:------------------------------------------: -:Originally in place : 25 31 13: 6 : 0 0 0: -:========================:==========================================:================:==========================================: -FIPNUM report region 1 pressure dependent pore volume = 50 RB -=================================================== -: FIPNUM report region 1 : -: PAV = 0 PSIA : -: PORV = 371 RB : -:--------------- Oil STB ---------------:-- Wat STB --:--------------- Gas MSCF ---------------: -: Liquid Vapour Total : Total : Free Dissolved Total : -:------------------------:------------------------------------------:----------------:------------------------------------------: -:Currently in place : 346 352 333: 327 : 2 2 2: -:------------------------:------------------------------------------:----------------:------------------------------------------: -:Originally in place : 239 245 226: 220 : 1 1 1: -:========================:==========================================:================:==========================================: + const std::string reference = R"( + ================================================== + : FIELD TOTALS : + : PAV = 0 PSIA : + : PORV= 157 RB : + : Pressure is weighted by hydrocarbon pore volume: + : Pore volumes are taken at reference conditions : + :--------------- OIL STB ----------------:-- WAT STB --:--------------- GAS MSCF ----------------: + : LIQUID VAPOUR TOTAL : TOTAL : FREE DISSOLVED TOTAL : + :-------------------------:-------------------------------------------:----------------:-------------------------------------------: + :CURRENTLY IN PLACE : 132 138 120: 113 : 1 1 1: + :-------------------------:-------------------------------------------:----------------:-------------------------------------------: + :ORIGINALLY IN PLACE : 25 31 13: 6 : 0 0 0: + ==================================================================================================================================== + + + + ================================================== + : FIPNUM REPORT REGION 1 : + : PAV = 0 PSIA : + : PORV= 371 RB : + :--------------- OIL STB ----------------:-- WAT STB --:--------------- GAS MSCF ----------------: + : LIQUID VAPOUR TOTAL : TOTAL : FREE DISSOLVED TOTAL : + :-------------------------:-------------------------------------------:----------------:-------------------------------------------: + :CURRENTLY IN PLACE : 346 352 333: 327 : 2 2 2: + :-------------------------:-------------------------------------------:----------------:-------------------------------------------: + :ORIGINALLY IN PLACE : 239 245 226: 220 : 1 1 1: + :-------------------------:-------------------------------------------:----------------:-------------------------------------------: + ==================================================================================================================================== + + )"; + std::stringstream str; Opm::OpmLog::addBackend("stream", std::make_shared(str, Opm::Log::MessageType::Note)); @@ -274,22 +284,25 @@ FIPNUM report region 1 pressure dependent pore volume = 50 RB helper.fip(current, initial, ""); helper.fip(current, initial, "FIPNUM"); - std::string data = trimStream(str); - BOOST_CHECK_EQUAL(data, reference); + + BOOST_CHECK_EQUAL(str.str(), reference); } BOOST_AUTO_TEST_CASE(FipResv) { - const std::string reference = R"(=================================== -: RESERVOIR VOLUMES RB : -:---------:---------------:---------------:---------------:---------------:---------------: -: REGION : TOTAL PORE : PORE VOLUME : PORE VOLUME : PORE VOLUME : PORE VOLUME : -: : VOLUME : CONTAINING : CONTAINING : CONTAINING : CONTAINING : -: : : OIL : WATER : GAS : HYDRO-CARBON : -:---------:---------------:---------------:---------------:---------------:--------------- -: 1: 176: 170: 164: 176: 346: -:---------:---------------:---------------:---------------:---------------:---------------: + const std::string reference = R"( + =================================== + : RESERVOIR VOLUMES RB : + :---------:---------------:---------------:---------------:---------------:---------------: + : REGION : TOTAL PORE : PORE VOLUME : PORE VOLUME : PORE VOLUME : PORE VOLUME : + : : VOLUME : CONTAINING : CONTAINING : CONTAINING : CONTAINING : + : : : OIL : WATER : GAS : HYDRO-CARBON : + :---------:---------------:---------------:---------------:---------------:--------------- + : FIELD : 176: 13: 19: 25: 38: + : 1 : 176: 170: 164: 176: 346: + =========================================================================================== )"; + std::stringstream str; Opm::OpmLog::addBackend("stream", @@ -323,11 +336,11 @@ BOOST_AUTO_TEST_CASE(FipResv) current.add(Opm::Inplace::Phase::GasResVolume, 4.0); current.add("FIPNUM", Opm::Inplace::Phase::DynamicPoreVolume, 1, 11.0 + phases.size()); - helper.fipResv(current); - std::string data = trimStream(str); - BOOST_CHECK_EQUAL(data, reference); + helper.fipResv(current, "FIPNUM"); + BOOST_CHECK_EQUAL(str.str(), reference); } + BOOST_AUTO_TEST_CASE(Injection) { const std::string reference = R"(=================================================== INJECTION REPORT ======================================== @@ -382,6 +395,7 @@ BOOST_AUTO_TEST_CASE(Injection) BOOST_CHECK_EQUAL(data, reference); } + BOOST_AUTO_TEST_CASE(Production) { const std::string reference = R"(======================================================= PRODUCTION REPORT ======================================================= @@ -441,3 +455,4 @@ BOOST_AUTO_TEST_CASE(Production) std::string data = trimStream(str); BOOST_CHECK_EQUAL(data, reference); } +