68 static const std::uint64_t event_mask = ScheduleEvents::WELL_STATUS_CHANGE
69 | ScheduleEvents::PRODUCTION_UPDATE
70 | ScheduleEvents::INJECTION_UPDATE;
76 static const int waterPhaseIdx = IndexTraits::waterPhaseIdx;
77 static const int oilPhaseIdx = IndexTraits::oilPhaseIdx;
78 static const int gasPhaseIdx = IndexTraits::gasPhaseIdx;
89 std::size_t size()
const
91 return this->wells_.size();
94 std::vector<std::string> wells()
const
96 return this->wells_.wells();
107 return this->phaseUsageInfo_;
120 const int report_step,
124 const bool enableDistributedWells);
126 void resize(
const std::vector<Well>&
wells_ecl,
130 const std::size_t numCells,
135 void setCurrentWellRates(
const std::string& wellName,
138 auto& [owner, rates] = this->well_rates.at(wellName);
143 const std::vector<Scalar>& currentWellRates(
const std::string& wellName)
const;
145 bool hasWellRates(
const std::string& wellName)
const
147 return this->well_rates.find(wellName) != this->well_rates.end();
150 void clearWellRates()
152 this->well_rates.clear();
155 void gatherVectorsOnRoot(
const std::vector<data::Connection>&
from_connections,
157 const Parallel::Communication& comm)
const;
163 void reportConnections(std::vector<data::Connection>&
connections,
164 std::size_t well_index,
180 void communicateGroupRates(
const Parallel::Communication& comm);
182 void updateGlobalIsGrup(
const Parallel::Communication& comm,
184 void updateEfficiencyScalingFactor(
const std::string& wellName,
187 bool isInjectionGrup(
const std::string& name)
const
189 return this->global_well_info.value().in_injecting_group(name);
192 bool isProductionGrup(
const std::string& name)
const
194 return this->global_well_info.value().in_producing_group(name);
197 bool isOpen(
const std::string& name)
const
199 return this->global_well_info.value().is_open(name);
202 Scalar getGlobalEfficiencyScalingFactor(
const std::string& name)
const
204 return this->global_well_info.value().efficiency_scaling_factor(name);
211 void updateWellsDefaultALQ(
const Schedule& schedule,
212 const int report_step,
215 void gliftTimeStepInit()
217 for (
size_t i = 0; i < this->size(); ++i) {
218 this->wells_[i].alq_state.reset_count();
223 int wellNameToGlobalIdx(
const std::string& name)
225 return this->global_well_info.value().well_index(name);
228 std::string globalIdxToWellName(
const int index)
230 return this->global_well_info.value().well_name(index);
233 bool wellIsOwned(std::size_t well_index,
234 const std::string& wellName)
const;
236 bool wellIsOwned(
const std::string& wellName)
const;
238 bool isRank0()
const {
239 return this->global_well_info.value().isRank0();
242 void updateStatus(
int well_index,
WellStatus status);
244 void openWell(
int well_index);
245 void shutWell(
int well_index);
246 void stopWell(
int well_index);
251 return phaseUsageInfo_.numActivePhases();
256 {
return this->wells_[well_index].surface_rates; }
257 const std::vector<Scalar>&
wellRates(std::size_t well_index)
const
258 {
return this->wells_[well_index].surface_rates; }
260 const std::string& name(std::size_t well_index)
const
262 return this->wells_.well_name(well_index);
265 std::optional<std::size_t> index(
const std::string& well_name)
const
267 return this->wells_.well_index(well_name);
272 return this->wells_[well_index];
277 return this->wells_[well_name];
282 return this->wells_[well_index];
287 return this->wells_[well_name];
292 return this->operator[](well_index);
297 return this->operator[](well_name);
302 return this->operator[](well_index);
307 return this->operator[](well_name);
310 bool has(
const std::string& well_name)
const
312 return this->wells_.has(well_name);
315 bool operator==(
const WellState&)
const;
317 template<
class Serializer>
324 std::size_t size = 0;
326 if (size != wells_.size()) {
327 OPM_THROW(std::runtime_error,
"Error deserializing WellState: size mismatch");
330 for (
auto&
w : wells_) {
336 bool is_permanently_inactive_well(
const std::string&
wname)
const {
337 return std::find(this->permanently_inactive_well_names_.begin(),
this->permanently_inactive_well_names_.end(),
wname) != this->permanently_inactive_well_names_.end();
341 bool enableDistributedWells_ =
false;
356 std::optional<GlobalWellInfo<Scalar>> global_well_info;
361 std::map<std::string, std::pair<bool, std::vector<Scalar>>> well_rates;
364 std::vector<std::string> permanently_inactive_well_names_;
367 reportSegmentResults(
const int well_id,
384 void initSingleWell(
const std::vector<Scalar>&
cellPressures,
391 void initSingleProducer(
const Well& well,
393 Scalar pressure_first_connection,
397 void initSingleInjector(
const Well& well,
399 Scalar pressure_first_connection,
412 void reportConnectionFactors(
const std::size_t well_index,
415 void reportConnectionPressuresAndRates(
const std::size_t well_index,
418 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:276