Reorder Well Data Report Function

The shut connection handling should be the final stage of this
reporting.  While here, also split the tracer rate assingments out
to a separate helper function.
This commit is contained in:
Bård Skaflestad committed 2025-05-05 13:46:06 +02:00
1 parent e833b07173
commit a1313a9d00
4 files changed
+44 -31

No files matched your search

+21 -27
View File
@@ -20,7 +20,6 @@
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OPM_BLACKOILWELLMODEL_HEADER_INCLUDED
#define OPM_BLACKOILWELLMODEL_HEADER_INCLUDED
@@ -198,39 +197,33 @@ template<class Scalar> class WellContributions;
data::Wells wellData() const
{
auto wsrpt = this->wellState()
.report(simulator_.vanguard().globalCell().data(),
[this](const int well_index) -> bool
.report(this->simulator_.vanguard().globalCell().data(),
[this](const int well_index)
{
return this->wasDynamicallyShutThisTimeStep(well_index);
});
{
const auto& tracerRates = this->simulator_.problem()
.tracerModel().getWellTracerRates();
const auto& freeTracerRates = simulator_.problem()
.tracerModel().getWellFreeTracerRates();
const auto& solTracerRates = simulator_.problem()
.tracerModel().getWellSolTracerRates();
const auto& mswTracerRates = simulator_.problem()
.tracerModel().getMswTracerRates();
this->assignWellTracerRates(wsrpt, tracerRates, this->reportStepIndex());
this->assignWellTracerRates(wsrpt, freeTracerRates, this->reportStepIndex());
this->assignWellTracerRates(wsrpt, solTracerRates, this->reportStepIndex());
this->assignMswTracerRates(wsrpt, mswTracerRates, this->reportStepIndex());
}
BlackoilWellModelGuideRates(*this)
.assignWellGuideRates(wsrpt, this->reportStepIndex());
this->assignWellTargets(wsrpt);
this->assignShutConnections(wsrpt, this->reportStepIndex());
// only used to compute gas injection mass rates for CO2STORE/H2STORE runs
// The gas reference density is thus the same for all pvt regions
// We therefore for simplicity use 0 here
if (eclState().runspec().co2Storage() || eclState().runspec().h2Storage()) {
this->assignWellTracerRates(wsrpt);
if (const auto& rspec = eclState().runspec();
rspec.co2Storage() || rspec.h2Storage())
{
// The gas reference density (surface condition) is the
// same for all PVT regions in CO2STORE/H2STORE runs so,
// for simplicity, we use region zero (0) here.
this->assignMassGasRate(wsrpt, FluidSystem::referenceDensity(FluidSystem::gasPhaseIdx, 0));
}
this->assignWellTargets(wsrpt);
// Assigning (a subset of the) property values in shut
// connections should be the last step of wellData().
this->assignShutConnections(wsrpt, this->reportStepIndex());
return wsrpt;
}
@@ -512,11 +505,12 @@ template<class Scalar> class WellContributions;
// Their state is not relevant between function calls, so they can
// (and must) be mutable, as the functions using them are const.
mutable BVector x_local_;
};
void assignWellTracerRates(data::Wells& wsrpt) const;
};
} // namespace Opm
#include "BlackoilWellModel_impl.hpp"
#endif
#endif // OPM_BLACKOILWELLMODEL_HEADER_INCLUDED
@@ -1832,12 +1832,14 @@ getWellsForTesting(const int timeStepIdx,
template<class Scalar>
void BlackoilWellModelGeneric<Scalar>::
assignMassGasRate(data::Wells& wsrpt,
const Scalar& gasDensity) const
const Scalar gasDensity) const
{
using rt = data::Rates::opt;
for (auto& wrpt : wsrpt) {
auto& well_rates = wrpt.second.rates;
const auto w_mass_rate = well_rates.get(rt::gas, 0.0) * gasDensity;
well_rates.set(rt::mass_gas, w_mass_rate);
}
}
@@ -1870,8 +1872,9 @@ assignMswTracerRates(data::Wells& wsrpt,
const MswTracerRates& mswTracerRates,
const unsigned reportStep) const
{
if (mswTracerRates.empty())
if (mswTracerRates.empty()) {
return;
}
for (const auto& mswTR : mswTracerRates) {
const auto& eclWell = schedule_.getWell(mswTR.first, reportStep);
@@ -461,7 +461,7 @@ protected:
const unsigned reportStep) const;
void assignMassGasRate(data::Wells& wsrpt,
const Scalar& gasDensity) const;
const Scalar gasDensity) const;
Schedule& schedule_;
const SummaryState& summaryState_;
@@ -2351,6 +2351,22 @@ namespace Opm {
}
}
}
template <typename TypeTag>
void BlackoilWellModel<TypeTag>::
assignWellTracerRates(data::Wells& wsrpt) const
{
const auto reportStepIdx = static_cast<unsigned int>(this->reportStepIndex());
const auto& trMod = this->simulator_.problem().tracerModel();
BlackoilWellModelGeneric<Scalar>::assignWellTracerRates(wsrpt, trMod.getWellTracerRates(), reportStepIdx);
BlackoilWellModelGeneric<Scalar>::assignWellTracerRates(wsrpt, trMod.getWellFreeTracerRates(), reportStepIdx);
BlackoilWellModelGeneric<Scalar>::assignWellTracerRates(wsrpt, trMod.getWellSolTracerRates(), reportStepIdx);
this->assignMswTracerRates(wsrpt, trMod.getMswTracerRates(), reportStepIdx);
}
} // namespace Opm
#endif
#endif // OPM_BLACKOILWELLMODEL_IMPL_HEADER_INCLUDED