From 91a4701fa47a8754b04b75ac9fa8bbe01ed0ef82 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Fri, 4 Aug 2023 12:12:28 +0200 Subject: [PATCH] added: add dedicated class for output of logs start by moving output of cumulative logs to the new class --- CMakeLists_files.cmake | 2 + ebos/eclgenericoutputblackoilmodule.cc | 197 +------------------ ebos/eclgenericoutputblackoilmodule.hh | 27 +-- opm/simulators/flow/LogOutputHelper.cpp | 245 ++++++++++++++++++++++++ opm/simulators/flow/LogOutputHelper.hpp | 79 ++++++++ 5 files changed, 333 insertions(+), 217 deletions(-) create mode 100644 opm/simulators/flow/LogOutputHelper.cpp create mode 100644 opm/simulators/flow/LogOutputHelper.hpp diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index 1cacf7854..5d615f113 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -48,6 +48,7 @@ list (APPEND MAIN_SOURCE_FILES opm/simulators/flow/ExtraConvergenceOutputThread.cpp opm/simulators/flow/FlowMainEbos.cpp opm/simulators/flow/KeywordValidation.cpp + opm/simulators/flow/LogOutputHelper.cpp opm/simulators/flow/Main.cpp opm/simulators/flow/NonlinearSolverEbos.cpp opm/simulators/flow/SimulatorFullyImplicitBlackoilEbos.cpp @@ -425,6 +426,7 @@ list (APPEND PUBLIC_HEADER_FILES opm/simulators/flow/NonlinearSolverEbos.hpp opm/simulators/flow/SimulatorFullyImplicitBlackoilEbos.hpp opm/simulators/flow/KeywordValidation.hpp + opm/simulators/flow/LogOutputHelper.hpp opm/simulators/flow/ValidationFunctions.hpp opm/simulators/flow/partitionCells.hpp opm/simulators/flow/SubDomain.hpp diff --git a/ebos/eclgenericoutputblackoilmodule.cc b/ebos/eclgenericoutputblackoilmodule.cc index 1ac73c3ef..3a43ec680 100644 --- a/ebos/eclgenericoutputblackoilmodule.cc +++ b/ebos/eclgenericoutputblackoilmodule.cc @@ -161,6 +161,7 @@ EclGenericOutputBlackoilModule(const EclipseState& eclState, , summaryConfig_(summaryConfig) , summaryState_(summaryState) , interRegionFlows_(numCells(eclState), defineInterRegionFlowArrays(eclState, summaryConfig)) + , logOutput_(eclState, schedule, summaryState) , enableEnergy_(enableEnergy) , enableTemperature_(enableTemperature) , enableSolvent_(enableSolvent) @@ -222,160 +223,10 @@ template void EclGenericOutputBlackoilModule:: outputCumLog(size_t reportStepNum, const bool substep, bool forceDisableCumOutput) { - if (!substep) { - ScalarBuffer tmp_values(WellCumDataType::numWCValues, 0.0); - StringBuffer tmp_names(WellCumDataType::numWCNames, ""); - outputCumulativeReport_(tmp_values, tmp_names, forceDisableCumOutput); - - const auto& st = summaryState_; - for (const auto& gname: schedule_.groupNames()) { - - auto gName = static_cast(gname); - auto get = [&st, &gName](const std::string& vector) - { - const auto key = vector + ':' + gName; - - return st.has(key) ? st.get(key) : 0.0; - }; - - tmp_names[0] = gname; - - if (tmp_names[0] == "FIELD"){ - tmp_values[2] = st.get("FOPT", 0.0); //WellCumDataType::OilProd - tmp_values[3] = st.get("FWPT", 0.0); //WellCumDataType::WaterProd - tmp_values[4] = st.get("FGPT", 0.0); //WellCumDataType::GasProd - tmp_values[5] = st.get("FVPT", 0.0);//WellCumDataType::FluidResVolProd - tmp_values[6] = st.get("FOIT", 0.0); //WellCumDataType::OilInj - tmp_values[7] = st.get("FWIT", 0.0); //WellCumDataType::WaterInj - tmp_values[8] = st.get("FGIT", 0.0); //WellCumDataType::GasInj - tmp_values[9] = st.get("FVIT", 0.0);//WellCumDataType::FluidResVolInj - } - else { - tmp_values[2] = get("GOPT"); //WellCumDataType::OilProd - tmp_values[3] = get("GWPT"); //WellCumDataType::WaterProd - tmp_values[4] = get("GGPT"); //WellCumDataType::GasProd - tmp_values[5] = get("GVPT");//WellCumDataType::FluidResVolProd - tmp_values[6] = get("GOIT"); //WellCumDataType::OilInj - tmp_values[7] = get("GWIT"); //WellCumDataType::WaterInj - tmp_values[8] = get("GGIT"); //WellCumDataType::GasInj - tmp_values[9] = get("GVIT");//WellCumDataType::FluidResVolInj - } - - outputCumulativeReport_(tmp_values, tmp_names, forceDisableCumOutput); - } - - for (const auto& wname : schedule_.wellNames(reportStepNum)) { - - // don't bother with wells not on this process - if (isDefunctParallelWell(wname)) { - continue; - } - - const auto& well = schedule_.getWell(wname, reportStepNum); - - tmp_names[0] = wname; //WellCumDataType::WellName - - auto wName = static_cast(wname); - auto get = [&st, &wName](const std::string& vector) - { - const auto key = vector + ':' + wName; - - return st.has(key) ? st.get(key) : 0.0; - }; - - if (well.isInjector()) { - - const auto& controls = well.injectionControls(st); - const auto ctlMode = controls.cmode; - const auto injType = controls.injector_type; - using CMode = ::Opm::Well::InjectorCMode; - using WType = ::Opm::InjectorType; - - auto ftype = [](const auto wtype) -> std::string - { - switch (wtype) { - case WType::OIL: return "Oil"; - case WType::WATER: return "Wat"; - case WType::GAS: return "Gas"; - case WType::MULTI: return "Multi"; - default: - { - return ""; - } - } - }; - - auto fctl = [](const auto wmctl) -> std::string - { - switch (wmctl) { - case CMode::RATE: return "RATE"; - case CMode::RESV: return "RESV"; - case CMode::THP: return "THP"; - case CMode::BHP: return "BHP"; - case CMode::GRUP: return "GRUP"; - default: - { - return ""; - } - } - }; - - tmp_names[1] = "INJ"; //WellCumDataType::WellType - const auto flowctl = fctl(ctlMode); - if (flowctl == "RATE") //WellCumDataType::WellCTRL - { - const auto flowtype = ftype(injType); - if(flowtype == "Oil"){ tmp_names[2] = "ORAT"; } - else if(flowtype == "Wat"){ tmp_names[2] = "WRAT"; } - else if(flowtype == "Gas"){ tmp_names[2] = "GRAT"; } - } - else - { - tmp_names[2] = flowctl; - } - - } - else if (well.isProducer()) { - - const auto& controls = well.productionControls(st); - using CMode = ::Opm::Well::ProducerCMode; - - auto fctl = [](const auto wmctl) -> std::string - { - switch (wmctl) { - case CMode::ORAT: return "ORAT"; - case CMode::WRAT: return "WRAT"; - case CMode::GRAT: return "GRAT"; - case CMode::LRAT: return "LRAT"; - case CMode::RESV: return "RESV"; - case CMode::THP: return "THP"; - case CMode::BHP: return "BHP"; - case CMode::CRAT: return "CRAT"; - case CMode::GRUP: return "GRUP"; - default: - { - return "none"; - } - } - }; - tmp_names[1] = "PROD"; //WellProdDataType::CTRLMode - tmp_names[2] = fctl(controls.cmode); //WellProdDataType::CTRLMode - } - - tmp_values[0] = well.getHeadI() + 1; //WellCumDataType::wellLocationi - tmp_values[1] = well.getHeadJ() + 1; //WellCumDataType::wellLocationj - tmp_values[2] = get("WOPT"); //WellCumDataType::OilProd - tmp_values[3] = get("WWPT"); //WellCumDataType::WaterProd - tmp_values[4] = get("WGPT"); //WellCumDataType::GasProd - tmp_values[5] = get("WVPT");//WellCumDataType::FluidResVolProd - tmp_values[6] = get("WOIT"); //WellCumDataType::OilInj - tmp_values[7] = get("WWIT"); //WellCumDataType::WaterInj - tmp_values[8] = get("WGIT"); //WellCumDataType::GasInj - tmp_values[9] = get("WVIT");//WellCumDataType::FluidResVolInj - - outputCumulativeReport_(tmp_values, tmp_names, forceDisableCumOutput); - - } + if (!substep && !forceDisableCumOutput) { + logOutput_.cumulative(reportStepNum, + [this](const std::string& name) + { return this->isDefunctParallelWell(name); }); } } @@ -1637,44 +1488,6 @@ outputInjectionReport_(const ScalarBuffer& wellInj, OpmLog::note(ss.str()); } -template -void EclGenericOutputBlackoilModule:: -outputCumulativeReport_(const ScalarBuffer& wellCum, - const StringBuffer& wellCumNames, - const bool forceDisableCumOutput) -{ - if (forceDisableCumOutput) - return; - - const UnitSystem& units = eclState_.getUnits(); - std::ostringstream ss; - if (wellCumNames[WellCumDataType::WellName].empty()) { - ss << "=================================================== 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) { - ss << ": : : : : MSCM : MSCM : MMSCM : MRCM : MSCM : MSCM : MMSCM : MRCM :\n"; - } - if (units.getType() == UnitSystem::UnitType::UNIT_TYPE_FIELD) { - ss << ": : : : : MSTB : MSTB : MMSCF : MRB : MSTB : MSTB : MMSCF : MRB :\n"; - } - if (units.getType() == UnitSystem::UnitType::UNIT_TYPE_LAB) { - ss << ": : : : : MSCC : MSCC : MMSCC : MRCC : MSCC : MSCC : MMSCC : MRCC :\n"; - } - ss << "====================================================================================================================================\n"; - } - else { - if (wellCum[WellCumDataType::WellLocationi] < 1) { - ss << std::right << std::fixed << std::setprecision(0) << ":" << std::setw (8) << wellCumNames[WellCumDataType::WellName] << ":" << std::setw(11) << "" << ":" << std::setw(8) << wellCumNames[WellCumDataType::WellType] << ":" << std::setw(4) << wellCumNames[WellCumDataType::WellCTRL] << ":" << std::setprecision(1) << std::setw(11) << wellCum[WellCumDataType::OilProd]/1000 << ":" << std::setw(11) << wellCum[WellCumDataType::WaterProd]/1000 << ":" << std::setw(11)<< wellCum[WellCumDataType::GasProd]/1000 << ":" << std::setw(11) << wellCum[WellCumDataType::FluidResVolProd]/1000 << ":" << std::setw(11) << wellCum[WellCumDataType::OilInj]/1000 << ":" << std::setw(11) << wellCum[WellCumDataType::WaterInj]/1000 << ":" << std::setw(11) << wellCum[WellCumDataType::GasInj]/1000 << ":" << std::setw(11) << wellCum[WellCumDataType::FluidResVolInj]/1000 << ": \n"; - } - else { - ss << std::right << std::fixed << std::setprecision(0) << ":" << std::setw (8) << wellCumNames[WellCumDataType::WellName] << ":" << std::setw(5) << wellCum[WellCumDataType::WellLocationi] << "," << std::setw(5) << wellCum[WellCumDataType::WellLocationj] << ":" << std::setw(8) << wellCumNames[WellCumDataType::WellType] << ":" << std::setw(4) << wellCumNames[WellCumDataType::WellCTRL] << ":" << std::setprecision(1) << std::setw(11) << wellCum[WellCumDataType::OilProd]/1000 << ":" << std::setw(11) << wellCum[WellCumDataType::WaterProd]/1000 << ":" << std::setw(11)<< wellCum[WellCumDataType::GasProd]/1000 << ":" << std::setw(11) << wellCum[WellCumDataType::FluidResVolProd]/1000 << ":" << std::setw(11) << wellCum[WellCumDataType::OilInj]/1000 << ":" << std::setw(11) << wellCum[WellCumDataType::WaterInj]/1000 << ":" << std::setw(11) << wellCum[WellCumDataType::GasInj]/1000 << ":" << std::setw(11) << wellCum[WellCumDataType::FluidResVolInj]/1000 << ": \n"; - } - ss << ":--------:-----------:--------:----:------------:----------:-----------:-----------:------------:----------:-----------:-----------: \n"; - } - OpmLog::note(ss.str()); -} - template bool EclGenericOutputBlackoilModule:: isOutputCreationDirective_(const std::string& keyword) diff --git a/ebos/eclgenericoutputblackoilmodule.hh b/ebos/eclgenericoutputblackoilmodule.hh index 3ed81a109..645fc6a13 100644 --- a/ebos/eclgenericoutputblackoilmodule.hh +++ b/ebos/eclgenericoutputblackoilmodule.hh @@ -28,6 +28,7 @@ #include #include +#include #include #include @@ -339,28 +340,6 @@ protected: static constexpr int numWINames = 4; }; - struct WellCumDataType - { - enum WCId - { - WellLocationi = 0, //WLi - WellLocationj = 1, //WLj - OilProd = 2, //OP - WaterProd = 3, //WP - GasProd = 4, //GP - FluidResVolProd = 5, //FRVP - OilInj = 6, //OI - WaterInj = 7, //WI - GasInj = 8, //GI - FluidResVolInj = 9, //FRVI - WellName = 0, //WName - WellType = 1, //WType - WellCTRL = 2, //WCTRL - }; - static constexpr int numWCValues = 10; - static constexpr int numWCNames = 3; - }; - void doAllocBuffers(unsigned bufferSize, unsigned reportStepNum, const bool substep, @@ -386,9 +365,6 @@ protected: void outputInjectionReport_(const ScalarBuffer& wellInj, const StringBuffer& wellInjNames, const bool forceDisableInjOutput); - void outputCumulativeReport_(const ScalarBuffer& wellCum, - const StringBuffer& wellCumNames, - const bool forceDisableCumOutput); void outputFipLogImpl(const Inplace& inplace) const; @@ -444,6 +420,7 @@ protected: const SummaryState& summaryState_; EclInterRegFlowMap interRegionFlows_; + LogOutputHelper logOutput_; bool enableEnergy_; bool enableTemperature_; diff --git a/opm/simulators/flow/LogOutputHelper.cpp b/opm/simulators/flow/LogOutputHelper.cpp new file mode 100644 index 000000000..e81380050 --- /dev/null +++ b/opm/simulators/flow/LogOutputHelper.cpp @@ -0,0 +1,245 @@ +// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- +// vi: set et ts=4 sw=4 sts=4: +/* + This file is part of the Open Porous Media project (OPM). + OPM is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + OPM is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + You should have received a copy of the GNU General Public License + along with OPM. If not, see . + Consult the COPYING file in the top-level source directory of this + module for the precise wording of the license and the list of + copyright holders. +*/ + +#include +#include + +#include + +#include +#include +#include +#include + +#include +#include +#include + +namespace Opm { + +template +LogOutputHelper::LogOutputHelper(const EclipseState& eclState, + const Schedule& schedule, + const SummaryState& summaryState) + : eclState_(eclState) + , schedule_(schedule) + , summaryState_(summaryState) +{} + +template +void LogOutputHelper:: +cumulative(const std::size_t reportStepNum, + std::function isDefunct) const +{ + std::vector tmp_values(WellCumDataType::numWCValues, 0.0); + std::vector tmp_names(WellCumDataType::numWCNames, ""); + this->outputCumulativeReport_(tmp_values, tmp_names); + + const auto& st = summaryState_; + for (const auto& gname : schedule_.groupNames()) { + auto gName = static_cast(gname); + auto get = [&st, &gName](const std::string& vector) + { + const auto key = vector + ':' + gName; + return st.has(key) ? st.get(key) : 0.0; + }; + + tmp_names[0] = gname; + + if (tmp_names[0] == "FIELD") { + tmp_values[2] = st.get("FOPT", 0.0); // WellCumDataType::OilProd + tmp_values[3] = st.get("FWPT", 0.0); // WellCumDataType::WaterProd + tmp_values[4] = st.get("FGPT", 0.0); // WellCumDataType::GasProd + tmp_values[5] = st.get("FVPT", 0.0); // WellCumDataType::FluidResVolProd + tmp_values[6] = st.get("FOIT", 0.0); // WellCumDataType::OilInj + tmp_values[7] = st.get("FWIT", 0.0); // WellCumDataType::WaterInj + tmp_values[8] = st.get("FGIT", 0.0); // WellCumDataType::GasInj + tmp_values[9] = st.get("FVIT", 0.0); // WellCumDataType::FluidResVolInj + } else { + tmp_values[2] = get("GOPT"); // WellCumDataType::OilProd + tmp_values[3] = get("GWPT"); // WellCumDataType::WaterProd + tmp_values[4] = get("GGPT"); // WellCumDataType::GasProd + tmp_values[5] = get("GVPT"); // WellCumDataType::FluidResVolProd + tmp_values[6] = get("GOIT"); // WellCumDataType::OilInj + tmp_values[7] = get("GWIT"); // WellCumDataType::WaterInj + tmp_values[8] = get("GGIT"); // WellCumDataType::GasInj + tmp_values[9] = get("GVIT"); // WellCumDataType::FluidResVolInj + } + + this->outputCumulativeReport_(tmp_values, tmp_names); + } + + for (const auto& wname : schedule_.wellNames(reportStepNum)) { + // don't bother with wells not on this process + if (isDefunct(wname)) { + continue; + } + + const auto& well = schedule_.getWell(wname, reportStepNum); + tmp_names[0] = wname; // WellCumDataType::WellName + auto wName = static_cast(wname); + auto get = [&st, &wName](const std::string& vector) + { + const auto key = vector + ':' + wName; + return st.has(key) ? st.get(key) : 0.0; + }; + + if (well.isInjector()) { + const auto& controls = well.injectionControls(st); + const auto ctlMode = controls.cmode; + const auto injType = controls.injector_type; + using CMode = ::Opm::Well::InjectorCMode; + using WType = ::Opm::InjectorType; + + auto ftype = [](const auto wtype) -> std::string + { + switch (wtype) { + case WType::OIL: return "Oil"; + case WType::WATER: return "Wat"; + case WType::GAS: return "Gas"; + case WType::MULTI: return "Multi"; + default: return ""; + } + }; + + auto fctl = [](const auto wmctl) -> std::string + { + switch (wmctl) { + case CMode::RATE: return "RATE"; + case CMode::RESV: return "RESV"; + case CMode::THP: return "THP"; + case CMode::BHP: return "BHP"; + case CMode::GRUP: return "GRUP"; + default: return ""; + } + }; + + tmp_names[1] = "INJ"; // WellCumDataType::WellType + const auto flowctl = fctl(ctlMode); + if (flowctl == "RATE") { // WellCumDataType::WellCTRL + const auto flowtype = ftype(injType); + if (flowtype == "Oil") { + tmp_names[2] = "ORAT"; + } else if (flowtype == "Wat") { + tmp_names[2] = "WRAT"; + } else if (flowtype == "Gas") { + tmp_names[2] = "GRAT"; + } + } else { + tmp_names[2] = flowctl; + } + } else if (well.isProducer()) { + const auto& controls = well.productionControls(st); + using CMode = ::Opm::Well::ProducerCMode; + + auto fctl = [](const auto wmctl) -> std::string + { + switch (wmctl) { + case CMode::ORAT: return "ORAT"; + case CMode::WRAT: return "WRAT"; + case CMode::GRAT: return "GRAT"; + case CMode::LRAT: return "LRAT"; + case CMode::RESV: return "RESV"; + case CMode::THP: return "THP"; + case CMode::BHP: return "BHP"; + case CMode::CRAT: return "CRAT"; + case CMode::GRUP: return "GRUP"; + default: + { + return "none"; + } + } + }; + tmp_names[1] = "PROD"; //WellProdDataType::CTRLMode + tmp_names[2] = fctl(controls.cmode); //WellProdDataType::CTRLMode + } + + tmp_values[0] = well.getHeadI() + 1; //WellCumDataType::wellLocationi + tmp_values[1] = well.getHeadJ() + 1; //WellCumDataType::wellLocationj + tmp_values[2] = get("WOPT"); //WellCumDataType::OilProd + tmp_values[3] = get("WWPT"); //WellCumDataType::WaterProd + tmp_values[4] = get("WGPT"); //WellCumDataType::GasProd + tmp_values[5] = get("WVPT");//WellCumDataType::FluidResVolProd + tmp_values[6] = get("WOIT"); //WellCumDataType::OilInj + tmp_values[7] = get("WWIT"); //WellCumDataType::WaterInj + tmp_values[8] = get("WGIT"); //WellCumDataType::GasInj + tmp_values[9] = get("WVIT");//WellCumDataType::FluidResVolInj + + outputCumulativeReport_(tmp_values, tmp_names); + } +} + +template +void LogOutputHelper:: +outputCumulativeReport_(const std::vector& wellCum, + const std::vector& wellCumNames) const +{ + const UnitSystem& units = eclState_.getUnits(); + std::ostringstream ss; + if (wellCumNames[WellCumDataType::WellName].empty()) { + ss << "=================================================== 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) { + ss << ": : : : : MSCM : MSCM : MMSCM : MRCM : MSCM : MSCM : MMSCM : MRCM :\n"; + } else if (units.getType() == UnitSystem::UnitType::UNIT_TYPE_FIELD) { + 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 << "====================================================================================================================================\n"; + } else { + if (wellCum[WellCumDataType::WellLocationi] < 1) { + ss << std::right << std::fixed << std::setprecision(0) << ":" << std::setw (8) + << wellCumNames[WellCumDataType::WellName] << ":" + << std::setw(11) << "" << ":" + << std::setw(8) << wellCumNames[WellCumDataType::WellType] << ":" + << std::setw(4) << wellCumNames[WellCumDataType::WellCTRL] << ":" + << std::setprecision(1) << std::setw(11) << wellCum[WellCumDataType::OilProd] / 1000.0 << ":" + << std::setw(11) << wellCum[WellCumDataType::WaterProd] / 1000.0 << ":" + << std::setw(11)<< wellCum[WellCumDataType::GasProd] / 1000.0 << ":" + << std::setw(11) << wellCum[WellCumDataType::FluidResVolProd] / 1000.0 << ":" + << std::setw(11) << wellCum[WellCumDataType::OilInj] / 1000.0 << ":" + << std::setw(11) << wellCum[WellCumDataType::WaterInj] / 1000.0 << ":" + << std::setw(11) << wellCum[WellCumDataType::GasInj] / 1000.0 << ":" + << std::setw(11) << wellCum[WellCumDataType::FluidResVolInj] / 1000.0 << ": \n"; + } else { + ss << std::right << std::fixed << std::setprecision(0) << ":" + << std::setw (8) << wellCumNames[WellCumDataType::WellName] << ":" + << std::setw(5) << wellCum[WellCumDataType::WellLocationi] << "," + << std::setw(5) << wellCum[WellCumDataType::WellLocationj] << ":" + << std::setw(8) << wellCumNames[WellCumDataType::WellType] << ":" + << std::setw(4) << wellCumNames[WellCumDataType::WellCTRL] << ":" + << std::setprecision(1) << std::setw(11) << wellCum[WellCumDataType::OilProd] / 1000.0 << ":" + << std::setw(11) << wellCum[WellCumDataType::WaterProd] / 1000.0 << ":" + << std::setw(11)<< wellCum[WellCumDataType::GasProd] / 1000.0 << ":" + << std::setw(11) << wellCum[WellCumDataType::FluidResVolProd] / 1000.0 << ":" + << std::setw(11) << wellCum[WellCumDataType::OilInj] / 1000.0 << ":" + << std::setw(11) << wellCum[WellCumDataType::WaterInj] / 1000.0 << ":" + << std::setw(11) << wellCum[WellCumDataType::GasInj] / 1000.0 << ":" + << std::setw(11) << wellCum[WellCumDataType::FluidResVolInj] / 1000.0 << ": \n"; + } + ss << ":--------:-----------:--------:----:------------:----------:-----------:-----------:------------:----------:-----------:-----------: \n"; + } + OpmLog::note(ss.str()); +} + +template class LogOutputHelper; + +} // namespace Opm diff --git a/opm/simulators/flow/LogOutputHelper.hpp b/opm/simulators/flow/LogOutputHelper.hpp new file mode 100644 index 000000000..8bc28061e --- /dev/null +++ b/opm/simulators/flow/LogOutputHelper.hpp @@ -0,0 +1,79 @@ +// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- +// vi: set et ts=4 sw=4 sts=4: +/* + This file is part of the Open Porous Media project (OPM). + OPM is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + OPM is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + You should have received a copy of the GNU General Public License + along with OPM. If not, see . + Consult the COPYING file in the top-level source directory of this + module for the precise wording of the license and the list of + copyright holders. +*/ +/*! + * \file + */ +#ifndef LOG_OUTPUT_HELPER_HPP +#define LOG_OUTPUT_HELPER_HPP + +#include +#include +#include + +namespace Opm { + +class EclipseState; +class Schedule; +class SummaryState; + +template +class LogOutputHelper { +public: + LogOutputHelper(const EclipseState& eclState, + const Schedule& schedule, + const SummaryState& st); + + //! \brief Write cumulative production and injection reports to output. + void cumulative(const std::size_t reportStepNum, + std::function isDefunct) const; + +private: + void outputCumulativeReport_(const std::vector& wellCum, + const std::vector& wellCumNames) const; + + struct WellCumDataType + { + enum WCId + { + WellLocationi = 0, // WLi + WellLocationj = 1, // WLj + OilProd = 2, // OP + WaterProd = 3, // WP + GasProd = 4, // GP + FluidResVolProd = 5, // FRVP + OilInj = 6, // OI + WaterInj = 7, // WI + GasInj = 8, // GI + FluidResVolInj = 9, // FRVI + WellName = 0, // WName + WellType = 1, // WType + WellCTRL = 2, // WCTRL + }; + static constexpr int numWCValues = 10; + static constexpr int numWCNames = 3; + }; + + const EclipseState& eclState_; + const Schedule& schedule_; + const SummaryState& summaryState_; +}; + +} // namespace Opm + +#endif // LOG_OUTPUT_HELPER_HPP