97 const EclipseState& eclState,
99 const Parallel::Communication& comm);
103 int numLocalWells()
const;
104 int numLocalWellsEnd()
const;
105 int numLocalNonshutWells()
const;
106 int numPhases()
const;
121 bool anyMSWellOpenLocal()
const;
123 const std::vector<Well>& eclWells()
const
124 {
return wells_ecl_; }
126 bool terminalOutput()
const
127 {
return terminal_output_; }
129 const Well& getWellEcl(
const std::string& well_name)
const;
130 std::vector<Well> getLocalWells(
const int timeStepIdx)
const;
131 const Schedule& schedule()
const {
return schedule_; }
132 const PhaseUsage& phaseUsage()
const {
return phase_usage_; }
133 const GroupState<Scalar>& groupState()
const {
return this->active_wgstate_.group_state; }
134 std::vector<const WellInterfaceGeneric<Scalar>*> genericWells()
const
135 {
return {well_container_generic_.begin(), well_container_generic_.end()}; }
137 std::vector<WellInterfaceGeneric<Scalar>*> genericWells()
138 {
return well_container_generic_; }
145 return this->active_wgstate_.well_state;
153 return this->active_wgstate_.well_state;
162 return this->nupcol_wgstate_.well_state;
166 WellTestState& wellTestState() {
return this->active_wgstate_.well_test_state; }
168 const WellTestState& wellTestState()
const {
return this->active_wgstate_.well_test_state; }
170 Scalar wellPI(
const int well_index)
const;
171 Scalar wellPI(
const std::string& well_name)
const;
179 const std::size_t numCells,
182 void prepareDeserialize(
int report_step,
183 const std::size_t numCells,
194 this->last_valid_wgstate_ = this->active_wgstate_;
197 data::GroupAndNetworkValues groupAndNetworkData(
const int reportStepIdx)
const;
213 const std::vector<PerforationData<Scalar>>& perfData(
const int well_idx)
const
214 {
return well_perf_data_[
well_idx]; }
216 const Parallel::Communication& comm()
const {
return comm_; }
218 const EclipseState& eclipseState()
const {
return eclState_; }
220 const SummaryState& summaryState()
const {
return summaryState_; }
222 const GuideRate& guideRate()
const {
return guideRate_; }
224 const std::map<std::string, double>& wellOpenTimes()
const {
return well_open_times_; }
225 const std::map<std::string, double>& wellCloseTimes()
const {
return well_close_times_; }
228 std::vector<int> getCellsForConnections(
const Well& well)
const;
230 bool reportStepStarts()
const {
return report_step_starts_; }
232 bool shouldBalanceNetwork(
const int reportStepIndex,
235 void updateClosedWellsThisStep(
const std::string& well_name)
const
237 this->closed_this_step_.insert(well_name);
239 bool wasDynamicallyShutThisTimeStep(
const std::string& well_name)
const;
241 void logPrimaryVars()
const;
243 template<
class Serializer>
266 parallelWellInfo(
const std::size_t
idx)
const
267 {
return local_parallel_well_info_[
idx].get(); }
270 {
return conn_idx_map_[
idx]; }
302 return this->last_valid_wgstate_.well_state;
307 return this->last_valid_wgstate_;
317 this->last_valid_wgstate_ = std::move(
wgstate);
327 this->active_wgstate_ = this->last_valid_wgstate_;
335 void updateNupcolWGState()
337 this->nupcol_wgstate_ = this->active_wgstate_;
344 std::vector<std::reference_wrapper<ParallelWellInfo<Scalar>>>
347 void initializeWellProdIndCalculators();
348 void initializeWellPerfData();
350 bool wasDynamicallyShutThisTimeStep(
const int well_index)
const;
356 void updateWsolvent(
const Group& group,
359 void setWsolvent(
const Group& group,
362 virtual void calcResvCoeff(
const int fipnum,
364 const std::vector<Scalar>& production_rates,
366 virtual void calcInjResvCoeff(
const int fipnum,
370 void assignShutConnections(data::Wells&
wsrpt,
371 const int reportStepIndex)
const;
372 void assignWellTargets(data::Wells&
wsrpt)
const;
373 void assignProductionWellTargets(
const Well& well, data::WellControlLimits&
limits)
const;
374 void assignInjectionWellTargets(
const Well& well, data::WellControlLimits&
limits)
const;
375 void assignGroupControl(
const Group& group,
376 data::GroupData&
gdata)
const;
378 std::map<std::string, data::GroupData>&
gvalues)
const;
379 void assignNodeValues(std::map<std::string, data::NodeData>&
nodevalues,
384 void checkGconsaleLimits(
const Group& group,
389 void checkGEconLimits(
const Group& group,
394 bool checkGroupHigherConstraints(
const Group& group,
404 void inferLocalShutWells();
406 void setRepRadiusPerfLength();
408 virtual void computePotentials(
const std::size_t
widx,
425 void updateFiltrationModelsPostStep(
const double dt,
432 virtual void createWellContainer(
const int time_step) = 0;
435 virtual void calculateProductivityIndexValuesShutWells(
const int reportStepIdx,
445 std::vector<std::vector<int>> getMaxWellConnections()
const;
447 std::vector<std::string> getWellsForTesting(
const int timeStepIdx,
450 using WellTracerRates = std::unordered_map<int, std::vector<WellTracerRate<Scalar>>>;
451 void assignWellTracerRates(data::Wells&
wsrpt,
453 const unsigned reportStep)
const;
455 using MswTracerRates = std::unordered_map<int, std::vector<MSWellTracerRate<Scalar>>>;
456 void assignMswTracerRates(data::Wells&
wsrpt,
458 const unsigned reportStep)
const;
460 void assignMassGasRate(data::Wells&
wsrpt,
465 const EclipseState& eclState_;
466 const Parallel::Communication& comm_;
471 bool terminal_output_{
false};
472 bool wells_active_{
false};
473 bool network_active_{
false};
474 bool initial_step_{};
475 bool report_step_starts_{};
477 std::optional<int> last_run_wellpi_{};
479 std::vector<Well> wells_ecl_;
480 std::vector<std::vector<PerforationData<Scalar>>> well_perf_data_;
483 std::map<std::string, double> well_open_times_;
486 std::map<std::string, double> well_close_times_;
488 std::vector<ConnectionIndexMap> conn_idx_map_{};
489 std::function<
bool(
const Well&)> not_on_process_{};
492 std::vector<WellInterfaceGeneric<Scalar>*> well_container_generic_{};
494 std::vector<int> local_shut_wells_{};
496 std::vector<ParallelWellInfo<Scalar>> parallel_well_info_;
497 std::vector<std::reference_wrapper<ParallelWellInfo<Scalar>>> local_parallel_well_info_;
499 std::vector<WellProdIndexCalculator<Scalar>> prod_index_calc_;
501 std::vector<int> pvt_region_idx_;
503 mutable std::unordered_set<std::string> closed_this_step_;
506 std::unique_ptr<VFPProperties<Scalar>> vfp_properties_{};
507 std::map<std::string, Scalar> node_pressures_;
510 std::unordered_map<std::string, std::vector<Scalar>> prev_inj_multipliers_;
513 std::unordered_map<std::string, WellFilterCake<Scalar>> filter_cake_;
526 bool wellStructureChangedDynamically_{
false};
529 std::map<std::string, std::vector<Group::ProductionCMode>> switched_prod_groups_;
530 std::map<std::string, std::array<std::vector<Group::InjectionCMode>, 3>> switched_inj_groups_;
532 std::map<std::string, std::pair<std::string, std::string>> closed_offending_wells_;
537 template <
typename Iter,
typename Body>
540 void updateEclWellsConstraints(
const int timeStepIdx,
544 void updateEclWellsCTFFromAction(
const int timeStepIdx,