RateConvert: introduce compile unit

move global rate reductions into it
This commit is contained in:
Arne Morten Kvarving
2023-03-06 08:34:02 +01:00
parent 6d07c490c3
commit 7672e14890
3 changed files with 75 additions and 20 deletions

View File

@@ -27,6 +27,8 @@
#include <opm/simulators/utils/DeferredLoggingErrorHelpers.hpp>
#include <opm/simulators/wells/RegionAttributeHelpers.hpp>
#include <opm/simulators/utils/ParallelCommunication.hpp>
#include <dune/grid/common/gridenums.hh>
#include <dune/grid/common/rangegenerators.hh>
@@ -204,26 +206,9 @@ namespace Opm {
OPM_END_PARALLEL_TRY_CATCH("SurfaceToReservoirVoidage::defineState() failed: ", simulator.vanguard().grid().comm());
for (const auto& reg : rmap_.activeRegions()) {
// Calculating first using the hydrocarbon pore volumes
auto& ra = attr_.attributes(reg);
const auto& attri_hpv = attributes_hpv[reg];
ra.data = attri_hpv.data;
comm.sum(ra.data.data(), ra.data.size());
// TODO: should we have some epsilon here instead of zero?
// No hydrocarbon pore volume, redo but this time using full pore volumes.
if (ra.pv <= 0.) {
// using the pore volume to do the averaging
const auto& attri_pv = attributes_pv[reg];
ra.data = attri_pv.data;
comm.sum(ra.data.data(), ra.data.size());
assert(ra.pv > 0.);
}
const double pv_sum = ra.pv;
for (double& d : ra.data)
d /= pv_sum;
ra.pv = pv_sum;
}
this->sumRates(attributes_hpv,
attributes_pv,
comm);
}
/**
@@ -625,6 +610,10 @@ namespace Opm {
double& saltConcentration;
};
void sumRates(std::unordered_map<RegionId,Attributes>& attributes_hpv,
std::unordered_map<RegionId,Attributes>& attributes_pv,
Parallel::Communication comm);
RegionAttributeHelpers::RegionAttributes<RegionId, Attributes> attr_;
template <typename Rates>