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
48
49#include <algorithm>
50#include <cstddef>
51#include <functional>
52#include <map>
53#include <memory>
54#include <optional>
55#include <string>
56#include <unordered_map>
57#include <unordered_set>
58#include <vector>
59
60
61namespace Opm {
62 class DeferredLogger;
63 class EclipseState;
64 template<typename Scalar, typename IndexTraits> class BlackoilWellModelGasLiftGeneric;
65 template<typename Scalar, typename IndexTraits> class BlackoilWellModelNetworkGeneric;
66 template<typename Scalar, typename IndexTraits> class GasLiftGroupInfo;
67 template<typename Scalar, typename IndexTraits> class GasLiftSingleWellGeneric;
68 template<class Scalar> class GasLiftWellState;
69 class Group;
70 class GuideRateConfig;
71 class RestartValue;
72 class Schedule;
73 struct SimulatorUpdate;
74 class SummaryConfig;
75 template<typename Scalar, typename IndexTraits> class VFPProperties;
76 template<typename Scalar, typename IndexTraits> class WellInterfaceGeneric;
77 template<typename Scalar, typename IndexTraits> class WellState;
78} // namespace Opm
79
80namespace Opm { namespace data {
81 struct GroupData;
82 struct GroupGuideRates;
83 class GroupAndNetworkValues;
84 struct NodeData;
85}} // namespace Opm::data
86
87namespace Opm::Parameters {
88
89struct EnableTerminalOutput { static constexpr bool value = true; };
90
91} // namespace Opm::Parameters
92
93namespace Opm {
94
96template<typename ScalarT, typename IndexTraitsT>
98{
100public:
101 using Scalar = ScalarT;
102 using IndexTraits = IndexTraitsT;
103
107 const SummaryState& summaryState,
108 const EclipseState& eclState,
109 const PhaseUsageInfo<IndexTraits>& phase_usage,
111 const NewtonIterationContext& iter_ctx);
112
113 virtual ~BlackoilWellModelGeneric() = default;
114 virtual int compressedIndexForInteriorLGR([[maybe_unused]] const std::string& lgr_tag,
115 [[maybe_unused]] const Connection& conn) const
116 {
117 throw std::runtime_error("compressedIndexForInteriorLGR not implemented");
118 }
119
120 int numLocalWells() const;
121 int numLocalWellsEnd() const;
123 int numPhases() const;
124
126 bool wellsActive() const;
127
129 bool hasLocalWell(const std::string& wname) const;
130
132 bool hasOpenLocalWell(const std::string& well_name) const;
133
134 // whether there exists any multisegment well open on this process
135 bool anyMSWellOpenLocal() const;
136
137 const std::vector<Well>& eclWells() const
138 { return wells_ecl_; }
139
140 bool terminalOutput() const
141 { return terminal_output_; }
142
143 const Well& getWellEcl(const std::string& well_name) const;
144 std::vector<Well> getLocalWells(const int timeStepIdx) const;
145 const Schedule& schedule() const { return schedule_; }
147 const GroupState<Scalar>& groupState() const { return this->active_wgstate_.group_state; }
148 std::vector<const WellInterfaceGeneric<Scalar, IndexTraits>*> genericWells() const
149 { return {well_container_generic_.begin(), well_container_generic_.end()}; }
150
151 std::vector<WellInterfaceGeneric<Scalar, IndexTraits>*> genericWells()
152 { return well_container_generic_; }
153
154 /*
155 Immutable version of the currently active wellstate.
156 */
158 {
159 return this->active_wgstate_.well_state;
160 }
161
162 /*
163 Mutable version of the currently active wellstate.
164 */
166 {
167 return this->active_wgstate_.well_state;
168 }
169
170 /*
171 Will return the currently active nupcolWellState; must update
172 the internal nupcol wellstate with updateNupcolWGState() first.
173
174 Both const and non-const accessors are provided. The non-const
175 accessor is required for the WellStateGuard pattern and pushWellState()
176 in WellGroupHelper, which temporarily switches WellGroupHelper to use this state.
177 */
179 {
180 return this->nupcol_wgstate_.well_state;
181 }
183 {
184 return this->nupcol_wgstate_.well_state;
185 }
186 GroupState<Scalar>& groupState() { return this->active_wgstate_.group_state; }
187
188 WellTestState& wellTestState() { return this->active_wgstate_.well_test_state; }
189
190 const WellTestState& wellTestState() const { return this->active_wgstate_.well_test_state; }
191
192 Scalar wellPI(const int well_index) const;
193 Scalar wellPI(const std::string& well_name) const;
194
195 void updateEclWells(const int timeStepIdx,
196 const SimulatorUpdate& sim_update,
197 const SummaryState& st);
198
199 void initFromRestartFile(const RestartValue& restartValues,
200 std::unique_ptr<WellTestState> wtestState,
201 const std::size_t numCells,
202 bool enable_distributed_wells);
203
204 void prepareDeserialize(int report_step,
205 const std::size_t numCells,
206 bool enable_distributed_wells);
207
208 /*
209 Will assign the internal member last_valid_well_state_ to the
210 current value of the this->active_well_state_. The state stored
211 with storeWellState() can then subsequently be recovered with the
212 resetWellState() method.
213 */
215
216 data::GroupAndNetworkValues groupAndNetworkData(const int reportStepIdx) const;
217
220 bool forceShutWellByName(const std::string& wellname,
221 const double simulation_time,
222 const bool dont_shut_grup_wells);
223
224 const std::vector<PerforationData<Scalar>>& perfData(const int well_idx) const
225 { return well_perf_data_[well_idx]; }
226
227 const Parallel::Communication& comm() const { return comm_; }
228
229 const EclipseState& eclipseState() const { return eclState_; }
230
231 const SummaryState& summaryState() const { return summaryState_; }
232
233 const GuideRate& guideRate() const { return guideRate_; }
234 GuideRate& guideRate() { return guideRate_; }
235
236 const std::map<std::string, double>& wellOpenTimes() const { return well_open_times_; }
237 const std::map<std::string, double>& wellCloseTimes() const { return well_close_times_; }
238 const WellGroupEvents& reportStepStartEvents() const { return report_step_start_events_; }
239
240 std::vector<int> getCellsForConnections(const Well& well) const;
241
242 bool reportStepStarts() const { return report_step_starts_; }
243
244 void updateClosedWellsThisStep(const std::string& well_name) const
245 {
246 this->closed_this_step_.insert(well_name);
247 }
248 bool wasDynamicallyShutThisTimeStep(const std::string& well_name) const;
249
250 void logPrimaryVars() const;
251
252 template<class Serializer>
253 void serializeOp(Serializer& serializer)
254 {
255 serializer(initial_step_);
256 serializer(report_step_starts_);
257 serializer(last_run_wellpi_);
258 serializer(local_shut_wells_);
259 serializer(closed_this_step_);
260 serializer(guideRate_);
261 serializer(genNetwork_);
262 serializer(prev_inj_multipliers_);
263 serializer(active_wgstate_);
264 serializer(last_valid_wgstate_);
265 serializer(nupcol_wgstate_);
266 serializer(switched_prod_groups_);
267 serializer(switched_inj_groups_);
268 serializer(closed_offending_wells_);
269 serializer(gen_gaslift_);
270 }
271
272 bool operator==(const BlackoilWellModelGeneric& rhs) const;
273
275 parallelWellInfo(const std::size_t idx) const
276 { return local_parallel_well_info_[idx].get(); }
277
278 bool isOwner(const std::string& wname) const
279 {
280 return this->parallelWellSatisfies
281 (wname, [](const auto& pwInfo) { return pwInfo.isOwner(); });
282 }
283
284 bool hasLocalCells(const std::string& wname) const
285 {
286 return this->parallelWellSatisfies
287 (wname, [](const auto& pwInfo) { return pwInfo.hasLocalCells(); });
288 }
289
290 const ConnectionIndexMap& connectionIndexMap(const std::size_t idx)
291 { return conn_idx_map_[idx]; }
292
295 std::pair<int, int> getGroupFipnumAndPvtreg() const;
296
297 virtual void calcResvCoeff(const int fipnum,
298 const int pvtreg,
299 const std::vector<Scalar>& production_rates,
300 std::vector<Scalar>& resv_coeff) const = 0;
301 virtual void calcInjResvCoeff(const int fipnum,
302 const int pvtreg,
303 std::vector<Scalar>& resv_coeff) const = 0;
304
306 {
307 return *vfp_properties_;
308 }
309
310 void updateAndCommunicateGroupData(const int reportStepIdx,
311 // we only want to update the wellgroup target
312 // after the groups have found their controls
313 const bool update_wellgrouptarget);
314
316 { return iter_ctx_; }
317
318 const EclipseState& eclState() const
319 { return eclState_; }
320
321protected:
322 /*
323 The dynamic state of the well model is maintained with an instance
324 of the WellState class. Currently we have
325 three different wellstate instances:
326
327 1. The currently active wellstate is in the active_well_state_
328 member. That is the state which is mutated by the simulator.
329
330 2. In the case timestep fails to converge and we must go back and
331 try again with a smaller timestep we need to recover the last
332 valid wellstate. This is maintained with the
333 last_valid_well_state_ member and the functions
334 commitWGState() and resetWellState().
335
336 3. For the NUPCOL functionality we should either use the
337 currently active wellstate or a wellstate frozen at max
338 nupcol iterations. This is handled with the member
339 nupcol_well_state_ and the updateNupcolWGState() function.
340 */
341
342 /*
343 Will return the last good wellstate. This is typcially used when
344 initializing a new report step where the Schedule object might
345 have introduced new wells. The wellstate returned by
346 prevWellState() must have been stored with the commitWGState()
347 function first.
348 */
350 {
351 return this->last_valid_wgstate_.well_state;
352 }
353
355 {
356 return this->last_valid_wgstate_;
357 }
358
359 /*
360 Will store a copy of the input argument well_state in the
361 last_valid_well_state_ member, that state can then be recovered
362 with a subsequent call to resetWellState().
363 */
365 {
366 this->last_valid_wgstate_ = std::move(wgstate);
367 }
368
369 /*
370 Will update the internal variable active_well_state_ to whatever
371 was stored in the last_valid_well_state_ member. This function
372 works in pair with commitWellState() which should be called first.
373 */
375 {
377 this->genNetwork_.resetState();
378 // Update helper pointers to reference the restored active state
379 this->group_state_helper_.updateState(this->wellState(), this->groupState());
380 }
381
382 /*
383 Will store the current active wellstate in the nupcol_well_state_
384 member. This can then be subsequently retrieved with accessor
385 nupcolWellState().
386 */
388 {
389 this->nupcol_wgstate_ = this->active_wgstate_;
390 }
391
392 void reportGroupSwitching(DeferredLogger& local_deferredLogger) const;
393
396 std::vector<std::reference_wrapper<ParallelWellInfo<Scalar>>>
397 createLocalParallelWellInfo(const std::vector<Well>& wells);
398
403 const ParallelWellInfo<Scalar>* findParallelWellInfo(const std::string& wname) const;
404
414
428 void registerNewParallelWells(int reportStepIdx);
429
432
433 bool wasDynamicallyShutThisTimeStep(const std::size_t well_index) const;
434
435 void updateWsolvent(const Group& group,
436 const int reportStepIdx,
438 void setWsolvent(const Group& group,
439 const int reportStepIdx,
440 Scalar wsolvent);
441
446 void assignDynamicWellStatus(data::Wells& wsrpt) const;
447
459 void assignShutConnections(data::Wells& wsrpt,
460 const int reportStepIndex) const;
461
462 void assignWellTargets(data::Wells& wsrpt) const;
463 void assignProductionWellTargets(const Well& well, data::WellControlLimits& limits) const;
464 void assignInjectionWellTargets(const Well& well, data::WellControlLimits& limits) const;
465
466 void assignGroupControl(const Group& group,
467 data::GroupData& gdata) const;
468 void assignGroupValues(const int reportStepIdx,
469 std::map<std::string, data::GroupData>& gvalues) const;
470
471 void calculateEfficiencyFactors(const int reportStepIdx);
472
473 void checkGconsaleLimits(const Group& group,
475 const int reportStepIdx,
476 DeferredLogger& deferred_logger);
477
478 void checkGEconLimits(const Group& group,
479 const double simulation_time,
480 const int report_step_idx,
481 DeferredLogger& deferred_logger);
482
483 bool checkGroupHigherConstraints(const Group& group,
484 DeferredLogger& deferred_logger,
485 const int reportStepIdx,
486 const bool update_group_switching_log);
487
489
491
492 virtual void computePotentials(const std::size_t widx,
493 const WellState<Scalar, IndexTraits>& well_state_copy,
494 std::string& exc_msg,
495 ExceptionType::ExcEnum& exc_type) = 0;
496
497 // Calculating well potentials for each well
498 void updateWellPotentials(const int reportStepIdx,
499 const bool onlyAfterEvent,
500 const SummaryConfig& summaryConfig,
501 DeferredLogger& deferred_logger);
502
504
505 void updateInjMult(DeferredLogger& deferred_logger);
506 void updateInjFCMult(DeferredLogger& deferred_logger);
507
508 void updateFiltrationModelsPostStep(const double dt,
509 const std::size_t water_index,
510 DeferredLogger& deferred_logger);
511
513
514 // create the well container
515 virtual void createWellContainer(const int time_step) = 0;
516 virtual void initWellContainer(const int reportStepIdx) = 0;
517
518 virtual void calculateProductivityIndexValuesShutWells(const int reportStepIdx,
519 DeferredLogger& deferred_logger) = 0;
520 virtual void calculateProductivityIndexValues(DeferredLogger& deferred_logger) = 0;
521
522 void runWellPIScaling(const int reportStepIdx,
523 DeferredLogger& local_deferredLogger);
524
526 virtual int compressedIndexForInterior(int cartesian_cell_idx) const = 0;
527
528 std::vector<std::vector<int>> getMaxWellConnections() const;
529
530 std::vector<std::string> getWellsForTesting(const int timeStepIdx,
531 const double simulationTime);
532
533 using WellTracerRates = std::unordered_map<int, std::vector<WellTracerRate<Scalar>>>;
534 void assignWellTracerRates(data::Wells& wsrpt,
535 const WellTracerRates& wellTracerRates,
536 const unsigned reportStep) const;
537
538 using MswTracerRates = std::unordered_map<int, std::vector<MSWellTracerRate<Scalar>>>;
539 void assignMswTracerRates(data::Wells& wsrpt,
540 const MswTracerRates& mswTracerRates,
541 const unsigned reportStep) const;
542
543 void assignMassGasRate(data::Wells& wsrpt,
544 const Scalar gasDensity) const;
545
546 Schedule& schedule_;
547
548 const SummaryState& summaryState_;
549 const EclipseState& eclState_;
555
557 bool terminal_output_{false};
558 bool wells_active_{false};
561
562 std::optional<int> last_run_wellpi_{};
563
564 std::vector<Well> wells_ecl_;
565 std::vector<std::vector<PerforationData<Scalar>>> well_perf_data_;
566
567 // Times at which wells were opened (for WCYCLE)
568 std::map<std::string, double> well_open_times_;
569
570 // Times at which wells were shut (for WCYCLE)
571 std::map<std::string, double> well_close_times_;
572
573 std::vector<ConnectionIndexMap> conn_idx_map_{};
574 std::function<bool(const std::string&)> not_on_process_{};
575
576 // a vector of all the wells.
577 std::vector<WellInterfaceGeneric<Scalar, IndexTraits>*> well_container_generic_{};
578
579 std::vector<int> local_shut_wells_{};
580
581 // Sorted on well name. Held by pointer so that entries added for wells
582 // that appear mid-run (ACTIONX) do not invalidate references handed out
583 // earlier, e.g. those held by the well container and the well state.
584 std::vector<std::unique_ptr<ParallelWellInfo<Scalar>>> parallel_well_info_;
585 std::vector<std::reference_wrapper<ParallelWellInfo<Scalar>>> local_parallel_well_info_;
586
587 std::vector<WellProdIndexCalculator<Scalar>> prod_index_calc_;
588
589 std::vector<int> pvt_region_idx_;
590
591 mutable std::unordered_set<std::string> closed_this_step_;
592
593 GuideRate guideRate_;
594 std::unique_ptr<VFPProperties<Scalar, IndexTraits>> vfp_properties_{};
595
596 // previous injection multiplier, it is used in the injection multiplier calculation for WINJMULT keyword
597 std::unordered_map<std::string, std::vector<Scalar>> prev_inj_multipliers_;
598
599 // Handling for filter cake injection multipliers
600 std::unordered_map<std::string, WellFilterCake<Scalar, IndexTraits>> filter_cake_;
601
602 /*
603 The various wellState members should be accessed and modified
604 through the accessor functions wellState(), prevWellState(),
605 commitWellState(), resetWellState(), nupcolWellState() and
606 updateNupcolWGState().
607 */
613
615
616 // Store maps of group name and new group controls for output
617 std::map<std::string, std::vector<Group::ProductionCMode>> switched_prod_groups_;
618 std::map<std::string, std::array<std::vector<Group::InjectionCMode>, 3>> switched_inj_groups_;
619 // Store map of group name and close offending well for output
620 std::map<std::string, std::pair<std::string, std::string>> closed_offending_wells_;
621
623
624 bool allConnectionsClosed(const Well& well_ecl) const;
625
626private:
627 WellInterfaceGeneric<Scalar, IndexTraits>* getGenWell(const std::string& well_name);
628
629 template <typename Iter, typename Body>
630 void wellUpdateLoop(Iter first, Iter last, const int timeStepIdx, Body&& body);
631
632 void updateEclWellsConstraints(const int timeStepIdx,
633 const SimulatorUpdate& sim_update,
634 const SummaryState& st);
635
636 void updateEclWellsCTFFromAction(const int timeStepIdx,
637 const SimulatorUpdate& sim_update);
638
652 template <typename Predicate>
653 bool parallelWellSatisfies(const std::string& wname, Predicate&& p) const
654 {
655 const auto* pwInfo = this->findParallelWellInfo(wname);
656
657 return (pwInfo != nullptr) && p(*pwInfo);
658 }
659
675 template <typename LoopBody>
676 void loopOwnedWells(LoopBody&& loopBody) const;
677};
678
679} // namespace Opm
680
681#endif
Definition: BlackoilWellModelGasLift.hpp:42
Class for handling the blackoil well model.
Definition: BlackoilWellModelGeneric.hpp:98
BlackoilWellModelWBP< Scalar, IndexTraits > wbp_
Definition: BlackoilWellModelGeneric.hpp:554
void assignMswTracerRates(data::Wells &wsrpt, const MswTracerRates &mswTracerRates, const unsigned reportStep) const
bool wellStructureChangedDynamically_
Definition: BlackoilWellModelGeneric.hpp:614
void updateNupcolWGState()
Definition: BlackoilWellModelGeneric.hpp:387
const BlackoilWellModelGenericParameters< Scalar > param_
Definition: BlackoilWellModelGeneric.hpp:551
bool isOwner(const std::string &wname) const
Definition: BlackoilWellModelGeneric.hpp:278
std::map< std::string, double > well_open_times_
Definition: BlackoilWellModelGeneric.hpp:568
bool initial_step_
Definition: BlackoilWellModelGeneric.hpp:559
void updateInjFCMult(DeferredLogger &deferred_logger)
GroupStateHelperType & groupStateHelper()
Definition: BlackoilWellModelGeneric.hpp:293
std::vector< ConnectionIndexMap > conn_idx_map_
Definition: BlackoilWellModelGeneric.hpp:573
GroupState< Scalar > & groupState()
Definition: BlackoilWellModelGeneric.hpp:186
std::vector< std::vector< PerforationData< Scalar > > > well_perf_data_
Definition: BlackoilWellModelGeneric.hpp:565
virtual int compressedIndexForInteriorLGR(const std::string &lgr_tag, const Connection &conn) const
Definition: BlackoilWellModelGeneric.hpp:114
GuideRate & guideRate()
Definition: BlackoilWellModelGeneric.hpp:234
bool forceShutWellByName(const std::string &wellname, const double simulation_time, const bool dont_shut_grup_wells)
WellState< Scalar, IndexTraits > & nupcolWellState()
Definition: BlackoilWellModelGeneric.hpp:182
void updateWsolvent(const Group &group, const int reportStepIdx, const WellState< Scalar, IndexTraits > &wellState)
const EclipseState & eclState_
Definition: BlackoilWellModelGeneric.hpp:549
const GroupState< Scalar > & groupState() const
Definition: BlackoilWellModelGeneric.hpp:147
Scalar wellPI(const int well_index) const
std::vector< std::unique_ptr< ParallelWellInfo< Scalar > > > parallel_well_info_
Definition: BlackoilWellModelGeneric.hpp:584
const VFPProperties< Scalar, IndexTraits > & getVFPProperties() const
Definition: BlackoilWellModelGeneric.hpp:305
virtual ~BlackoilWellModelGeneric()=default
std::vector< int > pvt_region_idx_
Definition: BlackoilWellModelGeneric.hpp:589
virtual void calcInjResvCoeff(const int fipnum, const int pvtreg, std::vector< Scalar > &resv_coeff) const =0
const WellState< Scalar, IndexTraits > & prevWellState() const
Definition: BlackoilWellModelGeneric.hpp:349
const ConnectionIndexMap & connectionIndexMap(const std::size_t idx)
Definition: BlackoilWellModelGeneric.hpp:290
const WellTestState & wellTestState() const
Definition: BlackoilWellModelGeneric.hpp:190
const WellGroupEvents & reportStepStartEvents() const
Definition: BlackoilWellModelGeneric.hpp:238
const Well & getWellEcl(const std::string &well_name) const
WGState< Scalar, IndexTraits > nupcol_wgstate_
Definition: BlackoilWellModelGeneric.hpp:610
ParallelWellInfo< Scalar > * findParallelWellInfo(const std::string &wname)
Look up a well's parallel well information for modification.
void updateAndCommunicateGroupData(const int reportStepIdx, const bool update_wellgrouptarget)
GuideRate guideRate_
Definition: BlackoilWellModelGeneric.hpp:593
const ParallelWellInfo< Scalar > & parallelWellInfo(const std::size_t idx) const
Definition: BlackoilWellModelGeneric.hpp:275
void updateClosedWellsThisStep(const std::string &well_name) const
Definition: BlackoilWellModelGeneric.hpp:244
const SummaryState & summaryState_
Definition: BlackoilWellModelGeneric.hpp:548
std::function< bool(const std::string &)> not_on_process_
Definition: BlackoilWellModelGeneric.hpp:574
std::map< std::string, double > well_close_times_
Definition: BlackoilWellModelGeneric.hpp:571
std::vector< Well > wells_ecl_
Definition: BlackoilWellModelGeneric.hpp:564
void checkGEconLimits(const Group &group, const double simulation_time, const int report_step_idx, DeferredLogger &deferred_logger)
void calculateEfficiencyFactors(const int reportStepIdx)
void assignWellTargets(data::Wells &wsrpt) const
void assignDynamicWellStatus(data::Wells &wsrpt) const
const std::vector< Well > & eclWells() const
Definition: BlackoilWellModelGeneric.hpp:137
Schedule & schedule_
Definition: BlackoilWellModelGeneric.hpp:546
const std::map< std::string, double > & wellCloseTimes() const
Definition: BlackoilWellModelGeneric.hpp:237
void assignGroupControl(const Group &group, data::GroupData &gdata) const
const std::map< std::string, double > & wellOpenTimes() const
Definition: BlackoilWellModelGeneric.hpp:236
std::vector< int > getCellsForConnections(const Well &well) const
const ParallelWellInfo< Scalar > * findParallelWellInfo(const std::string &wname) const
Look up a well's parallel well information.
std::unique_ptr< VFPProperties< Scalar, IndexTraits > > vfp_properties_
Definition: BlackoilWellModelGeneric.hpp:594
void updateWellPotentials(const int reportStepIdx, const bool onlyAfterEvent, const SummaryConfig &summaryConfig, DeferredLogger &deferred_logger)
virtual void computePotentials(const std::size_t widx, const WellState< Scalar, IndexTraits > &well_state_copy, std::string &exc_msg, ExceptionType::ExcEnum &exc_type)=0
virtual void createWellContainer(const int time_step)=0
const EclipseState & eclipseState() const
Definition: BlackoilWellModelGeneric.hpp:229
const NewtonIterationContext & iterationContext() const
Definition: BlackoilWellModelGeneric.hpp:315
const WellState< Scalar, IndexTraits > & nupcolWellState() const
Definition: BlackoilWellModelGeneric.hpp:178
void checkGconsaleLimits(const Group &group, WellState< Scalar, IndexTraits > &well_state, const int reportStepIdx, DeferredLogger &deferred_logger)
BlackoilWellModelGeneric(Schedule &schedule, BlackoilWellModelGasLiftGeneric< Scalar, IndexTraits > &gaslift, BlackoilWellModelNetworkGeneric< Scalar, IndexTraits > &network, const SummaryState &summaryState, const EclipseState &eclState, const PhaseUsageInfo< IndexTraits > &phase_usage, const Parallel::Communication &comm, const NewtonIterationContext &iter_ctx)
bool allConnectionsClosed(const Well &well_ecl) const
bool hasLocalWell(const std::string &wname) const
Returns true if well is defined and has connections on current rank.
void registerNewParallelWells(int reportStepIdx)
Add parallel well information for wells that entered the model after start-up.
std::unordered_map< int, std::vector< WellTracerRate< Scalar > > > WellTracerRates
Definition: BlackoilWellModelGeneric.hpp:533
std::unordered_set< std::string > closed_this_step_
Definition: BlackoilWellModelGeneric.hpp:591
bool hasOpenLocalWell(const std::string &well_name) const
Returns true if well is defined, open and has connections on current rank.
std::vector< std::vector< int > > getMaxWellConnections() const
bool reportStepStarts() const
Definition: BlackoilWellModelGeneric.hpp:242
void resetWGState()
Definition: BlackoilWellModelGeneric.hpp:374
void updateFiltrationModelsPostStep(const double dt, const std::size_t water_index, DeferredLogger &deferred_logger)
const GroupStateHelperType & groupStateHelper() const
Definition: BlackoilWellModelGeneric.hpp:294
GroupStateHelperType group_state_helper_
Definition: BlackoilWellModelGeneric.hpp:611
const SummaryState & summaryState() const
Definition: BlackoilWellModelGeneric.hpp:231
WellState< Scalar, IndexTraits > & wellState()
Definition: BlackoilWellModelGeneric.hpp:165
std::map< std::string, std::array< std::vector< Group::InjectionCMode >, 3 > > switched_inj_groups_
Definition: BlackoilWellModelGeneric.hpp:618
bool terminalOutput() const
Definition: BlackoilWellModelGeneric.hpp:140
void runWellPIScaling(const int reportStepIdx, DeferredLogger &local_deferredLogger)
bool wells_active_
Definition: BlackoilWellModelGeneric.hpp:558
const PhaseUsageInfo< IndexTraits > & phaseUsage() const
Definition: BlackoilWellModelGeneric.hpp:146
void updateInjMult(DeferredLogger &deferred_logger)
const Parallel::Communication & comm_
Definition: BlackoilWellModelGeneric.hpp:550
WellTestState & wellTestState()
Definition: BlackoilWellModelGeneric.hpp:188
const std::vector< PerforationData< Scalar > > & perfData(const int well_idx) const
Definition: BlackoilWellModelGeneric.hpp:224
WGState< Scalar, IndexTraits > last_valid_wgstate_
Definition: BlackoilWellModelGeneric.hpp:609
const WGState< Scalar, IndexTraits > & prevWGState() const
Definition: BlackoilWellModelGeneric.hpp:354
void updateEclWells(const int timeStepIdx, const SimulatorUpdate &sim_update, const SummaryState &st)
std::vector< std::reference_wrapper< ParallelWellInfo< Scalar > > > local_parallel_well_info_
Definition: BlackoilWellModelGeneric.hpp:585
bool hasLocalCells(const std::string &wname) const
Definition: BlackoilWellModelGeneric.hpp:284
void commitWGState(WGState< Scalar, IndexTraits > wgstate)
Definition: BlackoilWellModelGeneric.hpp:364
void reportGroupSwitching(DeferredLogger &local_deferredLogger) const
bool wellsActive() const
return true if wells are available in the reservoir
const GuideRate & guideRate() const
Definition: BlackoilWellModelGeneric.hpp:233
std::map< std::string, std::vector< Group::ProductionCMode > > switched_prod_groups_
Definition: BlackoilWellModelGeneric.hpp:617
void assignMassGasRate(data::Wells &wsrpt, const Scalar gasDensity) const
std::vector< const WellInterfaceGeneric< Scalar, IndexTraits > * > genericWells() const
Definition: BlackoilWellModelGeneric.hpp:148
virtual int compressedIndexForInterior(int cartesian_cell_idx) const =0
get compressed index for interior cells (-1, otherwise
virtual void calculateProductivityIndexValuesShutWells(const int reportStepIdx, DeferredLogger &deferred_logger)=0
std::vector< std::string > getWellsForTesting(const int timeStepIdx, const double simulationTime)
std::unordered_map< std::string, std::vector< Scalar > > prev_inj_multipliers_
Definition: BlackoilWellModelGeneric.hpp:597
const WellState< Scalar, IndexTraits > & wellState() const
Definition: BlackoilWellModelGeneric.hpp:157
const Schedule & schedule() const
Definition: BlackoilWellModelGeneric.hpp:145
bool operator==(const BlackoilWellModelGeneric &rhs) const
virtual void calcResvCoeff(const int fipnum, const int pvtreg, const std::vector< Scalar > &production_rates, std::vector< Scalar > &resv_coeff) const =0
std::vector< WellInterfaceGeneric< Scalar, IndexTraits > * > well_container_generic_
Definition: BlackoilWellModelGeneric.hpp:577
void assignInjectionWellTargets(const Well &well, data::WellControlLimits &limits) const
const NewtonIterationContext & iter_ctx_
Definition: BlackoilWellModelGeneric.hpp:552
bool checkGroupHigherConstraints(const Group &group, DeferredLogger &deferred_logger, const int reportStepIdx, const bool update_group_switching_log)
Scalar wellPI(const std::string &well_name) const
const Parallel::Communication & comm() const
Definition: BlackoilWellModelGeneric.hpp:227
std::vector< int > local_shut_wells_
Definition: BlackoilWellModelGeneric.hpp:579
std::unordered_map< int, std::vector< MSWellTracerRate< Scalar > > > MswTracerRates
Definition: BlackoilWellModelGeneric.hpp:538
std::vector< WellProdIndexCalculator< Scalar > > prod_index_calc_
Definition: BlackoilWellModelGeneric.hpp:587
std::unordered_map< std::string, WellFilterCake< Scalar, IndexTraits > > filter_cake_
Definition: BlackoilWellModelGeneric.hpp:600
BlackoilWellModelNetworkGeneric< Scalar, IndexTraits > & genNetwork_
Definition: BlackoilWellModelGeneric.hpp:622
data::GroupAndNetworkValues groupAndNetworkData(const int reportStepIdx) const
std::vector< std::reference_wrapper< ParallelWellInfo< Scalar > > > createLocalParallelWellInfo(const std::vector< Well > &wells)
Create the parallel well information.
void prepareDeserialize(int report_step, const std::size_t numCells, bool enable_distributed_wells)
std::vector< WellInterfaceGeneric< Scalar, IndexTraits > * > genericWells()
Definition: BlackoilWellModelGeneric.hpp:151
std::map< std::string, std::pair< std::string, std::string > > closed_offending_wells_
Definition: BlackoilWellModelGeneric.hpp:620
const PhaseUsageInfo< IndexTraits > & phase_usage_info_
Definition: BlackoilWellModelGeneric.hpp:556
bool wasDynamicallyShutThisTimeStep(const std::size_t well_index) const
void assignProductionWellTargets(const Well &well, data::WellControlLimits &limits) const
bool report_step_starts_
Definition: BlackoilWellModelGeneric.hpp:560
bool wasDynamicallyShutThisTimeStep(const std::string &well_name) const
std::optional< int > last_run_wellpi_
Definition: BlackoilWellModelGeneric.hpp:562
virtual void calculateProductivityIndexValues(DeferredLogger &deferred_logger)=0
const EclipseState & eclState() const
Definition: BlackoilWellModelGeneric.hpp:318
void assignWellTracerRates(data::Wells &wsrpt, const WellTracerRates &wellTracerRates, const unsigned reportStep) const
virtual void initWellContainer(const int reportStepIdx)=0
IndexTraitsT IndexTraits
Definition: BlackoilWellModelGeneric.hpp:102
ScalarT Scalar
Definition: BlackoilWellModelGeneric.hpp:101
bool terminal_output_
Definition: BlackoilWellModelGeneric.hpp:557
void initFromRestartFile(const RestartValue &restartValues, std::unique_ptr< WellTestState > wtestState, const std::size_t numCells, bool enable_distributed_wells)
WGState< Scalar, IndexTraits > active_wgstate_
Definition: BlackoilWellModelGeneric.hpp:608
void serializeOp(Serializer &serializer)
Definition: BlackoilWellModelGeneric.hpp:253
std::pair< int, int > getGroupFipnumAndPvtreg() const
void setWsolvent(const Group &group, const int reportStepIdx, Scalar wsolvent)
void updateFiltrationModelsPreStep(DeferredLogger &deferred_logger)
std::vector< Well > getLocalWells(const int timeStepIdx) const
void assignShutConnections(data::Wells &wsrpt, const int reportStepIndex) const
WellGroupEvents report_step_start_events_
Well group events at start of report step.
Definition: BlackoilWellModelGeneric.hpp:612
void assignGroupValues(const int reportStepIdx, std::map< std::string, data::GroupData > &gvalues) const
BlackoilWellModelGasLiftGeneric< Scalar, IndexTraits > & gen_gaslift_
Definition: BlackoilWellModelGeneric.hpp:553
Class for handling the blackoil well network model.
Definition: BlackoilWellModelNetworkGeneric.hpp:50
Class for handling the blackoil well model.
Definition: BlackoilWellModelWBP.hpp:42
Connection index mappings.
Definition: ConnectionIndexMap.hpp:33
Definition: DeferredLogger.hpp:57
void updateState(WellState< Scalar, IndexTraits > &well_state, GroupState< Scalar > &group_state)
Definition: GroupState.hpp:41
Class encapsulating some information about parallel wells.
Definition: ParallelWellInfo.hpp:198
Definition: GasLiftGroupInfo.hpp:38
Definition: VFPProperties.hpp:40
Definition: WellInterfaceGeneric.hpp:55
Definition: WellState.hpp:68
ExcEnum
Definition: DeferredLogger.hpp:45
Dune::Communication< MPIComm > Communication
Definition: ParallelCommunication.hpp:30
Definition: blackoilnewtonmethodparams.hpp:31
Definition: blackoilbioeffectsmodules.hh:45
Definition: BlackoilWellModelGenericParameters.hpp:39
Context for iteration-dependent decisions in the Newton solver.
Definition: NewtonIterationContext.hpp:43
Definition: BlackoilWellModelGeneric.hpp:89
static constexpr bool value
Definition: BlackoilWellModelGeneric.hpp:89
Definition: WGState.hpp:39