move guideRateUpdateIsNeeded into BlackoilWellModelGuideRates

This commit is contained in:
Arne Morten Kvarving 2022-10-24 09:36:05 +02:00
parent d42cdd409b
commit 9f78e0454d
5 changed files with 30 additions and 32 deletions

View File

@ -1191,33 +1191,4 @@ runWellPIScaling(const int timeStepIdx,
this->last_run_wellpi_ = timeStepIdx;
}
bool
BlackoilWellModelGeneric::
guideRateUpdateIsNeeded(const int reportStepIdx) const {
auto need_update =
std::any_of(this->well_container_generic_.begin(),
this->well_container_generic_.end(),
[](const WellInterfaceGeneric* well)
{
return well->changedToOpenThisStep();
});
if (!need_update && this->report_step_starts_) {
const auto& events = this->schedule()[reportStepIdx].wellgroup_events();
constexpr auto effective_events_mask = ScheduleEvents::WELL_STATUS_CHANGE
+ ScheduleEvents::INJECTION_TYPE_CHANGED
+ ScheduleEvents::WELL_SWITCHED_INJECTOR_PRODUCER
+ ScheduleEvents::NEW_WELL;
need_update = std::any_of(this->well_container_generic_.begin(),
this->well_container_generic_.end(),
[&events](const WellInterfaceGeneric* well)
{
return events.hasEvent(well->name(), effective_events_mask);
});
}
return this->comm_.max(static_cast<int>(need_update));
}
}

View File

@ -320,8 +320,6 @@ protected:
const SummaryConfig& summaryConfig,
DeferredLogger& deferred_logger);
bool guideRateUpdateIsNeeded(const int reportStepIdx) const;
// create the well container
virtual void createWellContainer(const int time_step) = 0;
virtual void initWellContainer(const int reportStepIdx) = 0;

View File

@ -569,5 +569,30 @@ assignGroupGuideRates(const Group& group,
}
}
bool BlackoilWellModelGuideRates::
guideRateUpdateIsNeeded(const int reportStepIdx) const
{
const auto& genWells = wellModel_.genericWells();
auto need_update =
std::any_of(genWells.begin(), genWells.end(),
[](const WellInterfaceGeneric* well)
{
return well->changedToOpenThisStep();
});
if (!need_update && wellModel_.reportStepStarts()) {
const auto& events = wellModel_.schedule()[reportStepIdx].wellgroup_events();
constexpr auto effective_events_mask = ScheduleEvents::WELL_STATUS_CHANGE
+ ScheduleEvents::INJECTION_TYPE_CHANGED
+ ScheduleEvents::WELL_SWITCHED_INJECTOR_PRODUCER
+ ScheduleEvents::NEW_WELL;
need_update = std::any_of(genWells.begin(), genWells.end(),
[&events](const WellInterfaceGeneric* well)
{
return events.hasEvent(well->name(), effective_events_mask);
});
}
return wellModel_.comm().max(static_cast<int>(need_update));
}
} // namespace Opm

View File

@ -62,6 +62,9 @@ public:
const std::unordered_map<std::string, data::GroupGuideRates>& groupGuideRates,
data::GroupData& gdata) const;
//! \brief Check if a guide rate update is needed.
bool guideRateUpdateIsNeeded(const int reportStepIdx) const;
private:
//! \brief Obtain guide rate values.
void getGuideRateValues(const GuideRate::RateVector& qs,

View File

@ -918,7 +918,8 @@ namespace Opm {
//update guide rates
const int reportStepIdx = ebosSimulator_.episodeIndex();
if (alq_updated || guideRateUpdateIsNeeded(reportStepIdx)) {
if (alq_updated || BlackoilWellModelGuideRates(*this).
guideRateUpdateIsNeeded(reportStepIdx)) {
const double simulationTime = ebosSimulator_.time();
const auto& comm = ebosSimulator_.vanguard().grid().comm();
const auto& summaryState = ebosSimulator_.vanguard().summaryState();