21 #ifndef OPM_WELLSTATEFULLYIMPLICITBLACKOIL_HEADER_INCLUDED
22 #define OPM_WELLSTATEFULLYIMPLICITBLACKOIL_HEADER_INCLUDED
24 #include <opm/simulators/wells/ALQState.hpp>
25 #include <opm/simulators/wells/SingleWellState.hpp>
26 #include <opm/simulators/wells/GlobalWellInfo.hpp>
27 #include <opm/simulators/wells/SegmentState.hpp>
28 #include <opm/simulators/wells/WellContainer.hpp>
29 #include <opm/core/props/BlackoilPhases.hpp>
30 #include <opm/simulators/wells/PerforationData.hpp>
31 #include <opm/simulators/wells/PerfData.hpp>
32 #include <opm/output/data/Wells.hpp>
34 #include <opm/parser/eclipse/EclipseState/Schedule/Events.hpp>
35 #include <opm/parser/eclipse/EclipseState/Schedule/Well/Well.hpp>
37 #include <dune/common/version.hh>
38 #include <dune/common/parallel/mpihelper.hh>
50 class ParallelWellInfo;
58 static const uint64_t event_mask = ScheduleEvents::WELL_STATUS_CHANGE + ScheduleEvents::PRODUCTION_UPDATE + ScheduleEvents::INJECTION_UPDATE;
63 static const int Water = BlackoilPhases::Aqua;
64 static const int Oil = BlackoilPhases::Liquid;
65 static const int Gas = BlackoilPhases::Vapour;
69 this->phase_usage_ = pu;
72 std::size_t size()
const {
73 return this->wells_.size();
89 void init(
const std::vector<double>& cellPressures,
90 const Schedule& schedule,
91 const std::vector<Well>& wells_ecl,
92 const std::vector<std::reference_wrapper<ParallelWellInfo>>& parallel_well_info,
93 const int report_step,
95 const std::vector<std::vector<PerforationData>>& well_perf_data,
96 const SummaryState& summary_state);
98 void resize(
const std::vector<Well>& wells_ecl,
99 const std::vector<std::reference_wrapper<ParallelWellInfo>>& parallel_well_info,
100 const Schedule& schedule,
101 const bool handle_ms_well,
102 const size_t numCells,
103 const std::vector<std::vector<PerforationData>>& well_perf_data,
104 const SummaryState& summary_state);
106 void setCurrentWellRates(
const std::string& wellName,
const std::vector<double>& new_rates ) {
107 auto& [owner, rates] = this->well_rates.at(wellName);
112 const std::vector<double>& currentWellRates(
const std::string& wellName)
const;
114 bool hasWellRates(
const std::string& wellName)
const {
115 return this->well_rates.find(wellName) != this->well_rates.end();
118 template<
class Communication>
119 void gatherVectorsOnRoot(
const std::vector< data::Connection >& from_connections,
120 std::vector< data::Connection >& to_connections,
121 const Communication& comm)
const;
124 report(
const int* globalCellIdxMap,
125 const std::function<
bool(
const int)>& wasDynamicallyClosed)
const;
127 void reportConnections(std::vector<data::Connection>& connections,
const PhaseUsage &pu,
128 std::size_t well_index,
129 const int* globalCellIdxMap)
const;
135 static void calculateSegmentRates(
const std::vector<std::vector<int>>& segment_inlets,
const std::vector<std::vector<int>>&segment_perforations,
136 const std::vector<double>& perforation_rates,
const int np,
const int segment, std::vector<double>& segment_rates);
140 void communicateGroupRates(
const Comm& comm);
143 void updateGlobalIsGrup(
const Comm& comm);
145 bool isInjectionGrup(
const std::string& name)
const {
146 return this->global_well_info.value().in_injecting_group(name);
149 bool isProductionGrup(
const std::string& name)
const {
150 return this->global_well_info.value().in_producing_group(name);
153 double getALQ(
const std::string& name)
const
155 return this->alq_state.get(name);
158 void setALQ(
const std::string& name,
double value)
160 this->alq_state.set(name, value);
163 bool gliftCheckAlqOscillation(
const std::string &name)
const {
164 return this->alq_state.oscillation(name);
167 int gliftGetAlqDecreaseCount(
const std::string &name) {
168 return this->alq_state.get_decrement_count(name);
171 int gliftGetAlqIncreaseCount(
const std::string &name) {
172 return this->alq_state.get_increment_count(name);
175 void gliftUpdateAlqIncreaseCount(
const std::string &name,
bool increase) {
176 this->alq_state.update_count(name, increase);
179 void gliftTimeStepInit() {
180 this->alq_state.reset_count();
183 int wellNameToGlobalIdx(
const std::string &name) {
184 return this->global_well_info.value().well_index(name);
187 std::string globalIdxToWellName(
const int index) {
188 return this->global_well_info.value().well_name(index);
191 bool wellIsOwned(std::size_t well_index,
192 const std::string& wellName)
const;
194 bool wellIsOwned(
const std::string& wellName)
const;
206 const std::vector<PerforationData>& well_perf_data);
208 void updateStatus(
int well_index, Well::Status status);
210 void openWell(
int well_index);
211 void shutWell(
int well_index);
212 void stopWell(
int well_index);
217 return this->phase_usage_.num_phases;
221 return this->phase_usage_;
225 std::vector<double>&
wellRates(std::size_t well_index) {
return this->wells_[well_index].surface_rates; }
226 const std::vector<double>&
wellRates(std::size_t well_index)
const {
return this->wells_[well_index].surface_rates; }
228 const std::string& name(std::size_t well_index)
const {
229 return this->wells_.well_name(well_index);
232 std::optional<std::size_t> index(
const std::string& well_name)
const {
233 return this->wells_.well_index(well_name);
236 const SingleWellState& well(std::size_t well_index)
const {
237 return this->wells_[well_index];
240 const SingleWellState& well(
const std::string& well_name)
const {
241 return this->wells_[well_name];
244 SingleWellState& well(std::size_t well_index) {
245 return this->wells_[well_index];
248 SingleWellState& well(
const std::string& well_name) {
249 return this->wells_[well_name];
252 bool has(
const std::string& well_name)
const {
253 return this->wells_.has(well_name);
257 PhaseUsage phase_usage_;
262 WellContainer<SingleWellState> wells_;
270 std::optional<GlobalWellInfo> global_well_info;
276 std::map<std::string, std::pair<bool, std::vector<double>>> well_rates;
279 reportSegmentResults(
const int well_id,
281 const int seg_no)
const;
288 void updateWellsDefaultALQ(
const std::vector<Well>& wells_ecl);
295 void base_init(
const std::vector<double>& cellPressures,
296 const std::vector<Well>& wells_ecl,
297 const std::vector<std::reference_wrapper<ParallelWellInfo>>& parallel_well_info,
298 const std::vector<std::vector<PerforationData>>& well_perf_data,
299 const SummaryState& summary_state);
301 void initSingleWell(
const std::vector<double>& cellPressures,
303 const std::vector<PerforationData>& well_perf_data,
304 const ParallelWellInfo& well_info,
305 const SummaryState& summary_state);
Class encapsulating some information about parallel wells.
Definition: ParallelWellInfo.hpp:252
The state of a set of wells, tailored for use by the fully implicit blackoil simulator.
Definition: WellState.hpp:56
void initWellStateMSWell(const std::vector< Well > &wells_ecl, const WellState *prev_well_state)
init the MS well related.
Definition: WellState.cpp:589
void resetConnectionTransFactors(const int well_index, const std::vector< PerforationData > &well_perf_data)
Special purpose method to support dynamically rescaling a well's CTFs through WELPI.
Definition: WellState.cpp:914
std::vector< double > & wellRates(std::size_t well_index)
One rate per well and phase.
Definition: WellState.hpp:225
int numPhases() const
The number of phases present.
Definition: WellState.hpp:215
void init(const std::vector< double > &cellPressures, const Schedule &schedule, const std::vector< Well > &wells_ecl, const std::vector< std::reference_wrapper< ParallelWellInfo >> ¶llel_well_info, const int report_step, const WellState *prevState, const std::vector< std::vector< PerforationData >> &well_perf_data, const SummaryState &summary_state)
Allocate and initialize if wells is non-null.
Definition: WellState.cpp:194
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition: BlackoilPhases.hpp:26
Definition: BlackoilPhases.hpp:45