From 6b18cbafc6ed9224fcfa0a884018f729a4ce81af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Thu, 7 Dec 2023 15:18:03 +0100 Subject: [PATCH 1/3] Pull Substep Checking out of *Log() Functions This commit removes the 'substep' parameter from the output module's outputProdLog(), outputInjLog(), and outputCumLog() member functions. This parameter was only used in the same way in internal conditions in each member function and we can enforce that check on the outside without losing expressivity. --- ebos/eclgenericoutputblackoilmodule.cc | 40 ++++++++++++-------------- ebos/eclgenericoutputblackoilmodule.hh | 3 -- ebos/eclwriter.hh | 18 ++++++------ 3 files changed, 29 insertions(+), 32 deletions(-) diff --git a/ebos/eclgenericoutputblackoilmodule.cc b/ebos/eclgenericoutputblackoilmodule.cc index ded98a672..e9cab195e 100644 --- a/ebos/eclgenericoutputblackoilmodule.cc +++ b/ebos/eclgenericoutputblackoilmodule.cc @@ -200,7 +200,7 @@ EclGenericOutputBlackoilModule(const EclipseState& eclState, enableFlows_ = false; enableFlowsn_ = false; - for (const auto& block : this->schedule_) { // Uses Schedule::begin() and Schedule::end() + for (const auto& block : this->schedule_) { const auto& rstkw = block.rst_config().keywords; if (! anyFlores_) { @@ -226,37 +226,35 @@ EclGenericOutputBlackoilModule:: template void EclGenericOutputBlackoilModule:: -outputCumLog(std::size_t reportStepNum, const bool substep, bool forceDisableCumOutput) +outputCumLog(std::size_t reportStepNum, bool forceDisableCumOutput) { - if (!substep && !forceDisableCumOutput) { - logOutput_.cumulative(reportStepNum, - [this](const std::string& name) - { return this->isDefunctParallelWell(name); }); - } + if (forceDisableCumOutput) { return; } + + logOutput_.cumulative(reportStepNum, + [this](const std::string& name) + { return this->isDefunctParallelWell(name); }); } template void EclGenericOutputBlackoilModule:: -outputProdLog(std::size_t reportStepNum, - const bool substep, - bool forceDisableProdOutput) +outputProdLog(std::size_t reportStepNum, bool forceDisableProdOutput) { - if (!substep && !forceDisableProdOutput) { - logOutput_.production(reportStepNum, - [this](const std::string& name) - { return this->isDefunctParallelWell(name); }); - } + if (forceDisableProdOutput) { return; } + + logOutput_.production(reportStepNum, + [this](const std::string& name) + { return this->isDefunctParallelWell(name); }); } template void EclGenericOutputBlackoilModule:: -outputInjLog(std::size_t reportStepNum, const bool substep, bool forceDisableInjOutput) +outputInjLog(std::size_t reportStepNum, bool forceDisableInjOutput) { - if (!substep && !forceDisableInjOutput) { - logOutput_.injection(reportStepNum, - [this](const std::string& name) - { return this->isDefunctParallelWell(name); }); - } + if (forceDisableInjOutput) { return; } + + logOutput_.injection(reportStepNum, + [this](const std::string& name) + { return this->isDefunctParallelWell(name); }); } template diff --git a/ebos/eclgenericoutputblackoilmodule.hh b/ebos/eclgenericoutputblackoilmodule.hh index b25c6a9b0..83d96d861 100644 --- a/ebos/eclgenericoutputblackoilmodule.hh +++ b/ebos/eclgenericoutputblackoilmodule.hh @@ -63,17 +63,14 @@ public: // write cumulative production and injection reports to output void outputCumLog(std::size_t reportStepNum, - const bool substep, bool forceDisableCumOutput); // write production report to output void outputProdLog(std::size_t reportStepNum, - const bool substep, bool forceDisableProdOutput); // write injection report to output void outputInjLog(std::size_t reportStepNum, - const bool substep, bool forceDisableInjOutput); // write Fluid In Place to output log diff --git a/ebos/eclwriter.hh b/ebos/eclwriter.hh index 4991c95bd..cfe66f442 100644 --- a/ebos/eclwriter.hh +++ b/ebos/eclwriter.hh @@ -254,9 +254,6 @@ public: eclOutputModule_->outputFipresvLog(miscSummaryData, regionData, reportStepNum, isSubStep, simulator_.gridView().comm()); } - bool forceDisableProdOutput = false; - bool forceDisableInjOutput = false; - bool forceDisableCumOutput = false; // Add TCPU if (totalCpuTime != 0.0) { @@ -311,11 +308,16 @@ public: this->udqState()); } - { - OPM_TIMEBLOCK(outputXXX); - eclOutputModule_->outputProdLog(reportStepNum, isSubStep, forceDisableProdOutput); - eclOutputModule_->outputInjLog(reportStepNum, isSubStep, forceDisableInjOutput); - eclOutputModule_->outputCumLog(reportStepNum, isSubStep, forceDisableCumOutput); + if (! isSubStep) { + OPM_TIMEBLOCK(outputProdInjLogs); + + const bool forceDisableProdOutput = false; + const bool forceDisableInjOutput = false; + const bool forceDisableCumOutput = false; + + eclOutputModule_->outputProdLog(reportStepNum, forceDisableProdOutput); + eclOutputModule_->outputInjLog(reportStepNum, forceDisableInjOutput); + eclOutputModule_->outputCumLog(reportStepNum, forceDisableCumOutput); } } From ec549df37ba42b1378bf92e88adeef1b01b03eed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Thu, 7 Dec 2023 15:29:08 +0100 Subject: [PATCH 2/3] Remove Spurious Blank Lines in PRT File Reports The StreamLog::addMessageUnconditionally() member function will end each message with a newline (std::endl) so we should not add such newlines ourselves. The extra newline characters produce spurious blank lines in the report sheets, e.g., for the "PRODUCTION REPORT". This commit removes the last newline character from each report request, thus deferring that responsibility to OpmLog::note() instead. Doing so, however, means we have take a little more care with the first line of each report lest we create report sheets which are smushed together. --- ebos/eclwriter.hh | 2 ++ opm/simulators/flow/LogOutputHelper.cpp | 28 +++++++++++++------------ tests/test_LogOutputHelper.cpp | 14 ++++++------- 3 files changed, 24 insertions(+), 20 deletions(-) diff --git a/ebos/eclwriter.hh b/ebos/eclwriter.hh index cfe66f442..df7fd3799 100644 --- a/ebos/eclwriter.hh +++ b/ebos/eclwriter.hh @@ -318,6 +318,8 @@ public: eclOutputModule_->outputProdLog(reportStepNum, forceDisableProdOutput); eclOutputModule_->outputInjLog(reportStepNum, forceDisableInjOutput); eclOutputModule_->outputCumLog(reportStepNum, forceDisableCumOutput); + + OpmLog::note(""); // Blank line after all reports. } } diff --git a/opm/simulators/flow/LogOutputHelper.cpp b/opm/simulators/flow/LogOutputHelper.cpp index 9087fe40b..ef0833610 100644 --- a/opm/simulators/flow/LogOutputHelper.cpp +++ b/opm/simulators/flow/LogOutputHelper.cpp @@ -571,7 +571,7 @@ outputCumulativeReport_(const std::vector& wellCum, const UnitSystem& units = eclState_.getUnits(); std::ostringstream ss; if (wellCumNames[WellCumDataType::WellName].empty()) { - ss << "=================================================== CUMULATIVE PRODUCTION/INJECTION REPORT =========================================\n" + ss << "\n=================================================== CUMULATIVE PRODUCTION/INJECTION REPORT =========================================\n" << ": WELL : LOCATION : WELL :CTRL: OIL : WATER : GAS : Prod : OIL : WATER : GAS : INJ :\n" << ": NAME : (I,J,K) : TYPE :MODE: PROD : PROD : PROD : RES.VOL. : INJ : INJ : INJ : RES.VOL. :\n"; if (units.getType() == UnitSystem::UnitType::UNIT_TYPE_METRIC) { @@ -580,8 +580,9 @@ outputCumulativeReport_(const std::vector& wellCum, ss << ": : : : : MSTB : MSTB : MMSCF : MRB : MSTB : MSTB : MMSCF : MRB :\n"; } else if (units.getType() == UnitSystem::UnitType::UNIT_TYPE_LAB) { ss << ": : : : : MSCC : MSCC : MMSCC : MRCC : MSCC : MSCC : MMSCC : MRCC :\n"; + ss << ":--------:-----------:--------:----:-----------:-----------:-----------:-----------:------------:----------:-----------:-----------:"; } - ss << "====================================================================================================================================\n"; + ss << "===================================================================================================================================="; } else { if (wellCum[WellCumDataType::WellLocationi] < 1) { ss << std::right << std::fixed << std::setprecision(0) << ":" << std::setw (8) @@ -613,7 +614,7 @@ outputCumulativeReport_(const std::vector& wellCum, << std::setw(11) << wellCum[WellCumDataType::GasInj] / 1000.0 << ":" << std::setw(11) << wellCum[WellCumDataType::FluidResVolInj] / 1000.0 << ": \n"; } - ss << ":--------:-----------:--------:----:------------:----------:-----------:-----------:------------:----------:-----------:-----------: \n"; + ss << ":--------:-----------:--------:----:-----------:-----------:-----------:-----------:------------:----------:-----------:-----------:"; } OpmLog::note(ss.str()); } @@ -626,7 +627,7 @@ outputInjectionReport_(const std::vector& wellInj, const UnitSystem& units = eclState_.getUnits(); std::ostringstream ss; if (wellInjNames[WellInjDataType::WellName].empty()) { - ss << "=================================================== INJECTION REPORT ========================================\n"//===================== \n" + ss << "\n=================================================== INJECTION REPORT ========================================\n"//===================== \n" << ": WELL : LOCATION : CTRL : CTRL : CTRL : OIL : WATER : GAS : FLUID : BHP OR : THP OR :\n"// STEADY-ST II :\n" << ": NAME : (I,J,K) : MODE : MODE : MODE : RATE : RATE : RATE : RES.VOL. : CON.PR.: BLK.PR.:\n";// OR POTENTIAL :\n"; if (units.getType() == UnitSystem::UnitType::UNIT_TYPE_METRIC) { @@ -635,8 +636,9 @@ outputInjectionReport_(const std::vector& wellInj, ss << ": : : OIL : WAT : GAS : STB/DAY : STB/DAY : MSCF/DAY : RB/DAY : PSIA : PSIA :\n";// :\n"; } else if (units.getType() == UnitSystem::UnitType::UNIT_TYPE_LAB) { ss << ": : : OIL : WAT : GAS : SCC/HR : SCC/HR : SCC/HR : RCC/HR : ATMA : ATMA :\n";// :\n"; + ss << ":--------:-----------:------:------:------:-----------:-----------:-----------:-----------:--------:--------:";//--------------------:"; } - ss << "==============================================================================================================\n";//===================== \n"; + ss << "==============================================================================================================";//====================="; } else { if (wellInj[WellInjDataType::WellLocationi] < 1) { ss << std::right << std::fixed << std::setprecision(0) << ":" @@ -665,7 +667,7 @@ outputInjectionReport_(const std::vector& wellInj, << std::setw(8) << wellInj[WellInjDataType::BHP] << ":" << std::setw(8)<< wellInj[WellInjDataType::THP] << ": \n";//wellInj[WellInjDataType::SteadyStateII] << std::setw(10) << "\n" } - ss << ":--------:-----------:------:------:------:------------:----------:-----------:-----------:--------:--------: \n";//--------------------:\n"; + ss << ":--------:-----------:------:------:------:-----------:-----------:-----------:-----------:--------:--------:";//--------------------:"; } OpmLog::note(ss.str()); } @@ -678,7 +680,7 @@ outputProductionReport_(const std::vector& wellProd, const UnitSystem& units = eclState_.getUnits(); std::ostringstream ss; if (wellProdNames[WellProdDataType::WellName].empty()) { - ss << "======================================================= PRODUCTION REPORT =======================================================\n"//=================== \n" + ss << "\n======================================================= PRODUCTION REPORT =======================================================\n"//=================== \n" << ": WELL : LOCATION :CTRL: OIL : WATER : GAS : FLUID : WATER : GAS/OIL : WAT/GAS : BHP OR : THP OR :\n"// STEADY-ST PI :\n" << ": NAME : (I,J,K) :MODE: RATE : RATE : RATE : RES.VOL. : CUT : RATIO : RATIO : CON.PR.: BLK.PR.:\n";// OR POTN OF PREF. PH:\n"; if (units.getType() == UnitSystem::UnitType::UNIT_TYPE_METRIC) { @@ -688,7 +690,7 @@ outputProductionReport_(const std::vector& wellProd, } else if (units.getType() == UnitSystem::UnitType::UNIT_TYPE_LAB) { ss << ": : : : SCC/HR : SCC/HR : SCC/HR : RCC : SCC/SCC : SCC/SCC : SCC/SCC : ATMA : ATMA :\n";// :\n"; } - ss << "=================================================================================================================================\n";//=================== \n"; + ss << "=================================================================================================================================";//==================="; } else { if (wellProd[WellProdDataType::WellLocationi] < 1) { ss << std::right << std::fixed << ":" @@ -730,7 +732,7 @@ outputProductionReport_(const std::vector& wellProd, << std::setfill ('-') << std::setw (11) << ":" << std::setfill ('-') << std::setw (13) << ":" << std::setfill ('-') << std::setw (9) << ":" - << std::setfill ('-') << std::setw (9) << ":" << "\n"; + << std::setfill ('-') << std::setw (9) << ':'; } OpmLog::note(ss.str()); } @@ -808,7 +810,7 @@ outputRegionFluidInPlace_(std::unordered_map oip, << std::setw(14) << oip[Inplace::Phase::GasInGasPhase] << std::setw(14) << oip[Inplace::Phase::GasInLiquidPhase] << std::setw(14) << oip[Inplace::Phase::GAS] << ":\n" - << ":========================:==========================================:================:==========================================:\n"; + << ":========================:==========================================:================:==========================================:"; OpmLog::note(ss.str()); } @@ -825,7 +827,7 @@ outputResvFluidInPlace_(std::unordered_map cipr, const UnitSystem& units = eclState_.getUnits(); std::ostringstream ss; if (reg == 0) { - ss << " ===================================\n"; + ss << "\n ===================================\n"; if (units.getType() == UnitSystem::UnitType::UNIT_TYPE_METRIC) { ss << " : RESERVOIR VOLUMES M3 :\n"; } else if (units.getType() == UnitSystem::UnitType::UNIT_TYPE_FIELD) { @@ -835,7 +837,7 @@ outputResvFluidInPlace_(std::unordered_map cipr, << ": 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"; + << ":---------:---------------:---------------:---------------:---------------:---------------"; } else { ss << std::right << std::fixed << std::setprecision(0) << ":" @@ -846,7 +848,7 @@ outputResvFluidInPlace_(std::unordered_map cipr, << std::setw(15) << cipr[Inplace::Phase::GasResVolume] << ":" << std::setw(15) << cipr[Inplace::Phase::OilResVolume] + cipr[Inplace::Phase::GasResVolume] << ":\n" - << ":---------:---------------:---------------:---------------:---------------:---------------:\n"; + << ":---------:---------------:---------------:---------------:---------------:---------------:"; } OpmLog::note(ss.str()); } diff --git a/tests/test_LogOutputHelper.cpp b/tests/test_LogOutputHelper.cpp index 9713c1ea8..9efda8ecf 100644 --- a/tests/test_LogOutputHelper.cpp +++ b/tests/test_LogOutputHelper.cpp @@ -99,13 +99,13 @@ BOOST_AUTO_TEST_CASE(Cumulative) : : : : : MSTB : MSTB : MMSCF : MRB : MSTB : MSTB : MMSCF : MRB : ==================================================================================================================================== : FIELD: : : : 1.0: 2.0: 3.0: 4.0: 5.0: 6.0: 7.0: 8.0: -:--------:-----------:--------:----:------------:----------:-----------:-----------:------------:----------:-----------:-----------: +:--------:-----------:--------:----:-----------:-----------:-----------:-----------:------------:----------:-----------:-----------: : G1: : : : 9.0: 10.0: 11.0: 12.0: 13.0: 14.0: 15.0: 15.0: -:--------:-----------:--------:----:------------:----------:-----------:-----------:------------:----------:-----------:-----------: +:--------:-----------:--------:----:-----------:-----------:-----------:-----------:------------:----------:-----------:-----------: : PROD: 10, 10: PROD:ORAT: 16.0: 17.0: 18.0: 19.0: 20.0: 21.0: 22.0: 23.0: -:--------:-----------:--------:----:------------:----------:-----------:-----------:------------:----------:-----------:-----------: +:--------:-----------:--------:----:-----------:-----------:-----------:-----------:------------:----------:-----------:-----------: : INJ: 1, 1: INJ:GRAT: 24.0: 25.0: 26.0: 27.0: 28.0: 29.0: 30.0: 31.0: -:--------:-----------:--------:----:------------:----------:-----------:-----------:------------:----------:-----------:-----------: +:--------:-----------:--------:----:-----------:-----------:-----------:-----------:------------:----------:-----------:-----------: )"; std::stringstream str; @@ -335,11 +335,11 @@ BOOST_AUTO_TEST_CASE(Injection) : : : OIL : WAT : GAS : STB/DAY : STB/DAY : MSCF/DAY : RB/DAY : PSIA : PSIA : ============================================================================================================== : FIELD: : : : : 1.0: 2.0: 3.0: 4.0: : : -:--------:-----------:------:------:------:------------:----------:-----------:-----------:--------:--------: +:--------:-----------:------:------:------:-----------:-----------:-----------:-----------:--------:--------: : G1: : : : : 5.0: 6.0: 7.0: 8.0: : : -:--------:-----------:------:------:------:------------:----------:-----------:-----------:--------:--------: +:--------:-----------:------:------:------:-----------:-----------:-----------:-----------:--------:--------: : INJ: 1, 1: : : GRAT: 9.0: 10.0: 11.0: 12.0: 13.0: 14.0: -:--------:-----------:------:------:------:------------:----------:-----------:-----------:--------:--------: +:--------:-----------:------:------:------:-----------:-----------:-----------:-----------:--------:--------: )"; std::stringstream str; From d79bd2848f0b1fd5ffb6c3239ba77c8dd3d37a5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Fri, 8 Dec 2023 10:18:41 +0100 Subject: [PATCH 3/3] Prune ForceDisable Parameters From *Log Functions They aren't really needed in the current sources. We can readd them, or something similar, if the need to turn off these reports from a command line parameter arises. Suggested by: [at]akva2. --- ebos/eclgenericoutputblackoilmodule.cc | 12 +++--------- ebos/eclgenericoutputblackoilmodule.hh | 9 +++------ ebos/eclwriter.hh | 10 +++------- 3 files changed, 9 insertions(+), 22 deletions(-) diff --git a/ebos/eclgenericoutputblackoilmodule.cc b/ebos/eclgenericoutputblackoilmodule.cc index e9cab195e..5ff877d88 100644 --- a/ebos/eclgenericoutputblackoilmodule.cc +++ b/ebos/eclgenericoutputblackoilmodule.cc @@ -226,10 +226,8 @@ EclGenericOutputBlackoilModule:: template void EclGenericOutputBlackoilModule:: -outputCumLog(std::size_t reportStepNum, bool forceDisableCumOutput) +outputCumLog(std::size_t reportStepNum) { - if (forceDisableCumOutput) { return; } - logOutput_.cumulative(reportStepNum, [this](const std::string& name) { return this->isDefunctParallelWell(name); }); @@ -237,10 +235,8 @@ outputCumLog(std::size_t reportStepNum, bool forceDisableCumOutput) template void EclGenericOutputBlackoilModule:: -outputProdLog(std::size_t reportStepNum, bool forceDisableProdOutput) +outputProdLog(std::size_t reportStepNum) { - if (forceDisableProdOutput) { return; } - logOutput_.production(reportStepNum, [this](const std::string& name) { return this->isDefunctParallelWell(name); }); @@ -248,10 +244,8 @@ outputProdLog(std::size_t reportStepNum, bool forceDisableProdOutput) template void EclGenericOutputBlackoilModule:: -outputInjLog(std::size_t reportStepNum, bool forceDisableInjOutput) +outputInjLog(std::size_t reportStepNum) { - if (forceDisableInjOutput) { return; } - logOutput_.injection(reportStepNum, [this](const std::string& name) { return this->isDefunctParallelWell(name); }); diff --git a/ebos/eclgenericoutputblackoilmodule.hh b/ebos/eclgenericoutputblackoilmodule.hh index 83d96d861..acd192ef5 100644 --- a/ebos/eclgenericoutputblackoilmodule.hh +++ b/ebos/eclgenericoutputblackoilmodule.hh @@ -62,16 +62,13 @@ public: }; // write cumulative production and injection reports to output - void outputCumLog(std::size_t reportStepNum, - bool forceDisableCumOutput); + void outputCumLog(std::size_t reportStepNum); // write production report to output - void outputProdLog(std::size_t reportStepNum, - bool forceDisableProdOutput); + void outputProdLog(std::size_t reportStepNum); // write injection report to output - void outputInjLog(std::size_t reportStepNum, - bool forceDisableInjOutput); + void outputInjLog(std::size_t reportStepNum); // write Fluid In Place to output log Inplace outputFipLog(std::map& miscSummaryData, diff --git a/ebos/eclwriter.hh b/ebos/eclwriter.hh index df7fd3799..a05e5569c 100644 --- a/ebos/eclwriter.hh +++ b/ebos/eclwriter.hh @@ -311,13 +311,9 @@ public: if (! isSubStep) { OPM_TIMEBLOCK(outputProdInjLogs); - const bool forceDisableProdOutput = false; - const bool forceDisableInjOutput = false; - const bool forceDisableCumOutput = false; - - eclOutputModule_->outputProdLog(reportStepNum, forceDisableProdOutput); - eclOutputModule_->outputInjLog(reportStepNum, forceDisableInjOutput); - eclOutputModule_->outputCumLog(reportStepNum, forceDisableCumOutput); + eclOutputModule_->outputProdLog(reportStepNum); + eclOutputModule_->outputInjLog(reportStepNum); + eclOutputModule_->outputCumLog(reportStepNum); OpmLog::note(""); // Blank line after all reports. }