62 static const uint64_t event_mask = ScheduleEvents::WELL_STATUS_CHANGE + ScheduleEvents::PRODUCTION_UPDATE + ScheduleEvents::INJECTION_UPDATE;
64 static const int Water = BlackoilPhases::Aqua;
65 static const int Oil = BlackoilPhases::Liquid;
66 static const int Gas = BlackoilPhases::Vapour;
77 std::size_t size()
const {
78 return this->wells_.size();
81 std::vector<std::string> wells()
const {
82 return this->wells_.wells();
102 const int report_step,
107 void resize(
const std::vector<Well>&
wells_ecl,
115 void setCurrentWellRates(
const std::string& wellName,
const std::vector<double>&
new_rates ) {
116 auto& [owner, rates] = this->well_rates.at(wellName);
121 const std::vector<double>& currentWellRates(
const std::string& wellName)
const;
123 bool hasWellRates(
const std::string& wellName)
const {
124 return this->well_rates.find(wellName) != this->well_rates.end();
127 void clearWellRates()
129 this->well_rates.clear();
132 template<
class Communication>
133 void gatherVectorsOnRoot(
const std::vector< data::Connection >&
from_connections,
135 const Communication& comm)
const;
142 std::size_t well_index,
154 void communicateGroupRates(
const Comm& comm);
157 void updateGlobalIsGrup(
const Comm& comm);
159 bool isInjectionGrup(
const std::string& name)
const {
160 return this->global_well_info.value().in_injecting_group(name);
163 bool isProductionGrup(
const std::string& name)
const {
164 return this->global_well_info.value().in_producing_group(name);
167 double getALQ(
const std::string& name)
const
169 return this->alq_state.get(name);
172 void setALQ(
const std::string& name,
double value)
174 this->alq_state.set(name, value);
177 int gliftGetDebugCounter() {
178 return this->alq_state.get_debug_counter();
181 void gliftSetDebugCounter(
int value) {
182 return this->alq_state.set_debug_counter(value);
185 int gliftUpdateDebugCounter() {
186 return this->alq_state.update_debug_counter();
189 bool gliftCheckAlqOscillation(
const std::string &name)
const {
190 return this->alq_state.oscillation(name);
193 int gliftGetAlqDecreaseCount(
const std::string &name) {
194 return this->alq_state.get_decrement_count(name);
197 int gliftGetAlqIncreaseCount(
const std::string &name) {
198 return this->alq_state.get_increment_count(name);
201 void gliftUpdateAlqIncreaseCount(
const std::string &name,
bool increase) {
202 this->alq_state.update_count(name, increase);
205 void gliftTimeStepInit() {
206 this->alq_state.reset_count();
209 int wellNameToGlobalIdx(
const std::string &name) {
210 return this->global_well_info.value().well_index(name);
213 std::string globalIdxToWellName(
const int index) {
214 return this->global_well_info.value().well_name(index);
217 bool wellIsOwned(std::size_t well_index,
218 const std::string& wellName)
const;
220 bool wellIsOwned(
const std::string& wellName)
const;
222 void updateStatus(
int well_index,
WellStatus status);
224 void openWell(
int well_index);
225 void shutWell(
int well_index);
226 void stopWell(
int well_index);
231 return this->phase_usage_.num_phases;
235 return this->phase_usage_;
239 std::vector<double>&
wellRates(std::size_t well_index) {
return this->wells_[well_index].surface_rates; }
240 const std::vector<double>&
wellRates(std::size_t well_index)
const {
return this->wells_[well_index].surface_rates; }
242 const std::string& name(std::size_t well_index)
const {
243 return this->wells_.well_name(well_index);
246 std::optional<std::size_t> index(
const std::string& well_name)
const {
247 return this->wells_.well_index(well_name);
250 const SingleWellState& operator[](std::size_t well_index)
const {
251 return this->wells_[well_index];
254 const SingleWellState& operator[](
const std::string& well_name)
const {
255 return this->wells_[well_name];
258 SingleWellState& operator[](std::size_t well_index) {
259 return this->wells_[well_index];
262 SingleWellState& operator[](
const std::string& well_name) {
263 return this->wells_[well_name];
266 const SingleWellState& well(std::size_t well_index)
const {
267 return this->operator[](well_index);
270 const SingleWellState& well(
const std::string& well_name)
const {
271 return this->operator[](well_name);
274 SingleWellState& well(std::size_t well_index) {
275 return this->operator[](well_index);
278 SingleWellState& well(
const std::string& well_name) {
279 return this->operator[](well_name);
282 bool has(
const std::string& well_name)
const {
283 return this->wells_.has(well_name);
286 bool operator==(
const WellState&)
const;
288 template<
class Serializer>
289 void serializeOp(Serializer& serializer)
291 serializer(alq_state);
292 serializer(well_rates);
293 if (serializer.isSerializing()) {
294 serializer(wells_.size());
296 std::size_t size = 0;
298 if (size != wells_.size()) {
299 OPM_THROW(std::runtime_error,
"Error deserializing WellState: size mismatch");
302 for (
auto& w : wells_) {
308 PhaseUsage phase_usage_;
313 WellContainer<SingleWellState> wells_;
321 std::optional<GlobalWellInfo> global_well_info;
327 std::map<std::string, std::pair<bool, std::vector<double>>> well_rates;
330 reportSegmentResults(
const int well_id,
332 const int seg_no)
const;
339 void updateWellsDefaultALQ(
const std::vector<Well>& wells_ecl);
346 void base_init(
const std::vector<double>& cellPressures,
347 const std::vector<Well>& wells_ecl,
348 const std::vector<std::reference_wrapper<ParallelWellInfo>>& parallel_well_info,
349 const std::vector<std::vector<PerforationData>>& well_perf_data,
350 const SummaryState& summary_state);
352 void initSingleWell(
const std::vector<double>& cellPressures,
354 const std::vector<PerforationData>& well_perf_data,
355 const ParallelWellInfo& well_info,
356 const SummaryState& summary_state);
358 void initSingleProducer(
const Well& well,
359 const ParallelWellInfo& well_info,
360 double pressure_first_connection,
361 const std::vector<PerforationData>& well_perf_data,
362 const SummaryState& summary_state);
364 void initSingleInjector(
const Well& well,
365 const ParallelWellInfo& well_info,
366 double pressure_first_connection,
367 const std::vector<PerforationData>& well_perf_data,
368 const SummaryState& summary_state);