move output of fip log to LogOutputHelper

This commit is contained in:
Arne Morten Kvarving 2023-08-04 12:37:48 +02:00
parent 38e9b5a100
commit daced47301
4 changed files with 201 additions and 136 deletions

View File

@ -271,8 +271,9 @@ outputFipLog(std::map<std::string, double>& miscSummaryData,
miscSummaryData, miscSummaryData,
regionData); regionData);
if (!substep) if (!substep && !forceDisableFipOutput_) {
outputFipLogImpl(inplace); logOutput_.fip(inplace, this->initialInplace());
}
return inplace; return inplace;
} }
@ -1085,75 +1086,6 @@ pressureUnitConvert_(Scalar& pav) const
.from_si(UnitSystem::measure::pressure, pav); .from_si(UnitSystem::measure::pressure, pav);
} }
template<class FluidSystem, class Scalar>
void EclGenericOutputBlackoilModule<FluidSystem,Scalar>::
outputRegionFluidInPlace_(std::unordered_map<Inplace::Phase, Scalar> oip,
std::unordered_map<Inplace::Phase, Scalar> cip,
const Scalar& pav, const int reg) const
{
if (forceDisableFipOutput_)
return;
// don't output FIPNUM report if the region has no porv.
if (! (cip[Inplace::Phase::PoreVolume] > Scalar{0}))
return;
const UnitSystem& units = eclState_.getUnits();
std::ostringstream ss;
ss << '\n';
if (reg == 0) {
ss << "Field total";
}
else {
ss << "FIPNUM 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";
}
else {
ss << " ===================================================\n"
<< " : FIPNUM report region "
<< std::setw(2) << reg << " :\n";
}
if (units.getType() == UnitSystem::UnitType::UNIT_TYPE_METRIC) {
ss << " : PAV =" << std::setw(14) << pav << " BARSA :\n"
<< std::fixed << std::setprecision(0)
<< " : 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 << " :--------------- Oil SM3 ---------------:-- Wat SM3 --:--------------- Gas SM3 ---------------:\n";
}
if (units.getType() == UnitSystem::UnitType::UNIT_TYPE_FIELD) {
ss << " : PAV =" << std::setw(14) << pav << " PSIA :\n"
<< std::fixed << std::setprecision(0)
<< " : 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 << " :--------------- 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] << std::setw(14) << cip[Inplace::Phase::OilInGasPhase] << std::setw(14) << cip[Inplace::Phase::OIL] << ":"
<< std::setw(13) << 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(14) << oip[Inplace::Phase::OilInGasPhase] << std::setw(14) << oip[Inplace::Phase::OIL] << ":"
<< std::setw(13) << 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"
<< ":========================:==========================================:================:==========================================:\n";
OpmLog::note(ss.str());
}
template<class FluidSystem, class Scalar> template<class FluidSystem, class Scalar>
void EclGenericOutputBlackoilModule<FluidSystem,Scalar>:: void EclGenericOutputBlackoilModule<FluidSystem,Scalar>::
outputResvFluidInPlace_(std::unordered_map<Inplace::Phase, Scalar> cipr, const int reg) const outputResvFluidInPlace_(std::unordered_map<Inplace::Phase, Scalar> cipr, const int reg) const
@ -1271,66 +1203,6 @@ outputErrorLog(const Parallel::Communication& comm) const
ijkString); ijkString);
} }
template<class FluidSystem,class Scalar>
void EclGenericOutputBlackoilModule<FluidSystem,Scalar>::
outputFipLogImpl(const Inplace& inplace) const
{
{
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);
std::unordered_map<Inplace::Phase, Scalar> initial_values;
std::unordered_map<Inplace::Phase, Scalar> current_values;
for (const auto& phase : Inplace::phases()) {
initial_values[phase] = this->initialInplace_->get(phase);
current_values[phase] = inplace.get(phase);
}
current_values[Inplace::Phase::DynamicPoreVolume] =
inplace.get(Inplace::Phase::DynamicPoreVolume);
fipUnitConvert_(initial_values);
fipUnitConvert_(current_values);
pressureUnitConvert_(fieldHydroCarbonPoreVolumeAveragedPressure);
outputRegionFluidInPlace_(std::move(initial_values),
std::move(current_values),
fieldHydroCarbonPoreVolumeAveragedPressure);
}
for (size_t reg = 1; reg <= inplace.max_region("FIPNUM"); ++reg) {
std::unordered_map<Inplace::Phase, Scalar> initial_values;
std::unordered_map<Inplace::Phase, Scalar> current_values;
for (const auto& phase : Inplace::phases()) {
initial_values[phase] = this->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);
fipUnitConvert_(initial_values);
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),
true);
pressureUnitConvert_(regHydroCarbonPoreVolumeAveragedPressure);
outputRegionFluidInPlace_(std::move(initial_values),
std::move(current_values),
regHydroCarbonPoreVolumeAveragedPressure, reg);
}
}
template<class FluidSystem,class Scalar> template<class FluidSystem,class Scalar>
void EclGenericOutputBlackoilModule<FluidSystem,Scalar>:: void EclGenericOutputBlackoilModule<FluidSystem,Scalar>::
outputFipresvLogImpl(const Inplace& inplace) const outputFipresvLogImpl(const Inplace& inplace) const

