101 const EclipseState& eclState,
103 const Parallel::Communication& comm);
109 throw std::runtime_error(
"compressedIndexForInteriorLGR not implemented");
112 int numLocalWells()
const;
113 int numLocalWellsEnd()
const;
114 int numLocalNonshutWells()
const;
115 int numPhases()
const;
130 bool anyMSWellOpenLocal()
const;
132 const std::vector<Well>& eclWells()
const
133 {
return wells_ecl_; }
135 bool terminalOutput()
const
136 {
return terminal_output_; }
138 const Well& getWellEcl(
const std::string& well_name)
const;
139 std::vector<Well> getLocalWells(
const int timeStepIdx)
const;
140 const Schedule& schedule()
const {
return schedule_; }
142 const GroupState<Scalar>& groupState()
const {
return this->active_wgstate_.group_state; }
143 std::vector<const WellInterfaceGeneric<Scalar, IndexTraits>*> genericWells()
const
144 {
return {well_container_generic_.begin(), well_container_generic_.end()}; }
146 std::vector<WellInterfaceGeneric<Scalar, IndexTraits>*> genericWells()
147 {
return well_container_generic_; }
154 return this->active_wgstate_.well_state;
162 return this->active_wgstate_.well_state;
171 return this->nupcol_wgstate_.well_state;
175 WellTestState& wellTestState() {
return this->active_wgstate_.well_test_state; }
177 const WellTestState& wellTestState()
const {
return this->active_wgstate_.well_test_state; }
179 Scalar wellPI(
const int well_index)
const;
180 Scalar wellPI(
const std::string& well_name)
const;
188 const std::size_t numCells,
192 void prepareDeserialize(
int report_step,
193 const std::size_t numCells,
205 this->last_valid_wgstate_ = this->active_wgstate_;
206 this->last_valid_node_pressures_ = this->node_pressures_;
209 data::GroupAndNetworkValues groupAndNetworkData(
const int reportStepIdx)
const;
225 const std::vector<PerforationData<Scalar>>& perfData(
const int well_idx)
const
226 {
return well_perf_data_[
well_idx]; }
228 const Parallel::Communication& comm()
const {
return comm_; }
230 const EclipseState& eclipseState()
const {
return eclState_; }
232 const SummaryState& summaryState()
const {
return summaryState_; }
234 const GuideRate& guideRate()
const {
return guideRate_; }
235 GuideRate& guideRate() {
return guideRate_; }
237 const std::map<std::string, double>& wellOpenTimes()
const {
return well_open_times_; }
238 const std::map<std::string, double>& wellCloseTimes()
const {
return well_close_times_; }
241 std::vector<int> getCellsForConnections(
const Well& well)
const;
243 bool reportStepStarts()
const {
return report_step_starts_; }
245 bool shouldBalanceNetwork(
const int reportStepIndex,
248 void updateClosedWellsThisStep(
const std::string& well_name)
const
250 this->closed_this_step_.insert(well_name);
252 bool wasDynamicallyShutThisTimeStep(
const std::string& well_name)
const;
254 void logPrimaryVars()
const;
256 template<
class Serializer>
280 parallelWellInfo(
const std::size_t
idx)
const
281 {
return local_parallel_well_info_[
idx].get(); }
283 bool isOwner(
const std::string&
wname)
const
285 return this->parallelWellSatisfies
289 bool hasLocalCells(
const std::string&
wname)
const
291 return this->parallelWellSatisfies
296 {
return conn_idx_map_[
idx]; }
328 return this->last_valid_wgstate_.well_state;
333 return this->last_valid_wgstate_;
343 this->last_valid_wgstate_ = std::move(
wgstate);
353 this->active_wgstate_ = this->last_valid_wgstate_;
354 this->node_pressures_ = this->last_valid_node_pressures_;
362 void updateNupcolWGState()
364 this->nupcol_wgstate_ = this->active_wgstate_;
371 std::vector<std::reference_wrapper<ParallelWellInfo<Scalar>>>
374 void initializeWellProdIndCalculators();
375 void initializeWellPerfData();
377 bool wasDynamicallyShutThisTimeStep(
const int well_index)
const;
383 void updateWsolvent(
const Group& group,
386 void setWsolvent(
const Group& group,
389 virtual void calcResvCoeff(
const int fipnum,
391 const std::vector<Scalar>& production_rates,
393 virtual void calcInjResvCoeff(
const int fipnum,
415 const int reportStepIndex)
const;
417 void assignWellTargets(data::Wells&
wsrpt)
const;
418 void assignProductionWellTargets(
const Well& well, data::WellControlLimits&
limits)
const;
419 void assignInjectionWellTargets(
const Well& well, data::WellControlLimits&
limits)
const;
421 void assignGroupControl(
const Group& group,
422 data::GroupData&
gdata)
const;
424 std::map<std::string, data::GroupData>&
gvalues)
const;
425 void assignNodeValues(std::map<std::string, data::NodeData>&
nodevalues,
430 void checkGconsaleLimits(
const Group& group,
435 void checkGEconLimits(
const Group& group,
440 bool checkGroupHigherConstraints(
const Group& group,
452 void inferLocalShutWells();
454 void setRepRadiusPerfLength();
456 virtual void computePotentials(
const std::size_t
widx,
473 void updateFiltrationModelsPostStep(
const double dt,
480 virtual void createWellContainer(
const int time_step) = 0;
483 virtual void calculateProductivityIndexValuesShutWells(
const int reportStepIdx,
493 std::vector<std::vector<int>> getMaxWellConnections()
const;
495 std::vector<std::string> getWellsForTesting(
const int timeStepIdx,
498 using WellTracerRates = std::unordered_map<int, std::vector<WellTracerRate<Scalar>>>;
499 void assignWellTracerRates(data::Wells&
wsrpt,
501 const unsigned reportStep)
const;
503 using MswTracerRates = std::unordered_map<int, std::vector<MSWellTracerRate<Scalar>>>;
504 void assignMswTracerRates(data::Wells&
wsrpt,
506 const unsigned reportStep)
const;
508 void assignMassGasRate(data::Wells&
wsrpt,
514 const EclipseState& eclState_;
515 const Parallel::Communication& comm_;
521 bool terminal_output_{
false};
522 bool wells_active_{
false};
523 bool network_active_{
false};
524 bool initial_step_{};
525 bool report_step_starts_{};
527 std::optional<int> last_run_wellpi_{};
529 std::vector<Well> wells_ecl_;
530 std::vector<std::vector<PerforationData<Scalar>>> well_perf_data_;
533 std::map<std::string, double> well_open_times_;
536 std::map<std::string, double> well_close_times_;
538 std::vector<ConnectionIndexMap> conn_idx_map_{};
539 std::function<
bool(
const std::string&)> not_on_process_{};
542 std::vector<WellInterfaceGeneric<Scalar, IndexTraits>*> well_container_generic_{};
544 std::vector<int> local_shut_wells_{};
546 std::vector<ParallelWellInfo<Scalar>> parallel_well_info_;
547 std::vector<std::reference_wrapper<ParallelWellInfo<Scalar>>> local_parallel_well_info_;
549 std::vector<WellProdIndexCalculator<Scalar>> prod_index_calc_;
551 std::vector<int> pvt_region_idx_;
553 mutable std::unordered_set<std::string> closed_this_step_;
556 std::unique_ptr<VFPProperties<Scalar, IndexTraits>> vfp_properties_{};
559 std::map<std::string, Scalar> node_pressures_;
561 std::map<std::string, Scalar> last_valid_node_pressures_;
564 std::unordered_map<std::string, std::vector<Scalar>> prev_inj_multipliers_;
567 std::unordered_map<std::string, WellFilterCake<Scalar, IndexTraits>> filter_cake_;
580 bool wellStructureChangedDynamically_{
false};
583 std::map<std::string, std::vector<Group::ProductionCMode>> switched_prod_groups_;
584 std::map<std::string, std::array<std::vector<Group::InjectionCMode>, 3>> switched_inj_groups_;
586 std::map<std::string, std::pair<std::string, std::string>> closed_offending_wells_;
591 template <
typename Iter,
typename Body>
594 void updateEclWellsConstraints(
const int timeStepIdx,
598 void updateEclWellsCTFFromAction(
const int timeStepIdx,
614 template <
typename Predicate>
615 bool parallelWellSatisfies(
const std::string&
wname,
Predicate&&
p)
const
617 auto pwInfoPos = std::find_if(this->parallel_well_info_.begin(),
618 this->parallel_well_info_.end(),
620 { return pwInfo.name() == wname; });
622 return (
pwInfoPos != this->parallel_well_info_.end())
641 template <
typename LoopBody>