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