View File

@ -308,14 +308,9 @@ protected:
void pressureUnitConvert_(Scalar& pav) const; void pressureUnitConvert_(Scalar& pav) const;
void outputRegionFluidInPlace_(std::unordered_map<Inplace::Phase, Scalar> oip,
std::unordered_map<Inplace::Phase, Scalar> cip,
const Scalar& pav, const int reg = 0) const;
void outputResvFluidInPlace_(std::unordered_map<Inplace::Phase, Scalar> cipr, void outputResvFluidInPlace_(std::unordered_map<Inplace::Phase, Scalar> cipr,
const int reg = 0) const; const int reg = 0) const;
void outputFipLogImpl(const Inplace& inplace) const;
void outputFipresvLogImpl(const Inplace& inplace) const; void outputFipresvLogImpl(const Inplace& inplace) const;
void makeRegionSum(Inplace& inplace, void makeRegionSum(Inplace& inplace,

View File

@ -27,6 +27,8 @@
#include <opm/input/eclipse/Schedule/SummaryState.hpp> #include <opm/input/eclipse/Schedule/SummaryState.hpp>
#include <opm/input/eclipse/Schedule/Well/Well.hpp> #include <opm/input/eclipse/Schedule/Well/Well.hpp>
#include <opm/simulators/utils/PressureAverage.hpp>
#include <cmath> #include <cmath>
#include <iomanip> #include <iomanip>
#include <sstream> #include <sstream>
@ -183,6 +185,67 @@ cumulative(const std::size_t reportStepNum,
} }
} }
template<class Scalar>
void LogOutputHelper<Scalar>::
fip(const Inplace& inplace,
const Inplace& initialInplace) const
{
{
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);
std::unordered_map<Inplace::Phase, Scalar> initial_values;
std::unordered_map<Inplace::Phase, Scalar> current_values;
for (const auto& phase : Inplace::phases()) {
initial_values[phase] = initialInplace.get(phase);
current_values[phase] = inplace.get(phase);
}
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<Inplace::Phase, Scalar> initial_values;
std::unordered_map<Inplace::Phase, Scalar> 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);
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),
true);
this->pressureUnitConvert_(regHydroCarbonPoreVolumeAveragedPressure);
this->outputRegionFluidInPlace_(std::move(initial_values),
std::move(current_values),
regHydroCarbonPoreVolumeAveragedPressure, reg);
}
}
template<class Scalar> template<class Scalar>
void LogOutputHelper<Scalar>:: void LogOutputHelper<Scalar>::
injection(const std::size_t reportStepNum, injection(const std::size_t reportStepNum,
@ -587,6 +650,125 @@ outputProductionReport_(const std::vector<Scalar>& wellProd,
OpmLog::note(ss.str()); OpmLog::note(ss.str());
} }
template<class Scalar>
void LogOutputHelper<Scalar>::
outputRegionFluidInPlace_(std::unordered_map<Inplace::Phase, Scalar> oip,
std::unordered_map<Inplace::Phase, Scalar> cip,
const Scalar pav,
const int reg) const
{
// don't output FIPNUM report if the region has no porv.
if (! (cip[Inplace::Phase::PoreVolume] > Scalar{0})) {
return;
}
const UnitSystem& units = eclState_.getUnits();
std::ostringstream ss;
ss << '\n';
if (reg == 0) {
ss << "Field total";
} else {
ss << "FIPNUM 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";
}
else {
ss << " ===================================================\n"
<< " : FIPNUM report region "
<< std::setw(2) << reg << " :\n";
}
if (units.getType() == UnitSystem::UnitType::UNIT_TYPE_METRIC) {
ss << " : PAV =" << std::setw(14) << pav << " BARSA :\n"
<< std::fixed << std::setprecision(0)
<< " : 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 << " :--------------- Oil SM3 ---------------:-- Wat SM3 --:--------------- Gas SM3 ---------------:\n";
} else if (units.getType() == UnitSystem::UnitType::UNIT_TYPE_FIELD) {
ss << " : PAV =" << std::setw(14) << pav << " PSIA :\n"
<< std::fixed << std::setprecision(0)
<< " : 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 << " :--------------- 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]
<< std::setw(14) << cip[Inplace::Phase::OilInGasPhase]
<< std::setw(14) << cip[Inplace::Phase::OIL] << ":"
<< std::setw(13) << 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(14) << oip[Inplace::Phase::OilInGasPhase]
<< std::setw(14) << oip[Inplace::Phase::OIL] << ":"
<< std::setw(13) << 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"
<< ":========================:==========================================:================:==========================================:\n";
OpmLog::note(ss.str());
}
template<class Scalar>
void LogOutputHelper<Scalar>::
fipUnitConvert_(std::unordered_map<Inplace::Phase, Scalar>& fip) const
{
const UnitSystem& units = eclState_.getUnits();
using M = UnitSystem::measure;
const auto unit_map = std::unordered_map<Inplace::Phase, M> {
{Inplace::Phase::WATER, M::liquid_surface_volume},
{Inplace::Phase::OIL, M::liquid_surface_volume},
{Inplace::Phase::OilInLiquidPhase, M::liquid_surface_volume},
{Inplace::Phase::OilInGasPhase, M::liquid_surface_volume},
{Inplace::Phase::GAS, M::gas_surface_volume},
{Inplace::Phase::GasInLiquidPhase, M::gas_surface_volume},
{Inplace::Phase::GasInGasPhase, M::gas_surface_volume},
{Inplace::Phase::PoreVolume, M::volume},
{Inplace::Phase::DynamicPoreVolume, M::volume},
{Inplace::Phase::WaterResVolume, M::volume},
{Inplace::Phase::OilResVolume, M::volume},
{Inplace::Phase::GasResVolume, M::volume},
{Inplace::Phase::SALT, M::mass},
{Inplace::Phase::CO2InWaterPhase, M::moles},
{Inplace::Phase::CO2InGasPhaseInMob,M::moles},
{Inplace::Phase::CO2InGasPhaseMob, M::moles},
{Inplace::Phase::WaterInWaterPhase, M::liquid_surface_volume},
{Inplace::Phase::WaterInGasPhase, M::liquid_surface_volume},
};
for (auto& [phase, value] : fip) {
auto unitPos = unit_map.find(phase);
if (unitPos != unit_map.end()) {
value = units.from_si(unitPos->second, value);
}
}
}
template<class Scalar>
void LogOutputHelper<Scalar>::
pressureUnitConvert_(Scalar& pav) const
{
pav = eclState_.getUnits()
.from_si(UnitSystem::measure::pressure, pav);
}
template class LogOutputHelper<double>; template class LogOutputHelper<double>;
} // namespace Opm } // namespace Opm

