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#include <opm/grid/utility/SparseTable.hpp>
33
34#include <opm/input/eclipse/Schedule/Group/Group.hpp>
35#include <opm/input/eclipse/Schedule/Group/GuideRate.hpp>
36#include <opm/input/eclipse/Schedule/Schedule.hpp>
37#include <opm/input/eclipse/Schedule/Well/WellTestState.hpp>
38
39#include <opm/material/densead/Math.hpp>
40
43
46
49
51
78
79#include <cstddef>
80#include <map>
81#include <memory>
82#include <optional>
83#include <string>
84#include <tuple>
85#include <vector>
86
87namespace Opm {
88
89template<class Scalar> class BlackoilWellModelNldd;
90template<class T, template <typename, typename...> class Storage> class SparseTable;
91
92#if COMPILE_GPU_BRIDGE
93template<class Scalar> class WellContributions;
94#endif
95
97 template<typename TypeTag>
98 class BlackoilWellModel : public WellConnectionAuxiliaryModule<TypeTag, BlackoilWellModel<TypeTag>>
99 , public BlackoilWellModelGeneric<GetPropType<TypeTag, Properties::Scalar>,
100 typename GetPropType<TypeTag, Properties::FluidSystem>::IndexTraitsType>
101 {
102 public:
103 // --------- Types ---------
115
117 using IndexTraits = typename FluidSystem::IndexTraitsType;
119
121
122 static const int numEq = Indices::numEq;
123 static const int solventSaturationIdx = Indices::solventSaturationIdx;
124 static constexpr bool has_solvent_ = getPropValue<TypeTag, Properties::EnableSolvent>();
125 static constexpr bool has_polymer_ = getPropValue<TypeTag, Properties::EnablePolymer>();
126 static constexpr EnergyModules energyModuleType_ = getPropValue<TypeTag, Properties::EnergyModuleType>();
127 static constexpr bool has_energy_ = (energyModuleType_ == EnergyModules::FullyImplicitThermal);
128 static constexpr bool has_micp_ = Indices::enableMICP;
129 static constexpr bool has_geochem_ = getPropValue<TypeTag, Properties::EnableGeochemistry>();
130 static constexpr bool has_bioeffects_ = getPropValue<TypeTag, Properties::EnableBioeffects>();
131
132 // TODO: where we should put these types, WellInterface or Well Model?
133 // or there is some other strategy, like TypeTag
134 using VectorBlockType = Dune::FieldVector<Scalar, numEq>;
135 using BVector = Dune::BlockVector<VectorBlockType>;
136
137 using PolymerModule = BlackOilPolymerModule<TypeTag, has_polymer_>;
138 using BioeffectsModule = BlackOilBioeffectsModule<TypeTag, has_bioeffects_>;
139
140 // For the conversion between the surface volume rate and reservoir voidage rate
141 using RateConverterType = RateConverter::
142 SurfaceToReservoirVoidage<FluidSystem, std::vector<int> >;
143
144 // For computing average pressured used by gpmaint
145 using AverageRegionalPressureType = RegionAverageCalculator::
146 AverageRegionalPressure<FluidSystem, std::vector<int> >;
147
149
150 void init();
151 void initWellContainer(const int reportStepIdx) override;
152
154 {
155 OPM_TIMEBLOCK(beginEpsiode);
156 beginReportStep(simulator_.episodeIndex());
157 }
158
159 void beginTimeStep();
160
162 {
163 OPM_TIMEBLOCK(beginIteration);
164 assemble(simulator_.timeStepSize());
165 }
166
168 { }
169
171 {
172 OPM_TIMEBLOCK(endTimeStep);
173 timeStepSucceeded(simulator_.time(), simulator_.timeStepSize());
174 }
175
177 {
179 }
180
182 unsigned globalIdx) const;
183
184 template <class Context>
186 const Context& context,
187 unsigned spaceIdx,
188 unsigned timeIdx) const;
189
190
191 using WellInterfacePtr = std::unique_ptr<WellInterface<TypeTag>>;
192
194 void initFromRestartFile(const RestartValue& restartValues)
195 {
196 initFromRestartFile(restartValues,
197 this->simulator_.vanguard().transferWTestState(),
198 grid().size(0),
199 this->simulator_.vanguard().enableDistributedWells());
200 }
201
203 void prepareDeserialize(const int report_step)
204 {
205 prepareDeserialize(report_step, grid().size(0),
206 this->simulator_.vanguard().enableDistributedWells());
207 }
208
209 data::Wells wellData() const
210 {
211 auto wsrpt = this->wellState()
212 .report(this->simulator_.vanguard().globalCell().data(),
213 [this](const std::size_t well_index)
214 { return this->wasDynamicallyShutThisTimeStep(well_index); },
215 this->rsConstInfo());
216
218 .assignWellGuideRates(wsrpt, this->reportStepIndex());
219
220 this->assignWellTracerRates_(wsrpt);
221
222 if constexpr (has_geochem_) {
223 this->assignWellSpeciesRates_(wsrpt);
224 }
225
226 if (const auto& rspec = eclState().runspec();
227 rspec.co2Storage() || rspec.h2Storage())
228 {
229 // The gas reference density (surface condition) is the
230 // same for all PVT regions in CO2STORE/H2STORE runs so,
231 // for simplicity, we use region zero (0) here.
232
233 this->assignMassGasRate(wsrpt, FluidSystem::referenceDensity(FluidSystem::gasPhaseIdx, 0));
234 }
235
236 this->assignWellTargets(wsrpt);
237
238 this->assignDynamicWellStatus(wsrpt);
239
240 // Assigning (a subset of the) property values in shut
241 // connections should be the last step of wellData().
242 this->assignShutConnections(wsrpt, this->reportStepIndex());
243
244 return wsrpt;
245 }
246
247 data::WellBlockAveragePressures wellBlockAveragePressures() const
248 {
249 return this->wbp_.computeWellBlockAveragePressures(this->gravity_);
250 }
251
252#if COMPILE_GPU_BRIDGE
253 // accumulate the contributions of all Wells in the WellContributions object
254 void getWellContributions(WellContributions<Scalar>& x) const;
255#endif
256
257 // Check if well equations is converged.
258 ConvergenceReport getWellConvergence(const std::vector<Scalar>& B_avg, const bool checkWellGroupControlsAndNetwork = false) const;
259
260 const SimulatorReportSingle& lastReport() const;
261
262 void addWellContributions(SparseMatrixAdapter& jacobian) const;
263
264 // add source from wells to the reservoir matrix
266 const std::vector<typename SparseMatrixAdapter::MatrixBlock*>& diagMatAddress) const;
267
268 // called at the beginning of a report step
269 void beginReportStep(const int time_step);
270
274 void calculateExplicitQuantities() const;
275
278 void prepareTimeStep(DeferredLogger& deferred_logger);
279
280 bool
281 updateWellControls(DeferredLogger& deferred_logger);
282
283 void updateAndCommunicate(const int reportStepIdx);
284
285 bool updateGroupControls(const Group& group,
286 DeferredLogger& deferred_logger,
287 const int reportStepIdx);
288
289 static constexpr int numResDofs = Indices::numEq;
290 static constexpr int numWellDofs = numResDofs + 1;//NB will fail for for thermal for now
291 using BMatrix = Dune::BCRSMatrix<Dune::FieldMatrix<Scalar, numWellDofs, numResDofs>>;
292 using CMatrix = Dune::BCRSMatrix<Dune::FieldMatrix<Scalar, numResDofs, numWellDofs>>;
293 using DMatrix = Dune::BCRSMatrix<Dune::FieldMatrix<Scalar, numWellDofs, numWellDofs>>;
294 using WVector = Dune::BlockVector<Dune::FieldVector<Scalar, numWellDofs>>;
295
296 void addBCDMatrix(std::vector<BMatrix>& b_matrices,
297 std::vector<CMatrix>& c_matrices,
298 std::vector<DMatrix>& d_matrices,
299 Opm::SparseTable<int>& wcells) const;
300
301 const WellInterface<TypeTag>& getWell(const std::string& well_name) const;
302
303 using PressureMatrix = Dune::BCRSMatrix<Opm::MatrixBlock<Scalar, 1, 1>>;
304
306 const BVector& weights,
307 const bool use_well_weights) const;
310 const BVector& weights,
311 const bool use_well_weights,
312 const int domainIndex) const
313 {
314 if (!nldd_) {
315 OPM_THROW(std::logic_error, "Attempt to access NLDD data without a NLDD solver");
316 }
317 return nldd_->addWellPressureEquations(jacobian,
318 weights,
319 use_well_weights,
320 domainIndex);
321 }
322
324 const std::vector<WellInterfacePtr>& localNonshutWells() const
325 {
326 return well_container_;
327 }
328
330 {
331 if (!nldd_) {
332 OPM_THROW(std::logic_error, "Attempt to access NLDD data without a NLDD solver");
333 }
334 return nldd_->well_local_cells();
335 }
336
337 const std::map<std::string, int>& well_domain() const
338 {
339 if (!nldd_) {
340 OPM_THROW(std::logic_error, "Attempt to access NLDD data without a NLDD solver");
341 }
342
343 return nldd_->well_domain();
344 }
345
346 auto begin() const { return well_container_.begin(); }
347 auto end() const { return well_container_.end(); }
348 bool empty() const { return well_container_.empty(); }
349
352
355
356 int compressedIndexForInterior(int cartesian_cell_idx) const override
357 {
358 return simulator_.vanguard().compressedIndexForInterior(cartesian_cell_idx);
359 }
360
361 int compressedIndexForInteriorLGR(const std::string& lgr_tag, const Connection& conn) const override
362 {
363 return simulator_.vanguard().compressedIndexForInteriorLGR(lgr_tag, conn);
364 }
365
366 // using the solution x to recover the solution xw for wells and applying
367 // xw to update Well State
369
370 // using the solution x to recover the solution xw for wells and applying
371 // xw to update Well State
373 const int domainIdx);
374 // Update cellRates_ with contributions from all wells
375 void updateCellRates();
376
377 // Update cellRates_ with contributions from wells in a specific domain
378 void updateCellRatesForDomain(int domainIndex,
379 const std::map<std::string, int>& well_domain_map);
380
381 const Grid& grid() const
382 { return simulator_.vanguard().grid(); }
383
384 const Simulator& simulator() const
385 { return simulator_; }
387 { return simulator_; }
388
390 const BlackoilWellModelNetwork<TypeTag>& network() const { return network_; }
391
392 std::vector<WellInterfacePtr>& wellContainer() { return well_container_; }
393 const std::vector<WellInterfacePtr>& wellContainer() const { return well_container_; }
394
396 { nldd_ = mod; }
397
399 { return guide_rate_handler_; }
400
402 { return guide_rate_handler_; }
403
404 // === Reservoir Coupling ===
405
409
417 void updateGuideRates(const int report_step_idx,
418 const double sim_time)
419 {
420 this->guide_rate_handler_.updateGuideRates(
421 report_step_idx, sim_time, this->wellState(), this->groupState()
422 );
423 }
424
426 bool isReservoirCouplingMaster() const { return rescoup_.isMaster(); }
427
429 bool isReservoirCouplingSlave() const { return rescoup_.isSlave(); }
430
436 bool isReservoirCouplingMasterGroup(const std::string& group_name) const {
437 return rescoup_.isMasterGroup(group_name);
438 }
439
443 return rescoup_.master();
444 }
446 return rescoup_.master();
447 }
448
452 return rescoup_.slave();
453 }
455 return rescoup_.slave();
456 }
457
458#ifdef RESERVOIR_COUPLING_ENABLED
459 void setReservoirCouplingMaster(ReservoirCouplingMaster<Scalar>* master)
460 {
461 rescoup_.setMaster(master);
462 this->guide_rate_handler_.setReservoirCouplingMaster(master);
463 this->groupStateHelper().setReservoirCouplingMaster(master);
464 }
465 void setReservoirCouplingSlave(ReservoirCouplingSlave<Scalar>* slave)
466 {
467 rescoup_.setSlave(slave);
468 this->guide_rate_handler_.setReservoirCouplingSlave(slave);
469 this->groupStateHelper().setReservoirCouplingSlave(slave);
470 }
471#endif
472
473 bool updateWellControlsAndNetwork(const bool mandatory_network_balance,
474 const double dt,
475 DeferredLogger& local_deferredLogger);
476
477 // TODO: finding a better naming
478 void assembleWellEqWithoutIteration(const double dt);
479
480 const std::vector<Scalar>& B_avg() const
481 { return B_avg_; }
482
483 const ModelParameters& param() const
484 { return param_; }
485
491
492#ifdef RESERVOIR_COUPLING_ENABLED
496 BlackoilWellModelRescoup<TypeTag>& rescoupHelper() { return rescoupHelper_; }
497#endif
498
499
500 template<class FluidState, class SingleWellState>
501 static Scalar computeTemperatureWeightFactor(const int perf_index, const int np, const FluidState& fs, const SingleWellState& ws)
502 {
503 const auto& perf_phase_rate = ws.perf_data.phase_rates;
504 // we only have one temperature pr cell any phaseIdx will do
505 Scalar cellTemperatures = fs.temperature(/*phaseIdx*/0).value();
506 Scalar weight_factor = 0.0;
507 for (unsigned phaseIdx = 0; phaseIdx < FluidSystem::numPhases; ++phaseIdx) {
508 if (!FluidSystem::phaseIsActive(phaseIdx)) {
509 continue;
510 }
511 Scalar cellInternalEnergy = fs.enthalpy(phaseIdx).value() -
512 fs.pressure(phaseIdx).value() / fs.density(phaseIdx).value();
513 Scalar cellBinv = fs.invB(phaseIdx).value();
514 Scalar cellDensity = fs.density(phaseIdx).value();
515 Scalar perfPhaseRate = perf_phase_rate[perf_index*np + phaseIdx];
516 weight_factor += cellDensity * (perfPhaseRate / cellBinv) * (cellInternalEnergy / cellTemperatures);
517 }
518 return (std::abs(weight_factor) + 1e-13);
519 }
520
521 protected:
523
524 // a vector of all the wells.
525 std::vector<WellInterfacePtr> well_container_{};
526
527 std::vector<bool> is_cell_perforated_{};
528
529 void initializeWellState(const int timeStepIdx);
530
531 // create the well container
532 void createWellContainer(const int report_step) override;
533
535 createWellPointer(const int wellID,
536 const int report_step) const;
537
538 template <typename WellType>
539 std::unique_ptr<WellType>
540 createTypedWellPointer(const int wellID,
541 const int time_step) const;
542
543 WellInterfacePtr createWellForWellTest(const std::string& well_name,
544 const int report_step,
545 DeferredLogger& deferred_logger) const;
546
548 std::size_t global_num_cells_{};
549 // the number of the cells in the local grid
550 std::size_t local_num_cells_{};
552 std::vector<Scalar> depth_{};
554 std::unique_ptr<RateConverterType> rateConverter_{};
555 std::map<std::string, std::unique_ptr<AverageRegionalPressureType>> regionalAveragePressureCalculator_{};
556
560
561 // A flag to tell the convergence report whether we need to take another newton step
563
564 std::vector<Scalar> B_avg_{};
565
566 const EquilGrid& equilGrid() const
567 { return simulator_.vanguard().equilGrid(); }
568
569 const EclipseState& eclState() const
570 { return simulator_.vanguard().eclState(); }
571
572 // compute the well fluxes and assemble them in to the reservoir equations as source terms
573 // and in the well equations.
574 void assemble(const double dt);
575
576 // well controls and network pressures affect each other and are solved in an iterative manner.
577 // the function handles one iteration of updating well controls and network pressures.
578 // it is possible to decouple the update of well controls and network pressures further.
579 // the returned two booleans are {continue_due_to_network, well_group_control_changed}, respectively
580 std::tuple<bool, bool, Scalar> updateWellControlsAndNetworkIteration(const bool mandatory_network_balance,
581 const bool relax_network_tolerance,
582 const bool optimize_gas_lift,
583 const double dt,
584 DeferredLogger& local_deferredLogger);
585
594 void initializeLocalWellStructure(const int reportStepIdx,
595 const bool enableWellPIScaling);
596
600 void initializeGroupStructure(const int reportStepIdx);
601
602 // called at the end of a time step
603 void timeStepSucceeded(const double simulationTime, const double dt);
604
605 // called at the end of a report step
606 void endReportStep();
607
608 // setting the well_solutions_ based on well_state.
610
612
613 void computePotentials(const std::size_t widx,
614 const WellState<Scalar, IndexTraits>& well_state_copy,
615 std::string& exc_msg,
616 ExceptionType::ExcEnum& exc_type) override;
617
618 const std::vector<Scalar>& wellPerfEfficiencyFactors() const;
619
620 void calculateProductivityIndexValuesShutWells(const int reportStepIdx, DeferredLogger& deferred_logger) override;
621 void calculateProductivityIndexValues(DeferredLogger& deferred_logger) override;
623 DeferredLogger& deferred_logger);
624
625 // The number of conservation quantities.
626 int numConservationQuantities() const;
627
628 int reportStepIndex() const;
629
630 void assembleWellEq(const double dt);
631
632 void prepareWellsBeforeAssembling(const double dt);
633
635
636 void extractLegacyDepth_();
637
639 void updateWellTestState(const double simulationTime, WellTestState& wellTestState);
640
641 void wellTesting(const int timeStepIdx, const double simulationTime, DeferredLogger& deferred_logger);
642
643 void calcResvCoeff(const int fipnum,
644 const int pvtreg,
645 const std::vector<Scalar>& production_rates,
646 std::vector<Scalar>& resv_coeff) const override;
647
648 void calcInjResvCoeff(const int fipnum,
649 const int pvtreg,
650 std::vector<Scalar>& resv_coeff) const override;
651
653
654 private:
655 // Private helper methods (alphabetical order)
656 // --------------------------------------------
657
658 void assignWellSpeciesRates_(data::Wells& wsrpt) const;
659 void assignWellTracerRates_(data::Wells& wsrpt) const;
660
669 bool isRescoupCoupledNetworkParticipant_() const;
670
678 bool isRescoupMasterCoupledNetworkIteration_() const;
679
687 bool isRescoupSlaveCoupledNetworkIteration_() const;
688
695 bool isRescoupSlaveOnSyncStepFirstSubstep_() const;
696
705 bool isRescoupSlaveConnectedToMasterNetwork_() const;
706
713 bool maybeSendSlaveGroupFlowToMaster_(const int reportStepIdx);
714
719 void sendSlaveNetworkLoopTerminationSignal_();
720
723 bool shouldDoPreStepNetworkRebalance_(const int episodeIdx) const;
724
726 void updateNetworkActiveState_();
727
730#ifdef RESERVOIR_COUPLING_ENABLED
731 BlackoilWellModelRescoup<TypeTag> rescoupHelper_;
732#endif
733 BlackoilWellModelNldd<TypeTag>* nldd_ = nullptr;
734
735 // These members are used to avoid reallocation in specific functions
736 // instead of using local variables.
737 // Their state is not relevant between function calls, so they can
738 // (and must) be mutable, as the functions using them are const.
739 mutable BVector x_local_;
740
741 // Store cell rates after assembling to avoid iterating all wells and connections for every element
742 std::map<int, RateVector> cellRates_;
743
744 // Cached well solution from the system solver, consumed by
745 // recoverWellSolutionAndUpdateWellState during postSolve.
746 std::optional<WellVector<Scalar>> cachedSystemWellSolution_;
747 std::vector<int> cachedWellDofOffsets_;
748
749 void assignWellTracerRates(data::Wells& wsrpt) const;
750 void assignWellSpeciesRates(data::Wells& wsrpt) const;
751
752 [[nodiscard]] auto rsConstInfo() const
753 -> typename WellState<Scalar,IndexTraits>::RsConstInfo;
754 };
755
756} // namespace Opm
757
758#include "BlackoilWellModel_impl.hpp"
759
760#endif // OPM_BLACKOILWELLMODEL_HEADER_INCLUDED
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 WellState< Scalar, IndexTraits > & wellState() const
Definition: BlackoilWellModelGeneric.hpp:157
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:101
ReservoirCoupling::Proxy< Scalar > & rescoup()
Get the reservoir coupling proxy.
Definition: BlackoilWellModel.hpp:407
void initializeGroupStructure(const int reportStepIdx)
Definition: BlackoilWellModel_impl.hpp:294
bool network_needs_more_balancing_force_another_newton_iteration_
Definition: BlackoilWellModel.hpp:562
Dune::BCRSMatrix< Dune::FieldMatrix< Scalar, numWellDofs, numWellDofs > > DMatrix
Definition: BlackoilWellModel.hpp:293
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:2162
ReservoirCouplingMaster< Scalar > & reservoirCouplingMaster()
Get reference to reservoir coupling master.
Definition: BlackoilWellModel.hpp:442
void endTimeStep()
Definition: BlackoilWellModel.hpp:170
void prepareTimeStep(DeferredLogger &deferred_logger)
Definition: BlackoilWellModel_impl.hpp:1985
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:1264
static constexpr bool has_bioeffects_
Definition: BlackoilWellModel.hpp:130
Dune::BCRSMatrix< Dune::FieldMatrix< Scalar, numWellDofs, numResDofs > > BMatrix
Definition: BlackoilWellModel.hpp:291
WellInterfacePtr createWellPointer(const int wellID, const int report_step) const
Definition: BlackoilWellModel_impl.hpp:1051
GuideRateHandler< Scalar, IndexTraits > guide_rate_handler_
Definition: BlackoilWellModel.hpp:558
const EclipseState & eclState() const
Definition: BlackoilWellModel.hpp:569
void prepareWellsBeforeAssembling(const double dt)
Definition: BlackoilWellModel_impl.hpp:1363
const std::vector< WellInterfacePtr > & localNonshutWells() const
Get list of local nonshut wells.
Definition: BlackoilWellModel.hpp:324
void prepareDeserialize(const int report_step)
Definition: BlackoilWellModel.hpp:203
void init()
Definition: BlackoilWellModel_impl.hpp:163
void setNlddAdapter(BlackoilWellModelNldd< TypeTag > *mod)
Definition: BlackoilWellModel.hpp:395
const Simulator & simulator() const
Definition: BlackoilWellModel.hpp:384
std::vector< Scalar > depth_
Definition: BlackoilWellModel.hpp:552
static constexpr bool has_geochem_
Definition: BlackoilWellModel.hpp:129
static constexpr EnergyModules energyModuleType_
Definition: BlackoilWellModel.hpp:126
std::size_t global_num_cells_
Definition: BlackoilWellModel.hpp:548
GetPropType< TypeTag, Properties::Scalar > Scalar
Definition: BlackoilWellModel.hpp:110
const std::vector< Scalar > & B_avg() const
Definition: BlackoilWellModel.hpp:480
SimulatorReportSingle last_report_
Definition: BlackoilWellModel.hpp:557
static const int solventSaturationIdx
Definition: BlackoilWellModel.hpp:123
Scalar gravity_
Definition: BlackoilWellModel.hpp:551
void initWellContainer(const int reportStepIdx) override
Definition: BlackoilWellModel_impl.hpp:182
void beginReportStep(const int time_step)
Definition: BlackoilWellModel_impl.hpp:199
static constexpr int numResDofs
Definition: BlackoilWellModel.hpp:289
const WellInterface< TypeTag > & getWell(const std::string &well_name) const
Definition: BlackoilWellModel_impl.hpp:2134
bool useTightRcNetworkCoupling() const
True when tight (per-sub-iteration) reservoir-coupling network coupling is in effect....
Definition: BlackoilWellModel.hpp:489
GetPropType< TypeTag, Properties::FluidSystem > FluidSystem
Definition: BlackoilWellModel.hpp:106
void beginIteration()
Definition: BlackoilWellModel.hpp:161
bool isReservoirCouplingMaster() const
Check if this process is a reservoir coupling master.
Definition: BlackoilWellModel.hpp:426
Dune::FieldVector< Scalar, numEq > VectorBlockType
Definition: BlackoilWellModel.hpp:134
const BlackoilWellModelNetwork< TypeTag > & network() const
Definition: BlackoilWellModel.hpp:390
void initFromRestartFile(const RestartValue &restartValues)
Definition: BlackoilWellModel.hpp:194
const ModelParameters param_
Definition: BlackoilWellModel.hpp:547
void beginEpisode()
Definition: BlackoilWellModel.hpp:153
GetPropType< TypeTag, Properties::ElementContext > ElementContext
Definition: BlackoilWellModel.hpp:107
GetPropType< TypeTag, Properties::Grid > Grid
Definition: BlackoilWellModel.hpp:104
GetPropType< TypeTag, Properties::EquilGrid > EquilGrid
Definition: BlackoilWellModel.hpp:105
static constexpr int numWellDofs
Definition: BlackoilWellModel.hpp:290
int numConservationQuantities() const
Definition: BlackoilWellModel_impl.hpp:2106
const std::map< std::string, int > & well_domain() const
Definition: BlackoilWellModel.hpp:337
const ReservoirCouplingSlave< Scalar > & reservoirCouplingSlave() const
Definition: BlackoilWellModel.hpp:454
bool updateWellControls(DeferredLogger &deferred_logger)
Definition: BlackoilWellModel_impl.hpp:1660
void endIteration()
Definition: BlackoilWellModel.hpp:167
static constexpr bool has_polymer_
Definition: BlackoilWellModel.hpp:125
int reportStepIndex() const
Definition: BlackoilWellModel_impl.hpp:2150
void calculateProductivityIndexValues(DeferredLogger &deferred_logger) override
Definition: BlackoilWellModel_impl.hpp:1927
void extractLegacyDepth_()
Definition: BlackoilWellModel_impl.hpp:2122
void extractLegacyCellPvtRegionIndex_()
Definition: BlackoilWellModel_impl.hpp:2090
std::vector< WellInterfacePtr > & wellContainer()
Definition: BlackoilWellModel.hpp:392
void recoverWellSolutionAndUpdateWellStateDomain(const BVector &x, const int domainIdx)
Definition: BlackoilWellModel_impl.hpp:1581
void updateAverageFormationFactor()
Definition: BlackoilWellModel_impl.hpp:2033
GetPropType< TypeTag, Properties::Simulator > Simulator
Definition: BlackoilWellModel.hpp:109
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:429
const ReservoirCouplingMaster< Scalar > & reservoirCouplingMaster() const
Definition: BlackoilWellModel.hpp:445
void initializeWellState(const int timeStepIdx)
Definition: BlackoilWellModel_impl.hpp:761
const Grid & grid() const
Definition: BlackoilWellModel.hpp:381
void updatePrimaryVariables()
Definition: BlackoilWellModel_impl.hpp:2081
const ReservoirCoupling::Proxy< Scalar > & rescoup() const
Definition: BlackoilWellModel.hpp:408
BlackOilPolymerModule< TypeTag, has_polymer_ > PolymerModule
Definition: BlackoilWellModel.hpp:137
void computeWellTemperature()
Definition: BlackoilWellModel_impl.hpp:2184
static const int numEq
Definition: BlackoilWellModel.hpp:122
void addWellPressureEquations(PressureMatrix &jacobian, const BVector &weights, const bool use_well_weights) const
Definition: BlackoilWellModel_impl.hpp:1485
const SimulatorReportSingle & lastReport() const
Definition: BlackoilWellModel_impl.hpp:637
bool updateWellControlsAndNetwork(const bool mandatory_network_balance, const double dt, DeferredLogger &local_deferredLogger)
Definition: BlackoilWellModel_impl.hpp:1202
void endEpisode()
Definition: BlackoilWellModel.hpp:176
GetPropType< TypeTag, Properties::SparseMatrixAdapter > SparseMatrixAdapter
Definition: BlackoilWellModel.hpp:113
void addWellContributions(SparseMatrixAdapter &jacobian) const
Definition: BlackoilWellModel_impl.hpp:1462
const EquilGrid & equilGrid() const
Definition: BlackoilWellModel.hpp:566
void assembleWellEq(const double dt)
Definition: BlackoilWellModel_impl.hpp:1351
WellInterfacePtr createWellForWellTest(const std::string &well_name, const int report_step, DeferredLogger &deferred_logger) const
Definition: BlackoilWellModel_impl.hpp:1102
GetPropType< TypeTag, Properties::Indices > Indices
Definition: BlackoilWellModel.hpp:108
int compressedIndexForInteriorLGR(const std::string &lgr_tag, const Connection &conn) const override
Definition: BlackoilWellModel.hpp:361
void calculateExplicitQuantities() const
Definition: BlackoilWellModel_impl.hpp:1645
BlackoilWellModelNetwork< TypeTag > & network()
Definition: BlackoilWellModel.hpp:389
Dune::BlockVector< Dune::FieldVector< Scalar, numWellDofs > > WVector
Definition: BlackoilWellModel.hpp:294
std::vector< WellInterfacePtr > well_container_
Definition: BlackoilWellModel.hpp:525
static constexpr std::size_t pressureVarIndex
Definition: BlackoilWellModel.hpp:120
void updateAndCommunicate(const int reportStepIdx)
Definition: BlackoilWellModel_impl.hpp:1740
Dune::BCRSMatrix< Opm::MatrixBlock< Scalar, 1, 1 > > PressureMatrix
Definition: BlackoilWellModel.hpp:303
bool empty() const
Definition: BlackoilWellModel.hpp:348
void computeTotalRatesForDof(RateVector &rate, unsigned globalIdx) const
Definition: BlackoilWellModel_impl.hpp:724
bool addMatrixContributions() const
Definition: BlackoilWellModel.hpp:350
void beginTimeStep()
Definition: BlackoilWellModel_impl.hpp:326
std::vector< Scalar > B_avg_
Definition: BlackoilWellModel.hpp:564
const std::vector< Scalar > & wellPerfEfficiencyFactors() const
GetPropType< TypeTag, Properties::RateVector > RateVector
Definition: BlackoilWellModel.hpp:111
bool updateGroupControls(const Group &group, DeferredLogger &deferred_logger, const int reportStepIdx)
Definition: BlackoilWellModel_impl.hpp:1767
std::map< std::string, std::unique_ptr< AverageRegionalPressureType > > regionalAveragePressureCalculator_
Definition: BlackoilWellModel.hpp:555
void calcInjResvCoeff(const int fipnum, const int pvtreg, std::vector< Scalar > &resv_coeff) const override
Definition: BlackoilWellModel_impl.hpp:2173
static Scalar computeTemperatureWeightFactor(const int perf_index, const int np, const FluidState &fs, const SingleWellState &ws)
Definition: BlackoilWellModel.hpp:501
GetPropType< TypeTag, Properties::GlobalEqVector > GlobalEqVector
Definition: BlackoilWellModel.hpp:112
void initializeLocalWellStructure(const int reportStepIdx, const bool enableWellPIScaling)
Definition: BlackoilWellModel_impl.hpp:248
GuideRateHandler< Scalar, IndexTraits > & guideRateHandler()
Definition: BlackoilWellModel.hpp:398
static constexpr bool has_solvent_
Definition: BlackoilWellModel.hpp:124
Dune::BlockVector< VectorBlockType > BVector
Definition: BlackoilWellModel.hpp:135
static constexpr bool has_micp_
Definition: BlackoilWellModel.hpp:128
std::unique_ptr< RateConverterType > rateConverter_
Definition: BlackoilWellModel.hpp:554
const SparseTable< int > & well_local_cells() const
Definition: BlackoilWellModel.hpp:329
void wellTesting(const int timeStepIdx, const double simulationTime, DeferredLogger &deferred_logger)
Definition: BlackoilWellModel_impl.hpp:560
std::vector< bool > is_cell_perforated_
Definition: BlackoilWellModel.hpp:527
ConvergenceReport getWellConvergence(const std::vector< Scalar > &B_avg, const bool checkWellGroupControlsAndNetwork=false) const
Definition: BlackoilWellModel_impl.hpp:1594
int numStrictIterations() const
Definition: BlackoilWellModel.hpp:353
typename FluidSystem::IndexTraitsType IndexTraits
Definition: BlackoilWellModel.hpp:117
void updateCellRatesForDomain(int domainIndex, const std::map< std::string, int > &well_domain_map)
Definition: BlackoilWellModel_impl.hpp:1409
data::WellBlockAveragePressures wellBlockAveragePressures() const
Definition: BlackoilWellModel.hpp:247
void assembleWellEqWithoutIteration(const double dt)
Definition: BlackoilWellModel_impl.hpp:1377
void updateCellRates()
Definition: BlackoilWellModel_impl.hpp:1397
void assemble(const double dt)
Definition: BlackoilWellModel_impl.hpp:1127
auto begin() const
Definition: BlackoilWellModel.hpp:346
std::size_t local_num_cells_
Definition: BlackoilWellModel.hpp:550
auto end() const
Definition: BlackoilWellModel.hpp:347
BlackOilBioeffectsModule< TypeTag, has_bioeffects_ > BioeffectsModule
Definition: BlackoilWellModel.hpp:138
bool alternative_well_rate_init_
Definition: BlackoilWellModel.hpp:553
Simulator & simulator()
Definition: BlackoilWellModel.hpp:386
void timeStepSucceeded(const double simulationTime, const double dt)
Definition: BlackoilWellModel_impl.hpp:647
std::unique_ptr< WellType > createTypedWellPointer(const int wellID, const int time_step) const
Definition: BlackoilWellModel_impl.hpp:1071
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:1892
Simulator & simulator_
Definition: BlackoilWellModel.hpp:522
void updateGuideRates(const int report_step_idx, const double sim_time)
Update guide rates for all wells and groups.
Definition: BlackoilWellModel.hpp:417
ReservoirCoupling::Proxy< Scalar > rescoup_
Definition: BlackoilWellModel.hpp:559
void createWellContainer(const int report_step) override
Definition: BlackoilWellModel_impl.hpp:804
std::unique_ptr< WellInterface< TypeTag > > WellInterfacePtr
Definition: BlackoilWellModel.hpp:191
ReservoirCouplingSlave< Scalar > & reservoirCouplingSlave()
Get reference to reservoir coupling slave.
Definition: BlackoilWellModel.hpp:451
data::Wells wellData() const
Definition: BlackoilWellModel.hpp:209
const ModelParameters & param() const
Definition: BlackoilWellModel.hpp:483
void updateWellTestState(const double simulationTime, WellTestState &wellTestState)
upate the wellTestState related to economic limits
Definition: BlackoilWellModel_impl.hpp:1821
void addWellPressureEquationsDomain(PressureMatrix &jacobian, const BVector &weights, const bool use_well_weights, const int domainIndex) const
Definition: BlackoilWellModel.hpp:309
bool isReservoirCouplingMasterGroup(const std::string &group_name) const
Check if a group is a reservoir coupling master group.
Definition: BlackoilWellModel.hpp:436
void addBCDMatrix(std::vector< BMatrix > &b_matrices, std::vector< CMatrix > &c_matrices, std::vector< DMatrix > &d_matrices, Opm::SparseTable< int > &wcells) const
Definition: BlackoilWellModel_impl.hpp:1471
const GuideRateHandler< Scalar, IndexTraits > & guideRateHandler() const
Definition: BlackoilWellModel.hpp:401
void addReservoirSourceTerms(GlobalEqVector &residual, const std::vector< typename SparseMatrixAdapter::MatrixBlock * > &diagMatAddress) const
Definition: BlackoilWellModel_impl.hpp:1507
int compressedIndexForInterior(int cartesian_cell_idx) const override
get compressed index for interior cells (-1, otherwise
Definition: BlackoilWellModel.hpp:356
Dune::BCRSMatrix< Dune::FieldMatrix< Scalar, numResDofs, numWellDofs > > CMatrix
Definition: BlackoilWellModel.hpp:292
static constexpr bool has_energy_
Definition: BlackoilWellModel.hpp:127
void recoverWellSolutionAndUpdateWellState(const BVector &x)
Definition: BlackoilWellModel_impl.hpp:1557
void addWellPressureEquationsStruct(PressureMatrix &jacobian) const
Definition: BlackoilWellModel_impl.hpp:1537
void calculateProductivityIndexValuesShutWells(const int reportStepIdx, DeferredLogger &deferred_logger) override
Definition: BlackoilWellModel_impl.hpp:1941
const std::vector< WellInterfacePtr > & wellContainer() const
Definition: BlackoilWellModel.hpp:393
void endReportStep()
Definition: BlackoilWellModel_impl.hpp:620
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:90
Definition: WellConnectionAuxiliaryModule.hpp:39
Definition: WellContributions.hpp:51
Definition: WellInterface.hpp:78
Definition: WellState.hpp:66
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 NonlinearSystemBlackOilReservoir.
Definition: BlackoilModelParameters.hpp:201
bool matrix_add_well_contributions_
Whether to add influences of wells between cells to the matrix and preconditioner matrix.
Definition: BlackoilModelParameters.hpp:315
int strict_outer_iter_wells_
Newton iteration where wells are stricly convergent.
Definition: BlackoilModelParameters.hpp:265
bool rc_network_loose_coupling_
Definition: BlackoilModelParameters.hpp:357
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