Chase API Update of Action::Result

The type no longer uses operator overloading and the matching entity
back-end has been revised to no longer expose a vector of strings
for the well names directly.
This commit is contained in:
Bård Skaflestad 2024-11-05 18:30:07 +01:00
parent ac346b4c23
commit d199977d75

View File

@ -85,9 +85,10 @@ namespace {
Opm::OpmLog::info("ACTION_TRIGGERED", message); Opm::OpmLog::info("ACTION_TRIGGERED", message);
} }
void logActiveAction(const std::string& actionName, template <typename WellNameRange>
const std::vector<std::string>& matchingWells, void logActiveAction(const std::string& actionName,
const std::string& timeString) const WellNameRange& matchingWells,
const std::string& timeString)
{ {
const auto wellString = matchingWells.empty() const auto wellString = matchingWells.empty()
? std::string{} ? std::string{}
@ -136,17 +137,17 @@ 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 int reportStep,
const Opm::Schedule& schedule, const Opm::Schedule& schedule,
const WellModel& wellModel, const WellModel& wellModel,
const Opm::Action::ActionX& action, const Opm::Action::ActionX& action,
const std::vector<std::string>& matching_wells, 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 const auto wellpi_wells = action.wellpi_wells
(schedule.wellMatcher(reportStep), matching_wells); (schedule.wellMatcher(reportStep), matches);
if (wellpi_wells.empty()) { if (wellpi_wells.empty()) {
return wellpi; return wellpi;
@ -226,22 +227,22 @@ applyActions(const int reportStep,
const auto simTime = asTimeT(now); const auto simTime = asTimeT(now);
for (const auto& action : actions.pending(this->actionState_, simTime)) { for (const auto& action : actions.pending(this->actionState_, simTime)) {
const auto actionResult = action->eval(context); const auto actionResult = action->eval(context);
if (! actionResult) { if (! actionResult.conditionSatisfied()) {
++non_triggered; ++non_triggered;
logInactiveAction(action->name(), ts); logInactiveAction(action->name(), ts);
continue; continue;
} }
const auto& matching_wells = actionResult.wells(); const auto& matches = actionResult.matches();
logActiveAction(action->name(), matching_wells, ts); logActiveAction(action->name(), matches.wells(), ts);
const auto wellpi = fetchWellPI<Scalar> const auto wellpi = fetchWellPI<Scalar>
(reportStep, this->schedule_, this->wellModel_, (reportStep, this->schedule_, this->wellModel_,
*action, matching_wells, this->comm_); *action, matches, this->comm_);
const auto sim_update = this->schedule_ const auto sim_update = this->schedule_
.applyAction(reportStep, *action, matching_wells, wellpi); .applyAction(reportStep, *action, matches, wellpi);
this->applySimulatorUpdate(reportStep, sim_update, transUp, commit_wellstate); this->applySimulatorUpdate(reportStep, sim_update, transUp, commit_wellstate);
this->actionState_.add_run(*action, simTime, actionResult); this->actionState_.add_run(*action, simTime, actionResult);