diff --git a/ebos/eclgenericoutputblackoilmodule.cc b/ebos/eclgenericoutputblackoilmodule.cc index 40daeea2e..5dd804ba6 100644 --- a/ebos/eclgenericoutputblackoilmodule.cc +++ b/ebos/eclgenericoutputblackoilmodule.cc @@ -277,7 +277,8 @@ outputFipLog(std::map& miscSummaryData, regionData); if (!substep && !forceDisableFipOutput_) { - logOutput_.fip(inplace, this->initialInplace()); + logOutput_.fip(inplace, this->initialInplace(), ""); + logOutput_.fip(inplace, this->initialInplace(), "FIPNUM"); } return inplace; diff --git a/opm/simulators/flow/LogOutputHelper.cpp b/opm/simulators/flow/LogOutputHelper.cpp index 7443a0f1e..9087fe40b 100644 --- a/opm/simulators/flow/LogOutputHelper.cpp +++ b/opm/simulators/flow/LogOutputHelper.cpp @@ -259,61 +259,47 @@ error(const std::vector& failedCellsPbub, template void LogOutputHelper:: fip(const Inplace& inplace, - const Inplace& initialInplace) const + const Inplace& initialInplace, + const std::string& name) const { + auto iget = [&name](const Inplace& ip, + Inplace::Phase phase, + std::size_t idx) { - Scalar fieldHydroCarbonPoreVolumeAveragedPressure = - detail::pressureAverage(inplace.get(Inplace::Phase::PressureHydroCarbonPV), - inplace.get(Inplace::Phase::HydroCarbonPV), - inplace.get(Inplace::Phase::PressurePV), - inplace.get(Inplace::Phase::DynamicPoreVolume), - true); + if (name.empty()) { + return ip.get(phase); + } + return ip.get(name, phase, idx); + }; + + for (std::size_t reg = 1; reg <= (name.empty() ? 1 : inplace.max_region(name)); ++reg) { std::unordered_map initial_values; std::unordered_map current_values; for (const auto& phase : Inplace::phases()) { - initial_values[phase] = initialInplace.get(phase); - current_values[phase] = inplace.get(phase); + initial_values[phase] = iget(initialInplace, phase, reg); + current_values[phase] = iget(inplace, phase, reg); } current_values[Inplace::Phase::DynamicPoreVolume] = - inplace.get(Inplace::Phase::DynamicPoreVolume); - - this->fipUnitConvert_(initial_values); - this->fipUnitConvert_(current_values); - - this->pressureUnitConvert_(fieldHydroCarbonPoreVolumeAveragedPressure); - this->outputRegionFluidInPlace_(std::move(initial_values), - std::move(current_values), - fieldHydroCarbonPoreVolumeAveragedPressure, 0); - } - - for (std::size_t reg = 1; reg <= inplace.max_region("FIPNUM"); ++reg) { - std::unordered_map initial_values; - std::unordered_map current_values; - - for (const auto& phase : Inplace::phases()) { - initial_values[phase] = initialInplace.get("FIPNUM", phase, reg); - current_values[phase] = inplace.get("FIPNUM", phase, reg); - } - - current_values[Inplace::Phase::DynamicPoreVolume] = - inplace.get("FIPNUM", Inplace::Phase::DynamicPoreVolume, reg); + iget(inplace, Inplace::Phase::DynamicPoreVolume, reg); this->fipUnitConvert_(initial_values); this->fipUnitConvert_(current_values); Scalar regHydroCarbonPoreVolumeAveragedPressure = - detail::pressureAverage(inplace.get("FIPNUM", Inplace::Phase::PressureHydroCarbonPV, reg), - inplace.get("FIPNUM", Inplace::Phase::HydroCarbonPV, reg), - inplace.get("FIPNUM", Inplace::Phase::PressurePV, reg), - inplace.get("FIPNUM", Inplace::Phase::DynamicPoreVolume, reg), + detail::pressureAverage(iget(inplace, Inplace::Phase::PressureHydroCarbonPV, reg), + iget(inplace, Inplace::Phase::HydroCarbonPV, reg), + iget(inplace, Inplace::Phase::PressurePV, reg), + iget(inplace, Inplace::Phase::DynamicPoreVolume, reg), true); this->pressureUnitConvert_(regHydroCarbonPoreVolumeAveragedPressure); this->outputRegionFluidInPlace_(std::move(initial_values), std::move(current_values), - regHydroCarbonPoreVolumeAveragedPressure, reg); + regHydroCarbonPoreVolumeAveragedPressure, + name, + name.empty() ? 0 : reg); } } @@ -754,6 +740,7 @@ void LogOutputHelper:: outputRegionFluidInPlace_(std::unordered_map oip, std::unordered_map cip, const Scalar pav, + const std::string& name, const int reg) const { // don't output FIPNUM report if the region has no porv. @@ -768,7 +755,7 @@ outputRegionFluidInPlace_(std::unordered_map oip, if (reg == 0) { ss << "Field total"; } else { - ss << "FIPNUM report region " << reg; + ss << name << " report region " << reg; } ss << " pressure dependent pore volume = " @@ -782,8 +769,8 @@ outputRegionFluidInPlace_(std::unordered_map oip, } else { ss << " ===================================================\n" - << " : FIPNUM report region " - << std::setw(2) << reg << " :\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" diff --git a/opm/simulators/flow/LogOutputHelper.hpp b/opm/simulators/flow/LogOutputHelper.hpp index 9c37dd28e..dfade6a40 100644 --- a/opm/simulators/flow/LogOutputHelper.hpp +++ b/opm/simulators/flow/LogOutputHelper.hpp @@ -54,7 +54,8 @@ public: //! \brief Write fluid-in-place reports to output. void fip(const Inplace& inplace, - const Inplace& initialInplace) const; + const Inplace& initialInplace, + const std::string& name) const; //! \brief Write fluid-in-place reservoir reports to output. void fipResv(const Inplace& inplace) const; @@ -74,6 +75,7 @@ private: void outputRegionFluidInPlace_(std::unordered_map oip, std::unordered_map cip, const Scalar pav, + const std::string& name, const int reg) const; void outputResvFluidInPlace_(std::unordered_map cipr, diff --git a/tests/test_LogOutputHelper.cpp b/tests/test_LogOutputHelper.cpp index d1e88d480..0ade72861 100644 --- a/tests/test_LogOutputHelper.cpp +++ b/tests/test_LogOutputHelper.cpp @@ -269,7 +269,8 @@ FIPNUM report region 1 pressure dependent pore volume = 50 RB current.add("FIPNUM", Opm::Inplace::Phase::PressurePV, 1, 6.0); current.add("FIPNUM", Opm::Inplace::Phase::DynamicPoreVolume, 1, 8.0); - helper.fip(current, initial); + helper.fip(current, initial, ""); + helper.fip(current, initial, "FIPNUM"); std::string data = trimStream(str); BOOST_CHECK_EQUAL(data, reference); }