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
49
50#include <algorithm>
51#include <cstddef>
52#include <functional>
53#include <map>
54#include <memory>
55#include <optional>
56#include <string>
57#include <unordered_map>
58#include <unordered_set>
59#include <vector>
60
61
62namespace Opm {
63 class DeferredLogger;
64 class EclipseState;
65 template<typename Scalar, typename IndexTraits> class BlackoilWellModelGasLiftGeneric;
66 template<typename Scalar, typename IndexTraits> class BlackoilWellModelNetworkGeneric;
67 template<typename Scalar, typename IndexTraits> class GasLiftGroupInfo;
68 template<typename Scalar, typename IndexTraits> class GasLiftSingleWellGeneric;
69 template<class Scalar> class GasLiftWellState;
70 class Group;
71 class GuideRateConfig;
72 class RegionVariableCollection;
73 class RestartValue;
74 class Schedule;
75 struct SimulatorUpdate;
76 class SummaryConfig;
77 template<typename Scalar, typename IndexTraits> class VFPProperties;
78 template<typename Scalar, typename IndexTraits> class WellInterfaceGeneric;
79 template<typename Scalar, typename IndexTraits> class WellState;
80} // namespace Opm
81
82namespace Opm { namespace data {
83 struct GroupData;
84 struct GroupGuideRates;
85 class GroupAndNetworkValues;
86 struct NodeData;
87}} // namespace Opm::data
88
89namespace Opm::Parameters {
90
91struct EnableTerminalOutput { static constexpr bool value = true; };
92
93} // namespace Opm::Parameters
94
95namespace Opm {
96
98template<typename ScalarT, typename IndexTraitsT>
100{
102public:
103 using Scalar = ScalarT;
104 using IndexTraits = IndexTraitsT;
105
109 const SummaryState& summaryState,
110 const EclipseState& eclState,
111 const PhaseUsageInfo<IndexTraits>& phase_usage,
113 const NewtonIterationContext& iter_ctx);
114
115 virtual ~BlackoilWellModelGeneric() = default;
116 virtual int compressedIndexForInteriorLGR([[maybe_unused]] const std::string& lgr_tag,
117 [[maybe_unused]] const Connection& conn) const
118 {
119 throw std::runtime_error("compressedIndexForInteriorLGR not implemented");
120 }
121
122 int numLocalWells() const;
123 int numLocalWellsEnd() const;
125 int numPhases() const;
126
128 bool wellsActive() const;
129
131 bool hasLocalWell(const std::string& wname) const;
132
134 bool hasOpenLocalWell(const std::string& well_name) const;
135
136 // whether there exists any multisegment well open on this process
137 bool anyMSWellOpenLocal() const;
138
139 const std::vector<Well>& eclWells() const
140 { return wells_ecl_; }
141
142 bool terminalOutput() const
143 { return terminal_output_; }
144
145 const Well& getWellEcl(const std::string& well_name) const;
146 std::vector<Well> getLocalWells(const int timeStepIdx) const;
147 const Schedule& schedule() const { return schedule_; }
149 const GroupState<Scalar>& groupState() const { return this->active_wgstate_.group_state; }
150 std::vector<const WellInterfaceGeneric<Scalar, IndexTraits>*> genericWells() const
151 { return {well_container_generic_.begin(), well_container_generic_.end()}; }
152
153 std::vector<WellInterfaceGeneric<Scalar, IndexTraits>*> genericWells()
154 { return well_container_generic_; }
155
156 /*
157 Immutable version of the currently active wellstate.
158 */
160 {
161 return this->active_wgstate_.well_state;
162 }
163
164 /*
165 Mutable version of the currently active wellstate.
166 */
168 {
169 return this->active_wgstate_.well_state;
170 }
171
172 /*
173 Will return the currently active nupcolWellState; must update
174 the internal nupcol wellstate with updateNupcolWGState() first.
175
176 Both const and non-const accessors are provided. The non-const
177 accessor is required for the WellStateGuard pattern and pushWellState()
178 in WellGroupHelper, which temporarily switches WellGroupHelper to use this state.
179 */
181 {
182 return this->nupcol_wgstate_.well_state;
183 }
185 {
186 return this->nupcol_wgstate_.well_state;
187 }
188 GroupState<Scalar>& groupState() { return this->active_wgstate_.group_state; }
189
190 WellTestState& wellTestState() { return this->active_wgstate_.well_test_state; }
191
192 const WellTestState& wellTestState() const { return this->active_wgstate_.well_test_state; }
193
194 Scalar wellPI(const int well_index) const;
195 Scalar wellPI(const std::string& well_name) const;
196
197 void updateEclWells(const int timeStepIdx,
198 const SimulatorUpdate& sim_update,
199 const SummaryState& st);
200
201 void initFromRestartFile(const RestartValue& restartValues,
202 std::unique_ptr<WellTestState> wtestState,
203 const std::size_t numCells,
204 bool enable_distributed_wells);
205
206 void prepareDeserialize(int report_step,
207 const std::size_t numCells,
208 bool enable_distributed_wells);
209
210 /*
211 Will assign the internal member last_valid_well_state_ to the
212 current value of the this->active_well_state_. The state stored
213 with storeWellState() can then subsequently be recovered with the
214 resetWellState() method.
215 */
217
218 data::GroupAndNetworkValues groupAndNetworkData(const int reportStepIdx) const;
219
220 // Snapshot dynamic state at start of timestep for failure recovery.
229 {
236 this->genNetwork_.commitState();
237 }
238 }
239
242 {
249 this->genNetwork_.resetState();
250 this->group_state_helper_.updateState(this->wellState(), this->groupState());
251 }
252 }
253
255 const std::size_t conn_opt_ix,
256 RegionVariableCollection& regVars) const;
259 bool forceShutWellByName(const std::string& wellname,
260 const double simulation_time,
261 const bool dont_shut_grup_wells);
262
263 const std::vector<PerforationData<Scalar>>& perfData(const int well_idx) const
264 { return well_perf_data_[well_idx]; }
265
266 const Parallel::Communication& comm() const { return comm_; }
267
268 const EclipseState& eclipseState() const { return eclState_; }
269
270 const SummaryState& summaryState() const { return summaryState_; }
271
272 const GuideRate& guideRate() const { return guideRate_; }
273 GuideRate& guideRate() { return guideRate_; }
274
275 const std::map<std::string, double>& wellOpenTimes() const { return well_open_times_; }
276 const std::map<std::string, double>& wellCloseTimes() const { return well_close_times_; }
277 const WellGroupEvents& reportStepStartEvents() const { return report_step_start_events_; }
278
279 std::vector<int> getCellsForConnections(const Well& well) const;
280
281 bool reportStepStarts() const { return report_step_starts_; }
282
283 void updateClosedWellsThisStep(const std::string& well_name) const
284 {
285 this->closed_this_step_.insert(well_name);
286 }
287 bool wasDynamicallyShutThisTimeStep(const std::string& well_name) const;
288
289 void logPrimaryVars() const;
290
291 template<class Serializer>
292 void serializeOp(Serializer& serializer)
293 {
294 serializer(initial_step_);
295 serializer(report_step_starts_);
296 serializer(last_run_wellpi_);
297 serializer(well_perf_data_);
298 serializer(local_shut_wells_);
299 serializer(closed_this_step_);
300 serializer(guideRate_);
301 serializer(genNetwork_);
302 serializer(prev_inj_multipliers_);
303 serializer(filter_cake_);
304 serializer(active_wgstate_);
305 serializer(last_valid_wgstate_);
306 serializer(nupcol_wgstate_);
307 serializer(switched_prod_groups_);
308 serializer(switched_inj_groups_);
309 serializer(closed_offending_wells_);
310 serializer(gen_gaslift_);
312 }
313
314 bool operator==(const BlackoilWellModelGeneric& rhs) const;
315
317 parallelWellInfo(const std::size_t idx) const
318 { return local_parallel_well_info_[idx].get(); }
319
320 bool isOwner(const std::string& wname) const
321 {
322 return this->parallelWellSatisfies
323 (wname, [](const auto& pwInfo) { return pwInfo.isOwner(); });
324 }
325
326 bool hasLocalCells(const std::string& wname) const
327 {
328 return this->parallelWellSatisfies
329 (wname, [](const auto& pwInfo) { return pwInfo.hasLocalCells(); });
330 }
331
332 const ConnectionIndexMap& connectionIndexMap(const std::size_t idx)
333 { return conn_idx_map_[idx]; }
334
337 std::pair<int, int> getGroupFipnumAndPvtreg() const;
338
339 virtual void calcResvCoeff(const int fipnum,
340 const int pvtreg,
341 const std::vector<Scalar>& production_rates,
342 std::vector<Scalar>& resv_coeff) const = 0;
343 virtual void calcInjResvCoeff(const int fipnum,
344 const int pvtreg,
345 std::vector<Scalar>& resv_coeff) const = 0;
346
348 {
349 return *vfp_properties_;
350 }
351
352 void updateAndCommunicateGroupData(const int reportStepIdx,
353 // we only want to update the wellgroup target
354 // after the groups have found their controls
355 const bool update_wellgrouptarget);
356
358 { return iter_ctx_; }
359
360 const EclipseState& eclState() const
361 { return eclState_; }
362
363protected:
364 /*
365 The dynamic state of the well model is maintained with an instance
366 of the WellState class. Currently we have
367 three different wellstate instances:
368
369 1. The currently active wellstate is in the active_well_state_
370 member. That is the state which is mutated by the simulator.
371
372 2. In the case timestep fails to converge and we must go back and
373 try again with a smaller timestep we need to recover the last
374 valid wellstate. This is maintained with the
375 last_valid_well_state_ member and the functions
376 commitWGState() and resetWellState().
377
378 3. For the NUPCOL functionality we should either use the
379 currently active wellstate or a wellstate frozen at max
380 nupcol iterations. This is handled with the member
381 nupcol_well_state_ and the updateNupcolWGState() function.
382 */
383
384 /*
385 Will return the last good wellstate. This is typcially used when
386 initializing a new report step where the Schedule object might
387 have introduced new wells. The wellstate returned by
388 prevWellState() must have been stored with the commitWGState()
389 function first.
390 */
392 {
393 return this->last_valid_wgstate_.well_state;
394 }
395
397 {
398 return this->last_valid_wgstate_;
399 }
400
401 /*
402 Will store a copy of the input argument well_state in the
403 last_valid_well_state_ member, that state can then be recovered
404 with a subsequent call to resetWellState().
405 */
407 {
408 this->last_valid_wgstate_ = std::move(wgstate);
409 }
410
411 /*
412 Will update the internal variable active_well_state_ to whatever
413 was stored in the last_valid_well_state_ member. This function
414 works in pair with commitWellState() which should be called first.
415 */
417 {
419 this->genNetwork_.resetState();
420 // Update helper pointers to reference the restored active state
421 this->group_state_helper_.updateState(this->wellState(), this->groupState());
422 }
423
424 /*
425 Will store the current active wellstate in the nupcol_well_state_
426 member. This can then be subsequently retrieved with accessor
427 nupcolWellState().
428 */
430 {
431 this->nupcol_wgstate_ = this->active_wgstate_;
432 }
433
434 void reportGroupSwitching(DeferredLogger& local_deferredLogger) const;
435
438 std::vector<std::reference_wrapper<ParallelWellInfo<Scalar>>>
439 createLocalParallelWellInfo(const std::vector<Well>& wells);
440
445 const ParallelWellInfo<Scalar>* findParallelWellInfo(const std::string& wname) const;
446
456
470 void registerNewParallelWells(int reportStepIdx);
473
474 bool wasDynamicallyShutThisTimeStep(const std::size_t well_index) const;
475
476 void updateWsolvent(const Group& group,
477 const int reportStepIdx,
479 void setWsolvent(const Group& group,
480 const int reportStepIdx,
481 Scalar wsolvent);
482
487 void assignDynamicWellStatus(data::Wells& wsrpt) const;
488
494 void assignWellPerformanceEventTracker(data::Wells& wsrpt) const;
495
502
514 void assignShutConnections(data::Wells& wsrpt,
515 const int reportStepIndex) const;
516
517 void assignWellTargets(data::Wells& wsrpt) const;
518 void assignProductionWellTargets(const Well& well, data::WellControlLimits& limits) const;
519 void assignInjectionWellTargets(const Well& well, data::WellControlLimits& limits) const;
520
521 void assignGroupControl(const Group& group,
522 data::GroupData& gdata) const;
523 void assignGroupValues(const int reportStepIdx,
524 std::map<std::string, data::GroupData>& gvalues) const;
525
526 void calculateEfficiencyFactors(const int reportStepIdx);
527
528 void checkGconsaleLimits(const Group& group,
530 const int reportStepIdx,
531 DeferredLogger& deferred_logger);
532
533 void checkGEconLimits(const Group& group,
534 const double simulation_time,
535 const int report_step_idx,
536 DeferredLogger& deferred_logger);
537
538 bool checkGroupHigherConstraints(const Group& group,
539 DeferredLogger& deferred_logger,
540 const int reportStepIdx,
541 const bool update_group_switching_log);
542
544
546
547 virtual void computePotentials(const std::size_t widx,
548 const WellState<Scalar, IndexTraits>& well_state_copy,
549 std::string& exc_msg,
550 ExceptionType::ExcEnum& exc_type) = 0;
551
552 // Calculating well potentials for each well
553 void updateWellPotentials(const int reportStepIdx,
554 const bool onlyAfterEvent,
555 const SummaryConfig& summaryConfig,
556 DeferredLogger& deferred_logger);
557
559
560 void updateInjMult(DeferredLogger& deferred_logger);
561 void updateInjFCMult(DeferredLogger& deferred_logger);
562
563 void updateFiltrationModelsPostStep(const double dt,
564 const std::size_t water_index,
565 DeferredLogger& deferred_logger);
566
568
569 // create the well container
570 virtual void createWellContainer(const int time_step) = 0;
571 virtual void initWellContainer(const int reportStepIdx) = 0;
572
573 virtual void calculateProductivityIndexValuesShutWells(const int reportStepIdx,
574 DeferredLogger& deferred_logger) = 0;
575 virtual void calculateProductivityIndexValues(DeferredLogger& deferred_logger) = 0;
576
577 void runWellPIScaling(const int reportStepIdx,
578 DeferredLogger& local_deferredLogger);
579
581 virtual int compressedIndexForInterior(int cartesian_cell_idx) const = 0;
582
583 std::vector<std::vector<int>> getMaxWellConnections() const;
584
585 std::vector<std::string> getWellsForTesting(const int timeStepIdx,
586 const double simulationTime);
587
588 using WellTracerRates = std::unordered_map<int, std::vector<WellTracerRate<Scalar>>>;
589 void assignWellTracerRates(data::Wells& wsrpt,
590 const WellTracerRates& wellTracerRates,
591 const unsigned reportStep) const;
592
593 using MswTracerRates = std::unordered_map<int, std::vector<MSWellTracerRate<Scalar>>>;
594 void assignMswTracerRates(data::Wells& wsrpt,
595 const MswTracerRates& mswTracerRates,
596 const unsigned reportStep) const;
597
598 void assignMassGasRate(data::Wells& wsrpt,
599 const Scalar gasDensity) const;
600
601 Schedule& schedule_;
602
603 const SummaryState& summaryState_;
604 const EclipseState& eclState_;
610
612 bool terminal_output_{false};
613 bool wells_active_{false};
617
618 std::optional<int> last_run_wellpi_{};
619
620 std::vector<Well> wells_ecl_;
621 std::vector<std::vector<PerforationData<Scalar>>> well_perf_data_;
622
623 // Times at which wells were opened (for WCYCLE)
624 std::map<std::string, double> well_open_times_;
625
626 // Times at which wells were shut (for WCYCLE)
627 std::map<std::string, double> well_close_times_;
628
629 std::vector<ConnectionIndexMap> conn_idx_map_{};
630 std::function<bool(const std::string&)> not_on_process_{};
631
632 // a vector of all the wells.
633 std::vector<WellInterfaceGeneric<Scalar, IndexTraits>*> well_container_generic_{};
634
635 std::vector<int> local_shut_wells_{};
636
637 // Sorted on well name. Held by pointer so that entries added for wells
638 // that appear mid-run (ACTIONX) do not invalidate references handed out
639 // earlier, e.g. those held by the well container and the well state.
640 std::vector<std::unique_ptr<ParallelWellInfo<Scalar>>> parallel_well_info_;
641 std::vector<std::reference_wrapper<ParallelWellInfo<Scalar>>> local_parallel_well_info_;
642
643 std::vector<WellProdIndexCalculator<Scalar>> prod_index_calc_;
644
645 std::vector<int> pvt_region_idx_;
646
647 mutable std::unordered_set<std::string> closed_this_step_;
648
650
651 GuideRate guideRate_;
652 std::unique_ptr<VFPProperties<Scalar, IndexTraits>> vfp_properties_{};
653
654 // previous injection multiplier, it is used in the injection multiplier calculation for WINJMULT keyword
655 std::unordered_map<std::string, std::vector<Scalar>> prev_inj_multipliers_;
656
657 // Handling for filter cake injection multipliers
658 std::unordered_map<std::string, WellFilterCake<Scalar, IndexTraits>> filter_cake_;
659
660 /*
661 The various wellState members should be accessed and modified
662 through the accessor functions wellState(), prevWellState(),
663 commitWellState(), resetWellState(), nupcolWellState() and
664 updateNupcolWGState().
665 */
669
676 {
678 : wgstate(pu), nupcol_wgstate(pu)
679 {}
680
683 std::unordered_set<std::string> closed_this_step;
684 std::map<std::string, double> well_open_times;
685 std::map<std::string, double> well_close_times;
686 };
687
691
693
694 // Store maps of group name and new group controls for output
695 std::map<std::string, std::vector<Group::ProductionCMode>> switched_prod_groups_;
696 std::map<std::string, std::array<std::vector<Group::InjectionCMode>, 3>> switched_inj_groups_;
697 // Store map of group name and close offending well for output
698 std::map<std::string, std::pair<std::string, std::string>> closed_offending_wells_;
699
702
705 WellStatus closedWellStatus(const Well& well_ecl) const;
706
707private:
708 WellInterfaceGeneric<Scalar, IndexTraits>* getGenWell(const std::string& well_name);
709
710 template <typename Iter, typename Body>
711 void wellUpdateLoop(Iter first, Iter last, const int timeStepIdx, Body&& body);
712
713 void updateEclWellsConstraints(const int timeStepIdx,
714 const SimulatorUpdate& sim_update,
715 const SummaryState& st);
716
717 void updateEclWellsCTFFromAction(const int timeStepIdx,
718 const SimulatorUpdate& sim_update);
719
733 template <typename Predicate>
734 bool parallelWellSatisfies(const std::string& wname, Predicate&& p) const
735 {
736 const auto* pwInfo = this->findParallelWellInfo(wname);
737
738 return (pwInfo != nullptr) && p(*pwInfo);
739 }
740
756 template <typename LoopBody>
757 void loopOwnedWells(LoopBody&& loopBody) const;
758};
759
760} // namespace Opm
761
762#endif
Definition: BlackoilWellModelGasLift.hpp:42
Class for handling the blackoil well model.
Definition: BlackoilWellModelGeneric.hpp:100
BlackoilWellModelWBP< Scalar, IndexTraits > wbp_
Definition: BlackoilWellModelGeneric.hpp:609
void assignMswTracerRates(data::Wells &wsrpt, const MswTracerRates &mswTracerRates, const unsigned reportStep) const
bool wellStructureChangedDynamically_
Definition: BlackoilWellModelGeneric.hpp:692
void updateNupcolWGState()
Definition: BlackoilWellModelGeneric.hpp:429
const BlackoilWellModelGenericParameters< Scalar > param_
Definition: BlackoilWellModelGeneric.hpp:606
bool isOwner(const std::string &wname) const
Definition: BlackoilWellModelGeneric.hpp:320
std::map< std::string, double > well_open_times_
Definition: BlackoilWellModelGeneric.hpp:624
bool initial_step_
Definition: BlackoilWellModelGeneric.hpp:614
void updateInjFCMult(DeferredLogger &deferred_logger)
GroupStateHelperType & groupStateHelper()
Definition: BlackoilWellModelGeneric.hpp:335
std::vector< ConnectionIndexMap > conn_idx_map_
Definition: BlackoilWellModelGeneric.hpp:629
GroupState< Scalar > & groupState()
Definition: BlackoilWellModelGeneric.hpp:188
std::vector< std::vector< PerforationData< Scalar > > > well_perf_data_
Definition: BlackoilWellModelGeneric.hpp:621
virtual int compressedIndexForInteriorLGR(const std::string &lgr_tag, const Connection &conn) const
Definition: BlackoilWellModelGeneric.hpp:116
GuideRate & guideRate()
Definition: BlackoilWellModelGeneric.hpp:273
bool forceShutWellByName(const std::string &wellname, const double simulation_time, const bool dont_shut_grup_wells)
WellState< Scalar, IndexTraits > & nupcolWellState()
Definition: BlackoilWellModelGeneric.hpp:184
void updateWsolvent(const Group &group, const int reportStepIdx, const WellState< Scalar, IndexTraits > &wellState)
const EclipseState & eclState_
Definition: BlackoilWellModelGeneric.hpp:604
bool enable_state_rollback_
Definition: BlackoilWellModelGeneric.hpp:701
const GroupState< Scalar > & groupState() const
Definition: BlackoilWellModelGeneric.hpp:149
Scalar wellPI(const int well_index) const
std::vector< std::unique_ptr< ParallelWellInfo< Scalar > > > parallel_well_info_
Definition: BlackoilWellModelGeneric.hpp:640
const VFPProperties< Scalar, IndexTraits > & getVFPProperties() const
Definition: BlackoilWellModelGeneric.hpp:347
virtual ~BlackoilWellModelGeneric()=default
std::vector< int > pvt_region_idx_
Definition: BlackoilWellModelGeneric.hpp:645
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:391
const ConnectionIndexMap & connectionIndexMap(const std::size_t idx)
Definition: BlackoilWellModelGeneric.hpp:332
const WellTestState & wellTestState() const
Definition: BlackoilWellModelGeneric.hpp:192
const WellGroupEvents & reportStepStartEvents() const
Definition: BlackoilWellModelGeneric.hpp:277
const Well & getWellEcl(const std::string &well_name) const
WGState< Scalar, IndexTraits > nupcol_wgstate_
Definition: BlackoilWellModelGeneric.hpp:668
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)
WellStatusSnapshot wellStatusSnapshot() const
GuideRate guideRate_
Definition: BlackoilWellModelGeneric.hpp:651
const ParallelWellInfo< Scalar > & parallelWellInfo(const std::size_t idx) const
Definition: BlackoilWellModelGeneric.hpp:317
void updateClosedWellsThisStep(const std::string &well_name) const
Definition: BlackoilWellModelGeneric.hpp:283
const SummaryState & summaryState_
Definition: BlackoilWellModelGeneric.hpp:603
std::function< bool(const std::string &)> not_on_process_
Definition: BlackoilWellModelGeneric.hpp:630
std::map< std::string, double > well_close_times_
Definition: BlackoilWellModelGeneric.hpp:627
std::vector< Well > wells_ecl_
Definition: BlackoilWellModelGeneric.hpp:620
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:139
Schedule & schedule_
Definition: BlackoilWellModelGeneric.hpp:601
const std::map< std::string, double > & wellCloseTimes() const
Definition: BlackoilWellModelGeneric.hpp:276
WellPerformanceEventTracker well_performance_event_tracker_
Definition: BlackoilWellModelGeneric.hpp:649
void assignGroupControl(const Group &group, data::GroupData &gdata) const
const std::map< std::string, double > & wellOpenTimes() const
Definition: BlackoilWellModelGeneric.hpp:275
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:652
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:268
const NewtonIterationContext & iterationContext() const
Definition: BlackoilWellModelGeneric.hpp:357
const WellState< Scalar, IndexTraits > & nupcolWellState() const
Definition: BlackoilWellModelGeneric.hpp:180
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)
void updateFailed()
Restore the state captured at the start of the failing timestep.
Definition: BlackoilWellModelGeneric.hpp:241
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:588
void advanceTimeLevel()
Snapshot the mutable well-model state at the start of a timestep.
Definition: BlackoilWellModelGeneric.hpp:228
std::unordered_set< std::string > closed_this_step_
Definition: BlackoilWellModelGeneric.hpp:647
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:281
void resetWGState()
Definition: BlackoilWellModelGeneric.hpp:416
void updateFiltrationModelsPostStep(const double dt, const std::size_t water_index, DeferredLogger &deferred_logger)
const GroupStateHelperType & groupStateHelper() const
Definition: BlackoilWellModelGeneric.hpp:336
void assignWellPerformanceEventTracker(data::Wells &wsrpt) const
GroupStateHelperType group_state_helper_
Definition: BlackoilWellModelGeneric.hpp:689
const SummaryState & summaryState() const
Definition: BlackoilWellModelGeneric.hpp:270
WellState< Scalar, IndexTraits > & wellState()
Definition: BlackoilWellModelGeneric.hpp:167
std::map< std::string, std::array< std::vector< Group::InjectionCMode >, 3 > > switched_inj_groups_
Definition: BlackoilWellModelGeneric.hpp:696
bool terminalOutput() const
Definition: BlackoilWellModelGeneric.hpp:142
void runWellPIScaling(const int reportStepIdx, DeferredLogger &local_deferredLogger)
bool wells_active_
Definition: BlackoilWellModelGeneric.hpp:613
const PhaseUsageInfo< IndexTraits > & phaseUsage() const
Definition: BlackoilWellModelGeneric.hpp:148
void updateInjMult(DeferredLogger &deferred_logger)
const Parallel::Communication & comm_
Definition: BlackoilWellModelGeneric.hpp:605
WellTestState & wellTestState()
Definition: BlackoilWellModelGeneric.hpp:190
const std::vector< PerforationData< Scalar > > & perfData(const int well_idx) const
Definition: BlackoilWellModelGeneric.hpp:263
PrevTimestepState prev_timestep_state_
Definition: BlackoilWellModelGeneric.hpp:688
WGState< Scalar, IndexTraits > last_valid_wgstate_
Definition: BlackoilWellModelGeneric.hpp:667
const WGState< Scalar, IndexTraits > & prevWGState() const
Definition: BlackoilWellModelGeneric.hpp:396
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:641
bool hasLocalCells(const std::string &wname) const
Definition: BlackoilWellModelGeneric.hpp:326
void commitWGState(WGState< Scalar, IndexTraits > wgstate)
Definition: BlackoilWellModelGeneric.hpp:406
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:272
std::map< std::string, std::vector< Group::ProductionCMode > > switched_prod_groups_
Definition: BlackoilWellModelGeneric.hpp:695
void assignMassGasRate(data::Wells &wsrpt, const Scalar gasDensity) const
std::vector< const WellInterfaceGeneric< Scalar, IndexTraits > * > genericWells() const
Definition: BlackoilWellModelGeneric.hpp:150
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:655
const WellState< Scalar, IndexTraits > & wellState() const
Definition: BlackoilWellModelGeneric.hpp:159
void reportIntervalConnectionOilProduction(const double dt, const std::size_t conn_opt_ix, RegionVariableCollection &regVars) const
const Schedule & schedule() const
Definition: BlackoilWellModelGeneric.hpp:147
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:633
void assignInjectionWellTargets(const Well &well, data::WellControlLimits &limits) const
const NewtonIterationContext & iter_ctx_
Definition: BlackoilWellModelGeneric.hpp:607
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:266
std::vector< int > local_shut_wells_
Definition: BlackoilWellModelGeneric.hpp:635
std::unordered_map< int, std::vector< MSWellTracerRate< Scalar > > > MswTracerRates
Definition: BlackoilWellModelGeneric.hpp:593
std::vector< WellProdIndexCalculator< Scalar > > prod_index_calc_
Definition: BlackoilWellModelGeneric.hpp:643
std::unordered_map< std::string, WellFilterCake< Scalar, IndexTraits > > filter_cake_
Definition: BlackoilWellModelGeneric.hpp:658
BlackoilWellModelNetworkGeneric< Scalar, IndexTraits > & genNetwork_
Definition: BlackoilWellModelGeneric.hpp:700
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:153
std::map< std::string, std::pair< std::string, std::string > > closed_offending_wells_
Definition: BlackoilWellModelGeneric.hpp:698
const PhaseUsageInfo< IndexTraits > & phase_usage_info_
Definition: BlackoilWellModelGeneric.hpp:611
bool wasDynamicallyShutThisTimeStep(const std::size_t well_index) const
bool deserialized_state_pending_
Definition: BlackoilWellModelGeneric.hpp:616
void assignProductionWellTargets(const Well &well, data::WellControlLimits &limits) const
bool report_step_starts_
Definition: BlackoilWellModelGeneric.hpp:615
WellStatus closedWellStatus(const Well &well_ecl) const
bool wasDynamicallyShutThisTimeStep(const std::string &well_name) const
std::optional< int > last_run_wellpi_
Definition: BlackoilWellModelGeneric.hpp:618
virtual void calculateProductivityIndexValues(DeferredLogger &deferred_logger)=0
const EclipseState & eclState() const
Definition: BlackoilWellModelGeneric.hpp:360
void assignWellTracerRates(data::Wells &wsrpt, const WellTracerRates &wellTracerRates, const unsigned reportStep) const
virtual void initWellContainer(const int reportStepIdx)=0
IndexTraitsT IndexTraits
Definition: BlackoilWellModelGeneric.hpp:104
ScalarT Scalar
Definition: BlackoilWellModelGeneric.hpp:103
bool terminal_output_
Definition: BlackoilWellModelGeneric.hpp:612
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:666
void serializeOp(Serializer &serializer)
Definition: BlackoilWellModelGeneric.hpp:292
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:690
void assignGroupValues(const int reportStepIdx, std::map< std::string, data::GroupData > &gvalues) const
BlackoilWellModelGasLiftGeneric< Scalar, IndexTraits > & gen_gaslift_
Definition: BlackoilWellModelGeneric.hpp:608
Class for handling the blackoil well network model.
Definition: BlackoilWellModelNetworkGeneric.hpp:107
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:217
Definition: GasLiftGroupInfo.hpp:38
Definition: VFPProperties.hpp:40
Definition: WellInterfaceGeneric.hpp:59
Definition: WellPerformanceEventTracker.hpp:136
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
Well-model state as it was at the start of the current timestep.
Definition: BlackoilWellModelGeneric.hpp:676
WGState< Scalar, IndexTraits > nupcol_wgstate
NUPCOL: the state group control targets are computed from.
Definition: BlackoilWellModelGeneric.hpp:682
std::map< std::string, double > well_close_times
WCYCLE.
Definition: BlackoilWellModelGeneric.hpp:685
PrevTimestepState(const PhaseUsageInfo< IndexTraits > &pu)
Definition: BlackoilWellModelGeneric.hpp:677
std::map< std::string, double > well_open_times
WCYCLE.
Definition: BlackoilWellModelGeneric.hpp:684
std::unordered_set< std::string > closed_this_step
wells shut by the solver during this step
Definition: BlackoilWellModelGeneric.hpp:683
WGState< Scalar, IndexTraits > wgstate
well and group rates, pressures, controls
Definition: BlackoilWellModelGeneric.hpp:681
Definition: BlackoilWellModelGenericParameters.hpp:39
Context for iteration-dependent decisions in the Newton solver.
Definition: NewtonIterationContext.hpp:43
Definition: BlackoilWellModelGeneric.hpp:91
static constexpr bool value
Definition: BlackoilWellModelGeneric.hpp:91
Definition: WGState.hpp:39
Definition: WellPerformanceEventTracker.hpp:42