BlackoilWellModel.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_HEADER_INCLUDED
24#define OPM_BLACKOILWELLMODEL_HEADER_INCLUDED
25
26#include <dune/common/fmatrix.hh>
27
28#include <dune/istl/bcrsmatrix.hh>
29#include <dune/istl/matrixmatrix.hh>
30
31#include <opm/common/OpmLog/OpmLog.hpp>
32
33#include <opm/input/eclipse/Schedule/Group/Group.hpp>
34#include <opm/input/eclipse/Schedule/Group/GuideRate.hpp>
35#include <opm/input/eclipse/Schedule/Schedule.hpp>
36#include <opm/input/eclipse/Schedule/Well/WellTestState.hpp>
37
38#include <opm/material/densead/Math.hpp>
39
42
44
47
49
76
77#include <cstddef>
78#include <map>
79#include <memory>
80#include <optional>
81#include <string>
82#include <tuple>
83#include <vector>
84
85namespace Opm {
86
87template<class Scalar> class BlackoilWellModelNldd;
88template<class T, template <typename, typename...> class Storage> class SparseTable;
89
90#if COMPILE_GPU_BRIDGE
91template<class Scalar> class WellContributions;
92#endif
93
95 template<typename TypeTag>
96 class BlackoilWellModel : public WellConnectionAuxiliaryModule<TypeTag, BlackoilWellModel<TypeTag>>
97 , public BlackoilWellModelGeneric<GetPropType<TypeTag, Properties::Scalar>,
98 typename GetPropType<TypeTag, Properties::FluidSystem>::IndexTraitsType>
99 {
100 public:
101 // --------- Types ---------
113
115 using IndexTraits = typename FluidSystem::IndexTraitsType;
117
119
120 static const int numEq = Indices::numEq;
121 static const int solventSaturationIdx = Indices::solventSaturationIdx;
122 static constexpr bool has_solvent_ = getPropValue<TypeTag, Properties::EnableSolvent>();
123 static constexpr bool has_polymer_ = getPropValue<TypeTag, Properties::EnablePolymer>();
124 static constexpr EnergyModules energyModuleType_ = getPropValue<TypeTag, Properties::EnergyModuleType>();
125 static constexpr bool has_energy_ = (energyModuleType_ == EnergyModules::FullyImplicitThermal);
126 static constexpr bool has_micp_ = Indices::enableMICP;
127 static constexpr bool has_geochem_ = getPropValue<TypeTag, Properties::EnableGeochemistry>();
128
129 // TODO: where we should put these types, WellInterface or Well Model?
130 // or there is some other strategy, like TypeTag
131 using VectorBlockType = Dune::FieldVector<Scalar, numEq>;
132 using BVector = Dune::BlockVector<VectorBlockType>;
133
136
137 // For the conversion between the surface volume rate and reservoir voidage rate
138 using RateConverterType = RateConverter::
139 SurfaceToReservoirVoidage<FluidSystem, std::vector<int> >;
140
141 // For computing average pressured used by gpmaint
142 using AverageRegionalPressureType = RegionAverageCalculator::
143 AverageRegionalPressure<FluidSystem, std::vector<int> >;
144
146
147 void init();
148 void initWellContainer(const int reportStepIdx) override;
149
151 {
152 OPM_TIMEBLOCK(beginEpsiode);
153 beginReportStep(simulator_.episodeIndex());
154 }
155
156 void beginTimeStep();
157
159 {
160 OPM_TIMEBLOCK(beginIteration);
161 assemble(simulator_.timeStepSize());
162 }
163
165 { }
166
168 {
169 OPM_TIMEBLOCK(endTimeStep);
170 timeStepSucceeded(simulator_.time(), simulator_.timeStepSize());
171 }
172
174 {
176 }
177
179 unsigned globalIdx) const;
180
181 template <class Context>
183 const Context& context,
184 unsigned spaceIdx,
185 unsigned timeIdx) const;
186
187
188 using WellInterfacePtr = std::unique_ptr<WellInterface<TypeTag>>;
189
191 void initFromRestartFile(const RestartValue& restartValues)
192 {
193 initFromRestartFile(restartValues,
194 this->simulator_.vanguard().transferWTestState(),
195 grid().size(0),
196 this->simulator_.vanguard().enableDistributedWells());
197 }
198
200 void prepareDeserialize(const int report_step)
201 {
202 prepareDeserialize(report_step, grid().size(0),
203 this->simulator_.vanguard().enableDistributedWells());
204 }
205
206 data::Wells wellData() const
207 {
208 auto wsrpt = this->wellState()
209 .report(this->simulator_.vanguard().globalCell().data(),
210 [this](const int well_index)
211 { return this->wasDynamicallyShutThisTimeStep(well_index); },
212 this->rsConstInfo());
213
215 .assignWellGuideRates(wsrpt, this->reportStepIndex());
216
217 this->assignWellTracerRates(wsrpt);
218
219 if constexpr (has_geochem_) {
220 this->assignWellSpeciesRates(wsrpt);
221 }
222
223 if (const auto& rspec = eclState().runspec();
224 rspec.co2Storage() || rspec.h2Storage())
225 {
226 // The gas reference density (surface condition) is the
227 // same for all PVT regions in CO2STORE/H2STORE runs so,
228 // for simplicity, we use region zero (0) here.
229
230 this->assignMassGasRate(wsrpt, FluidSystem::referenceDensity(FluidSystem::gasPhaseIdx, 0));
231 }
232
233 this->assignWellTargets(wsrpt);
234
235 this->assignDynamicWellStatus(wsrpt);
236
237 // Assigning (a subset of the) property values in shut
238 // connections should be the last step of wellData().
239 this->assignShutConnections(wsrpt, this->reportStepIndex());
240
241 return wsrpt;
242 }
243
244 data::WellBlockAveragePressures wellBlockAveragePressures() const
245 {
247 }
248
249#if COMPILE_GPU_BRIDGE
250 // accumulate the contributions of all Wells in the WellContributions object
251 void getWellContributions(WellContributions<Scalar>& x) const;
252#endif
253
254 // Check if well equations is converged.
255 ConvergenceReport getWellConvergence(const std::vector<Scalar>& B_avg, const bool checkWellGroupControlsAndNetwork = false) const;
256
257 const SimulatorReportSingle& lastReport() const;
258
259 void addWellContributions(SparseMatrixAdapter& jacobian) const;
260
261 // add source from wells to the reservoir matrix
263 const std::vector<typename SparseMatrixAdapter::MatrixBlock*>& diagMatAddress) const;
264
265 // called at the beginning of a report step
266 void beginReportStep(const int time_step);
267
271 void calculateExplicitQuantities() const;
272
275 void prepareTimeStep(DeferredLogger& deferred_logger);
276
277 bool
278 updateWellControls(DeferredLogger& deferred_logger);
279
280 void updateAndCommunicate(const int reportStepIdx);
281
282 bool updateGroupControls(const Group& group,
283 DeferredLogger& deferred_logger,
284 const int reportStepIdx);
285
286 const WellInterface<TypeTag>& getWell(const std::string& well_name) const;
287
288 using PressureMatrix = Dune::BCRSMatrix<Opm::MatrixBlock<Scalar, 1, 1>>;
289
291 const BVector& weights,
292 const bool use_well_weights) const;
295 const BVector& weights,
296 const bool use_well_weights,
297 const int domainIndex) const
298 {
299 if (!nldd_) {
300 OPM_THROW(std::logic_error, "Attempt to access NLDD data without a NLDD solver");
301 }
302 return nldd_->addWellPressureEquations(jacobian,
303 weights,
304 use_well_weights,
305 domainIndex);
306 }
307
309 const std::vector<WellInterfacePtr>& localNonshutWells() const
310 {
311 return well_container_;
312 }
313
315 {
316 if (!nldd_) {
317 OPM_THROW(std::logic_error, "Attempt to access NLDD data without a NLDD solver");
318 }
319 return nldd_->well_local_cells();
320 }
321
322 const std::map<std::string, int>& well_domain() const
323 {
324 if (!nldd_) {
325 OPM_THROW(std::logic_error, "Attempt to access NLDD data without a NLDD solver");
326 }
327
328 return nldd_->well_domain();
329 }
330
331 auto begin() const { return well_container_.begin(); }
332 auto end() const { return well_container_.end(); }
333 bool empty() const { return well_container_.empty(); }
334
337
340
341 int compressedIndexForInterior(int cartesian_cell_idx) const override
342 {
343 return simulator_.vanguard().compressedIndexForInterior(cartesian_cell_idx);
344 }
345
346 int compressedIndexForInteriorLGR(const std::string& lgr_tag, const Connection& conn) const override
347 {
348 return simulator_.vanguard().compressedIndexForInteriorLGR(lgr_tag, conn);
349 }
350
351 // using the solution x to recover the solution xw for wells and applying
352 // xw to update Well State
354
355 // using the solution x to recover the solution xw for wells and applying
356 // xw to update Well State
358 const int domainIdx);
359 // Update cellRates_ with contributions from all wells
360 void updateCellRates();
361
362 // Update cellRates_ with contributions from wells in a specific domain
363 void updateCellRatesForDomain(int domainIndex,
364 const std::map<std::string, int>& well_domain_map);
365
366 const Grid& grid() const
367 { return simulator_.vanguard().grid(); }
368
369 const Simulator& simulator() const
370 { return simulator_; }
371
373 { nldd_ = mod; }
374
376 { return guide_rate_handler_; }
377
379 { return guide_rate_handler_; }
380
381 // === Reservoir Coupling ===
382
386
394 void updateGuideRates(const int report_step_idx,
395 const double sim_time)
396 {
397 this->guide_rate_handler_.updateGuideRates(
398 report_step_idx, sim_time, this->wellState(), this->groupState()
399 );
400 }
401
403 bool isReservoirCouplingMaster() const { return rescoup_.isMaster(); }
404
406 bool isReservoirCouplingSlave() const { return rescoup_.isSlave(); }
407
413 bool isReservoirCouplingMasterGroup(const std::string& group_name) const {
414 return rescoup_.isMasterGroup(group_name);
415 }
416
420 return rescoup_.master();
421 }
422
426 return rescoup_.slave();
427 }
428
429#ifdef RESERVOIR_COUPLING_ENABLED
430 void setReservoirCouplingMaster(ReservoirCouplingMaster<Scalar>* master)
431 {
432 rescoup_.setMaster(master);
433 this->guide_rate_handler_.setReservoirCouplingMaster(master);
434 this->groupStateHelper().setReservoirCouplingMaster(master);
435 }
436 void setReservoirCouplingSlave(ReservoirCouplingSlave<Scalar>* slave)
437 {
438 rescoup_.setSlave(slave);
439 this->guide_rate_handler_.setReservoirCouplingSlave(slave);
440 this->groupStateHelper().setReservoirCouplingSlave(slave);
441 }
442#endif
443
444 bool updateWellControlsAndNetwork(const bool mandatory_network_balance,
445 const double dt,
446 DeferredLogger& local_deferredLogger);
447
448 // TODO: finding a better naming
449 void assembleWellEqWithoutIteration(const double dt);
450
451 const std::vector<Scalar>& B_avg() const
452 { return B_avg_; }
453
454 const ModelParameters& param() const
455 { return param_; }
456
457
458 template<class FluidState, class SingleWellState>
459 static Scalar computeTemperatureWeightFactor(const int perf_index, const int np, const FluidState& fs, const SingleWellState& ws)
460 {
461 const auto& perf_phase_rate = ws.perf_data.phase_rates;
462 // we only have one temperature pr cell any phaseIdx will do
463 Scalar cellTemperatures = fs.temperature(/*phaseIdx*/0).value();
464 Scalar weight_factor = 0.0;
465 for (unsigned phaseIdx = 0; phaseIdx < FluidSystem::numPhases; ++phaseIdx) {
466 if (!FluidSystem::phaseIsActive(phaseIdx)) {
467 continue;
468 }
469 Scalar cellInternalEnergy = fs.enthalpy(phaseIdx).value() -
470 fs.pressure(phaseIdx).value() / fs.density(phaseIdx).value();
471 Scalar cellBinv = fs.invB(phaseIdx).value();
472 Scalar cellDensity = fs.density(phaseIdx).value();
473 Scalar perfPhaseRate = perf_phase_rate[perf_index*np + phaseIdx];
474 weight_factor += cellDensity * (perfPhaseRate / cellBinv) * (cellInternalEnergy / cellTemperatures);
475 }
476 return (std::abs(weight_factor) + 1e-13);
477 }
478
479 protected:
481
482 // a vector of all the wells.
483 std::vector<WellInterfacePtr> well_container_{};
484
485 std::vector<bool> is_cell_perforated_{};
486
487 void initializeWellState(const int timeStepIdx);
488
489 // create the well container
490 void createWellContainer(const int report_step) override;
491
493 createWellPointer(const int wellID,
494 const int report_step) const;
495
496 template <typename WellType>
497 std::unique_ptr<WellType>
498 createTypedWellPointer(const int wellID,
499 const int time_step) const;
500
501 WellInterfacePtr createWellForWellTest(const std::string& well_name,
502 const int report_step,
503 DeferredLogger& deferred_logger) const;
504
506 std::size_t global_num_cells_{};
507 // the number of the cells in the local grid
508 std::size_t local_num_cells_{};
510 std::vector<Scalar> depth_{};
512 std::unique_ptr<RateConverterType> rateConverter_{};
513 std::map<std::string, std::unique_ptr<AverageRegionalPressureType>> regionalAveragePressureCalculator_{};
514
518
519 // A flag to tell the convergence report whether we need to take another newton step
521
522 std::vector<Scalar> B_avg_{};
523
524 const EquilGrid& equilGrid() const
525 { return simulator_.vanguard().equilGrid(); }
526
527 const EclipseState& eclState() const
528 { return simulator_.vanguard().eclState(); }
529
530 // compute the well fluxes and assemble them in to the reservoir equations as source terms
531 // and in the well equations.
532 void assemble(const double dt);
533
534 // well controls and network pressures affect each other and are solved in an iterative manner.
535 // the function handles one iteration of updating well controls and network pressures.
536 // it is possible to decouple the update of well controls and network pressures further.
537 // the returned two booleans are {continue_due_to_network, well_group_control_changed}, respectively
538 std::tuple<bool, bool, Scalar> updateWellControlsAndNetworkIteration(const bool mandatory_network_balance,
539 const bool relax_network_tolerance,
540 const bool optimize_gas_lift,
541 const double dt,
542 DeferredLogger& local_deferredLogger);
543
552 void initializeLocalWellStructure(const int reportStepIdx,
553 const bool enableWellPIScaling);
554
558 void initializeGroupStructure(const int reportStepIdx);
559
560 // called at the end of a time step
561 void timeStepSucceeded(const double simulationTime, const double dt);
562
563 // called at the end of a report step
564 void endReportStep();
565
566 // setting the well_solutions_ based on well_state.
568
570
571 void computePotentials(const std::size_t widx,
572 const WellState<Scalar, IndexTraits>& well_state_copy,
573 std::string& exc_msg,
574 ExceptionType::ExcEnum& exc_type) override;
575
576 const std::vector<Scalar>& wellPerfEfficiencyFactors() const;
577
578 void calculateProductivityIndexValuesShutWells(const int reportStepIdx, DeferredLogger& deferred_logger) override;
579 void calculateProductivityIndexValues(DeferredLogger& deferred_logger) override;
581 DeferredLogger& deferred_logger);
582
583 // The number of conservation quantities.
584 int numConservationQuantities() const;
585
586 int reportStepIndex() const;
587
588 void assembleWellEq(const double dt);
589
590 void prepareWellsBeforeAssembling(const double dt);
591
593
594 void extractLegacyDepth_();
595
597 void updateWellTestState(const double simulationTime, WellTestState& wellTestState);
598
599 void wellTesting(const int timeStepIdx, const double simulationTime, DeferredLogger& deferred_logger);
600
601 void calcResvCoeff(const int fipnum,
602 const int pvtreg,
603 const std::vector<Scalar>& production_rates,
604 std::vector<Scalar>& resv_coeff) const override;
605
606 void calcInjResvCoeff(const int fipnum,
607 const int pvtreg,
608 std::vector<Scalar>& resv_coeff) const override;
609
611
612 private:
615#ifdef RESERVOIR_COUPLING_ENABLED
616 BlackoilWellModelRescoup<TypeTag> rescoupHelper_;
617#endif
618 BlackoilWellModelNldd<TypeTag>* nldd_ = nullptr;
619
620 // These members are used to avoid reallocation in specific functions
621 // instead of using local variables.
622 // Their state is not relevant between function calls, so they can
623 // (and must) be mutable, as the functions using them are const.
624 mutable BVector x_local_;
625
626 // Store cell rates after assembling to avoid iterating all wells and connections for every element
627 std::map<int, RateVector> cellRates_;
628
629 void assignWellTracerRates(data::Wells& wsrpt) const;
630 void assignWellSpeciesRates(data::Wells& wsrpt) const;
631
632 [[nodiscard]] auto rsConstInfo() const
633 -> typename WellState<Scalar,IndexTraits>::RsConstInfo;
634 };
635
636} // namespace Opm
637
638#include "BlackoilWellModel_impl.hpp"
639
640#endif // OPM_BLACKOILWELLMODEL_HEADER_INCLUDED
Contains the high level supplements required to extend the black oil model by bioeffects.
Definition: blackoilbioeffectsmodules.hh:95
Contains the high level supplements required to extend the black oil model by polymer.
Definition: blackoilpolymermodules.hh:65
Class for handling the gaslift in the blackoil well model.
Definition: BlackoilWellModelGasLift.hpp:96
Class for handling the blackoil well model.
Definition: BlackoilWellModelGeneric.hpp:98
const GroupState< GetPropType< TypeTag, Properties::Scalar > > & groupState() const
Definition: BlackoilWellModelGeneric.hpp:144
BlackoilWellModelWBP< GetPropType< TypeTag, Properties::Scalar >, GetPropType< TypeTag, Properties::FluidSystem >::IndexTraitsType > wbp_
Definition: BlackoilWellModelGeneric.hpp:520
const WellState< GetPropType< TypeTag, Properties::Scalar >, GetPropType< TypeTag, Properties::FluidSystem >::IndexTraitsType > & wellState() const
Definition: BlackoilWellModelGeneric.hpp:154
void assignMassGasRate(data::Wells &wsrpt, const GetPropType< TypeTag, Properties::Scalar > gasDensity) const
Class for handling the guide rates in the blackoil well model.
Definition: BlackoilWellModelGuideRates.hpp:47
void assignWellGuideRates(data::Wells &wsrpt, const int reportStepIdx) const
Assign well guide rates.
Class for handling the blackoil well network model.
Definition: BlackoilWellModelNetwork.hpp:47
Class for handling the blackoil well model in a NLDD solver.
Definition: BlackoilWellModelNldd.hpp:80
Class for handling the blackoil well model.
Definition: BlackoilWellModel.hpp:99
ReservoirCoupling::Proxy< Scalar > & rescoup()
Get the reservoir coupling proxy.
Definition: BlackoilWellModel.hpp:384
void initializeGroupStructure(const int reportStepIdx)
Definition: BlackoilWellModel_impl.hpp:294
bool network_needs_more_balancing_force_another_newton_iteration_
Definition: BlackoilWellModel.hpp:520
void calcResvCoeff(const int fipnum, const int pvtreg, const std::vector< Scalar > &production_rates, std::vector< Scalar > &resv_coeff) const override
Definition: BlackoilWellModel_impl.hpp:2081
ReservoirCouplingMaster< Scalar > & reservoirCouplingMaster()
Get reference to reservoir coupling master.
Definition: BlackoilWellModel.hpp:419
void endTimeStep()
Definition: BlackoilWellModel.hpp:167
void prepareTimeStep(DeferredLogger &deferred_logger)
Definition: BlackoilWellModel_impl.hpp:1900
std::tuple< bool, bool, Scalar > updateWellControlsAndNetworkIteration(const bool mandatory_network_balance, const bool relax_network_tolerance, const bool optimize_gas_lift, const double dt, DeferredLogger &local_deferredLogger)
Definition: BlackoilWellModel_impl.hpp:1214
WellInterfacePtr createWellPointer(const int wellID, const int report_step) const
Definition: BlackoilWellModel_impl.hpp:1011
GuideRateHandler< Scalar, IndexTraits > guide_rate_handler_
Definition: BlackoilWellModel.hpp:516
const EclipseState & eclState() const
Definition: BlackoilWellModel.hpp:527
void prepareWellsBeforeAssembling(const double dt)
Definition: BlackoilWellModel_impl.hpp:1288
const std::vector< WellInterfacePtr > & localNonshutWells() const
Get list of local nonshut wells.
Definition: BlackoilWellModel.hpp:309
void prepareDeserialize(const int report_step)
Definition: BlackoilWellModel.hpp:200
void init()
Definition: BlackoilWellModel_impl.hpp:163
void setNlddAdapter(BlackoilWellModelNldd< TypeTag > *mod)
Definition: BlackoilWellModel.hpp:372
const Simulator & simulator() const
Definition: BlackoilWellModel.hpp:369
std::vector< Scalar > depth_
Definition: BlackoilWellModel.hpp:510
static constexpr bool has_geochem_
Definition: BlackoilWellModel.hpp:127
static constexpr EnergyModules energyModuleType_
Definition: BlackoilWellModel.hpp:124
std::size_t global_num_cells_
Definition: BlackoilWellModel.hpp:506
GetPropType< TypeTag, Properties::Scalar > Scalar
Definition: BlackoilWellModel.hpp:108
const std::vector< Scalar > & B_avg() const
Definition: BlackoilWellModel.hpp:451
SimulatorReportSingle last_report_
Definition: BlackoilWellModel.hpp:515
static const int solventSaturationIdx
Definition: BlackoilWellModel.hpp:121
Scalar gravity_
Definition: BlackoilWellModel.hpp:509
void initWellContainer(const int reportStepIdx) override
Definition: BlackoilWellModel_impl.hpp:182
void beginReportStep(const int time_step)
Definition: BlackoilWellModel_impl.hpp:199
const WellInterface< TypeTag > & getWell(const std::string &well_name) const
Definition: BlackoilWellModel_impl.hpp:2053
GetPropType< TypeTag, Properties::FluidSystem > FluidSystem
Definition: BlackoilWellModel.hpp:104
void beginIteration()
Definition: BlackoilWellModel.hpp:158
bool isReservoirCouplingMaster() const
Check if this process is a reservoir coupling master.
Definition: BlackoilWellModel.hpp:403
Dune::FieldVector< Scalar, numEq > VectorBlockType
Definition: BlackoilWellModel.hpp:131
void initFromRestartFile(const RestartValue &restartValues)
Definition: BlackoilWellModel.hpp:191
const ModelParameters param_
Definition: BlackoilWellModel.hpp:505
void beginEpisode()
Definition: BlackoilWellModel.hpp:150
GetPropType< TypeTag, Properties::ElementContext > ElementContext
Definition: BlackoilWellModel.hpp:105
GetPropType< TypeTag, Properties::Grid > Grid
Definition: BlackoilWellModel.hpp:102
GetPropType< TypeTag, Properties::EquilGrid > EquilGrid
Definition: BlackoilWellModel.hpp:103
int numConservationQuantities() const
Definition: BlackoilWellModel_impl.hpp:2025
const std::map< std::string, int > & well_domain() const
Definition: BlackoilWellModel.hpp:322
bool updateWellControls(DeferredLogger &deferred_logger)
Definition: BlackoilWellModel_impl.hpp:1575
void endIteration()
Definition: BlackoilWellModel.hpp:164
static constexpr bool has_polymer_
Definition: BlackoilWellModel.hpp:123
int reportStepIndex() const
Definition: BlackoilWellModel_impl.hpp:2069
void calculateProductivityIndexValues(DeferredLogger &deferred_logger) override
Definition: BlackoilWellModel_impl.hpp:1842
void extractLegacyDepth_()
Definition: BlackoilWellModel_impl.hpp:2041
void extractLegacyCellPvtRegionIndex_()
Definition: BlackoilWellModel_impl.hpp:2009
void recoverWellSolutionAndUpdateWellStateDomain(const BVector &x, const int domainIdx)
Definition: BlackoilWellModel_impl.hpp:1496
void updateAverageFormationFactor()
Definition: BlackoilWellModel_impl.hpp:1952
GetPropType< TypeTag, Properties::Simulator > Simulator
Definition: BlackoilWellModel.hpp:107
BlackoilWellModel(Simulator &simulator, const NewtonIterationContext &iter_ctx)
Definition: BlackoilWellModel_impl.hpp:72
bool isReservoirCouplingSlave() const
Check if this process is a reservoir coupling slave.
Definition: BlackoilWellModel.hpp:406
void initializeWellState(const int timeStepIdx)
Definition: BlackoilWellModel_impl.hpp:759
const Grid & grid() const
Definition: BlackoilWellModel.hpp:366
void updatePrimaryVariables()
Definition: BlackoilWellModel_impl.hpp:2000
const ReservoirCoupling::Proxy< Scalar > & rescoup() const
Definition: BlackoilWellModel.hpp:385
void computeWellTemperature()
Definition: BlackoilWellModel_impl.hpp:2103
static const int numEq
Definition: BlackoilWellModel.hpp:120
void addWellPressureEquations(PressureMatrix &jacobian, const BVector &weights, const bool use_well_weights) const
Definition: BlackoilWellModel_impl.hpp:1397
const SimulatorReportSingle & lastReport() const
Definition: BlackoilWellModel_impl.hpp:635
bool updateWellControlsAndNetwork(const bool mandatory_network_balance, const double dt, DeferredLogger &local_deferredLogger)
Definition: BlackoilWellModel_impl.hpp:1156
void endEpisode()
Definition: BlackoilWellModel.hpp:173
GetPropType< TypeTag, Properties::SparseMatrixAdapter > SparseMatrixAdapter
Definition: BlackoilWellModel.hpp:111
void addWellContributions(SparseMatrixAdapter &jacobian) const
Definition: BlackoilWellModel_impl.hpp:1387
const EquilGrid & equilGrid() const
Definition: BlackoilWellModel.hpp:524
void assembleWellEq(const double dt)
Definition: BlackoilWellModel_impl.hpp:1276
WellInterfacePtr createWellForWellTest(const std::string &well_name, const int report_step, DeferredLogger &deferred_logger) const
Definition: BlackoilWellModel_impl.hpp:1062
GetPropType< TypeTag, Properties::Indices > Indices
Definition: BlackoilWellModel.hpp:106
int compressedIndexForInteriorLGR(const std::string &lgr_tag, const Connection &conn) const override
Definition: BlackoilWellModel.hpp:346
void calculateExplicitQuantities() const
Definition: BlackoilWellModel_impl.hpp:1560
std::vector< WellInterfacePtr > well_container_
Definition: BlackoilWellModel.hpp:483
static constexpr std::size_t pressureVarIndex
Definition: BlackoilWellModel.hpp:118
void updateAndCommunicate(const int reportStepIdx)
Definition: BlackoilWellModel_impl.hpp:1655
Dune::BCRSMatrix< Opm::MatrixBlock< Scalar, 1, 1 > > PressureMatrix
Definition: BlackoilWellModel.hpp:288
bool empty() const
Definition: BlackoilWellModel.hpp:333
void computeTotalRatesForDof(RateVector &rate, unsigned globalIdx) const
Definition: BlackoilWellModel_impl.hpp:722
bool addMatrixContributions() const
Definition: BlackoilWellModel.hpp:335
void beginTimeStep()
Definition: BlackoilWellModel_impl.hpp:326
std::vector< Scalar > B_avg_
Definition: BlackoilWellModel.hpp:522
const std::vector< Scalar > & wellPerfEfficiencyFactors() const
GetPropType< TypeTag, Properties::RateVector > RateVector
Definition: BlackoilWellModel.hpp:109
bool updateGroupControls(const Group &group, DeferredLogger &deferred_logger, const int reportStepIdx)
Definition: BlackoilWellModel_impl.hpp:1682
std::map< std::string, std::unique_ptr< AverageRegionalPressureType > > regionalAveragePressureCalculator_
Definition: BlackoilWellModel.hpp:513
void calcInjResvCoeff(const int fipnum, const int pvtreg, std::vector< Scalar > &resv_coeff) const override
Definition: BlackoilWellModel_impl.hpp:2092
static Scalar computeTemperatureWeightFactor(const int perf_index, const int np, const FluidState &fs, const SingleWellState &ws)
Definition: BlackoilWellModel.hpp:459
GetPropType< TypeTag, Properties::GlobalEqVector > GlobalEqVector
Definition: BlackoilWellModel.hpp:110
void initializeLocalWellStructure(const int reportStepIdx, const bool enableWellPIScaling)
Definition: BlackoilWellModel_impl.hpp:248
GuideRateHandler< Scalar, IndexTraits > & guideRateHandler()
Definition: BlackoilWellModel.hpp:375
static constexpr bool has_solvent_
Definition: BlackoilWellModel.hpp:122
Dune::BlockVector< VectorBlockType > BVector
Definition: BlackoilWellModel.hpp:132
static constexpr bool has_micp_
Definition: BlackoilWellModel.hpp:126
std::unique_ptr< RateConverterType > rateConverter_
Definition: BlackoilWellModel.hpp:512
const SparseTable< int > & well_local_cells() const
Definition: BlackoilWellModel.hpp:314
void wellTesting(const int timeStepIdx, const double simulationTime, DeferredLogger &deferred_logger)
Definition: BlackoilWellModel_impl.hpp:558
std::vector< bool > is_cell_perforated_
Definition: BlackoilWellModel.hpp:485
ConvergenceReport getWellConvergence(const std::vector< Scalar > &B_avg, const bool checkWellGroupControlsAndNetwork=false) const
Definition: BlackoilWellModel_impl.hpp:1509
int numStrictIterations() const
Definition: BlackoilWellModel.hpp:338
typename FluidSystem::IndexTraitsType IndexTraits
Definition: BlackoilWellModel.hpp:115
void updateCellRatesForDomain(int domainIndex, const std::map< std::string, int > &well_domain_map)
Definition: BlackoilWellModel_impl.hpp:1334
data::WellBlockAveragePressures wellBlockAveragePressures() const
Definition: BlackoilWellModel.hpp:244
void assembleWellEqWithoutIteration(const double dt)
Definition: BlackoilWellModel_impl.hpp:1302
void updateCellRates()
Definition: BlackoilWellModel_impl.hpp:1322
void assemble(const double dt)
Definition: BlackoilWellModel_impl.hpp:1087
auto begin() const
Definition: BlackoilWellModel.hpp:331
std::size_t local_num_cells_
Definition: BlackoilWellModel.hpp:508
auto end() const
Definition: BlackoilWellModel.hpp:332
bool alternative_well_rate_init_
Definition: BlackoilWellModel.hpp:511
void timeStepSucceeded(const double simulationTime, const double dt)
Definition: BlackoilWellModel_impl.hpp:645
std::unique_ptr< WellType > createTypedWellPointer(const int wellID, const int time_step) const
Definition: BlackoilWellModel_impl.hpp:1031
void computePotentials(const std::size_t widx, const WellState< Scalar, IndexTraits > &well_state_copy, std::string &exc_msg, ExceptionType::ExcEnum &exc_type) override
Definition: BlackoilWellModel_impl.hpp:1807
Simulator & simulator_
Definition: BlackoilWellModel.hpp:480
void updateGuideRates(const int report_step_idx, const double sim_time)
Update guide rates for all wells and groups.
Definition: BlackoilWellModel.hpp:394
ReservoirCoupling::Proxy< Scalar > rescoup_
Definition: BlackoilWellModel.hpp:517
void createWellContainer(const int report_step) override
Definition: BlackoilWellModel_impl.hpp:802
std::unique_ptr< WellInterface< TypeTag > > WellInterfacePtr
Definition: BlackoilWellModel.hpp:188
ReservoirCouplingSlave< Scalar > & reservoirCouplingSlave()
Get reference to reservoir coupling slave.
Definition: BlackoilWellModel.hpp:425
data::Wells wellData() const
Definition: BlackoilWellModel.hpp:206
const ModelParameters & param() const
Definition: BlackoilWellModel.hpp:454
void updateWellTestState(const double simulationTime, WellTestState &wellTestState)
upate the wellTestState related to economic limits
Definition: BlackoilWellModel_impl.hpp:1736
void addWellPressureEquationsDomain(PressureMatrix &jacobian, const BVector &weights, const bool use_well_weights, const int domainIndex) const
Definition: BlackoilWellModel.hpp:294
bool isReservoirCouplingMasterGroup(const std::string &group_name) const
Check if a group is a reservoir coupling master group.
Definition: BlackoilWellModel.hpp:413
const GuideRateHandler< Scalar, IndexTraits > & guideRateHandler() const
Definition: BlackoilWellModel.hpp:378
void addReservoirSourceTerms(GlobalEqVector &residual, const std::vector< typename SparseMatrixAdapter::MatrixBlock * > &diagMatAddress) const
Definition: BlackoilWellModel_impl.hpp:1419
int compressedIndexForInterior(int cartesian_cell_idx) const override
get compressed index for interior cells (-1, otherwise
Definition: BlackoilWellModel.hpp:341
static constexpr bool has_energy_
Definition: BlackoilWellModel.hpp:125
void recoverWellSolutionAndUpdateWellState(const BVector &x)
Definition: BlackoilWellModel_impl.hpp:1472
void addWellPressureEquationsStruct(PressureMatrix &jacobian) const
Definition: BlackoilWellModel_impl.hpp:1449
void calculateProductivityIndexValuesShutWells(const int reportStepIdx, DeferredLogger &deferred_logger) override
Definition: BlackoilWellModel_impl.hpp:1856
void endReportStep()
Definition: BlackoilWellModel_impl.hpp:618
data::WellBlockAveragePressures computeWellBlockAveragePressures(const Scalar gravity) const
Definition: ConvergenceReport.hpp:38
Definition: DeferredLogger.hpp:57
Definition: GroupStateHelper.hpp:56
Handles computation and reporting of guide rates for wells and groups.
Definition: GuideRateHandler.hpp:46
Definition: RateConverter.hpp:70
Definition: RegionAverageCalculator.hpp:60
Thin proxy for reservoir coupling master/slave pointers.
Definition: RescoupProxy.hpp:54
Definition: ReservoirCouplingMaster.hpp:38
Definition: ReservoirCouplingSlave.hpp:40
Definition: SingleWellState.hpp:44
PerfData< Scalar > perf_data
Definition: SingleWellState.hpp:156
Definition: BlackoilWellModel.hpp:88
Definition: WellConnectionAuxiliaryModule.hpp:39
Definition: WellContributions.hpp:51
Definition: WellInterface.hpp:77
Definition: WellState.hpp:66
data::Wells report(const int *globalCellIdxMap, const std::function< bool(const int)> &wasDynamicallyClosed, const RsConstInfo &rsConst=RsConstInfo{}) const
ExcEnum
Definition: DeferredLogger.hpp:45
Definition: blackoilbioeffectsmodules.hh:45
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property (equivalent to old macro GET_PROP_TYPE(....
Definition: propertysystem.hh:233
Solver parameters for the BlackoilModel.
Definition: BlackoilModelParameters.hpp:196
bool matrix_add_well_contributions_
Whether to add influences of wells between cells to the matrix and preconditioner matrix.
Definition: BlackoilModelParameters.hpp:310
int strict_outer_iter_wells_
Newton iteration where wells are stricly convergent.
Definition: BlackoilModelParameters.hpp:260
Context for iteration-dependent decisions in the Newton solver.
Definition: NewtonIterationContext.hpp:43
A struct for returning timing data from a simulator to its caller.
Definition: SimulatorReport.hpp:34