68 static const std::uint64_t event_mask = ScheduleEvents::WELL_STATUS_CHANGE
69 | ScheduleEvents::PRODUCTION_UPDATE
70 | ScheduleEvents::INJECTION_UPDATE;
73 static const int Water = BlackoilPhases::Aqua;
74 static const int Oil = BlackoilPhases::Liquid;
75 static const int Gas = BlackoilPhases::Vapour;
86 std::size_t size()
const
88 return this->wells_.size();
91 std::vector<std::string> wells()
const
93 return this->wells_.wells();
111 const int report_step,
115 const bool enableDistributedWells);
117 void resize(
const std::vector<Well>&
wells_ecl,
121 const std::size_t numCells,
125 void setCurrentWellRates(
const std::string& wellName,
128 auto& [owner, rates] = this->well_rates.at(wellName);
133 const std::vector<Scalar>& currentWellRates(
const std::string& wellName)
const;
135 bool hasWellRates(
const std::string& wellName)
const
137 return this->well_rates.find(wellName) != this->well_rates.end();
140 void clearWellRates()
142 this->well_rates.clear();
145 void gatherVectorsOnRoot(
const std::vector<data::Connection>&
from_connections,
147 const Parallel::Communication& comm)
const;
153 void reportConnections(std::vector<data::Connection>&
connections,
155 std::size_t well_index,
171 void communicateGroupRates(
const Parallel::Communication& comm);
173 void updateGlobalIsGrup(
const Parallel::Communication& comm);
174 void updateEfficiencyScalingFactor(
const std::string& wellName,
177 bool isInjectionGrup(
const std::string& name)
const
179 return this->global_well_info.value().in_injecting_group(name);
182 bool isProductionGrup(
const std::string& name)
const
184 return this->global_well_info.value().in_producing_group(name);
187 bool isOpen(
const std::string& name)
const
189 return this->global_well_info.value().is_open(name);
192 Scalar getGlobalEfficiencyScalingFactor(
const std::string& name)
const
194 return this->global_well_info.value().efficiency_scaling_factor(name);
197 Scalar getALQ(
const std::string& name)
const
199 return this->alq_state.get(name);
202 void setALQ(
const std::string& name, Scalar value)
204 this->alq_state.set(name, value);
207 int gliftGetDebugCounter()
209 return this->alq_state.get_debug_counter();
212 void gliftSetDebugCounter(
int value)
214 return this->alq_state.set_debug_counter(value);
217 int gliftUpdateDebugCounter()
219 return this->alq_state.update_debug_counter();
222 bool gliftCheckAlqOscillation(
const std::string &name)
const
224 return this->alq_state.oscillation(name);
227 int gliftGetAlqDecreaseCount(
const std::string &name)
229 return this->alq_state.get_decrement_count(name);
232 int gliftGetAlqIncreaseCount(
const std::string &name)
234 return this->alq_state.get_increment_count(name);
237 void gliftUpdateAlqIncreaseCount(
const std::string &name,
bool increase)
239 this->alq_state.update_count(name, increase);
242 void gliftTimeStepInit()
244 this->alq_state.reset_count();
251 void updateWellsDefaultALQ(
const Schedule& schedule,
252 const int report_step,
255 int wellNameToGlobalIdx(
const std::string& name)
257 return this->global_well_info.value().well_index(name);
260 std::string globalIdxToWellName(
const int index)
262 return this->global_well_info.value().well_name(index);
265 bool wellIsOwned(std::size_t well_index,
266 const std::string& wellName)
const;
268 bool wellIsOwned(
const std::string& wellName)
const;
270 bool isRank0()
const {
271 return this->global_well_info.value().isRank0();
274 void updateStatus(
int well_index,
WellStatus status);
276 void openWell(
int well_index);
277 void shutWell(
int well_index);
278 void stopWell(
int well_index);
280 void switchToProducer(
const std::string& name) {
281 alq_state.insert(name);
287 return this->phase_usage_.num_phases;
292 return this->phase_usage_;
297 {
return this->wells_[well_index].surface_rates; }
298 const std::vector<Scalar>&
wellRates(std::size_t well_index)
const
299 {
return this->wells_[well_index].surface_rates; }
301 const std::string& name(std::size_t well_index)
const
303 return this->wells_.well_name(well_index);
306 std::optional<std::size_t> index(
const std::string& well_name)
const
308 return this->wells_.well_index(well_name);
313 return this->wells_[well_index];
318 return this->wells_[well_name];
323 return this->wells_[well_index];
328 return this->wells_[well_name];
333 return this->operator[](well_index);
338 return this->operator[](well_name);
343 return this->operator[](well_index);
348 return this->operator[](well_name);
351 bool has(
const std::string& well_name)
const
353 return this->wells_.has(well_name);
356 bool operator==(
const WellState&)
const;
358 template<
class Serializer>
366 std::size_t size = 0;
368 if (size != wells_.size()) {
369 OPM_THROW(std::runtime_error,
"Error deserializing WellState: size mismatch");
372 for (
auto&
w : wells_) {
378 bool is_permanently_inactive_well(
const std::string&
wname)
const {
379 return std::find(this->permanently_inactive_well_names_.begin(),
this->permanently_inactive_well_names_.end(),
wname) != this->permanently_inactive_well_names_.end();
383 bool enableDistributedWells_ =
false;
385 PhaseUsage phase_usage_;
398 std::optional<GlobalWellInfo<Scalar>> global_well_info;
404 std::map<std::string, std::pair<bool, std::vector<Scalar>>> well_rates;
407 std::vector<std::string> permanently_inactive_well_names_;
410 reportSegmentResults(
const int well_id,
427 void initSingleWell(
const std::vector<Scalar>&
cellPressures,
434 void initSingleProducer(
const Well& well,
436 Scalar pressure_first_connection,
440 void initSingleInjector(
const Well& well,
442 Scalar pressure_first_connection,
455 void reportConnectionFactors(
const std::size_t well_index,
458 void reportConnectionPressuresAndRates(
const std::size_t well_index,
459 const PhaseUsage& pu,
462 void reportConnectionFilterCake(
const std::size_t well_index,
void init(const std::vector< Scalar > &cellPressures, const std::vector< Scalar > &cellTemperatures, const Schedule &schedule, const std::vector< Well > &wells_ecl, const std::vector< std::reference_wrapper< ParallelWellInfo< Scalar > > > ¶llel_well_info, const int report_step, const WellState *prevState, const std::vector< std::vector< PerforationData< Scalar > > > &well_perf_data, const SummaryState &summary_state, const bool enableDistributedWells)
Allocate and initialize if wells is non-null.
Definition WellState.cpp:270