BlackoilWellModelGeneric.hpp
Go to the documentation of this file.
1/*
2 Copyright 2016 SINTEF ICT, Applied Mathematics.
3 Copyright 2016 - 2017 Statoil ASA.
4 Copyright 2017 Dr. Blatt - HPC-Simulation-Software & Services
5 Copyright 2016 - 2018 IRIS AS
6
7 This file is part of the Open Porous Media project (OPM).
8
9 OPM is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13
14 OPM is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with OPM. If not, see <http://www.gnu.org/licenses/>.
21*/
22
23#ifndef OPM_BLACKOILWELLMODEL_GENERIC_HEADER_INCLUDED
24#define OPM_BLACKOILWELLMODEL_GENERIC_HEADER_INCLUDED
25
26#include <opm/output/data/GuideRateValue.hpp>
27
28#include <opm/input/eclipse/Schedule/Group/GuideRate.hpp>
29#include <opm/input/eclipse/Schedule/Well/PAvg.hpp>
30#include <opm/input/eclipse/Schedule/Well/PAvgCalculator.hpp>
31#include <opm/input/eclipse/Schedule/Well/PAvgCalculatorCollection.hpp>
32#include <opm/input/eclipse/Schedule/Well/WellTestState.hpp>
33
46
47#include <algorithm>
48#include <cstddef>
49#include <functional>
50#include <map>
51#include <memory>
52#include <optional>
53#include <string>
54#include <unordered_map>
55#include <unordered_set>
56#include <vector>
57
58
59namespace Opm {
60 class DeferredLogger;
61 class EclipseState;
62 template<typename Scalar, typename IndexTraits> class BlackoilWellModelGasLiftGeneric;
63 template<typename Scalar, typename IndexTraits> class GasLiftGroupInfo;
64 template<typename Scalar, typename IndexTraits> class GasLiftSingleWellGeneric;
65 template<class Scalar> class GasLiftWellState;
66 class Group;
67 class GuideRateConfig;
68 class RestartValue;
69 class Schedule;
70 struct SimulatorUpdate;
71 class SummaryConfig;
72 template<typename Scalar, typename IndexTraits> class VFPProperties;
73 template<typename Scalar, typename IndexTraits> class WellInterfaceGeneric;
74 template<typename Scalar, typename IndexTraits> class WellState;
75} // namespace Opm
76
77namespace Opm { namespace data {
78 struct GroupData;
79 struct GroupGuideRates;
80 class GroupAndNetworkValues;
81 struct NodeData;
82}} // namespace Opm::data
83
84namespace Opm::Parameters {
85
86struct EnableTerminalOutput { static constexpr bool value = true; };
87
88} // namespace Opm::Parameters
89
90namespace Opm {
91
93template<typename Scalar, typename IndexTraits>
95{
97public:
100 const SummaryState& summaryState,
101 const EclipseState& eclState,
102 const PhaseUsageInfo<IndexTraits>& phase_usage,
104
105 virtual ~BlackoilWellModelGeneric() = default;
106 virtual int compressedIndexForInteriorLGR([[maybe_unused]] const std::string& lgr_tag,
107 [[maybe_unused]] const Connection& conn) const
108 {
109 throw std::runtime_error("compressedIndexForInteriorLGR not implemented");
110 }
111
112 int numLocalWells() const;
113 int numLocalWellsEnd() const;
115 int numPhases() const;
116
118 bool wellsActive() const;
119
121 bool hasLocalWell(const std::string& wname) const;
122
124 bool hasOpenLocalWell(const std::string& well_name) const;
125
127 bool networkActive() const;
128
129 // whether there exists any multisegment well open on this process
130 bool anyMSWellOpenLocal() const;
131
132 const std::vector<Well>& eclWells() const
133 { return wells_ecl_; }
134
135 bool terminalOutput() const
136 { return terminal_output_; }
137
138 const Well& getWellEcl(const std::string& well_name) const;
139 std::vector<Well> getLocalWells(const int timeStepIdx) const;
140 const Schedule& schedule() const { return schedule_; }
142 const GroupState<Scalar>& groupState() const { return this->active_wgstate_.group_state; }
143 std::vector<const WellInterfaceGeneric<Scalar, IndexTraits>*> genericWells() const
144 { return {well_container_generic_.begin(), well_container_generic_.end()}; }
145
146 std::vector<WellInterfaceGeneric<Scalar, IndexTraits>*> genericWells()
147 { return well_container_generic_; }
148
149 /*
150 Immutable version of the currently active wellstate.
151 */
153 {
154 return this->active_wgstate_.well_state;
155 }
156
157 /*
158 Mutable version of the currently active wellstate.
159 */
161 {
162 return this->active_wgstate_.well_state;
163 }
164
165 /*
166 Will return the currently active nupcolWellState; must update
167 the internal nupcol wellstate with updateNupcolWGState() first.
168
169 Both const and non-const accessors are provided. The non-const
170 accessor is required for the WellStateGuard pattern and pushWellState()
171 in WellGroupHelper, which temporarily switches WellGroupHelper to use this state.
172 */
174 {
175 return this->nupcol_wgstate_.well_state;
176 }
178 {
179 return this->nupcol_wgstate_.well_state;
180 }
181 GroupState<Scalar>& groupState() { return this->active_wgstate_.group_state; }
182
183 WellTestState& wellTestState() { return this->active_wgstate_.well_test_state; }
184
185 const WellTestState& wellTestState() const { return this->active_wgstate_.well_test_state; }
186
187 Scalar wellPI(const int well_index) const;
188 Scalar wellPI(const std::string& well_name) const;
189
190 void updateEclWells(const int timeStepIdx,
191 const SimulatorUpdate& sim_update,
192 const SummaryState& st);
193
194 void initFromRestartFile(const RestartValue& restartValues,
195 std::unique_ptr<WellTestState> wtestState,
196 const std::size_t numCells,
197 bool handle_ms_well,
198 bool enable_distributed_wells);
199
200 void prepareDeserialize(int report_step,
201 const std::size_t numCells,
202 bool handle_ms_well,
203 bool enable_distributed_wells);
204
205 /*
206 Will assign the internal member last_valid_well_state_ to the
207 current value of the this->active_well_state_. The state stored
208 with storeWellState() can then subsequently be recovered with the
209 resetWellState() method.
210 */
212 {
215 }
216
217 data::GroupAndNetworkValues groupAndNetworkData(const int reportStepIdx) const;
218
220 void updateNetworkActiveState(const int report_step);
221
225 bool needPreStepNetworkRebalance(const int report_step) const;
226
229 bool forceShutWellByName(const std::string& wellname,
230 const double simulation_time,
231 const bool dont_shut_grup_wells);
232
233 const std::vector<PerforationData<Scalar>>& perfData(const int well_idx) const
234 { return well_perf_data_[well_idx]; }
235
236 const Parallel::Communication& comm() const { return comm_; }
237
238 const EclipseState& eclipseState() const { return eclState_; }
239
240 const SummaryState& summaryState() const { return summaryState_; }
241
242 const GuideRate& guideRate() const { return guideRate_; }
243 GuideRate& guideRate() { return guideRate_; }
244
245 const std::map<std::string, double>& wellOpenTimes() const { return well_open_times_; }
246 const std::map<std::string, double>& wellCloseTimes() const { return well_close_times_; }
247 const WellGroupEvents& reportStepStartEvents() const { return report_step_start_events_; }
248
249 std::vector<int> getCellsForConnections(const Well& well) const;
250
251 bool reportStepStarts() const { return report_step_starts_; }
252
253 bool shouldBalanceNetwork(const int reportStepIndex,
254 const int iterationIdx) const;
255
256 void updateClosedWellsThisStep(const std::string& well_name) const
257 {
258 this->closed_this_step_.insert(well_name);
259 }
260 bool wasDynamicallyShutThisTimeStep(const std::string& well_name) const;
261
262 void logPrimaryVars() const;
263
264 template<class Serializer>
265 void serializeOp(Serializer& serializer)
266 {
267 serializer(initial_step_);
268 serializer(report_step_starts_);
269 serializer(last_run_wellpi_);
270 serializer(local_shut_wells_);
271 serializer(closed_this_step_);
272 serializer(guideRate_);
273 serializer(node_pressures_);
274 serializer(last_valid_node_pressures_);
275 serializer(prev_inj_multipliers_);
276 serializer(active_wgstate_);
277 serializer(last_valid_wgstate_);
278 serializer(nupcol_wgstate_);
279 serializer(switched_prod_groups_);
280 serializer(switched_inj_groups_);
281 serializer(closed_offending_wells_);
282 serializer(gen_gaslift_);
283 }
284
285 bool operator==(const BlackoilWellModelGeneric& rhs) const;
286
288 parallelWellInfo(const std::size_t idx) const
289 { return local_parallel_well_info_[idx].get(); }
290
291 bool isOwner(const std::string& wname) const
292 {
293 return this->parallelWellSatisfies
294 (wname, [](const auto& pwInfo) { return pwInfo.isOwner(); });
295 }
296
297 bool hasLocalCells(const std::string& wname) const
298 {
299 return this->parallelWellSatisfies
300 (wname, [](const auto& pwInfo) { return pwInfo.hasLocalCells(); });
301 }
302
303 const ConnectionIndexMap& connectionIndexMap(const std::size_t idx)
304 { return conn_idx_map_[idx]; }
305
307 const WellGroupHelperType& wgHelper() const { return wg_helper_; }
308
309protected:
310 /*
311 The dynamic state of the well model is maintained with an instance
312 of the WellState class. Currently we have
313 three different wellstate instances:
314
315 1. The currently active wellstate is in the active_well_state_
316 member. That is the state which is mutated by the simulator.
317
318 2. In the case timestep fails to converge and we must go back and
319 try again with a smaller timestep we need to recover the last
320 valid wellstate. This is maintained with the
321 last_valid_well_state_ member and the functions
322 commitWGState() and resetWellState().
323
324 3. For the NUPCOL functionality we should either use the
325 currently active wellstate or a wellstate frozen at max
326 nupcol iterations. This is handled with the member
327 nupcol_well_state_ and the updateNupcolWGState() function.
328 */
329
330 /*
331 Will return the last good wellstate. This is typcially used when
332 initializing a new report step where the Schedule object might
333 have introduced new wells. The wellstate returned by
334 prevWellState() must have been stored with the commitWGState()
335 function first.
336 */
338 {
339 return this->last_valid_wgstate_.well_state;
340 }
341
343 {
344 return this->last_valid_wgstate_;
345 }
346
347 /*
348 Will store a copy of the input argument well_state in the
349 last_valid_well_state_ member, that state can then be recovered
350 with a subsequent call to resetWellState().
351 */
353 {
354 this->last_valid_wgstate_ = std::move(wgstate);
355 }
356
357 /*
358 Will update the internal variable active_well_state_ to whatever
359 was stored in the last_valid_well_state_ member. This function
360 works in pair with commitWellState() which should be called first.
361 */
363 {
366 // Update helper pointers to reference the restored active state
367 this->wg_helper_.updateState(this->wellState(), this->groupState());
368 }
369
370 /*
371 Will store the current active wellstate in the nupcol_well_state_
372 member. This can then be subsequently retrieved with accessor
373 nupcolWellState().
374 */
376 {
377 this->nupcol_wgstate_ = this->active_wgstate_;
378 }
379
380 void reportGroupSwitching(DeferredLogger& local_deferredLogger) const;
381
384 std::vector<std::reference_wrapper<ParallelWellInfo<Scalar>>>
385 createLocalParallelWellInfo(const std::vector<Well>& wells);
386
389
390 bool wasDynamicallyShutThisTimeStep(const int well_index) const;
391
392 Scalar updateNetworkPressures(const int reportStepIdx,
393 const Scalar damping_factor,
394 const Scalar update_upper_bound);
395
396 void updateWsolvent(const Group& group,
397 const int reportStepIdx,
399 void setWsolvent(const Group& group,
400 const int reportStepIdx,
401 Scalar wsolvent);
402 virtual void calcResvCoeff(const int fipnum,
403 const int pvtreg,
404 const std::vector<Scalar>& production_rates,
405 std::vector<Scalar>& resv_coeff) = 0;
406 virtual void calcInjResvCoeff(const int fipnum,
407 const int pvtreg,
408 std::vector<Scalar>& resv_coeff) = 0;
409
414 void assignDynamicWellStatus(data::Wells& wsrpt) const;
415
427 void assignShutConnections(data::Wells& wsrpt,
428 const int reportStepIndex) const;
429
430 void assignWellTargets(data::Wells& wsrpt) const;
431 void assignProductionWellTargets(const Well& well, data::WellControlLimits& limits) const;
432 void assignInjectionWellTargets(const Well& well, data::WellControlLimits& limits) const;
433
434 void assignGroupControl(const Group& group,
435 data::GroupData& gdata) const;
436 void assignGroupValues(const int reportStepIdx,
437 std::map<std::string, data::GroupData>& gvalues) const;
438 void assignNodeValues(std::map<std::string, data::NodeData>& nodevalues,
439 const int reportStepIdx) const;
440
441 void calculateEfficiencyFactors(const int reportStepIdx);
442
443 void checkGconsaleLimits(const Group& group,
445 const int reportStepIdx,
446 DeferredLogger& deferred_logger);
447
448 void checkGEconLimits(const Group& group,
449 const double simulation_time,
450 const int report_step_idx,
451 DeferredLogger& deferred_logger);
452
453 bool checkGroupHigherConstraints(const Group& group,
454 DeferredLogger& deferred_logger,
455 const int reportStepIdx,
456 const int max_number_of_group_switch,
457 const bool update_group_switching_log);
458
459 void updateAndCommunicateGroupData(const int reportStepIdx,
460 const int iterationIdx,
461 const Scalar tol_nupcol,
462 const bool update_wellgrouptarget, // we only want to update the wellgrouptarget after the groups have found their controls
463 DeferredLogger& deferred_logger);
464
466
468
469 virtual void computePotentials(const std::size_t widx,
470 const WellState<Scalar, IndexTraits>& well_state_copy,
471 std::string& exc_msg,
472 ExceptionType::ExcEnum& exc_type,
473 DeferredLogger& deferred_logger) = 0;
474
475 // Calculating well potentials for each well
476 void updateWellPotentials(const int reportStepIdx,
477 const bool onlyAfterEvent,
478 const SummaryConfig& summaryConfig,
479 DeferredLogger& deferred_logger);
480
482
483 void updateInjMult(DeferredLogger& deferred_logger);
484 void updateInjFCMult(DeferredLogger& deferred_logger);
485
486 void updateFiltrationModelsPostStep(const double dt,
487 const std::size_t water_index,
488 DeferredLogger& deferred_logger);
489
491
492 // create the well container
493 virtual void createWellContainer(const int time_step) = 0;
494 virtual void initWellContainer(const int reportStepIdx) = 0;
495
496 virtual void calculateProductivityIndexValuesShutWells(const int reportStepIdx,
497 DeferredLogger& deferred_logger) = 0;
498 virtual void calculateProductivityIndexValues(DeferredLogger& deferred_logger) = 0;
499
500 void runWellPIScaling(const int reportStepIdx,
501 DeferredLogger& local_deferredLogger);
502
504 virtual int compressedIndexForInterior(int cartesian_cell_idx) const = 0;
505
506 std::vector<std::vector<int>> getMaxWellConnections() const;
507
508 std::vector<std::string> getWellsForTesting(const int timeStepIdx,
509 const double simulationTime);
510
511 using WellTracerRates = std::unordered_map<int, std::vector<WellTracerRate<Scalar>>>;
512 void assignWellTracerRates(data::Wells& wsrpt,
513 const WellTracerRates& wellTracerRates,
514 const unsigned reportStep) const;
515
516 using MswTracerRates = std::unordered_map<int, std::vector<MSWellTracerRate<Scalar>>>;
517 void assignMswTracerRates(data::Wells& wsrpt,
518 const MswTracerRates& mswTracerRates,
519 const unsigned reportStep) const;
520
521 void assignMassGasRate(data::Wells& wsrpt,
522 const Scalar gasDensity) const;
523
524 Schedule& schedule_;
525
526 const SummaryState& summaryState_;
527 const EclipseState& eclState_;
531
532
534 bool terminal_output_{false};
535 bool wells_active_{false};
536 bool network_active_{false};
539
540 std::optional<int> last_run_wellpi_{};
541
542 std::vector<Well> wells_ecl_;
543 std::vector<std::vector<PerforationData<Scalar>>> well_perf_data_;
544
545 // Times at which wells were opened (for WCYCLE)
546 std::map<std::string, double> well_open_times_;
547
548 // Times at which wells were shut (for WCYCLE)
549 std::map<std::string, double> well_close_times_;
550
551 std::vector<ConnectionIndexMap> conn_idx_map_{};
552 std::function<bool(const std::string&)> not_on_process_{};
553
554 // a vector of all the wells.
555 std::vector<WellInterfaceGeneric<Scalar, IndexTraits>*> well_container_generic_{};
556
557 std::vector<int> local_shut_wells_{};
558
559 std::vector<ParallelWellInfo<Scalar>> parallel_well_info_;
560 std::vector<std::reference_wrapper<ParallelWellInfo<Scalar>>> local_parallel_well_info_;
561
562 std::vector<WellProdIndexCalculator<Scalar>> prod_index_calc_;
563
564 std::vector<int> pvt_region_idx_;
565
566 mutable std::unordered_set<std::string> closed_this_step_;
567
568 GuideRate guideRate_;
569 std::unique_ptr<VFPProperties<Scalar, IndexTraits>> vfp_properties_{};
570
571 // Network pressures for output and initialization
572 std::map<std::string, Scalar> node_pressures_;
573 // Valid network pressures for output and initialization for safe restart after failed iterations
574 std::map<std::string, Scalar> last_valid_node_pressures_;
575
576 // previous injection multiplier, it is used in the injection multiplier calculation for WINJMULT keyword
577 std::unordered_map<std::string, std::vector<Scalar>> prev_inj_multipliers_;
578
579 // Handling for filter cake injection multipliers
580 std::unordered_map<std::string, WellFilterCake<Scalar, IndexTraits>> filter_cake_;
581
582 /*
583 The various wellState members should be accessed and modified
584 through the accessor functions wellState(), prevWellState(),
585 commitWellState(), resetWellState(), nupcolWellState() and
586 updateNupcolWGState().
587 */
593
595
596 // Store maps of group name and new group controls for output
597 std::map<std::string, std::vector<Group::ProductionCMode>> switched_prod_groups_;
598 std::map<std::string, std::array<std::vector<Group::InjectionCMode>, 3>> switched_inj_groups_;
599 // Store map of group name and close offending well for output
600 std::map<std::string, std::pair<std::string, std::string>> closed_offending_wells_;
601
602private:
603 WellInterfaceGeneric<Scalar, IndexTraits>* getGenWell(const std::string& well_name);
604
605 template <typename Iter, typename Body>
606 void wellUpdateLoop(Iter first, Iter last, const int timeStepIdx, Body&& body);
607
608 void updateEclWellsConstraints(const int timeStepIdx,
609 const SimulatorUpdate& sim_update,
610 const SummaryState& st);
611
612 void updateEclWellsCTFFromAction(const int timeStepIdx,
613 const SimulatorUpdate& sim_update);
614
628 template <typename Predicate>
629 bool parallelWellSatisfies(const std::string& wname, Predicate&& p) const
630 {
631 auto pwInfoPos = std::find_if(this->parallel_well_info_.begin(),
632 this->parallel_well_info_.end(),
633 [&wname](const auto& pwInfo)
634 { return pwInfo.name() == wname; });
635
636 return (pwInfoPos != this->parallel_well_info_.end())
637 && p(*pwInfoPos);
638 }
639
655 template <typename LoopBody>
656 void loopOwnedWells(LoopBody&& loopBody) const;
657};
658
659} // namespace Opm
660
661#endif
Definition: BlackoilWellModelGasLift.hpp:42
Class for handling the blackoil well model.
Definition: BlackoilWellModelGeneric.hpp:95
void commitWGState()
Definition: BlackoilWellModelGeneric.hpp:211
std::map< std::string, std::vector< Group::ProductionCMode > > switched_prod_groups_
Definition: BlackoilWellModelGeneric.hpp:597
void updateAndCommunicateGroupData(const int reportStepIdx, const int iterationIdx, const Scalar tol_nupcol, const bool update_wellgrouptarget, DeferredLogger &deferred_logger)
const EclipseState & eclState_
Definition: BlackoilWellModelGeneric.hpp:527
const PhaseUsageInfo< IndexTraits > & phaseUsage() const
Definition: BlackoilWellModelGeneric.hpp:141
const WGState< Scalar, IndexTraits > & prevWGState() const
Definition: BlackoilWellModelGeneric.hpp:342
BlackoilWellModelGeneric(Schedule &schedule, BlackoilWellModelGasLiftGeneric< Scalar, IndexTraits > &gaslift, const SummaryState &summaryState, const EclipseState &eclState, const PhaseUsageInfo< IndexTraits > &phase_usage, const Parallel::Communication &comm)
std::vector< Well > getLocalWells(const int timeStepIdx) const
const ConnectionIndexMap & connectionIndexMap(const std::size_t idx)
Definition: BlackoilWellModelGeneric.hpp:303
WellState< Scalar, IndexTraits > & nupcolWellState()
Definition: BlackoilWellModelGeneric.hpp:177
const GroupState< Scalar > & groupState() const
Definition: BlackoilWellModelGeneric.hpp:142
const PhaseUsageInfo< IndexTraits > & phase_usage_info_
Definition: BlackoilWellModelGeneric.hpp:533
void assignDynamicWellStatus(data::Wells &wsrpt) const
void serializeOp(Serializer &serializer)
Definition: BlackoilWellModelGeneric.hpp:265
WellGroupHelperType wg_helper_
Definition: BlackoilWellModelGeneric.hpp:591
bool reportStepStarts() const
Definition: BlackoilWellModelGeneric.hpp:251
bool operator==(const BlackoilWellModelGeneric &rhs) const
WGState< Scalar, IndexTraits > last_valid_wgstate_
Definition: BlackoilWellModelGeneric.hpp:589
const Parallel::Communication & comm() const
Definition: BlackoilWellModelGeneric.hpp:236
virtual int compressedIndexForInteriorLGR(const std::string &lgr_tag, const Connection &conn) const
Definition: BlackoilWellModelGeneric.hpp:106
GuideRate guideRate_
Definition: BlackoilWellModelGeneric.hpp:568
virtual int compressedIndexForInterior(int cartesian_cell_idx) const =0
get compressed index for interior cells (-1, otherwise
std::vector< WellInterfaceGeneric< Scalar, IndexTraits > * > well_container_generic_
Definition: BlackoilWellModelGeneric.hpp:555
WellGroupEvents report_step_start_events_
Well group events at start of report step.
Definition: BlackoilWellModelGeneric.hpp:592
void resetWGState()
Definition: BlackoilWellModelGeneric.hpp:362
void assignWellTargets(data::Wells &wsrpt) const
virtual void calcResvCoeff(const int fipnum, const int pvtreg, const std::vector< Scalar > &production_rates, std::vector< Scalar > &resv_coeff)=0
WGState< Scalar, IndexTraits > active_wgstate_
Definition: BlackoilWellModelGeneric.hpp:588
Scalar wellPI(const int well_index) const
virtual ~BlackoilWellModelGeneric()=default
std::vector< Well > wells_ecl_
Definition: BlackoilWellModelGeneric.hpp:542
bool hasLocalWell(const std::string &wname) const
Returns true if well is defined and has connections on current rank.
void assignInjectionWellTargets(const Well &well, data::WellControlLimits &limits) const
const ParallelWellInfo< Scalar > & parallelWellInfo(const std::size_t idx) const
Definition: BlackoilWellModelGeneric.hpp:288
BlackoilWellModelWBP< Scalar, IndexTraits > wbp_
Definition: BlackoilWellModelGeneric.hpp:530
const WellGroupEvents & reportStepStartEvents() const
Definition: BlackoilWellModelGeneric.hpp:247
std::vector< const WellInterfaceGeneric< Scalar, IndexTraits > * > genericWells() const
Definition: BlackoilWellModelGeneric.hpp:143
const std::map< std::string, double > & wellCloseTimes() const
Definition: BlackoilWellModelGeneric.hpp:246
const std::vector< Well > & eclWells() const
Definition: BlackoilWellModelGeneric.hpp:132
void updateNupcolWGState()
Definition: BlackoilWellModelGeneric.hpp:375
void updateFiltrationModelsPostStep(const double dt, const std::size_t water_index, DeferredLogger &deferred_logger)
const EclipseState & eclipseState() const
Definition: BlackoilWellModelGeneric.hpp:238
bool wells_active_
Definition: BlackoilWellModelGeneric.hpp:535
WGState< Scalar, IndexTraits > nupcol_wgstate_
Definition: BlackoilWellModelGeneric.hpp:590
std::unordered_map< int, std::vector< MSWellTracerRate< Scalar > > > MswTracerRates
Definition: BlackoilWellModelGeneric.hpp:516
std::unique_ptr< VFPProperties< Scalar, IndexTraits > > vfp_properties_
Definition: BlackoilWellModelGeneric.hpp:569
bool report_step_starts_
Definition: BlackoilWellModelGeneric.hpp:538
std::vector< std::reference_wrapper< ParallelWellInfo< Scalar > > > local_parallel_well_info_
Definition: BlackoilWellModelGeneric.hpp:560
const Well & getWellEcl(const std::string &well_name) const
const Parallel::Communication & comm_
Definition: BlackoilWellModelGeneric.hpp:528
std::vector< WellInterfaceGeneric< Scalar, IndexTraits > * > genericWells()
Definition: BlackoilWellModelGeneric.hpp:146
std::vector< int > getCellsForConnections(const Well &well) const
void updateWsolvent(const Group &group, const int reportStepIdx, const WellState< Scalar, IndexTraits > &wellState)
std::unordered_map< int, std::vector< WellTracerRate< Scalar > > > WellTracerRates
Definition: BlackoilWellModelGeneric.hpp:511
WellTestState & wellTestState()
Definition: BlackoilWellModelGeneric.hpp:183
bool wellStructureChangedDynamically_
Definition: BlackoilWellModelGeneric.hpp:594
std::vector< std::vector< PerforationData< Scalar > > > well_perf_data_
Definition: BlackoilWellModelGeneric.hpp:543
bool wellsActive() const
return true if wells are available in the reservoir
bool forceShutWellByName(const std::string &wellname, const double simulation_time, const bool dont_shut_grup_wells)
bool terminal_output_
Definition: BlackoilWellModelGeneric.hpp:534
const WellTestState & wellTestState() const
Definition: BlackoilWellModelGeneric.hpp:185
void reportGroupSwitching(DeferredLogger &local_deferredLogger) const
std::unordered_map< std::string, WellFilterCake< Scalar, IndexTraits > > filter_cake_
Definition: BlackoilWellModelGeneric.hpp:580
std::map< std::string, double > well_close_times_
Definition: BlackoilWellModelGeneric.hpp:549
virtual void calculateProductivityIndexValues(DeferredLogger &deferred_logger)=0
void checkGconsaleLimits(const Group &group, WellState< Scalar, IndexTraits > &well_state, const int reportStepIdx, DeferredLogger &deferred_logger)
void commitWGState(WGState< Scalar, IndexTraits > wgstate)
Definition: BlackoilWellModelGeneric.hpp:352
data::GroupAndNetworkValues groupAndNetworkData(const int reportStepIdx) const
void assignShutConnections(data::Wells &wsrpt, const int reportStepIndex) const
std::vector< int > pvt_region_idx_
Definition: BlackoilWellModelGeneric.hpp:564
void setWsolvent(const Group &group, const int reportStepIdx, Scalar wsolvent)
virtual void createWellContainer(const int time_step)=0
std::function< bool(const std::string &)> not_on_process_
Definition: BlackoilWellModelGeneric.hpp:552
const SummaryState & summaryState() const
Definition: BlackoilWellModelGeneric.hpp:240
bool wasDynamicallyShutThisTimeStep(const std::string &well_name) const
virtual void calculateProductivityIndexValuesShutWells(const int reportStepIdx, DeferredLogger &deferred_logger)=0
const GuideRate & guideRate() const
Definition: BlackoilWellModelGeneric.hpp:242
bool checkGroupHigherConstraints(const Group &group, DeferredLogger &deferred_logger, const int reportStepIdx, const int max_number_of_group_switch, const bool update_group_switching_log)
std::optional< int > last_run_wellpi_
Definition: BlackoilWellModelGeneric.hpp:540
const SummaryState & summaryState_
Definition: BlackoilWellModelGeneric.hpp:526
std::map< std::string, std::array< std::vector< Group::InjectionCMode >, 3 > > switched_inj_groups_
Definition: BlackoilWellModelGeneric.hpp:598
std::map< std::string, std::pair< std::string, std::string > > closed_offending_wells_
Definition: BlackoilWellModelGeneric.hpp:600
void updateClosedWellsThisStep(const std::string &well_name) const
Definition: BlackoilWellModelGeneric.hpp:256
const WellState< Scalar, IndexTraits > & wellState() const
Definition: BlackoilWellModelGeneric.hpp:152
std::vector< int > local_shut_wells_
Definition: BlackoilWellModelGeneric.hpp:557
void updateFiltrationModelsPreStep(DeferredLogger &deferred_logger)
void calculateEfficiencyFactors(const int reportStepIdx)
bool network_active_
Definition: BlackoilWellModelGeneric.hpp:536
virtual void calcInjResvCoeff(const int fipnum, const int pvtreg, std::vector< Scalar > &resv_coeff)=0
bool hasLocalCells(const std::string &wname) const
Definition: BlackoilWellModelGeneric.hpp:297
void assignMswTracerRates(data::Wells &wsrpt, const MswTracerRates &mswTracerRates, const unsigned reportStep) const
void updateInjFCMult(DeferredLogger &deferred_logger)
std::map< std::string, Scalar > node_pressures_
Definition: BlackoilWellModelGeneric.hpp:572
std::vector< ParallelWellInfo< Scalar > > parallel_well_info_
Definition: BlackoilWellModelGeneric.hpp:559
void assignProductionWellTargets(const Well &well, data::WellControlLimits &limits) const
void checkGEconLimits(const Group &group, const double simulation_time, const int report_step_idx, DeferredLogger &deferred_logger)
void assignGroupValues(const int reportStepIdx, std::map< std::string, data::GroupData > &gvalues) const
const Schedule & schedule() const
Definition: BlackoilWellModelGeneric.hpp:140
bool networkActive() const
return true if network is active (at least one network well in prediction mode)
Scalar updateNetworkPressures(const int reportStepIdx, const Scalar damping_factor, const Scalar update_upper_bound)
WellState< Scalar, IndexTraits > & wellState()
Definition: BlackoilWellModelGeneric.hpp:160
void assignNodeValues(std::map< std::string, data::NodeData > &nodevalues, const int reportStepIdx) const
const WellGroupHelperType & wgHelper() const
Definition: BlackoilWellModelGeneric.hpp:307
void assignGroupControl(const Group &group, data::GroupData &gdata) const
void assignMassGasRate(data::Wells &wsrpt, const Scalar gasDensity) const
bool hasOpenLocalWell(const std::string &well_name) const
Returns true if well is defined, open and has connections on current rank.
GuideRate & guideRate()
Definition: BlackoilWellModelGeneric.hpp:243
BlackoilWellModelGasLiftGeneric< Scalar, IndexTraits > & gen_gaslift_
Definition: BlackoilWellModelGeneric.hpp:529
const std::map< std::string, double > & wellOpenTimes() const
Definition: BlackoilWellModelGeneric.hpp:245
void initFromRestartFile(const RestartValue &restartValues, std::unique_ptr< WellTestState > wtestState, const std::size_t numCells, bool handle_ms_well, bool enable_distributed_wells)
bool shouldBalanceNetwork(const int reportStepIndex, const int iterationIdx) const
const WellState< Scalar, IndexTraits > & prevWellState() const
Definition: BlackoilWellModelGeneric.hpp:337
virtual void computePotentials(const std::size_t widx, const WellState< Scalar, IndexTraits > &well_state_copy, std::string &exc_msg, ExceptionType::ExcEnum &exc_type, DeferredLogger &deferred_logger)=0
std::vector< std::vector< int > > getMaxWellConnections() const
void assignWellTracerRates(data::Wells &wsrpt, const WellTracerRates &wellTracerRates, const unsigned reportStep) const
std::vector< std::string > getWellsForTesting(const int timeStepIdx, const double simulationTime)
void updateEclWells(const int timeStepIdx, const SimulatorUpdate &sim_update, const SummaryState &st)
void updateInjMult(DeferredLogger &deferred_logger)
bool initial_step_
Definition: BlackoilWellModelGeneric.hpp:537
bool needPreStepNetworkRebalance(const int report_step) const
void updateNetworkActiveState(const int report_step)
Checks if network is active (at least one network well on prediction).
bool terminalOutput() const
Definition: BlackoilWellModelGeneric.hpp:135
void prepareDeserialize(int report_step, const std::size_t numCells, bool handle_ms_well, bool enable_distributed_wells)
GroupState< Scalar > & groupState()
Definition: BlackoilWellModelGeneric.hpp:181
bool wasDynamicallyShutThisTimeStep(const int well_index) const
WellGroupHelperType & wgHelper()
Definition: BlackoilWellModelGeneric.hpp:306
const std::vector< PerforationData< Scalar > > & perfData(const int well_idx) const
Definition: BlackoilWellModelGeneric.hpp:233
std::vector< std::reference_wrapper< ParallelWellInfo< Scalar > > > createLocalParallelWellInfo(const std::vector< Well > &wells)
Create the parallel well information.
std::unordered_map< std::string, std::vector< Scalar > > prev_inj_multipliers_
Definition: BlackoilWellModelGeneric.hpp:577
Schedule & schedule_
Definition: BlackoilWellModelGeneric.hpp:524
const WellState< Scalar, IndexTraits > & nupcolWellState() const
Definition: BlackoilWellModelGeneric.hpp:173
std::vector< ConnectionIndexMap > conn_idx_map_
Definition: BlackoilWellModelGeneric.hpp:551
virtual void initWellContainer(const int reportStepIdx)=0
Scalar wellPI(const std::string &well_name) const
std::map< std::string, Scalar > last_valid_node_pressures_
Definition: BlackoilWellModelGeneric.hpp:574
void updateWellPotentials(const int reportStepIdx, const bool onlyAfterEvent, const SummaryConfig &summaryConfig, DeferredLogger &deferred_logger)
std::map< std::string, double > well_open_times_
Definition: BlackoilWellModelGeneric.hpp:546
std::unordered_set< std::string > closed_this_step_
Definition: BlackoilWellModelGeneric.hpp:566
bool isOwner(const std::string &wname) const
Definition: BlackoilWellModelGeneric.hpp:291
void runWellPIScaling(const int reportStepIdx, DeferredLogger &local_deferredLogger)
std::vector< WellProdIndexCalculator< Scalar > > prod_index_calc_
Definition: BlackoilWellModelGeneric.hpp:562
Class for handling the blackoil well model.
Definition: BlackoilWellModelWBP.hpp:42
Connection index mappings.
Definition: ConnectionIndexMap.hpp:33
Definition: DeferredLogger.hpp:57
Definition: GroupState.hpp:41
Class encapsulating some information about parallel wells.
Definition: ParallelWellInfo.hpp:198
Definition: GasLiftGroupInfo.hpp:37
Definition: WellGroupHelper.hpp:51
void updateState(WellState< Scalar, IndexTraits > &well_state, GroupState< Scalar > &group_state)
Definition: WellInterfaceGeneric.hpp:53
Definition: WellState.hpp:66
ExcEnum
Definition: DeferredLogger.hpp:45
Dune::Communication< MPIComm > Communication
Definition: ParallelCommunication.hpp:30
Definition: blackoilnewtonmethodparams.hpp:31
Definition: blackoilbioeffectsmodules.hh:43
Definition: BlackoilWellModelGeneric.hpp:86
static constexpr bool value
Definition: BlackoilWellModelGeneric.hpp:86
Definition: WGState.hpp:39