mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Retrieve welpi map for Pyaction calls as well and hand it over to the runPyAction function of the Schedule
This commit is contained in:
parent
2bbf48c39c
commit
f40f67023d
@ -137,18 +137,12 @@ namespace {
|
|||||||
|
|
||||||
template <typename Scalar, class WellModel>
|
template <typename Scalar, class WellModel>
|
||||||
std::unordered_map<std::string, Scalar>
|
std::unordered_map<std::string, Scalar>
|
||||||
fetchWellPI(const int reportStep,
|
fetchWellPI(const WellModel& wellModel,
|
||||||
const Opm::Schedule& schedule,
|
const std::vector<std::string>& wellpi_wells,
|
||||||
const WellModel& wellModel,
|
|
||||||
const Opm::Action::ActionX& action,
|
|
||||||
const Opm::Action::Result::MatchingEntities& matches,
|
|
||||||
const Opm::Parallel::Communication comm)
|
const Opm::Parallel::Communication comm)
|
||||||
{
|
{
|
||||||
auto wellpi = std::unordered_map<std::string, Scalar> {};
|
auto wellpi = std::unordered_map<std::string, Scalar> {};
|
||||||
|
|
||||||
const auto wellpi_wells = action.wellpi_wells
|
|
||||||
(schedule.wellMatcher(reportStep), matches);
|
|
||||||
|
|
||||||
if (wellpi_wells.empty()) {
|
if (wellpi_wells.empty()) {
|
||||||
return wellpi;
|
return wellpi;
|
||||||
}
|
}
|
||||||
@ -207,8 +201,13 @@ applyActions(const int reportStep,
|
|||||||
|
|
||||||
bool commit_wellstate = false;
|
bool commit_wellstate = false;
|
||||||
for (const auto& pyaction : actions.pending_python(actionState_)) {
|
for (const auto& pyaction : actions.pending_python(actionState_)) {
|
||||||
|
// The std::unordered_map<std::string, Scalar> wellpi contains the well production indices from the last
|
||||||
|
// timestep. This map is needed for the keyword WELPI. For a PyAction, we do not know which wells are
|
||||||
|
// affected by the PyAction, thus we get the production indices for all wells.
|
||||||
|
const std::vector<std::string> wellpi_wells = schedule_[reportStep].well_order().names();
|
||||||
|
const auto wellpi = fetchWellPI<Scalar>(this->wellModel_, wellpi_wells, this->comm_);
|
||||||
auto sim_update = schedule_.runPyAction(reportStep, *pyaction, actionState_,
|
auto sim_update = schedule_.runPyAction(reportStep, *pyaction, actionState_,
|
||||||
ecl_state_, summaryState_);
|
ecl_state_, summaryState_, wellpi);
|
||||||
|
|
||||||
if (const auto pyRes = this->actionState_.python_result(pyaction->name());
|
if (const auto pyRes = this->actionState_.python_result(pyaction->name());
|
||||||
!pyRes.has_value() || !*pyRes)
|
!pyRes.has_value() || !*pyRes)
|
||||||
@ -237,9 +236,11 @@ applyActions(const int reportStep,
|
|||||||
|
|
||||||
logActiveAction(action->name(), matches.wells(), ts);
|
logActiveAction(action->name(), matches.wells(), ts);
|
||||||
|
|
||||||
const auto wellpi = fetchWellPI<Scalar>
|
// The std::unordered_map<std::string, Scalar> wellpi contains the well production indices from the last
|
||||||
(reportStep, this->schedule_, this->wellModel_,
|
// timestep. This map is needed for the keyword WELPI. For an ActionX, we know which wells are affected by
|
||||||
*action, matches, this->comm_);
|
// the ActionX, thus fetch the well production indices only for the affected wells.
|
||||||
|
const std::vector<std::string> wellpi_wells = action->wellpi_wells(schedule_.wellMatcher(reportStep), matches);
|
||||||
|
const auto wellpi = fetchWellPI<Scalar>(this->wellModel_, wellpi_wells, this->comm_);
|
||||||
|
|
||||||
const auto sim_update = this->schedule_
|
const auto sim_update = this->schedule_
|
||||||
.applyAction(reportStep, *action, matches, wellpi);
|
.applyAction(reportStep, *action, matches, wellpi);
|
||||||
|
Loading…
Reference in New Issue
Block a user