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/input/eclipse/Schedule/Events.hpp>
35#include <opm/input/eclipse/Schedule/Well/Well.hpp>
37#include <dune/common/version.hh>
38#include <dune/common/parallel/mpihelper.hh>
50class 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();
76 std::vector<std::string> wells()
const {
77 return this->wells_.wells();
93 void init(
const std::vector<double>& cellPressures,
94 const Schedule& schedule,
95 const std::vector<Well>& wells_ecl,
96 const std::vector<std::reference_wrapper<ParallelWellInfo>>& parallel_well_info,
97 const int report_step,
99 const std::vector<std::vector<PerforationData>>& well_perf_data,
100 const SummaryState& summary_state);
102 void resize(
const std::vector<Well>& wells_ecl,
103 const std::vector<std::reference_wrapper<ParallelWellInfo>>& parallel_well_info,
104 const Schedule& schedule,
105 const bool handle_ms_well,
106 const size_t numCells,
107 const std::vector<std::vector<PerforationData>>& well_perf_data,
108 const SummaryState& summary_state);
110 void setCurrentWellRates(
const std::string& wellName,
const std::vector<double>& new_rates ) {
111 auto& [owner, rates] = this->well_rates.at(wellName);
116 const std::vector<double>& currentWellRates(
const std::string& wellName)
const;
118 bool hasWellRates(
const std::string& wellName)
const {
119 return this->well_rates.find(wellName) != this->well_rates.end();
122 template<
class Communication>
123 void gatherVectorsOnRoot(
const std::vector< data::Connection >& from_connections,
124 std::vector< data::Connection >& to_connections,
125 const Communication& comm)
const;
128 report(
const int* globalCellIdxMap,
129 const std::function<
bool(
const int)>& wasDynamicallyClosed)
const;
131 void reportConnections(std::vector<data::Connection>& connections,
const PhaseUsage &pu,
132 std::size_t well_index,
133 const int* globalCellIdxMap)
const;
139 static void calculateSegmentRates(
const std::vector<std::vector<int>>& segment_inlets,
const std::vector<std::vector<int>>&segment_perforations,
140 const std::vector<double>& perforation_rates,
const int np,
const int segment, std::vector<double>& segment_rates);
144 void communicateGroupRates(
const Comm& comm);
147 void updateGlobalIsGrup(
const Comm& comm);
149 bool isInjectionGrup(
const std::string& name)
const {
150 return this->global_well_info.value().in_injecting_group(name);
153 bool isProductionGrup(
const std::string& name)
const {
154 return this->global_well_info.value().in_producing_group(name);
157 double getALQ(
const std::string& name)
const
159 return this->alq_state.get(name);
162 void setALQ(
const std::string& name,
double value)
164 this->alq_state.set(name, value);
167 int gliftGetDebugCounter() {
168 return this->alq_state.get_debug_counter();
171 void gliftSetDebugCounter(
int value) {
172 return this->alq_state.set_debug_counter(value);
175 int gliftUpdateDebugCounter() {
176 return this->alq_state.update_debug_counter();
179 bool gliftCheckAlqOscillation(
const std::string &name)
const {
180 return this->alq_state.oscillation(name);
183 int gliftGetAlqDecreaseCount(
const std::string &name) {
184 return this->alq_state.get_decrement_count(name);
187 int gliftGetAlqIncreaseCount(
const std::string &name) {
188 return this->alq_state.get_increment_count(name);
191 void gliftUpdateAlqIncreaseCount(
const std::string &name,
bool increase) {
192 this->alq_state.update_count(name, increase);
195 void gliftTimeStepInit() {
196 this->alq_state.reset_count();
199 int wellNameToGlobalIdx(
const std::string &name) {
200 return this->global_well_info.value().well_index(name);
203 std::string globalIdxToWellName(
const int index) {
204 return this->global_well_info.value().well_name(index);
207 bool wellIsOwned(std::size_t well_index,
208 const std::string& wellName)
const;
210 bool wellIsOwned(
const std::string& wellName)
const;
212 void updateStatus(
int well_index, Well::Status status);
214 void openWell(
int well_index);
215 void shutWell(
int well_index);
216 void stopWell(
int well_index);
221 return this->phase_usage_.num_phases;
225 return this->phase_usage_;
229 std::vector<double>&
wellRates(std::size_t well_index) {
return this->wells_[well_index].surface_rates; }
230 const std::vector<double>&
wellRates(std::size_t well_index)
const {
return this->wells_[well_index].surface_rates; }
232 const std::string& name(std::size_t well_index)
const {
233 return this->wells_.well_name(well_index);
236 std::optional<std::size_t> index(
const std::string& well_name)
const {
237 return this->wells_.well_index(well_name);
240 const SingleWellState& operator[](std::size_t well_index)
const {
241 return this->wells_[well_index];
244 const SingleWellState& operator[](
const std::string& well_name)
const {
245 return this->wells_[well_name];
248 SingleWellState& operator[](std::size_t well_index) {
249 return this->wells_[well_index];
252 SingleWellState& operator[](
const std::string& well_name) {
253 return this->wells_[well_name];
256 const SingleWellState& well(std::size_t well_index)
const {
257 return this->operator[](well_index);
260 const SingleWellState& well(
const std::string& well_name)
const {
261 return this->operator[](well_name);
264 SingleWellState& well(std::size_t well_index) {
265 return this->operator[](well_index);
268 SingleWellState& well(
const std::string& well_name) {
269 return this->operator[](well_name);
272 bool has(
const std::string& well_name)
const {
273 return this->wells_.has(well_name);
277 PhaseUsage phase_usage_;
282 WellContainer<SingleWellState> wells_;
290 std::optional<GlobalWellInfo> global_well_info;
296 std::map<std::string, std::pair<bool, std::vector<double>>> well_rates;
299 reportSegmentResults(
const int well_id,
301 const int seg_no)
const;
308 void updateWellsDefaultALQ(
const std::vector<Well>& wells_ecl);
315 void base_init(
const std::vector<double>& cellPressures,
316 const std::vector<Well>& wells_ecl,
317 const std::vector<std::reference_wrapper<ParallelWellInfo>>& parallel_well_info,
318 const std::vector<std::vector<PerforationData>>& well_perf_data,
319 const SummaryState& summary_state);
321 void initSingleWell(
const std::vector<double>& cellPressures,
323 const std::vector<PerforationData>& well_perf_data,
324 const ParallelWellInfo& well_info,
325 const SummaryState& summary_state);
327 void initSingleProducer(
const Well& well,
328 const ParallelWellInfo& well_info,
329 double pressure_first_connection,
330 const std::vector<PerforationData>& well_perf_data,
331 const SummaryState& summary_state);
333 void initSingleInjector(
const Well& well,
334 const ParallelWellInfo& well_info,
335 double pressure_first_connection,
336 const std::vector<PerforationData>& well_perf_data,
337 const SummaryState& summary_state);
Class encapsulating some information about parallel wells.
Definition: ParallelWellInfo.hpp:243
The state of a set of wells, tailored for use by the fully implicit blackoil simulator.
Definition: WellState.hpp:56
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:122
void initWellStateMSWell(const std::vector< Well > &wells_ecl, const WellState *prev_well_state)
init the MS well related.
Definition: WellState.cpp:507
int numPhases() const
The number of phases present.
Definition: WellState.hpp:219
std::vector< double > & wellRates(std::size_t well_index)
One rate per well and phase.
Definition: WellState.hpp:229
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition: BlackoilPhases.hpp:27
Definition: BlackoilPhases.hpp:46