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 Events;
71 class Group;
72 class GuideRateConfig;
73 class RegionVariableCollection;
74 class RestartValue;
75 class Schedule;
76 struct SimulatorUpdate;
77 class SummaryConfig;
78 template<typename Scalar, typename IndexTraits> class VFPProperties;
79 template<typename Scalar, typename IndexTraits> class WellInterfaceGeneric;
80 template<typename Scalar, typename IndexTraits> class WellState;
81} // namespace Opm
82
83namespace Opm { namespace data {
84 struct GroupData;
85 struct GroupGuideRates;
86 class GroupAndNetworkValues;
87 struct NodeData;
88}} // namespace Opm::data
89
90namespace Opm::Parameters {
91
92struct EnableTerminalOutput { static constexpr bool value = true; };
93
94} // namespace Opm::Parameters
95
96namespace Opm {
97
99template<typename ScalarT, typename IndexTraitsT>
101{
103public:
104 using Scalar = ScalarT;
105 using IndexTraits = IndexTraitsT;
106
110 const SummaryState& summaryState,
111 const EclipseState& eclState,
112 const PhaseUsageInfo<IndexTraits>& phase_usage,
114 const NewtonIterationContext& iter_ctx);
115
116 virtual ~BlackoilWellModelGeneric() = default;
117 virtual int compressedIndexForInteriorLGR([[maybe_unused]] const std::string& lgr_tag,
118 [[maybe_unused]] const Connection& conn) const
119 {
120 throw std::runtime_error("compressedIndexForInteriorLGR not implemented");
121 }
122
123 int numLocalWells() const;
124 int numLocalWellsEnd() const;
126 int numPhases() const;
127
129 bool wellsActive() const;
130
132 bool hasLocalWell(const std::string& wname) const;
133
135 bool hasOpenLocalWell(const std::string& well_name) const;
136
137 // whether there exists any multisegment well open on this process
138 bool anyMSWellOpenLocal() const;
139
140 const std::vector<Well>& eclWells() const
141 { return wells_ecl_; }
142
143 bool terminalOutput() const
144 { return terminal_output_; }
145
146 const Well& getWellEcl(const std::string& well_name) const;
147 std::vector<Well> getLocalWells(const int timeStepIdx) const;
148 const Schedule& schedule() const { return schedule_; }
150 const GroupState<Scalar>& groupState() const { return this->active_wgstate_.group_state; }
151 std::vector<const WellInterfaceGeneric<Scalar, IndexTraits>*> genericWells() const
152 { return {well_container_generic_.begin(), well_container_generic_.end()}; }
153
154 std::vector<WellInterfaceGeneric<Scalar, IndexTraits>*> genericWells()
155 { return well_container_generic_; }
156
157 /*
158 Immutable version of the currently active wellstate.
159 */
161 {
162 return this->active_wgstate_.well_state;
163 }
164
165 /*
166 Mutable version of the currently active wellstate.
167 */
169 {
170 return this->active_wgstate_.well_state;
171 }
172
173 /*
174 Will return the currently active nupcolWellState; must update
175 the internal nupcol wellstate with updateNupcolWGState() first.
176
177 Both const and non-const accessors are provided. The non-const
178 accessor is required for the WellStateGuard pattern and pushWellState()
179 in WellGroupHelper, which temporarily switches WellGroupHelper to use this state.
180 */
182 {
183 return this->nupcol_wgstate_.well_state;
184 }
186 {
187 return this->nupcol_wgstate_.well_state;
188 }
189 GroupState<Scalar>& groupState() { return this->active_wgstate_.group_state; }
190
191 WellTestState& wellTestState() { return this->active_wgstate_.well_test_state; }
192
193 const WellTestState& wellTestState() const { return this->active_wgstate_.well_test_state; }
194
195 Scalar wellPI(const int well_index) const;
196 Scalar wellPI(const std::string& well_name) const;
197
198 void updateEclWells(const int timeStepIdx,
199 const SimulatorUpdate& sim_update,
200 const SummaryState& st);
201
202 void initFromRestartFile(const RestartValue& restartValues,
203 std::unique_ptr<WellTestState> wtestState,
204 const std::size_t numCells,
205 bool enable_distributed_wells);
206
207 void prepareDeserialize(int report_step,
208 const std::size_t numCells,
209 bool enable_distributed_wells);
210
211 /*
212 Will assign the internal member last_valid_well_state_ to the
213 current value of the this->active_well_state_. The state stored
214 with storeWellState() can then subsequently be recovered with the
215 resetWellState() method.
216 */
218
219 data::GroupAndNetworkValues groupAndNetworkData(const int reportStepIdx) const;
220
221 // Snapshot dynamic state at start of timestep for failure recovery.
230 {
237 this->genNetwork_.commitState();
238 }
239 }
240
243 {
250 this->genNetwork_.resetState();
251 this->group_state_helper_.updateState(this->wellState(), this->groupState());
252 }
253 }
254
256 const std::size_t conn_opt_ix,
257 RegionVariableCollection& regVars) const;
260 bool forceShutWellByName(const std::string& wellname,
261 const double simulation_time,
262 const bool dont_shut_grup_wells);
263
264 const std::vector<PerforationData<Scalar>>& perfData(const int well_idx) const
265 { return well_perf_data_[well_idx]; }
266
267 const Parallel::Communication& comm() const { return comm_; }
268
269 const EclipseState& eclipseState() const { return eclState_; }
270
271 const SummaryState& summaryState() const { return summaryState_; }
272
273 const GuideRate& guideRate() const { return guideRate_; }
274 GuideRate& guideRate() { return guideRate_; }
275
276 const std::map<std::string, double>& wellOpenTimes() const { return well_open_times_; }
277 const std::map<std::string, double>& wellCloseTimes() const { return well_close_times_; }
278 const WellGroupEvents& reportStepStartEvents() const { return report_step_start_events_; }
279
280 std::vector<int> getCellsForConnections(const Well& well) const;
281
282 bool reportStepStarts() const { return report_step_starts_; }
283
284 void updateClosedWellsThisStep(const std::string& well_name) const
285 {
286 this->closed_this_step_.insert(well_name);
287 }
288 bool wasDynamicallyShutThisTimeStep(const std::string& well_name) const;
289
291 bool wasClosedForRetry(const std::string& well_name) const
292 {
293 return this->retry_shut_wells_.count(well_name) != 0;
294 }
295
296 void logPrimaryVars() const;
297
298 template<class Serializer>
299 void serializeOp(Serializer& serializer)
300 {
301 serializer(initial_step_);
302 serializer(report_step_starts_);
303 serializer(last_run_wellpi_);
304 serializer(well_perf_data_);
305 serializer(local_shut_wells_);
306 serializer(closed_this_step_);
307 serializer(guideRate_);
308 serializer(genNetwork_);
309 serializer(prev_inj_multipliers_);
310 serializer(filter_cake_);
311 serializer(active_wgstate_);
312 serializer(last_valid_wgstate_);
313 serializer(nupcol_wgstate_);
314 serializer(switched_prod_groups_);
315 serializer(switched_inj_groups_);
316 serializer(closed_offending_wells_);
317 serializer(gen_gaslift_);
319 }
320
321 bool operator==(const BlackoilWellModelGeneric& rhs) const;
322
324 parallelWellInfo(const std::size_t idx) const
325 { return local_parallel_well_info_[idx].get(); }
326
327 bool isOwner(const std::string& wname) const
328 {
329 return this->parallelWellSatisfies
330 (wname, [](const auto& pwInfo) { return pwInfo.isOwner(); });
331 }
332
333 bool hasLocalCells(const std::string& wname) const
334 {
335 return this->parallelWellSatisfies
336 (wname, [](const auto& pwInfo) { return pwInfo.hasLocalCells(); });
337 }
338
339 const ConnectionIndexMap& connectionIndexMap(const std::size_t idx)
340 { return conn_idx_map_[idx]; }
341
344 std::pair<int, int> getGroupFipnumAndPvtreg() const;
345
346 virtual void calcResvCoeff(const int fipnum,
347 const int pvtreg,
348 const std::vector<Scalar>& production_rates,
349 std::vector<Scalar>& resv_coeff) const = 0;
350 virtual void calcInjResvCoeff(const int fipnum,
351 const int pvtreg,
352 std::vector<Scalar>& resv_coeff) const = 0;
353
355 {
356 return *vfp_properties_;
357 }
358
359 void updateAndCommunicateGroupData(const int reportStepIdx,
360 // we only want to update the wellgroup target
361 // after the groups have found their controls
362 const bool update_wellgrouptarget);
363
371 void updateGroupRatesFromWellState(const int reportStepIdx);
372
374 { return iter_ctx_; }
375
376 const EclipseState& eclState() const
377 { return eclState_; }
378
379protected:
380 /*
381 The dynamic state of the well model is maintained with an instance
382 of the WellState class. Currently we have
383 three different wellstate instances:
384
385 1. The currently active wellstate is in the active_well_state_
386 member. That is the state which is mutated by the simulator.
387
388 2. In the case timestep fails to converge and we must go back and
389 try again with a smaller timestep we need to recover the last
390 valid wellstate. This is maintained with the
391 last_valid_well_state_ member and the functions
392 commitWGState() and resetWellState().
393
394 3. For the NUPCOL functionality we should either use the
395 currently active wellstate or a wellstate frozen at max
396 nupcol iterations. This is handled with the member
397 nupcol_well_state_ and the updateNupcolWGState() function.
398 */
399
400 /*
401 Will return the last good wellstate. This is typcially used when
402 initializing a new report step where the Schedule object might
403 have introduced new wells. The wellstate returned by
404 prevWellState() must have been stored with the commitWGState()
405 function first.
406 */
408 {
409 return this->last_valid_wgstate_.well_state;
410 }
411
413 {
414 return this->last_valid_wgstate_;
415 }
416
417 /*
418 Will store a copy of the input argument well_state in the
419 last_valid_well_state_ member, that state can then be recovered
420 with a subsequent call to resetWellState().
421 */
423 {
424 this->last_valid_wgstate_ = std::move(wgstate);
425 }
426
427 /*
428 Will update the internal variable active_well_state_ to whatever
429 was stored in the last_valid_well_state_ member. This function
430 works in pair with commitWellState() which should be called first.
431 */
433 {
435 this->genNetwork_.resetState();
436 // Update helper pointers to reference the restored active state
437 this->group_state_helper_.updateState(this->wellState(), this->groupState());
438 }
439
440 /*
441 Will store the current active wellstate in the nupcol_well_state_
442 member. This can then be subsequently retrieved with accessor
443 nupcolWellState().
444 */
446 {
447 this->nupcol_wgstate_ = this->active_wgstate_;
448 }
449
450 void reportGroupSwitching(DeferredLogger& local_deferredLogger) const;
451
454 std::vector<std::reference_wrapper<ParallelWellInfo<Scalar>>>
455 createLocalParallelWellInfo(const std::vector<Well>& wells);
456
461 const ParallelWellInfo<Scalar>* findParallelWellInfo(const std::string& wname) const;
462
472
486 void registerNewParallelWells(int reportStepIdx);
489
490 bool wasDynamicallyShutThisTimeStep(const std::size_t well_index) const;
491
492 void updateWsolvent(const Group& group,
493 const int reportStepIdx,
495 void setWsolvent(const Group& group,
496 const int reportStepIdx,
497 Scalar wsolvent);
498
503 void assignDynamicWellStatus(data::Wells& wsrpt) const;
504
510 void assignWellPerformanceEventTracker(data::Wells& wsrpt) const;
511
518
530 void assignShutConnections(data::Wells& wsrpt,
531 const int reportStepIndex) const;
532
533 void assignWellTargets(data::Wells& wsrpt) const;
534 void assignProductionWellTargets(const Well& well, data::WellControlLimits& limits) const;
535 void assignInjectionWellTargets(const Well& well, data::WellControlLimits& limits) const;
536
537 void assignGroupControl(const Group& group,
538 data::GroupData& gdata) const;
539 void assignGroupValues(const int reportStepIdx,
540 std::map<std::string, data::GroupData>& gvalues) const;
541
542 void calculateEfficiencyFactors(const int reportStepIdx);
543
544 void checkGconsaleLimits(const Group& group,
546 const int reportStepIdx,
547 DeferredLogger& deferred_logger);
548
549 void checkGEconLimits(const Group& group,
550 const double simulation_time,
551 const int report_step_idx,
552 DeferredLogger& deferred_logger);
553
554 bool checkGroupHigherConstraints(const Group& group,
555 DeferredLogger& deferred_logger,
556 const int reportStepIdx,
557 const bool update_group_switching_log);
558
560
562
563 virtual void computePotentials(const std::size_t widx,
564 const WellState<Scalar, IndexTraits>& well_state_copy,
565 std::string& exc_msg,
566 ExceptionType::ExcEnum& exc_type) = 0;
567
568 // Calculating well potentials for each well
569 void updateWellPotentials(const int reportStepIdx,
570 const bool onlyAfterEvent,
571 const SummaryConfig& summaryConfig,
572 DeferredLogger& deferred_logger);
573
575
576 void updateInjMult(DeferredLogger& deferred_logger);
577 void updateInjFCMult(DeferredLogger& deferred_logger);
578
582 using InvBFunction = std::function<Scalar(int cell_index, unsigned canonical_phase)>;
583
584 void updateFiltrationModelsPostStep(const double dt,
585 const InvBFunction& inv_b,
586 DeferredLogger& deferred_logger);
587
589
590 // create the well container
591 virtual void createWellContainer(const int time_step) = 0;
592 virtual void initWellContainer(const int reportStepIdx) = 0;
593
594 virtual void calculateProductivityIndexValuesShutWells(const int reportStepIdx,
595 DeferredLogger& deferred_logger) = 0;
596 virtual void calculateProductivityIndexValues(DeferredLogger& deferred_logger) = 0;
597
598 void runWellPIScaling(const int reportStepIdx,
599 DeferredLogger& local_deferredLogger);
600
602 virtual int compressedIndexForInterior(int cartesian_cell_idx) const = 0;
603
604 std::vector<std::vector<int>> getMaxWellConnections() const;
605
606 std::vector<std::string> getWellsForTesting(const int timeStepIdx,
607 const double simulationTime);
608
609 using WellTracerRates = std::unordered_map<int, std::vector<WellTracerRate<Scalar>>>;
610 void assignWellTracerRates(data::Wells& wsrpt,
611 const WellTracerRates& wellTracerRates,
612 const unsigned reportStep) const;
613
614 using MswTracerRates = std::unordered_map<int, std::vector<MSWellTracerRate<Scalar>>>;
615 void assignMswTracerRates(data::Wells& wsrpt,
616 const MswTracerRates& mswTracerRates,
617 const unsigned reportStep) const;
618
619 void assignMassGasRate(data::Wells& wsrpt,
620 const Scalar gasDensity) const;
621
622 Schedule& schedule_;
623
624 const SummaryState& summaryState_;
625 const EclipseState& eclState_;
631
633 bool terminal_output_{false};
634 bool wells_active_{false};
638
639 std::optional<int> last_run_wellpi_{};
640
641 std::vector<Well> wells_ecl_;
642 std::vector<std::vector<PerforationData<Scalar>>> well_perf_data_;
643
644 // Times at which wells were opened (for WCYCLE)
645 std::map<std::string, double> well_open_times_;
646
647 // Times at which wells were shut (for WCYCLE)
648 std::map<std::string, double> well_close_times_;
649
650 std::vector<ConnectionIndexMap> conn_idx_map_{};
651 std::function<bool(const std::string&)> not_on_process_{};
652
653 // a vector of all the wells.
654 std::vector<WellInterfaceGeneric<Scalar, IndexTraits>*> well_container_generic_{};
655
656 std::vector<int> local_shut_wells_{};
657
658 // Sorted on well name. Held by pointer so that entries added for wells
659 // that appear mid-run (ACTIONX) do not invalidate references handed out
660 // earlier, e.g. those held by the well container and the well state.
661 std::vector<std::unique_ptr<ParallelWellInfo<Scalar>>> parallel_well_info_;
662 std::vector<std::reference_wrapper<ParallelWellInfo<Scalar>>> local_parallel_well_info_;
663
664 std::vector<WellProdIndexCalculator<Scalar>> prod_index_calc_;
665
666 std::vector<int> pvt_region_idx_;
667
668 mutable std::unordered_set<std::string> closed_this_step_;
669
670 // Wells force-shut between attempts of the current timestep. Deliberately
671 // retained across rollback, and cleared on timestep success. Unlike a
672 // timestamp, this distinguishes retry closures from restored closures and
673 // closures made at the end of the previous accepted timestep. Checkpoints
674 // are written after success, so this transient marker is not serialized.
675 std::unordered_set<std::string> retry_shut_wells_;
676
677 void closeWellForRetry(const std::string& well_name, double simulation_time);
678
681 void honorOpenRequest(const std::string& well_name,
682 Events& well_events,
683 double simulation_time);
684
686
687 GuideRate guideRate_;
688 std::unique_ptr<VFPProperties<Scalar, IndexTraits>> vfp_properties_{};
689
690 // previous injection multiplier, it is used in the injection multiplier calculation for WINJMULT keyword
691 std::unordered_map<std::string, std::vector<Scalar>> prev_inj_multipliers_;
692
693 // Handling for filter cake injection multipliers
694 std::unordered_map<std::string, WellFilterCake<Scalar, IndexTraits>> filter_cake_;
695
696 /*
697 The various wellState members should be accessed and modified
698 through the accessor functions wellState(), prevWellState(),
699 commitWellState(), resetWellState(), nupcolWellState() and
700 updateNupcolWGState().
701 */
705
712 {
714 : wgstate(pu), nupcol_wgstate(pu)
715 {}
716
719 std::unordered_set<std::string> closed_this_step;
720 std::map<std::string, double> well_open_times;
721 std::map<std::string, double> well_close_times;
722 };
723
727
729
730 // Store maps of group name and new group controls for output
731 std::map<std::string, std::vector<Group::ProductionCMode>> switched_prod_groups_;
732 std::map<std::string, std::array<std::vector<Group::InjectionCMode>, 3>> switched_inj_groups_;
733 // Store map of group name and close offending well for output
734 std::map<std::string, std::pair<std::string, std::string>> closed_offending_wells_;
735
738
741 WellStatus closedWellStatus(const Well& well_ecl) const;
742
743private:
744 WellInterfaceGeneric<Scalar, IndexTraits>* getGenWell(const std::string& well_name);
745
750 void updateGroupRates_(const Group& fieldGroup);
751
752 template <typename Iter, typename Body>
753 void wellUpdateLoop(Iter first, Iter last, const int timeStepIdx, Body&& body);
754
755 void updateEclWellsConstraints(const int timeStepIdx,
756 const SimulatorUpdate& sim_update,
757 const SummaryState& st);
758
759 void updateEclWellsCTFFromAction(const int timeStepIdx,
760 const SimulatorUpdate& sim_update);
761
775 template <typename Predicate>
776 bool parallelWellSatisfies(const std::string& wname, Predicate&& p) const
777 {
778 const auto* pwInfo = this->findParallelWellInfo(wname);
779
780 return (pwInfo != nullptr) && p(*pwInfo);
781 }
782
798 template <typename LoopBody>
799 void loopOwnedWells(LoopBody&& loopBody) const;
800};
801
802} // namespace Opm
803
804#endif
Definition: BlackoilWellModelGasLift.hpp:42
Class for handling the blackoil well model.
Definition: BlackoilWellModelGeneric.hpp:101
BlackoilWellModelWBP< Scalar, IndexTraits > wbp_
Definition: BlackoilWellModelGeneric.hpp:630
void assignMswTracerRates(data::Wells &wsrpt, const MswTracerRates &mswTracerRates, const unsigned reportStep) const
bool wellStructureChangedDynamically_
Definition: BlackoilWellModelGeneric.hpp:728
void updateNupcolWGState()
Definition: BlackoilWellModelGeneric.hpp:445
const BlackoilWellModelGenericParameters< Scalar > param_
Definition: BlackoilWellModelGeneric.hpp:627
bool isOwner(const std::string &wname) const
Definition: BlackoilWellModelGeneric.hpp:327
std::map< std::string, double > well_open_times_
Definition: BlackoilWellModelGeneric.hpp:645
bool initial_step_
Definition: BlackoilWellModelGeneric.hpp:635
void updateInjFCMult(DeferredLogger &deferred_logger)
GroupStateHelperType & groupStateHelper()
Definition: BlackoilWellModelGeneric.hpp:342
std::vector< ConnectionIndexMap > conn_idx_map_
Definition: BlackoilWellModelGeneric.hpp:650
GroupState< Scalar > & groupState()
Definition: BlackoilWellModelGeneric.hpp:189
std::vector< std::vector< PerforationData< Scalar > > > well_perf_data_
Definition: BlackoilWellModelGeneric.hpp:642
virtual int compressedIndexForInteriorLGR(const std::string &lgr_tag, const Connection &conn) const
Definition: BlackoilWellModelGeneric.hpp:117
GuideRate & guideRate()
Definition: BlackoilWellModelGeneric.hpp:274
bool forceShutWellByName(const std::string &wellname, const double simulation_time, const bool dont_shut_grup_wells)
WellState< Scalar, IndexTraits > & nupcolWellState()
Definition: BlackoilWellModelGeneric.hpp:185
void updateWsolvent(const Group &group, const int reportStepIdx, const WellState< Scalar, IndexTraits > &wellState)
const EclipseState & eclState_
Definition: BlackoilWellModelGeneric.hpp:625
bool enable_state_rollback_
Definition: BlackoilWellModelGeneric.hpp:737
const GroupState< Scalar > & groupState() const
Definition: BlackoilWellModelGeneric.hpp:150
Scalar wellPI(const int well_index) const
std::vector< std::unique_ptr< ParallelWellInfo< Scalar > > > parallel_well_info_
Definition: BlackoilWellModelGeneric.hpp:661
const VFPProperties< Scalar, IndexTraits > & getVFPProperties() const
Definition: BlackoilWellModelGeneric.hpp:354
virtual ~BlackoilWellModelGeneric()=default
std::vector< int > pvt_region_idx_
Definition: BlackoilWellModelGeneric.hpp:666
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:407
const ConnectionIndexMap & connectionIndexMap(const std::size_t idx)
Definition: BlackoilWellModelGeneric.hpp:339
const WellTestState & wellTestState() const
Definition: BlackoilWellModelGeneric.hpp:193
const WellGroupEvents & reportStepStartEvents() const
Definition: BlackoilWellModelGeneric.hpp:278
const Well & getWellEcl(const std::string &well_name) const
WGState< Scalar, IndexTraits > nupcol_wgstate_
Definition: BlackoilWellModelGeneric.hpp:704
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:687
const ParallelWellInfo< Scalar > & parallelWellInfo(const std::size_t idx) const
Definition: BlackoilWellModelGeneric.hpp:324
void updateClosedWellsThisStep(const std::string &well_name) const
Definition: BlackoilWellModelGeneric.hpp:284
const SummaryState & summaryState_
Definition: BlackoilWellModelGeneric.hpp:624
std::function< bool(const std::string &)> not_on_process_
Definition: BlackoilWellModelGeneric.hpp:651
std::map< std::string, double > well_close_times_
Definition: BlackoilWellModelGeneric.hpp:648
std::vector< Well > wells_ecl_
Definition: BlackoilWellModelGeneric.hpp:641
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:140
Schedule & schedule_
Definition: BlackoilWellModelGeneric.hpp:622
const std::map< std::string, double > & wellCloseTimes() const
Definition: BlackoilWellModelGeneric.hpp:277
WellPerformanceEventTracker well_performance_event_tracker_
Definition: BlackoilWellModelGeneric.hpp:685
void assignGroupControl(const Group &group, data::GroupData &gdata) const
void honorOpenRequest(const std::string &well_name, Events &well_events, double simulation_time)
const std::map< std::string, double > & wellOpenTimes() const
Definition: BlackoilWellModelGeneric.hpp:276
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:688
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:269
const NewtonIterationContext & iterationContext() const
Definition: BlackoilWellModelGeneric.hpp:373
const WellState< Scalar, IndexTraits > & nupcolWellState() const
Definition: BlackoilWellModelGeneric.hpp:181
void checkGconsaleLimits(const Group &group, WellState< Scalar, IndexTraits > &well_state, const int reportStepIdx, DeferredLogger &deferred_logger)
void updateFiltrationModelsPostStep(const double dt, const InvBFunction &inv_b, DeferredLogger &deferred_logger)
void closeWellForRetry(const std::string &well_name, double simulation_time)
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:242
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:609
void advanceTimeLevel()
Snapshot the mutable well-model state at the start of a timestep.
Definition: BlackoilWellModelGeneric.hpp:229
std::unordered_set< std::string > closed_this_step_
Definition: BlackoilWellModelGeneric.hpp:668
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:282
void resetWGState()
Definition: BlackoilWellModelGeneric.hpp:432
const GroupStateHelperType & groupStateHelper() const
Definition: BlackoilWellModelGeneric.hpp:343
void assignWellPerformanceEventTracker(data::Wells &wsrpt) const
GroupStateHelperType group_state_helper_
Definition: BlackoilWellModelGeneric.hpp:725
const SummaryState & summaryState() const
Definition: BlackoilWellModelGeneric.hpp:271
WellState< Scalar, IndexTraits > & wellState()
Definition: BlackoilWellModelGeneric.hpp:168
std::map< std::string, std::array< std::vector< Group::InjectionCMode >, 3 > > switched_inj_groups_
Definition: BlackoilWellModelGeneric.hpp:732
bool terminalOutput() const
Definition: BlackoilWellModelGeneric.hpp:143
void runWellPIScaling(const int reportStepIdx, DeferredLogger &local_deferredLogger)
bool wells_active_
Definition: BlackoilWellModelGeneric.hpp:634
const PhaseUsageInfo< IndexTraits > & phaseUsage() const
Definition: BlackoilWellModelGeneric.hpp:149
void updateInjMult(DeferredLogger &deferred_logger)
const Parallel::Communication & comm_
Definition: BlackoilWellModelGeneric.hpp:626
WellTestState & wellTestState()
Definition: BlackoilWellModelGeneric.hpp:191
const std::vector< PerforationData< Scalar > > & perfData(const int well_idx) const
Definition: BlackoilWellModelGeneric.hpp:264
PrevTimestepState prev_timestep_state_
Definition: BlackoilWellModelGeneric.hpp:724
WGState< Scalar, IndexTraits > last_valid_wgstate_
Definition: BlackoilWellModelGeneric.hpp:703
const WGState< Scalar, IndexTraits > & prevWGState() const
Definition: BlackoilWellModelGeneric.hpp:412
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:662
bool hasLocalCells(const std::string &wname) const
Definition: BlackoilWellModelGeneric.hpp:333
void commitWGState(WGState< Scalar, IndexTraits > wgstate)
Definition: BlackoilWellModelGeneric.hpp:422
std::unordered_set< std::string > retry_shut_wells_
Definition: BlackoilWellModelGeneric.hpp:675
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:273
std::map< std::string, std::vector< Group::ProductionCMode > > switched_prod_groups_
Definition: BlackoilWellModelGeneric.hpp:731
void assignMassGasRate(data::Wells &wsrpt, const Scalar gasDensity) const
std::vector< const WellInterfaceGeneric< Scalar, IndexTraits > * > genericWells() const
Definition: BlackoilWellModelGeneric.hpp:151
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:691
const WellState< Scalar, IndexTraits > & wellState() const
Definition: BlackoilWellModelGeneric.hpp:160
void reportIntervalConnectionOilProduction(const double dt, const std::size_t conn_opt_ix, RegionVariableCollection &regVars) const
const Schedule & schedule() const
Definition: BlackoilWellModelGeneric.hpp:148
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:654
void assignInjectionWellTargets(const Well &well, data::WellControlLimits &limits) const
const NewtonIterationContext & iter_ctx_
Definition: BlackoilWellModelGeneric.hpp:628
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:267
std::vector< int > local_shut_wells_
Definition: BlackoilWellModelGeneric.hpp:656
std::unordered_map< int, std::vector< MSWellTracerRate< Scalar > > > MswTracerRates
Definition: BlackoilWellModelGeneric.hpp:614
std::vector< WellProdIndexCalculator< Scalar > > prod_index_calc_
Definition: BlackoilWellModelGeneric.hpp:664
std::unordered_map< std::string, WellFilterCake< Scalar, IndexTraits > > filter_cake_
Definition: BlackoilWellModelGeneric.hpp:694
BlackoilWellModelNetworkGeneric< Scalar, IndexTraits > & genNetwork_
Definition: BlackoilWellModelGeneric.hpp:736
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:154
std::map< std::string, std::pair< std::string, std::string > > closed_offending_wells_
Definition: BlackoilWellModelGeneric.hpp:734
const PhaseUsageInfo< IndexTraits > & phase_usage_info_
Definition: BlackoilWellModelGeneric.hpp:632
bool wasDynamicallyShutThisTimeStep(const std::size_t well_index) const
bool deserialized_state_pending_
Definition: BlackoilWellModelGeneric.hpp:637
void assignProductionWellTargets(const Well &well, data::WellControlLimits &limits) const
bool report_step_starts_
Definition: BlackoilWellModelGeneric.hpp:636
WellStatus closedWellStatus(const Well &well_ecl) const
bool wasClosedForRetry(const std::string &well_name) const
A closure imposed to retry a failed timestep must survive OPEN requests.
Definition: BlackoilWellModelGeneric.hpp:291
bool wasDynamicallyShutThisTimeStep(const std::string &well_name) const
std::optional< int > last_run_wellpi_
Definition: BlackoilWellModelGeneric.hpp:639
virtual void calculateProductivityIndexValues(DeferredLogger &deferred_logger)=0
const EclipseState & eclState() const
Definition: BlackoilWellModelGeneric.hpp:376
void assignWellTracerRates(data::Wells &wsrpt, const WellTracerRates &wellTracerRates, const unsigned reportStep) const
virtual void initWellContainer(const int reportStepIdx)=0
IndexTraitsT IndexTraits
Definition: BlackoilWellModelGeneric.hpp:105
ScalarT Scalar
Definition: BlackoilWellModelGeneric.hpp:104
bool terminal_output_
Definition: BlackoilWellModelGeneric.hpp:633
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:702
void serializeOp(Serializer &serializer)
Definition: BlackoilWellModelGeneric.hpp:299
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 updateGroupRatesFromWellState(const int reportStepIdx)
Recompute the group rates from the current well state.
void assignShutConnections(data::Wells &wsrpt, const int reportStepIndex) const
std::function< Scalar(int cell_index, unsigned canonical_phase)> InvBFunction
Inverse formation volume factor of a canonical phase in a (local) cell, used to convert filtration co...
Definition: BlackoilWellModelGeneric.hpp:582
WellGroupEvents report_step_start_events_
Well group events at start of report step.
Definition: BlackoilWellModelGeneric.hpp:726
void assignGroupValues(const int reportStepIdx, std::map< std::string, data::GroupData > &gvalues) const
BlackoilWellModelGasLiftGeneric< Scalar, IndexTraits > & gen_gaslift_
Definition: BlackoilWellModelGeneric.hpp:629
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:42
Class encapsulating some information about parallel wells.
Definition: ParallelWellInfo.hpp:217
Definition: GasLiftGroupInfo.hpp:40
Definition: VFPProperties.hpp:40
Definition: WellInterfaceGeneric.hpp:60
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:712
WGState< Scalar, IndexTraits > nupcol_wgstate
NUPCOL: the state group control targets are computed from.
Definition: BlackoilWellModelGeneric.hpp:718
std::map< std::string, double > well_close_times
WCYCLE.
Definition: BlackoilWellModelGeneric.hpp:721
PrevTimestepState(const PhaseUsageInfo< IndexTraits > &pu)
Definition: BlackoilWellModelGeneric.hpp:713
std::map< std::string, double > well_open_times
WCYCLE.
Definition: BlackoilWellModelGeneric.hpp:720
std::unordered_set< std::string > closed_this_step
wells shut by the solver during this step
Definition: BlackoilWellModelGeneric.hpp:719
WGState< Scalar, IndexTraits > wgstate
well and group rates, pressures, controls
Definition: BlackoilWellModelGeneric.hpp:717
Definition: BlackoilWellModelGenericParameters.hpp:39
Context for iteration-dependent decisions in the Newton solver.
Definition: NewtonIterationContext.hpp:43
Definition: BlackoilWellModelGeneric.hpp:92
static constexpr bool value
Definition: BlackoilWellModelGeneric.hpp:92
Definition: WGState.hpp:39
Definition: WellPerformanceEventTracker.hpp:42