Merge pull request #4978 from akva2/loghelper_refactor_fip_output

changed: refactor LogOutputHelper::fip
This commit is contained in:
Bård Skaflestad 2023-11-10 14:49:09 +01:00 committed by GitHub
commit fe67e9f9d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 33 additions and 42 deletions

View File

@ -277,7 +277,8 @@ outputFipLog(std::map<std::string, double>& miscSummaryData,
regionData);
if (!substep && !forceDisableFipOutput_) {
logOutput_.fip(inplace, this->initialInplace());
logOutput_.fip(inplace, this->initialInplace(), "");
logOutput_.fip(inplace, this->initialInplace(), "FIPNUM");
}
return inplace;

View File

@ -259,61 +259,47 @@ error(const std::vector<int>& failedCellsPbub,
template<class Scalar>
void LogOutputHelper<Scalar>::
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<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);
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<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);
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<Scalar>::
outputRegionFluidInPlace_(std::unordered_map<Inplace::Phase, Scalar> oip,
std::unordered_map<Inplace::Phase, Scalar> 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<Inplace::Phase, Scalar> 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<Inplace::Phase, Scalar> 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"

View File

@ -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<Inplace::Phase, Scalar> oip,
std::unordered_map<Inplace::Phase, Scalar> cip,
const Scalar pav,
const std::string& name,
const int reg) const;
void outputResvFluidInPlace_(std::unordered_map<Inplace::Phase, Scalar> cipr,

View File

@ -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);
}