View File

@ -22,13 +22,17 @@
#ifndef LOG_OUTPUT_HELPER_HPP #ifndef LOG_OUTPUT_HELPER_HPP
#define LOG_OUTPUT_HELPER_HPP #define LOG_OUTPUT_HELPER_HPP
#include <opm/output/eclipse/Inplace.hpp>
#include <cstddef> #include <cstddef>
#include <functional> #include <functional>
#include <string> #include <string>
#include <unordered_map>
namespace Opm { namespace Opm {
class EclipseState; class EclipseState;
class Inplace;
class Schedule; class Schedule;
class SummaryState; class SummaryState;
@ -43,6 +47,10 @@ public:
void cumulative(const std::size_t reportStepNum, void cumulative(const std::size_t reportStepNum,
std::function<bool(const std::string&)> isDefunct) const; std::function<bool(const std::string&)> isDefunct) const;
//! \brief Write fluid-in-place reports to output.
void fip(const Inplace& inplace,
const Inplace& initialInplace) const;
//! \brief Write injection report to output. //! \brief Write injection report to output.
void injection(const std::size_t reportStepNum, void injection(const std::size_t reportStepNum,
std::function<bool(const std::string&)> isDefunct) const; std::function<bool(const std::string&)> isDefunct) const;
@ -55,12 +63,20 @@ private:
void outputCumulativeReport_(const std::vector<Scalar>& wellCum, void outputCumulativeReport_(const std::vector<Scalar>& wellCum,
const std::vector<std::string>& wellCumNames) const; const std::vector<std::string>& wellCumNames) const;
void outputRegionFluidInPlace_(std::unordered_map<Inplace::Phase, Scalar> oip,
std::unordered_map<Inplace::Phase, Scalar> cip,
const Scalar pav,
const int reg) const;
void outputInjectionReport_(const std::vector<Scalar>& wellInj, void outputInjectionReport_(const std::vector<Scalar>& wellInj,
const std::vector<std::string>& wellInjNames) const; const std::vector<std::string>& wellInjNames) const;
void outputProductionReport_(const std::vector<Scalar>& wellProd, void outputProductionReport_(const std::vector<Scalar>& wellProd,
const std::vector<std::string>& wellProdNames) const; const std::vector<std::string>& wellProdNames) const;
void fipUnitConvert_(std::unordered_map<Inplace::Phase, Scalar>& fip) const;
void pressureUnitConvert_(Scalar& pav) const;
struct WellCumDataType struct WellCumDataType
{ {
enum WCId enum WCId