101 typename GetPropType<TypeTag, Properties::FluidSystem>::IndexTraitsType>
119 using IndexTraits =
typename FluidSystem::IndexTraitsType;
123 static const int numEq = Indices::numEq;
124 static const int solventSaturationIdx = Indices::solventSaturationIdx;
128 static constexpr bool has_micp_ = Indices::enableMICP;
132 using VectorBlockType = Dune::FieldVector<Scalar, numEq>;
133 using BVector = Dune::BlockVector<VectorBlockType>;
140 SurfaceToReservoirVoidage<FluidSystem, std::vector<int> >;
144 AverageRegionalPressure<FluidSystem, std::vector<int> >;
156 beginReportStep(simulator_.episodeIndex());
159 void beginTimeStep();
161 void beginIteration()
164 assemble(simulator_.model().newtonMethod().numIterations(),
165 simulator_.timeStepSize());
174 timeStepSucceeded(simulator_.time(), simulator_.timeStepSize());
182 void computeTotalRatesForDof(RateVector& rate,
183 unsigned globalIdx)
const;
185 template <
class Context>
186 void computeTotalRatesForDof(RateVector& rate,
187 const Context& context,
192 using WellInterfacePtr = std::shared_ptr<WellInterface<TypeTag> >;
198 this->simulator_.vanguard().transferWTestState(),
201 this->simulator_.vanguard().enableDistributedWells());
205 void prepareDeserialize(
const int report_step)
207 prepareDeserialize(report_step, grid().size(0),
209 this->simulator_.vanguard().enableDistributedWells());
212 data::Wells wellData()
const
214 auto wsrpt = this->wellState()
215 .report(this->simulator_.vanguard().globalCell().data(),
216 [
this](
const int well_index)
218 return this->wasDynamicallyShutThisTimeStep(well_index);
224 this->assignWellTracerRates(
wsrpt);
233 this->assignMassGasRate(
wsrpt, FluidSystem::referenceDensity(FluidSystem::gasPhaseIdx, 0));
236 this->assignWellTargets(
wsrpt);
247 data::WellBlockAveragePressures wellBlockAveragePressures()
const
249 return this->wbp_.computeWellBlockAveragePressures(this->gravity_);
252#if COMPILE_GPU_BRIDGE
262 void addWellContributions(SparseMatrixAdapter& jacobian)
const;
265 void addReservoirSourceTerms(GlobalEqVector& residual,
266 const std::vector<typename SparseMatrixAdapter::MatrixBlock*>&
diagMatAddress)
const;
269 void beginReportStep(
const int time_step);
284 std::tuple<bool, Scalar>
292 bool updateGroupControls(
const Group& group,
297 WellInterfacePtr getWell(
const std::string& well_name)
const;
299 using PressureMatrix = Dune::BCRSMatrix<Opm::MatrixBlock<Scalar, 1, 1>>;
301 void addWellPressureEquations(PressureMatrix& jacobian,
302 const BVector& weights,
304 void addWellPressureEquationsStruct(PressureMatrix& jacobian)
const;
305 void addWellPressureEquationsDomain(PressureMatrix& jacobian,
306 const BVector& weights,
311 OPM_THROW(std::logic_error,
"Attempt to access NLDD data without a NLDD solver");
313 return nldd_->addWellPressureEquations(jacobian,
322 return well_container_;
328 OPM_THROW(std::logic_error,
"Attempt to access NLDD data without a NLDD solver");
330 return nldd_->well_local_cells();
333 const std::map<std::string, int>& well_domain()
const
336 OPM_THROW(std::logic_error,
"Attempt to access NLDD data without a NLDD solver");
339 return nldd_->well_domain();
342 auto begin()
const {
return well_container_.begin(); }
343 auto end()
const {
return well_container_.end(); }
344 bool empty()
const {
return well_container_.empty(); }
346 bool addMatrixContributions()
const
349 int numStrictIterations()
const
357 int compressedIndexForInteriorLGR(
const std::string&
lgr_tag,
const Connection&
conn)
const override
359 return simulator_.vanguard().compressedIndexForInteriorLGR(
lgr_tag,
conn);
364 void recoverWellSolutionAndUpdateWellState(
const BVector& x);
368 void recoverWellSolutionAndUpdateWellStateDomain(
const BVector& x,
371 const Grid& grid()
const
372 {
return simulator_.vanguard().grid(); }
374 const Simulator& simulator()
const
375 {
return simulator_; }
380#ifdef RESERVOIR_COUPLING_ENABLED
382 return *(this->simulator_.reservoirCouplingMaster());
385 return *(this->simulator_.reservoirCouplingSlave());
388 return this->simulator_.reservoirCouplingMaster() !=
nullptr;
391 return this->simulator_.reservoirCouplingSlave() !=
nullptr;
395 this->guide_rate_handler_.setReservoirCouplingMaster(
master);
399 this->guide_rate_handler_.setReservoirCouplingSlave(
slave);
403 Simulator& simulator_;
406 std::vector<WellInterfacePtr> well_container_{};
408 std::vector<bool> is_cell_perforated_{};
413 void createWellContainer(
const int report_step)
override;
416 createWellPointer(
const int wellID,
417 const int report_step)
const;
419 template <
typename WellType>
420 std::unique_ptr<WellType>
421 createTypedWellPointer(
const int wellID,
424 WellInterfacePtr createWellForWellTest(
const std::string& well_name,
425 const int report_step,
428 const ModelParameters param_;
429 std::size_t global_num_cells_{};
431 std::size_t local_num_cells_{};
433 std::vector<Scalar> depth_{};
434 bool alternative_well_rate_init_{};
435 std::map<std::string, Scalar> well_group_thp_calc_;
436 std::unique_ptr<RateConverterType> rateConverter_{};
437 std::map<std::string, std::unique_ptr<AverageRegionalPressureType>> regionalAveragePressureCalculator_{};
439 SimulatorReportSingle last_report_{};
443 bool network_needs_more_balancing_force_another_newton_iteration_{
false};
448 std::vector<Scalar> B_avg_{};
450 const EquilGrid& equilGrid()
const
451 {
return simulator_.vanguard().equilGrid(); }
453 const EclipseState& eclState()
const
454 {
return simulator_.vanguard().eclState(); }
497 void endReportStep();
502 void updateAverageFormationFactor();
504 void computePotentials(
const std::size_t
widx,
510 const std::vector<Scalar>& wellPerfEfficiencyFactors()
const;
513 void calculateProductivityIndexValues(DeferredLogger&
deferred_logger)
override;
518 int numConservationQuantities()
const;
520 int reportStepIndex()
const;
524 void prepareWellsBeforeAssembling(
const double dt, DeferredLogger&
deferred_logger);
527 void assembleWellEqWithoutIteration(
const double dt, DeferredLogger&
deferred_logger);
529 void extractLegacyCellPvtRegionIndex_();
531 void extractLegacyDepth_();
538 void calcResvCoeff(
const int fipnum,
540 const std::vector<Scalar>& production_rates,
543 void calcInjResvCoeff(
const int fipnum,
547 void computeWellTemperature();
557 mutable BVector x_local_;
559 void assignWellTracerRates(data::Wells&
wsrpt)
const;