23#ifndef OPM_BLACKOILWELLMODEL_IMPL_HEADER_INCLUDED
24#define OPM_BLACKOILWELLMODEL_IMPL_HEADER_INCLUDED
27#ifndef OPM_BLACKOILWELLMODEL_HEADER_INCLUDED
32#include <opm/grid/utility/cartesianToCompressed.hpp>
34#include <opm/input/eclipse/Schedule/Network/Balance.hpp>
35#include <opm/input/eclipse/Schedule/Network/ExtNetwork.hpp>
36#include <opm/input/eclipse/Schedule/Well/PAvgDynamicSourceData.hpp>
37#include <opm/input/eclipse/Schedule/Well/WellMatcher.hpp>
38#include <opm/input/eclipse/Schedule/Well/WellTestConfig.hpp>
39#include <opm/input/eclipse/Schedule/Well/WellEconProductionLimits.hpp>
41#include <opm/input/eclipse/Units/UnitSystem.hpp>
67#include <fmt/format.h>
70 template<
typename TypeTag>
77 simulator.vanguard().summaryState(),
78 simulator.vanguard().eclState(),
80 simulator.gridView().comm(),
82 , simulator_(simulator)
83 , guide_rate_handler_{
85 simulator.vanguard().schedule(),
86 simulator.vanguard().summaryState(),
87 simulator.vanguard().grid().comm()
89 , gaslift_(this->terminal_output_)
92 , rescoupHelper_(*this)
101 auto& parallel_wells =
simulator.vanguard().parallelWells();
104 for(
const auto& name_bool : parallel_wells) {
112 Parameters::Get<Parameters::AlternativeWellRateInit>();
114 using SourceDataSpan =
115 typename PAvgDynamicSourceData<Scalar>::template SourceDataSpan<Scalar>;
117 this->
wbp_.initializeSources(
118 [
this](
const std::size_t globalIndex)
120 [
this](
const int localCell, SourceDataSpan sourceTerms)
122 using Item =
typename SourceDataSpan::Item;
124 const auto* intQuants = this->
simulator_.model()
125 .cachedIntensiveQuantities(localCell, 0);
126 const auto& fs = intQuants->fluidState();
129 .set(Item::PoreVol, intQuants->porosity().value() *
130 this->
simulator_.model().dofTotalVolume(localCell))
131 .set(Item::Depth, this->
depth_[localCell]);
133 constexpr auto io = FluidSystem::oilPhaseIdx;
134 constexpr auto ig = FluidSystem::gasPhaseIdx;
135 constexpr auto iw = FluidSystem::waterPhaseIdx;
138 const auto haveOil = FluidSystem::phaseIsActive(io);
139 const auto haveGas = FluidSystem::phaseIsActive(ig);
140 const auto haveWat = FluidSystem::phaseIsActive(iw);
142 auto weightedPhaseDensity = [&fs](
const auto ip)
144 return fs.saturation(ip).value() * fs.density(ip).value();
147 if (haveOil) { sourceTerms.set(Item::Pressure, fs.pressure(io).value()); }
148 else if (haveGas) { sourceTerms.set(Item::Pressure, fs.pressure(ig).value()); }
149 else { sourceTerms.set(Item::Pressure, fs.pressure(iw).value()); }
153 if (haveOil) { rho += weightedPhaseDensity(io); }
154 if (haveGas) { rho += weightedPhaseDensity(ig); }
155 if (haveWat) { rho += weightedPhaseDensity(iw); }
157 sourceTerms.set(Item::MixtureDensity, rho);
162 template<
typename TypeTag>
167 extractLegacyCellPvtRegionIndex_();
168 extractLegacyDepth_();
170 gravity_ = simulator_.problem().gravity()[2];
172 this->initial_step_ =
true;
175 simulator_.model().addAuxiliaryModule(
this);
177 is_cell_perforated_.resize(local_num_cells_,
false);
181 template<
typename TypeTag>
186 const uint64_t effective_events_mask = ScheduleEvents::WELL_STATUS_CHANGE
187 + ScheduleEvents::NEW_WELL;
188 const auto& events = this->schedule()[reportStepIdx].wellgroup_events();
189 for (
auto& wellPtr : this->well_container_) {
190 const bool well_opened_this_step = this->report_step_starts_ &&
191 events.hasEvent(wellPtr->name(),
192 effective_events_mask);
193 wellPtr->init(this->depth_, this->gravity_,
194 this->B_avg_, well_opened_this_step);
198 template<
typename TypeTag>
203 this->groupStateHelper().setReportStep(timeStepIdx);
204 this->report_step_starts_ =
true;
205 this->report_step_start_events_ = this->schedule()[timeStepIdx].wellgroup_events();
207 this->rateConverter_ = std::make_unique<RateConverterType>
208 (std::vector<int>(this->local_num_cells_, 0));
211 const bool initializeWellState = !this->deserialized_state_pending_;
212 const auto enableWellPIScaling =
true;
213 this->initializeLocalWellStructure(timeStepIdx,
215 initializeWellState);
216 this->deserialized_state_pending_ =
false;
219 this->initializeGroupStructure(timeStepIdx);
221 const auto& comm = this->simulator_.vanguard().grid().comm();
227 this->rateConverter_->template defineState<ElementContext>(this->simulator_);
231 const auto& sched_state = this->schedule()[timeStepIdx];
233 this->vfp_properties_ = std::make_unique<VFPProperties<Scalar, IndexTraits>>
234 (sched_state.vfpinj(), sched_state.vfpprod(), this->wellState());
241 this->commitWGState();
243 this->wellStructureChangedDynamically_ =
false;
250 template <
typename TypeTag>
254 const bool enableWellPIScaling,
255 const bool initializeWellState)
257 auto logger_guard = this->groupStateHelper().pushLogger();
258 auto& local_deferredLogger = this->groupStateHelper().deferredLogger();
260 const auto& comm = this->simulator_.vanguard().grid().comm();
265 this->registerNewParallelWells(reportStepIdx);
268 this->wells_ecl_ = this->getLocalWells(reportStepIdx);
269 this->local_parallel_well_info_ =
270 this->createLocalParallelWellInfo(this->wells_ecl_);
277 if (initializeWellState) {
278 this->initializeWellPerfData();
279 this->initializeWellState(reportStepIdx);
281 this->wbp_.initializeWBPCalculationService();
283 if (initializeWellState && this->param_.use_multisegment_well_ && this->anyMSWellOpenLocal()) {
284 this->wellState().initWellStateMSWell(this->wells_ecl_, &this->prevWellState(), has_energy_);
287 this->initializeWellProdIndCalculators();
289 if (enableWellPIScaling && this->schedule()[reportStepIdx].events()
290 .hasEvent(ScheduleEvents::Events::WELL_PRODUCTIVITY_INDEX))
292 this->runWellPIScaling(reportStepIdx, local_deferredLogger);
296 "Failed to initialize local well structure: ",
297 this->terminal_output_, comm)
304 template <
typename TypeTag>
309 const auto& comm = this->simulator_.vanguard().grid().comm();
313 const auto& fieldGroup =
314 this->schedule().getGroup(
"FIELD", reportStepIdx);
316 this->groupStateHelper().setCmodeGroup(fieldGroup);
320 if (this->schedule()[reportStepIdx].has_gpmaint()) {
321 this->groupStateHelper().setRegionAveragePressureCalculator(
323 this->eclState_.fieldProps(),
324 this->regionalAveragePressureCalculator_
336 template<
typename TypeTag>
341 OPM_TIMEBLOCK(beginTimeStep);
343 this->updateAverageFormationFactor();
345 auto logger_guard = this->groupStateHelper().pushLogger();
346 auto& local_deferredLogger = this->groupStateHelper().deferredLogger();
348#ifdef RESERVOIR_COUPLING_ENABLED
349 auto rescoup_logger_guard = this->rescoupHelper_.setupScopedLogger(local_deferredLogger);
352 this->switched_prod_groups_.clear();
353 this->switched_inj_groups_.clear();
355 if (this->wellStructureChangedDynamically_) {
360 const auto reportStepIdx =
361 this->simulator_.episodeIndex();
365 const auto enableWellPIScaling =
false;
367 this->initializeLocalWellStructure(reportStepIdx, enableWellPIScaling,
true);
368 this->initializeGroupStructure(reportStepIdx);
370 this->commitWGState();
376 this->wellStructureChangedDynamically_ =
false;
379 this->resetWGState();
380 const int reportStepIdx = simulator_.episodeIndex();
382 this->wellState().updateWellsDefaultALQ(this->schedule(), reportStepIdx, this->summaryState());
383 this->wellState().gliftTimeStepInit();
385 const double simulationTime = simulator_.time();
389 wellTesting(reportStepIdx, simulationTime, local_deferredLogger);
392 createWellContainer(reportStepIdx);
394#ifdef RESERVOIR_COUPLING_ENABLED
395 if (this->isReservoirCouplingMaster()) {
396 if (this->reservoirCouplingMaster().isFirstSubstepOfSyncTimestep()) {
397 this->rescoupHelper_.receiveSlaveGroupData();
404 this->updateAndCommunicateGroupData(reportStepIdx,
false);
407 const Grid& grid = simulator_.vanguard().grid();
408 this->wells_active_ = grid.comm().max(!this->well_container_.empty());
413 this->initWellContainer(reportStepIdx);
416 std::fill(is_cell_perforated_.begin(), is_cell_perforated_.end(),
false);
417 for (
auto& well : well_container_) {
418 well->updatePerforatedCell(is_cell_perforated_);
422 this->calculateEfficiencyFactors(reportStepIdx);
424 if constexpr (has_polymer_)
426 if (PolymerModule::hasPlyshlog() || getPropValue<TypeTag, Properties::EnablePolymerMW>() ) {
427 this->setRepRadiusPerfLength();
434 this->terminal_output_, simulator_.vanguard().grid().comm());
436 for (
auto& well : well_container_) {
437 well->setVFPProperties(this->vfp_properties_.get());
438 well->setGuideRate(&this->guideRate_);
441 this->updateFiltrationModelsPreStep(local_deferredLogger);
444 for (
auto& well : well_container_) {
445 well->closeCompletions(this->wellTestState());
451 if (alternative_well_rate_init_) {
456 for (
const auto& well : well_container_) {
457 if (well->isProducer() && !well->wellIsStopped()) {
458 well->initializeProducerWellState(simulator_, this->wellState(), local_deferredLogger);
463 for (
const auto& well : well_container_) {
464 if (well->isVFPActive(local_deferredLogger)){
465 well->setPrevSurfaceRates(this->wellState(), this->prevWellState());
469 this->updateWellPotentials(reportStepIdx,
471 simulator_.vanguard().summaryConfig(),
472 local_deferredLogger);
473 }
catch ( std::runtime_error& e ) {
474 const std::string msg =
"A zero well potential is returned for output purposes. ";
475 local_deferredLogger.warning(
"WELL_POTENTIAL_CALCULATION_FAILED", msg);
478 this->guide_rate_handler_.updateGuideRates(
479 reportStepIdx, simulationTime, this->wellState(), this->groupState()
481 bool slave_needs_well_solution =
false;
482#ifdef RESERVOIR_COUPLING_ENABLED
483 if (this->isReservoirCouplingSlave()) {
484 if (this->reservoirCouplingSlave().isFirstSubstepOfSyncTimestep()) {
488 this->reservoirCouplingSlave().setWellsSolvedThisSyncStep(
false);
489 this->rescoupHelper_.sendSlaveGroupDataToMaster();
490 this->rescoupHelper_.receiveGroupConstraintsFromMaster();
491 this->rescoupHelper_.receiveCoupledNetworkActiveStatus();
492 this->groupStateHelper().updateSlaveGroupCmodesFromMaster();
493 this->reservoirCouplingSlave().markSlaveGroupsInSchedule(
494 this->schedule_, reportStepIdx);
495 slave_needs_well_solution =
true;
502 if (this->schedule_[reportStepIdx].has_gpmaint()) {
503 for (
const auto& calculator : regionalAveragePressureCalculator_) {
504 calculator.second->template defineState<ElementContext>(simulator_);
506 const double dt = simulator_.timeStepSize();
507 const Group& fieldGroup = this->schedule().getGroup(
"FIELD", reportStepIdx);
509 this->groupStateHelper().updateGpMaintTargetForGroups(fieldGroup,
510 regionalAveragePressureCalculator_,
516 this->updateAndCommunicateGroupData(reportStepIdx,
true);
519 for (
auto& well : well_container_) {
520 const uint64_t effective_events_mask = ScheduleEvents::WELL_STATUS_CHANGE
521 + ScheduleEvents::INJECTION_TYPE_CHANGED
522 + ScheduleEvents::WELL_SWITCHED_INJECTOR_PRODUCER
523 + ScheduleEvents::NEW_WELL;
525 const auto& events = this->schedule()[reportStepIdx].wellgroup_events();
526 const bool event = this->report_step_starts_ && events.hasEvent(well->name(), effective_events_mask);
527 const bool dyn_status_change = this->wellState().well(well->name()).status
528 != this->prevWellState().well(well->name()).status;
530 if (event || dyn_status_change || slave_needs_well_solution) {
532 well->scaleSegmentRatesAndPressure(this->wellState());
533 well->calculateExplicitQuantities(simulator_, this->groupStateHelper());
534 well->updateWellStateWithTarget(simulator_, this->groupStateHelper(), this->wellState());
535 well->updatePrimaryVariables(this->groupStateHelper());
536 well->solveWellEquation(
537 simulator_, this->groupStateHelper(), this->wellState()
539 }
catch (
const std::exception& e) {
540 const std::string msg =
"Compute initial well solution for new well " + well->name() +
" failed. Continue with zero initial rates";
541 local_deferredLogger.warning(
"WELL_INITIAL_SOLVE_FAILED", msg);
549#ifdef RESERVOIR_COUPLING_ENABLED
550 if (slave_needs_well_solution) {
552 this->reservoirCouplingSlave().setWellsSolvedThisSyncStep(
true);
554 this->updateAndCommunicateGroupData(reportStepIdx,
false);
555 this->rescoupHelper_.sendSlaveGroupDataToMaster();
557 else if (this->isReservoirCouplingMaster()) {
558 if (this->reservoirCouplingMaster().isFirstSubstepOfSyncTimestep()) {
559 this->rescoupHelper_.sendMasterGroupConstraintsToSlaves();
560 this->rescoupHelper_.sendCoupledNetworkActiveStatus();
561 this->rescoupHelper_.receiveSlaveGroupData();
567 const std::string msg =
"Compute initial well solution for new wells failed. Continue with zero initial rates";
568 local_deferredLogger.warning(
"WELL_INITIAL_SOLVE_FAILED", msg);
571 const auto& comm = simulator_.vanguard().grid().comm();
573 exc_type,
"beginTimeStep() failed: " + exc_msg, this->terminal_output_, comm);
577 template<
typename TypeTag>
585 template<
typename TypeTag>
593 template<
typename TypeTag>
596 const double simulationTime,
599 for (
const std::string& well_name : this->getWellsForTesting(timeStepIdx, simulationTime)) {
600 const Well& wellEcl = this->schedule().getWell(well_name, timeStepIdx);
601 if (wellEcl.getStatus() == Well::Status::SHUT)
604 WellInterfacePtr well = createWellForWellTest(well_name, timeStepIdx, deferred_logger);
606 well->init(depth_, gravity_, B_avg_,
true);
608 Scalar well_efficiency_factor = wellEcl.getEfficiencyFactor() *
609 this->wellState().getGlobalEfficiencyScalingFactor(well_name);
610 this->groupStateHelper().accumulateGroupEfficiencyFactor(
611 this->schedule().getGroup(wellEcl.groupName(), timeStepIdx),
612 well_efficiency_factor
615 well->setWellEfficiencyFactor(well_efficiency_factor);
616 well->setVFPProperties(this->vfp_properties_.get());
617 well->setGuideRate(&this->guideRate_);
620 if (well->isProducer() && alternative_well_rate_init_) {
621 well->initializeProducerWellState(simulator_, this->wellState(), deferred_logger);
623 if (well->isVFPActive(deferred_logger)) {
624 well->setPrevSurfaceRates(this->wellState(), this->prevWellState());
627 this->network_.initializeWell(*well);
630 GLiftEclWells ecl_well_map;
631 gaslift_.initGliftEclWellMap(well_container_, ecl_well_map);
632 well->wellTesting(simulator_,
634 this->groupStateHelper(),
636 this->wellTestState(),
638 this->well_open_times_);
639 }
catch (
const std::exception& e) {
640 const std::string msg =
641 fmt::format(fmt::runtime(
"Exception during testing of well: {}. The well will not open.\n"
642 "Exception message: {}"), wellEcl.name(), e.what());
643 deferred_logger.
warning(
"WELL_TESTING_FAILED", msg);
649 template<
typename TypeTag>
655 for (
auto&& pinfo : this->local_parallel_well_info_)
666 template<
typename TypeTag>
676 template<
typename TypeTag>
681 this->closed_this_step_.clear();
684 this->report_step_starts_ =
false;
685 const int reportStepIdx = simulator_.episodeIndex();
687 auto logger_guard = this->groupStateHelper().pushLogger();
688 auto& local_deferredLogger = this->groupStateHelper().deferredLogger();
689 for (
const auto& well : well_container_) {
690 if (getPropValue<TypeTag, Properties::EnablePolymerMW>() && well->isInjector()) {
691 well->updateWaterThroughput(dt, this->wellState());
695 for (
const auto& well : well_container_) {
696 well->updateConnectionTransmissibilityFactor(simulator_, this->wellState().well(well->indexOfWell()));
697 well->updateConnectionDFactor(simulator_, this->wellState().well(well->indexOfWell()));
700 if (Indices::waterEnabled) {
701 this->updateFiltrationModelsPostStep(dt, FluidSystem::waterPhaseIdx, local_deferredLogger);
705 this->updateInjMult(local_deferredLogger);
708 for (
const auto& well : well_container_) {
709 well->reportWellSwitching(this->wellState().well(well->indexOfWell()), local_deferredLogger);
712 if (this->terminal_output_) {
713 this->reportGroupSwitching(local_deferredLogger);
717 rateConverter_->template defineState<ElementContext>(simulator_);
721 this->updateWellPotentials(reportStepIdx,
723 simulator_.vanguard().summaryConfig(),
724 local_deferredLogger);
725 }
catch ( std::runtime_error& e ) {
726 const std::string msg =
"A zero well potential is returned for output purposes. ";
727 local_deferredLogger.warning(
"WELL_POTENTIAL_CALCULATION_FAILED", msg);
734 const double closure_time = simulationTime + dt;
736 updateWellTestState(closure_time, this->wellTestState());
739 const Group& fieldGroup = this->schedule_.getGroup(
"FIELD", reportStepIdx);
740 this->checkGEconLimits(fieldGroup, closure_time,
741 simulator_.episodeIndex(), local_deferredLogger);
742 this->checkGconsaleLimits(fieldGroup, this->wellState(),
743 simulator_.episodeIndex(), local_deferredLogger);
745 this->calculateProductivityIndexValues(local_deferredLogger);
747 this->groupStateHelper().updateNONEProductionGroups();
749#ifdef RESERVOIR_COUPLING_ENABLED
750 this->rescoupHelper_.rescoupSyncSummaryData();
752 this->commitWGState();
755 this->computeWellTemperature();
759 template<
typename TypeTag>
763 unsigned elemIdx)
const
767 if (!is_cell_perforated_[elemIdx] || cellRates_.count(elemIdx) == 0) {
771 rate = cellRates_.at(elemIdx);
775 template<
typename TypeTag>
776 template <
class Context>
780 const Context& context,
782 unsigned timeIdx)
const
785 int elemIdx = context.globalSpaceIndex(spaceIdx, timeIdx);
787 if (!is_cell_perforated_[elemIdx] || cellRates_.count(elemIdx) == 0) {
791 rate = cellRates_.at(elemIdx);
796 template<
typename TypeTag>
801 const auto pressIx = []()
803 if (Indices::oilEnabled) {
return FluidSystem::oilPhaseIdx; }
804 if (Indices::waterEnabled) {
return FluidSystem::waterPhaseIdx; }
806 return FluidSystem::gasPhaseIdx;
809 auto cellPressures = std::vector<Scalar>(this->local_num_cells_,
Scalar{0});
810 auto cellTemperatures = std::vector<Scalar>(this->local_num_cells_,
Scalar{0});
813 const auto& gridView = this->simulator_.vanguard().gridView();
816 for (
const auto& elem : elements(gridView, Dune::Partitions::interior)) {
817 elemCtx.updatePrimaryStencil(elem);
818 elemCtx.updatePrimaryIntensiveQuantities(0);
820 const auto ix = elemCtx.globalSpaceIndex(0, 0);
821 const auto& fs = elemCtx.intensiveQuantities(0, 0).fluidState();
823 cellPressures[ix] = fs.pressure(pressIx).value();
824 cellTemperatures[ix] = fs.temperature(0).value();
827 this->simulator_.vanguard().grid().comm());
829 this->wellState().init(cellPressures, cellTemperatures, this->schedule(), this->wells_ecl_,
830 this->local_parallel_well_info_, timeStepIdx,
831 &this->prevWellState(), this->well_perf_data_,
832 this->summaryState(), simulator_.vanguard().enableDistributedWells());
839 template<
typename TypeTag>
844 auto logger_guard = this->groupStateHelper().pushLogger();
845 auto& local_deferredLogger = this->groupStateHelper().deferredLogger();
847 const int nw = this->numLocalWells();
849 well_container_.clear();
852 well_container_.reserve(nw);
854 const auto& wmatcher = this->schedule().wellMatcher(report_step);
855 const auto& wcycle = this->schedule()[report_step].wcycle.get();
859 std::ranges::for_each(this->wells_ecl_,
860 [
this, &wg_events = this->report_step_start_events_](
const auto& well_ecl)
862 if (!well_ecl.hasConnections()) {
867 constexpr auto events_mask = ScheduleEvents::WELL_STATUS_CHANGE |
868 ScheduleEvents::REQUEST_OPEN_WELL |
869 ScheduleEvents::REQUEST_SHUT_WELL;
870 const bool well_event =
871 this->report_step_starts_ &&
872 wg_events.hasEvent(well_ecl.name(), events_mask);
881 if (well_ecl.getStatus() == WellStatus::OPEN) {
882 this->well_open_times_.insert_or_assign(well_ecl.name(),
883 this->simulator_.time());
884 this->well_close_times_.erase(well_ecl.name());
885 }
else if (well_ecl.getStatus() == WellStatus::SHUT) {
886 this->well_close_times_.insert_or_assign(well_ecl.name(),
887 this->simulator_.time());
888 this->well_open_times_.erase(well_ecl.name());
894 const auto cycle_states = wcycle.wellStatus(this->simulator_.time(),
896 this->well_open_times_,
897 this->well_close_times_);
899 for (
int w = 0; w < nw; ++w) {
900 const Well& well_ecl = this->wells_ecl_[w];
902 if (!well_ecl.hasConnections()) {
907 const std::string& well_name = well_ecl.name();
908 const auto well_status = this->schedule()
909 .getWell(well_name, report_step).getStatus();
911 const bool shut_event = this->wellState().well(w).events.hasEvent(ScheduleEvents::WELL_STATUS_CHANGE)
912 && well_status == Well::Status::SHUT;
913 const bool open_event = this->wellState().well(w).events.hasEvent(ScheduleEvents::WELL_STATUS_CHANGE)
914 && well_status == Well::Status::OPEN;
915 const auto& ws = this->wellState().well(well_name);
917 if (shut_event && ws.status != Well::Status::SHUT) {
918 this->closed_this_step_.insert(well_name);
919 this->wellState().shutWell(w);
920 }
else if (open_event && ws.status != Well::Status::OPEN) {
921 this->wellState().openWell(w);
925 if (this->wellTestState().well_is_closed(well_name)) {
938 const bool closed_this_step =
939 (this->wellTestState().lastTestTime(well_name) == simulator_.time()) &&
940 !this->wasDynamicallyShutThisTimeStep(well_name);
943 auto& events = this->wellState().well(w).events;
944 if (events.hasEvent(ScheduleEvents::REQUEST_OPEN_WELL)) {
945 if (!closed_this_step) {
946 this->wellTestState().open_well(well_name);
947 this->wellTestState().open_completions(well_name);
948 this->well_open_times_.insert_or_assign(well_name,
949 this->simulator_.time());
950 this->well_close_times_.erase(well_name);
952 events.clearEvent(ScheduleEvents::REQUEST_OPEN_WELL);
962 auto& well_test_state = this->wellTestState();
963 const auto& sched_state = this->schedule()[report_step];
964 const bool may_reopen_completions =
965 ws.status == Well::Status::OPEN &&
966 sched_state.events().hasEvent(ScheduleEvents::COMPLETION_CHANGE) &&
967 well_test_state.num_closed_completions() > 0;
969 if (may_reopen_completions) {
970 const auto& completion_events = sched_state.wellcompletion_events();
971 for (
const auto& connection : well_ecl.getConnections()) {
972 const int complnum = connection.complnum();
976 if (!well_test_state.completion_is_closed(well_name, complnum) ||
977 !completion_events.hasEvent(well_name, complnum, ScheduleEvents::REQUEST_OPEN_COMPLETION)) {
982 const bool closed_this_step =
983 (well_test_state.lastCompletionCloseTime(well_name, complnum) == simulator_.time());
984 if (closed_this_step) {
988 well_test_state.open_completion(well_name, complnum);
989 local_deferredLogger.info(
990 fmt::format(
"Completion {} - block ({}, {}, {}) for well {} "
991 "is reopened due to an explicit WELOPEN/COMPDAT "
994 connection.getI() + 1,
995 connection.getJ() + 1,
996 connection.getK() + 1,
1003 if (this->wellTestState().well_is_closed(well_name))
1005 if (well_ecl.getAutomaticShutIn() ||
1006 !well_ecl.getAllowCrossFlow() ||
1007 this->allConnectionsClosed(well_ecl))
1009 this->wellState().shutWell(w);
1010 this->well_close_times_.erase(well_name);
1011 this->well_open_times_.erase(well_name);
1015 this->wellState().stopWell(w);
1019 if (!well_ecl.getAllowCrossFlow()) {
1020 const bool any_zero_rate_constraint = well_ecl.isProducer()
1021 ? well_ecl.productionControls(this->summaryState_).anyZeroRateConstraint()
1022 : well_ecl.injectionControls(this->summaryState_).anyZeroRateConstraint();
1023 if (any_zero_rate_constraint) {
1025 local_deferredLogger.debug(fmt::format(fmt::runtime(
" Well {} gets shut due to having zero rate constraint and disallowing crossflow "), well_ecl.name()));
1026 this->wellState().shutWell(w);
1027 this->well_close_times_.erase(well_name);
1028 this->well_open_times_.erase(well_name);
1033 if (!wcycle.empty()) {
1034 const auto it = cycle_states.find(well_name);
1035 if (it != cycle_states.end()) {
1036 if (!it->second || well_status == Well::Status::SHUT) {
1038 if (well_status == Well::Status::SHUT) {
1039 this->well_open_times_.erase(well_name);
1040 this->well_close_times_.erase(well_name);
1042 this->wellState().shutWell(w);
1045 this->wellState().openWell(w);
1051 if (ws.status == Well::Status::SHUT) {
1055 well_container_.emplace_back(this->createWellPointer(w, report_step));
1057 if (ws.status == Well::Status::STOP) {
1058 well_container_.back()->stopWell();
1059 this->well_close_times_.erase(well_name);
1060 this->well_open_times_.erase(well_name);
1064 if (!wcycle.empty()) {
1065 const auto schedule_open =
1066 [&wg_events = this->report_step_start_events_](
const std::string& name)
1068 return wg_events.hasEvent(name, ScheduleEvents::REQUEST_OPEN_WELL);
1070 for (
const auto& [wname, wscale] : wcycle.efficiencyScale(this->simulator_.time(),
1071 this->simulator_.timeStepSize(),
1073 this->well_open_times_,
1076 this->wellState().updateEfficiencyScalingFactor(wname, wscale);
1077 this->schedule_.add_event(ScheduleEvents::WELLGROUP_EFFICIENCY_UPDATE, report_step);
1082 this->well_container_generic_.clear();
1083 for (
auto& w : well_container_) {
1084 this->well_container_generic_.push_back(w.get());
1087 this->network_.initialize(report_step);
1089 this->wbp_.registerOpenWellsForWBPCalculation();
1096 template <
typename TypeTag>
1101 const auto is_multiseg = this->wells_ecl_[wellID].isMultiSegment();
1103 if (! (this->param_.use_multisegment_well_ && is_multiseg)) {
1104 return this->
template createTypedWellPointer<StandardWell<TypeTag>>(wellID, report_step);
1107 return this->
template createTypedWellPointer<MultisegmentWell<TypeTag>>(wellID, report_step);
1115 template <
typename TypeTag>
1116 template <
typename WellType>
1117 std::unique_ptr<WellType>
1122 const auto& perf_data = this->well_perf_data_[wellID];
1125 const auto pvtreg = perf_data.empty()
1126 ? 0 : this->pvt_region_idx_[perf_data.front().cell_index];
1128 const auto& parallel_well_info = this->local_parallel_well_info_[wellID].get();
1129 const auto global_pvtreg = parallel_well_info.broadcastFirstPerforationValue(pvtreg);
1131 return std::make_unique<WellType>(this->wells_ecl_[wellID],
1135 *this->rateConverter_,
1137 this->numConservationQuantities(),
1147 template<
typename TypeTag>
1151 const int report_step,
1156 std::ranges::find_if(this->wells_ecl_,
1157 [&well_name](
const auto& w)
1158 {
return well_name == w.name(); });
1160 if (it == this->wells_ecl_.end()) {
1162 fmt::format(fmt::runtime(
"Could not find well {} in wells_ecl"), well_name),
1166 const int pos =
static_cast<int>(std::distance(this->wells_ecl_.begin(), it));
1167 return this->createWellPointer(pos, report_step);
1172 template<
typename TypeTag>
1178 auto logger_guard = this->groupStateHelper().pushLogger();
1179 auto& local_deferredLogger = this->groupStateHelper().deferredLogger();
1181 const auto& iterCtx = simulator_.problem().iterationContext();
1184 if (gaslift_.terminalOutput()) {
1185 const std::string msg =
1186 fmt::format(fmt::runtime(
"assemble() : iteration {}"), iterCtx.iteration());
1187 gaslift_.gliftDebug(msg, local_deferredLogger);
1191 Dune::Timer perfTimer;
1193 this->closed_offending_wells_.clear();
1196 if (iterCtx.needsTimestepInit()) {
1197 this->updateNetworkActiveState_();
1199 const int episodeIdx = simulator_.episodeIndex();
1200 const auto& network = this->schedule()[episodeIdx].network();
1201 if (!this->wellsActive() && !network.active()) {
1207 if (iterCtx.needsTimestepInit() && this->wellsActive()) {
1208 OPM_TIMEBLOCK(firstIterationAssemble);
1209 Dune::Timer prepareTimer;
1210 prepareTimer.start();
1217 calculateExplicitQuantities();
1218 prepareTimeStep(local_deferredLogger);
1221 "assemble() failed during well initialization: ",
1222 this->terminal_output_, grid().comm());
1223 last_report_.well_facility_time += prepareTimer.stop();
1226 Dune::Timer networkTimer;
1227 networkTimer.start();
1228 const bool well_group_control_changed = updateWellControlsAndNetwork(
1231 local_deferredLogger);
1234 const double network_time = networkTimer.stop();
1235 last_report_.well_control_network_time += network_time;
1236 last_report_.well_facility_time += network_time;
1240 if ( ! this->wellsActive() ) {
1244 assembleWellEqWithoutIteration(dt);
1251 collectWellSolveStats();
1255 last_report_.well_group_control_changed = well_group_control_changed;
1256 last_report_.assemble_time_well += perfTimer.stop();
1262 template<
typename TypeTag>
1267 for (
const auto& well : well_container_) {
1268 const auto& stats = well->solveStats();
1269 last_report_.well_solve_time += stats.solve_time;
1270 last_report_.well_potential_solve_time += stats.potential_solve_time;
1271 last_report_.well_solve_assemble_time += stats.assemble_time;
1272 last_report_.well_solve_linear_solve_time += stats.linear_solve_time;
1273 last_report_.total_well_iterations += stats.iterations;
1274 last_report_.total_well_potential_iterations += stats.potential_iterations;
1275 well->resetSolveStats();
1282 template<
typename TypeTag>
1291 bool do_network_update =
true;
1292 bool well_group_control_changed =
false;
1293 Scalar network_imbalance = 0.0;
1295 const std::size_t iteration_to_relax = param_.network_max_strict_outer_iterations_;
1297 const std::size_t max_iteration = param_.network_max_outer_iterations_;
1298 std::size_t network_update_iteration = 0;
1299 network_needs_more_balancing_force_another_newton_iteration_ =
false;
1300 while (do_network_update) {
1301 if (!this->isRescoupSlaveCoupledNetworkIteration_()
1302 && network_update_iteration >= max_iteration ) {
1304 const int episodeIdx = simulator_.episodeIndex();
1305 if (this->network_.willBalanceOnNextIteration(episodeIdx)) {
1306 if (this->terminal_output_) {
1307 const std::string msg = fmt::format(
"Maximum of {:d} network iterations has been used and we stop the update, \n"
1308 "and try again after the next Newton iteration (imbalance = {:.2e} bar)",
1309 max_iteration, network_imbalance*1.0e-5);
1310 local_deferredLogger.
debug(msg);
1314 network_needs_more_balancing_force_another_newton_iteration_ =
true;
1316 if (this->terminal_output_) {
1317 const std::string msg = fmt::format(
"Maximum of {:d} network iterations has been used and we stop the update. \n"
1318 "The simulator will continue with unconverged network results (imbalance = {:.2e} bar)",
1319 max_iteration, network_imbalance*1.0e-5);
1320 local_deferredLogger.
info(msg);
1325 if (this->terminal_output_ && (network_update_iteration == iteration_to_relax) ) {
1326 local_deferredLogger.
debug(
"We begin using relaxed tolerance for network update now after " +
std::to_string(iteration_to_relax) +
" iterations ");
1328 const bool relax_network_balance = network_update_iteration >= iteration_to_relax;
1330 const bool optimize_gas_lift = ( (network_update_iteration + 1) < std::max(max_iteration,
static_cast<std::size_t
>(2)) );
1331 std::tie(well_group_control_changed, do_network_update, network_imbalance) =
1332 updateWellControlsAndNetworkIteration(mandatory_network_balance, relax_network_balance, optimize_gas_lift, dt,local_deferredLogger);
1333 ++network_update_iteration;
1335 if (this->isRescoupMasterCoupledNetworkIteration_()) {
1336 this->sendSlaveNetworkLoopTerminationSignal_();
1339 if (this->schedule()[simulator_.episodeIndex()].network().active()) {
1340 last_report_.total_network_iterations += network_update_iteration;
1342 return well_group_control_changed;
1348 template<
typename TypeTag>
1349 std::tuple<bool, bool, typename BlackoilWellModel<TypeTag>::Scalar>
1352 const bool relax_network_tolerance,
1353 const bool optimize_gas_lift,
1358 const int reportStepIdx = simulator_.episodeIndex();
1360#ifdef RESERVOIR_COUPLING_ENABLED
1361 if (this->isRescoupSlaveCoupledNetworkIteration_()) {
1362 this->rescoupHelper_.receiveMasterGroupNodePressuresFromMaster();
1365 Dune::Timer groupTimer;
1367 this->updateAndCommunicateGroupData(reportStepIdx,
true);
1372 bool well_group_control_changed = updateWellControls(local_deferredLogger);
1373 last_report_.group_control_time += groupTimer.stop();
1375 Dune::Timer networkBalanceTimer;
1376 networkBalanceTimer.start();
1377 const auto [more_inner_network_update, network_imbalance] =
1378 this->network_.update(mandatory_network_balance,
1379 local_deferredLogger,
1380 relax_network_tolerance);
1382 if (this->schedule()[reportStepIdx].network().active()) {
1383 last_report_.network_balance_time += networkBalanceTimer.stop();
1385#ifdef RESERVOIR_COUPLING_ENABLED
1386 if (this->isReservoirCouplingMaster()) {
1387 this->rescoupHelper_.maybeExchangeNetworkOuterIterationWithSlaves(more_inner_network_update);
1391 bool alq_updated =
false;
1394 if (optimize_gas_lift) {
1397 const bool updatePotentials = (this->network_.shouldBalance(reportStepIdx) ||
1398 mandatory_network_balance);
1399 Dune::Timer gliftTimer;
1401 alq_updated = gaslift_.maybeDoGasLiftOptimize(simulator_,
1403 this->network_.nodePressures(),
1407 local_deferredLogger);
1409 if (this->schedule().glo(reportStepIdx).active()) {
1410 last_report_.gaslift_time += gliftTimer.stop();
1415 Dune::Timer prepareWellsTimer;
1416 prepareWellsTimer.start();
1417 prepareWellsBeforeAssembling(dt);
1418 last_report_.control_well_solve_time += prepareWellsTimer.stop();
1421 "updateWellControlsAndNetworkIteration() failed: ",
1422 this->terminal_output_, grid().comm());
1426 guideRateUpdateIsNeeded(reportStepIdx)) {
1427 const double simulationTime = simulator_.time();
1428 Dune::Timer guideRateTimer;
1429 guideRateTimer.start();
1433 this->guide_rate_handler_.updateGuideRates(
1434 reportStepIdx, simulationTime, this->wellState(), this->groupState()
1436 last_report_.group_control_time += guideRateTimer.stop();
1440 bool more_network_update = this->network_.shouldBalance(reportStepIdx) &&
1441 (more_inner_network_update || alq_updated);
1443 if (this->isRescoupSlaveOnSyncStepFirstSubstep_()
1444 && this->isRescoupSlaveConnectedToMasterNetwork_()) {
1451 const bool more_cross_rescoup_update =
1452 this->maybeSendSlaveGroupFlowToMaster_(reportStepIdx);
1453 more_network_update = more_network_update || more_cross_rescoup_update;
1456 return {well_group_control_changed, more_network_update, network_imbalance};
1459 template<
typename TypeTag>
1465 for (
auto& well : well_container_) {
1466 well->assembleWellEq(simulator_, dt, this->groupStateHelper(), this->wellState());
1471 template<
typename TypeTag>
1477 for (
auto& well : well_container_) {
1478 well->prepareWellBeforeAssembling(
1479 simulator_, dt, this->groupStateHelper(), this->wellState()
1485 template<
typename TypeTag>
1491 auto& deferred_logger = this->groupStateHelper().deferredLogger();
1496 for (
auto& well: well_container_) {
1497 well->assembleWellEqWithoutIteration(simulator_, this->groupStateHelper(), dt, this->wellState(),
1501 this->terminal_output_, grid().comm());
1505 template<
typename TypeTag>
1512 for (
const auto& well : well_container_) {
1513 well->addCellRates(cellRates_);
1517 template<
typename TypeTag>
1524 for (
const auto& well : well_container_) {
1525 const auto it = well_domain_map.find(well->name());
1526 if (it != well_domain_map.end() && it->second == domainIndex) {
1527 well->addCellRates(cellRates_);
1532#if COMPILE_GPU_BRIDGE
1533 template<
typename TypeTag>
1541 for(
unsigned int i = 0; i < well_container_.size(); i++){
1542 auto& well = well_container_[i];
1545 wellContribs.
addNumBlocks(derived->linSys().getNumBlocks());
1550 wellContribs.
alloc();
1552 for(
unsigned int i = 0; i < well_container_.size(); i++){
1553 auto& well = well_container_[i];
1555 auto derived_std =
dynamic_cast<StandardWell<TypeTag>*
>(well.get());
1557 derived_std->linSys().extract(derived_std->numStaticWellEq, wellContribs);
1559 auto derived_ms =
dynamic_cast<MultisegmentWell<TypeTag>*
>(well.get());
1561 derived_ms->linSys().extract(wellContribs);
1563 OpmLog::warning(
"Warning unknown type of well");
1570 template<
typename TypeTag>
1575 for (
const auto& well: well_container_ ) {
1576 well->addWellContributions(jacobian);
1580 template<
typename TypeTag>
1583 std::vector<CMatrix>& c_matrices,
1584 std::vector<DMatrix>& d_matrices,
1588 for (
const auto& well: well_container_ ) {
1589 well->addBCDMatrix(b_matrices, c_matrices, d_matrices, wcells);
1593 template<
typename TypeTag>
1598 const bool use_well_weights)
const
1600 int nw = this->numLocalWellsEnd();
1601 int rdofs = local_num_cells_;
1602 for (
int i = 0; i < nw; i++ ) {
1603 int wdof = rdofs + i;
1604 jacobian[wdof][wdof] = 1.0;
1607 for (
const auto& well : well_container_) {
1608 well->addWellPressureEquations(jacobian,
1616 template <
typename TypeTag>
1619 const std::vector<typename SparseMatrixAdapter::MatrixBlock*>& diagMatAddress)
const
1624 for (
const auto& well : well_container_) {
1625 if (!well->isOperableAndSolvable() && !well->wellIsStopped()) {
1628 const auto& cells = well->cells();
1629 const auto& rates = well->connectionRates();
1630 for (
unsigned perfIdx = 0; perfIdx < rates.size(); ++perfIdx) {
1631 unsigned cellIdx = cells[perfIdx];
1632 auto rate = rates[perfIdx];
1635 using MatrixBlockType =
typename SparseMatrixAdapter::MatrixBlock;
1636 MatrixBlockType bMat(0.0);
1637 simulator_.model().linearizer().setResAndJacobi(res, bMat, rate);
1638 residual[cellIdx] += res;
1639 *diagMatAddress[cellIdx] += bMat;
1645 template<
typename TypeTag>
1650 int nw = this->numLocalWellsEnd();
1651 int rdofs = local_num_cells_;
1652 const auto wellconnections = this->getMaxWellConnections();
1653 for (
int i = 0; i < nw; ++i) {
1654 int wdof = rdofs + i;
1655 jacobian.entry(wdof,wdof) = 0.0;
1656 const auto& perfcells = wellconnections[i];
1657 for (
int perfcell : perfcells) {
1658 jacobian.entry(wdof, perfcell) = 0.0;
1659 jacobian.entry(perfcell, wdof) = 0.0;
1665 template<
typename TypeTag>
1670 auto loggerGuard = this->groupStateHelper().pushLogger();
1673 for (
const auto& well : well_container_) {
1674 const auto& cells = well->cells();
1675 x_local_.resize(cells.size());
1677 for (
size_t i = 0; i < cells.size(); ++i) {
1678 x_local_[i] = x[cells[i]];
1680 well->recoverWellSolutionAndUpdateWellState(simulator_, x_local_,
1681 this->groupStateHelper(), this->wellState());
1685 simulator_.vanguard().grid().comm());
1689 template<
typename TypeTag>
1695 OPM_THROW(std::logic_error,
"Attempt to call NLDD method without a NLDD solver");
1698 return nldd_->recoverWellSolutionAndUpdateWellState(x, domainIdx);
1702 template<
typename TypeTag>
1705 getWellConvergence(
const std::vector<Scalar>& B_avg,
bool checkWellGroupControlsAndNetwork)
const
1709 const auto& iterCtx = simulator_.problem().iterationContext();
1710 const bool relaxTolerance = iterCtx.shouldRelax(param_.strict_outer_iter_wells_ + 1);
1712 auto logger_guard = this->groupStateHelper().pushLogger();
1713 for (
const auto& well : well_container_) {
1714 if (well->isOperableAndSolvable() || well->wellIsStopped()) {
1715 local_report += well->getWellConvergence(
1716 this->groupStateHelper(), B_avg,
1721 report.
setWellFailed({CR::WellFailure::Type::Unsolvable, CR::Severity::Normal, -1, well->name()});
1722 local_report += report;
1730 if (checkWellGroupControlsAndNetwork) {
1736 if (this->terminal_output_) {
1740 OpmLog::debug(
"NaN residual found with phase " +
std::to_string(f.phase()) +
" for well " + f.wellName());
1742 OpmLog::debug(
"Too large residual found with phase " +
std::to_string(f.phase()) +
" for well " + f.wellName());
1753 template<
typename TypeTag>
1759 for (
auto& well : well_container_) {
1760 well->calculateExplicitQuantities(simulator_, this->groupStateHelper());
1768 template<
typename TypeTag>
1774 if (!this->wellsActive() && !this->isReservoirCouplingMaster()) {
1777 const int episodeIdx = simulator_.episodeIndex();
1778 const auto& comm = simulator_.vanguard().grid().comm();
1785 const auto nupcol = this->schedule()[episodeIdx].nupcol();
1786 const auto& iter_ctx = simulator_.problem().iterationContext();
1787 if (iter_ctx.withinNupcol(nupcol)) {
1789 for (
const auto& well : well_container_) {
1790 well->updateWeldrawMaxRate(simulator_, this->wellState(), deferred_logger);
1793 simulator_.gridView().comm());
1798 bool changed_well_group =
false;
1799 const Group& fieldGroup = this->schedule().getGroup(
"FIELD", episodeIdx);
1802 const std::size_t max_iter = param_.well_group_constraints_max_iterations_;
1803 while(!changed_well_group && iter < max_iter) {
1804 changed_well_group = updateGroupControls(fieldGroup, deferred_logger, episodeIdx);
1807 bool changed_well_to_group =
false;
1809 OPM_TIMEBLOCK(UpdateWellControls);
1813 for (
const auto& well : well_container_) {
1816 simulator_, mode, this->groupStateHelper(), this->wellState()
1819 changed_well_to_group = changed_well || changed_well_to_group;
1823 simulator_.gridView().comm());
1826 changed_well_to_group = comm.sum(
static_cast<int>(changed_well_to_group));
1827 if (changed_well_to_group) {
1828 updateAndCommunicate(episodeIdx);
1829 changed_well_group =
true;
1833 bool changed_well_individual =
false;
1838 for (
const auto& well : well_container_) {
1841 simulator_, mode, this->groupStateHelper(), this->wellState()
1844 changed_well_individual = changed_well || changed_well_individual;
1848 simulator_.gridView().comm());
1851 changed_well_individual = comm.sum(
static_cast<int>(changed_well_individual));
1852 if (changed_well_individual) {
1853 updateAndCommunicate(episodeIdx);
1854 changed_well_group =
true;
1860 this->updateWsolvent(fieldGroup, episodeIdx, this->nupcolWellState());
1862 return changed_well_group;
1866 template<
typename TypeTag>
1871 this->updateAndCommunicateGroupData(reportStepIdx,
true);
1877 for (
const auto& well : well_container_) {
1879 const auto& ws = this->wellState().well(well->indexOfWell());
1880 if (ws.production_cmode == Well::ProducerCMode::GRUP ||
1881 ws.injection_cmode == Well::InjectorCMode::GRUP)
1883 well->updateWellStateWithTarget(
1884 simulator_, this->groupStateHelper(), this->wellState()
1889 simulator_.gridView().comm())
1890 this->updateAndCommunicateGroupData(reportStepIdx,
true);
1893 template<
typename TypeTag>
1898 const int reportStepIdx)
1901 const auto& iterCtx = simulator_.problem().iterationContext();
1902 bool changed =
false;
1904 const int nupcol = this->schedule()[reportStepIdx].nupcol();
1905 const bool update_group_switching_log = !iterCtx.withinNupcol(nupcol);
1906 const bool changed_hc = this->checkGroupHigherConstraints(
1907 group, deferred_logger, reportStepIdx, update_group_switching_log);
1910 updateAndCommunicate(reportStepIdx);
1913 bool changed_individual =
1915 updateGroupIndividualControl(group,
1917 param_.max_number_of_group_switches_,
1918 update_group_switching_log,
1919 this->switched_inj_groups_,
1920 this->switched_prod_groups_,
1921 this->closed_offending_wells_,
1926 if (changed_individual) {
1928 updateAndCommunicate(reportStepIdx);
1931 for (
const std::string& groupName : group.groups()) {
1932 bool changed_this = updateGroupControls(this->schedule().getGroup(groupName, reportStepIdx), deferred_logger, reportStepIdx);
1933 changed = changed || changed_this;
1938 template<
typename TypeTag>
1944 auto logger_guard = this->groupStateHelper().pushLogger();
1945 auto& local_deferredLogger = this->groupStateHelper().deferredLogger();
1946 for (
const auto& well : well_container_) {
1947 const auto& wname = well->name();
1948 const auto wasClosed = wellTestState.well_is_closed(wname);
1949 well->checkWellOperability(simulator_,
1951 this->groupStateHelper());
1952 const bool under_zero_target =
1953 well->wellUnderZeroGroupRateTarget(this->groupStateHelper());
1954 well->updateWellTestState(this->wellState().well(wname),
1960 this->eclipseState().getUnits(),
1961 this->schedule().getStartTime(),
1962 local_deferredLogger);
1964 if (!wasClosed && wellTestState.well_is_closed(wname)) {
1965 this->closed_this_step_.insert(wname);
1968 const WellEconProductionLimits& econ_production_limits = well->wellEcl().getEconLimits();
1969 if (econ_production_limits.validFollowonWell()) {
1970 const auto episode_idx = simulator_.episodeIndex();
1971 const auto follow_on_well = econ_production_limits.followonWell();
1972 if (!this->schedule().hasWell(follow_on_well, episode_idx)) {
1973 const auto msg = fmt::format(
"Well {} was closed. But the given follow on well {} does not exist."
1974 "The simulator continues without opening a follow on well.",
1975 wname, follow_on_well);
1976 local_deferredLogger.warning(msg);
1978 auto& ws = this->wellState().well(follow_on_well);
1979 const bool success = ws.updateStatus(WellStatus::OPEN);
1981 const auto msg = fmt::format(
"Well {} was closed. The follow on well {} opens instead.", wname, follow_on_well);
1982 local_deferredLogger.info(msg);
1984 const auto msg = fmt::format(
"Well {} was closed. The follow on well {} is already open.", wname, follow_on_well);
1985 local_deferredLogger.warning(msg);
1992 for (
const auto& [group_name, to] : this->closed_offending_wells_) {
1993 if (this->hasOpenLocalWell(to.second) &&
1994 !this->wasDynamicallyShutThisTimeStep(to.second))
1996 wellTestState.close_well(to.second,
1997 WellTestConfig::Reason::GROUP,
1999 this->updateClosedWellsThisStep(to.second);
2000 const std::string msg =
2001 fmt::format(
"Procedure on exceeding {} limit is WELL for group {}. "
2007 local_deferredLogger.info(msg);
2013 template<
typename TypeTag>
2017 std::string& exc_msg,
2021 const int np = this->numPhases();
2022 std::vector<Scalar> potentials;
2023 const auto& well = well_container_[widx];
2024 std::string cur_exc_msg;
2027 well->computeWellPotentials(simulator_, well_state_copy, this->groupStateHelper(), potentials);
2032 exc_msg += fmt::format(
"\nFor well {}: {}", well->name(), cur_exc_msg);
2034 exc_type = std::max(exc_type, cur_exc_type);
2038 auto& ws = this->wellState().well(well->indexOfWell());
2039 for (
int p = 0; p < np; ++p) {
2041 ws.well_potentials[p] = std::max(
Scalar{0.0}, potentials[p]);
2047 template <
typename TypeTag>
2052 for (
const auto& wellPtr : this->well_container_) {
2053 this->calculateProductivityIndexValues(wellPtr.get(), deferred_logger);
2061 template <
typename TypeTag>
2072 for (
const auto& shutWell : this->local_shut_wells_) {
2073 if (!this->wells_ecl_[shutWell].hasConnections()) {
2078 auto wellPtr = this->
template createTypedWellPointer
2081 wellPtr->
init(this->depth_, this->gravity_, this->B_avg_,
true);
2083 this->calculateProductivityIndexValues(wellPtr.get(), deferred_logger);
2091 template <
typename TypeTag>
2105 template<
typename TypeTag>
2110 const auto episodeIdx = simulator_.episodeIndex();
2113 const bool do_prestep_network_rebalance = this->shouldDoPreStepNetworkRebalance_(episodeIdx);
2115 for (
const auto& well : well_container_) {
2116 auto& events = this->wellState().well(well->indexOfWell()).events;
2118 well->updateWellStateWithTarget(
2119 simulator_, this->groupStateHelper(), this->wellState()
2121 well->updatePrimaryVariables(this->groupStateHelper());
2127 if (events.hasEvent(ScheduleEvents::REQUEST_OPEN_WELL)) {
2128 events.clearEvent(ScheduleEvents::REQUEST_OPEN_WELL);
2131 if (param_.solve_welleq_initially_ && well->isOperableAndSolvable()) {
2133 well->solveWellEquation(
2134 simulator_, this->groupStateHelper(), this->wellState()
2136 }
catch (
const std::exception& e) {
2137 const std::string msg =
"Compute initial well solution for " + well->name() +
" initially failed. Continue with the previous rates";
2138 deferred_logger.
warning(
"WELL_INITIAL_SOLVE_FAILED", msg);
2143 well->resetWellOperability();
2145 updatePrimaryVariables();
2148 if (do_prestep_network_rebalance) {
2149 network_.doPreStepRebalance(deferred_logger);
2153 template<
typename TypeTag>
2158 std::vector< Scalar > B_avg(numConservationQuantities(),
Scalar() );
2159 const auto& grid = simulator_.vanguard().grid();
2160 const auto& gridView = grid.leafGridView();
2164 for (
const auto& elem : elements(gridView, Dune::Partitions::interior)) {
2165 elemCtx.updatePrimaryStencil(elem);
2166 elemCtx.updatePrimaryIntensiveQuantities(0);
2168 const auto& intQuants = elemCtx.intensiveQuantities(0, 0);
2169 const auto& fs = intQuants.fluidState();
2171 for (
unsigned phaseIdx = 0; phaseIdx < FluidSystem::numPhases; ++phaseIdx)
2173 if (!FluidSystem::phaseIsActive(phaseIdx)) {
2177 const unsigned compIdx = FluidSystem::canonicalToActiveCompIdx(FluidSystem::solventComponentIndex(phaseIdx));
2178 auto& B = B_avg[ compIdx ];
2180 B += 1 / fs.invB(phaseIdx).value();
2182 if constexpr (has_solvent_) {
2183 auto& B = B_avg[solventSaturationIdx];
2184 B += 1 / intQuants.solventInverseFormationVolumeFactor().value();
2190 grid.comm().sum(B_avg.data(), B_avg.size());
2191 B_avg_.resize(B_avg.size());
2192 std::ranges::transform(B_avg, B_avg_.begin(),
2193 [gcells = global_num_cells_](
const auto bval)
2194 { return bval / gcells; });
2201 template<
typename TypeTag>
2206 for (
const auto& well : well_container_) {
2207 well->updatePrimaryVariables(this->groupStateHelper());
2211 template<
typename TypeTag>
2215 const auto& grid = simulator_.vanguard().grid();
2216 const auto& eclProblem = simulator_.problem();
2217 const unsigned numCells = grid.size(0);
2219 this->pvt_region_idx_.resize(numCells);
2220 for (
unsigned cellIdx = 0; cellIdx < numCells; ++cellIdx) {
2221 this->pvt_region_idx_[cellIdx] =
2222 eclProblem.pvtRegionIndex(cellIdx);
2227 template<
typename TypeTag>
2243 return this->numPhases() + has_solvent_;
2246 template<
typename TypeTag>
2250 const auto& eclProblem = simulator_.problem();
2251 depth_.resize(local_num_cells_);
2252 for (
unsigned cellIdx = 0; cellIdx < local_num_cells_; ++cellIdx) {
2253 depth_[cellIdx] = eclProblem.dofCenterDepth(cellIdx);
2257 template<
typename TypeTag>
2260 getWell(
const std::string& well_name)
const
2264 std::ranges::find_if(well_container_,
2266 {
return elem->name() == well_name; });
2268 assert(well != well_container_.end());
2273 template <
typename TypeTag>
2278 return std::max(this->simulator_.episodeIndex(), 0);
2285 template<
typename TypeTag>
2290 const std::vector<Scalar>& production_rates,
2291 std::vector<Scalar>& resv_coeff)
const
2293 rateConverter_->calcCoeff(fipnum, pvtreg, production_rates, resv_coeff);
2296 template<
typename TypeTag>
2301 std::vector<Scalar>& resv_coeff)
const
2303 rateConverter_->calcInjCoeff(fipnum, pvtreg, resv_coeff);
2307 template <
typename TypeTag>
2312 if constexpr (energyModuleType_ == EnergyModules::FullyImplicitThermal) {
2313 const int np = this->numPhases();
2314 const int nw = this->numLocalWells();
2315 for (
auto wellID = 0*nw; wellID < nw; ++wellID) {
2316 const Well& well = this->wells_ecl_[wellID];
2317 auto& ws = this->wellState().well(wellID);
2318 if (well.isInjector()) {
2319 if (ws.status != WellStatus::STOP) {
2320 this->wellState().well(wellID).temperature = well.inj_temperature();
2324 std::array<Scalar,2> weighted{0.0,0.0};
2325 auto& [weighted_temperature, total_weight] = weighted;
2326 const auto& well_info = this->local_parallel_well_info_[wellID].get();
2327 using int_type =
decltype(this->well_perf_data_[wellID].size());
2328 for (int_type perf = 0, end_perf = this->well_perf_data_[wellID].size(); perf < end_perf; ++perf) {
2329 const int cell_idx = this->well_perf_data_[wellID][perf].cell_index;
2330 const auto& intQuants = simulator_.model().intensiveQuantities(cell_idx, 0);
2331 const auto& fs = intQuants.fluidState();
2332 Scalar weight_factor = computeTemperatureWeightFactor(perf, np, fs, ws);
2333 total_weight += weight_factor;
2334 weighted_temperature += weight_factor * fs.temperature(0).value();
2336 well_info.communication().sum(weighted.data(), 2);
2337 this->wellState().well(wellID).temperature = weighted_temperature / total_weight;
2343 template <
typename TypeTag>
2345 -> typename
WellState<Scalar,IndexTraits>::RsConstInfo
2347 if (! FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx) ||
2348 ! FluidSystem::enableConstantRs())
2353 const auto& rsConstTables = this->eclState_
2354 .getTableManager().getRsconstTables();
2356 if (rsConstTables.empty() ||
2357 (rsConstTables[0].numRows() != std::size_t{1}))
2362 const auto rsConst = rsConstTables[0].getColumn(0).front();
2364 return {
true,
static_cast<Scalar
>(rsConst) };
2370 template <
typename TypeTag>
2371 void BlackoilWellModel<TypeTag>::
2372 assignWellTracerRates_(data::Wells& wsrpt)
const
2374 const auto reportStepIdx =
static_cast<unsigned int>(this->reportStepIndex());
2375 const auto& trMod = this->simulator_.problem().tracerModel();
2381 this->assignMswTracerRates(wsrpt, trMod.getMswTracerRates(), reportStepIdx);
2384 template <
typename TypeTag>
2385 void BlackoilWellModel<TypeTag>::
2386 assignWellSpeciesRates_(data::Wells& wsrpt)
const
2388 const auto reportStepIdx =
static_cast<unsigned int>(this->reportStepIndex());
2389 const auto& geochemMod = this->simulator_.problem().geochemistryModel();
2393 this->assignMswTracerRates(wsrpt, geochemMod.getMswSpeciesRates(), reportStepIdx);
2396 template <
typename TypeTag>
2397 bool BlackoilWellModel<TypeTag>::isRescoupMasterCoupledNetworkIteration_()
const
2399#ifdef RESERVOIR_COUPLING_ENABLED
2400 return this->rescoupHelper_.masterIsInCoupledNetworkIteration();
2406 template <
typename TypeTag>
2407 bool BlackoilWellModel<TypeTag>::isRescoupSlaveCoupledNetworkIteration_()
const
2418#ifdef RESERVOIR_COUPLING_ENABLED
2419 return this->isRescoupSlaveOnSyncStepFirstSubstep_()
2420 && this->reservoirCouplingSlave().connectedToMasterCoupledNetwork()
2421 && !this->reservoirCouplingSlave().lastReceivedMasterGroupNodePressuresIsFinal();
2427 template <
typename TypeTag>
2428 bool BlackoilWellModel<TypeTag>::isRescoupSlaveOnSyncStepFirstSubstep_()
const
2435#ifdef RESERVOIR_COUPLING_ENABLED
2436 return this->isReservoirCouplingSlave()
2437 && this->reservoirCouplingSlave().isFirstSubstepOfSyncTimestep();
2443 template <
typename TypeTag>
2444 bool BlackoilWellModel<TypeTag>::isRescoupSlaveConnectedToMasterNetwork_()
const
2446#ifdef RESERVOIR_COUPLING_ENABLED
2447 return this->isReservoirCouplingSlave()
2448 && this->reservoirCouplingSlave().connectedToMasterCoupledNetwork();
2454 template <
typename TypeTag>
2455 bool BlackoilWellModel<TypeTag>::
2456 maybeSendSlaveGroupFlowToMaster_([[maybe_unused]]
const int reportStepIdx)
2458#ifdef RESERVOIR_COUPLING_ENABLED
2465 assert(this->isReservoirCouplingSlave());
2466 const bool is_final =
2467 this->reservoirCouplingSlave().lastReceivedMasterGroupNodePressuresIsFinal();
2469 this->updateAndCommunicateGroupData(reportStepIdx,
false);
2470 this->rescoupHelper_.sendSlaveGroupDataToMaster();
2475 this->rescoupHelper_.receiveGroupConstraintsFromMaster();
2484 template <
typename TypeTag>
2485 void BlackoilWellModel<TypeTag>::
2486 sendSlaveNetworkLoopTerminationSignal_()
2488#ifdef RESERVOIR_COUPLING_ENABLED
2493 assert(this->isReservoirCouplingMaster());
2494 this->rescoupHelper_.sendMasterGroupNodePressuresToSlaves(
true);
2498 template <
typename TypeTag>
2499 bool BlackoilWellModel<TypeTag>::
2500 shouldDoPreStepNetworkRebalance_(
const int episodeIdx)
const
2513 return param_.pre_solve_network_
2514 && this->network_.needPreStepRebalance(episodeIdx)
2515 && !this->isRescoupCoupledNetworkParticipant_();
2518 template <
typename TypeTag>
2519 bool BlackoilWellModel<TypeTag>::isRescoupCoupledNetworkParticipant_()
const
2521#ifdef RESERVOIR_COUPLING_ENABLED
2522 if (this->isReservoirCouplingMaster()) {
2523 return this->rescoupHelper_.masterNetworkHasMasterGroupLeaves();
2525 if (this->isReservoirCouplingSlave()) {
2526 return this->reservoirCouplingSlave().connectedToMasterCoupledNetwork();
2534 template <
typename TypeTag>
2535 void BlackoilWellModel<TypeTag>::
2536 updateNetworkActiveState_()
2547 const int episodeIdx = this->simulator_.episodeIndex();
2548 this->network_.updateActiveState(episodeIdx);
#define OPM_END_PARALLEL_TRY_CATCH_LOG(obptc_logger, obptc_prefix, obptc_output, comm)
Catch exception, log, and throw in a parallel try-catch clause.
Definition: DeferredLoggingErrorHelpers.hpp:207
#define OPM_DEFLOG_THROW(Exception, message, deferred_logger)
Definition: DeferredLoggingErrorHelpers.hpp:47
#define OPM_END_PARALLEL_TRY_CATCH(prefix, comm)
Catch exception and throw in a parallel try-catch clause.
Definition: DeferredLoggingErrorHelpers.hpp:197
#define OPM_PARALLEL_CATCH_CLAUSE(obptc_exc_type, obptc_exc_msg)
Inserts catch classes for the parallel try-catch.
Definition: DeferredLoggingErrorHelpers.hpp:168
#define OPM_BEGIN_PARALLEL_TRY_CATCH()
Macro to setup the try of a parallel try-catch.
Definition: DeferredLoggingErrorHelpers.hpp:160
void logAndCheckForExceptionsAndThrow(Opm::DeferredLogger &deferred_logger, Opm::ExceptionType::ExcEnum exc_type, const std::string &message, const bool terminal_output, Opm::Parallel::Communication comm)
Definition: DeferredLoggingErrorHelpers.hpp:113
Class for handling constraints for the blackoil well model.
Definition: BlackoilWellModelConstraints.hpp:42
Class for handling the gaslift in the blackoil well model.
Definition: BlackoilWellModelGasLift.hpp:96
Class for handling the blackoil well model.
Definition: BlackoilWellModelGeneric.hpp:99
BlackoilWellModelWBP< Scalar, IndexTraits > wbp_
Definition: BlackoilWellModelGeneric.hpp:593
std::vector< std::unique_ptr< ParallelWellInfo< Scalar > > > parallel_well_info_
Definition: BlackoilWellModelGeneric.hpp:624
void updateFailed()
Restore the state captured at the start of the failing timestep.
Definition: BlackoilWellModelGeneric.hpp:240
void advanceTimeLevel()
Snapshot the mutable well-model state at the start of a timestep.
Definition: BlackoilWellModelGeneric.hpp:227
const Parallel::Communication & comm() const
Definition: BlackoilWellModelGeneric.hpp:265
void assignWellTracerRates(data::Wells &wsrpt, const WellTracerRates &wellTracerRates, const unsigned reportStep) const
Class for handling the guide rates in the blackoil well model.
Definition: BlackoilWellModelGuideRates.hpp:47
Class for handling the blackoil well model.
Definition: BlackoilWellModel.hpp:101
void initializeGroupStructure(const int reportStepIdx)
Definition: BlackoilWellModel_impl.hpp:307
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:2288
void prepareTimeStep(DeferredLogger &deferred_logger)
Definition: BlackoilWellModel_impl.hpp:2108
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:1351
WellInterfacePtr createWellPointer(const int wellID, const int report_step) const
Definition: BlackoilWellModel_impl.hpp:1099
void prepareWellsBeforeAssembling(const double dt)
Definition: BlackoilWellModel_impl.hpp:1474
void init()
Definition: BlackoilWellModel_impl.hpp:165
const Simulator & simulator() const
Definition: BlackoilWellModel.hpp:388
std::vector< Scalar > depth_
Definition: BlackoilWellModel.hpp:598
std::size_t global_num_cells_
Definition: BlackoilWellModel.hpp:594
GetPropType< TypeTag, Properties::Scalar > Scalar
Definition: BlackoilWellModel.hpp:110
void initWellContainer(const int reportStepIdx) override
Definition: BlackoilWellModel_impl.hpp:184
void beginReportStep(const int time_step)
Definition: BlackoilWellModel_impl.hpp:201
const WellInterface< TypeTag > & getWell(const std::string &well_name) const
Definition: BlackoilWellModel_impl.hpp:2260
GetPropType< TypeTag, Properties::FluidSystem > FluidSystem
Definition: BlackoilWellModel.hpp:106
Dune::FieldVector< Scalar, numEq > VectorBlockType
Definition: BlackoilWellModel.hpp:134
GetPropType< TypeTag, Properties::ElementContext > ElementContext
Definition: BlackoilWellModel.hpp:107
GetPropType< TypeTag, Properties::Grid > Grid
Definition: BlackoilWellModel.hpp:104
int numConservationQuantities() const
Definition: BlackoilWellModel_impl.hpp:2229
bool updateWellControls(DeferredLogger &deferred_logger)
Definition: BlackoilWellModel_impl.hpp:1771
int reportStepIndex() const
Definition: BlackoilWellModel_impl.hpp:2276
void calculateProductivityIndexValues(DeferredLogger &deferred_logger) override
Definition: BlackoilWellModel_impl.hpp:2050
void extractLegacyDepth_()
Definition: BlackoilWellModel_impl.hpp:2248
void extractLegacyCellPvtRegionIndex_()
Definition: BlackoilWellModel_impl.hpp:2213
void recoverWellSolutionAndUpdateWellStateDomain(const BVector &x, const int domainIdx)
Definition: BlackoilWellModel_impl.hpp:1692
void updateAverageFormationFactor()
Definition: BlackoilWellModel_impl.hpp:2156
GetPropType< TypeTag, Properties::Simulator > Simulator
Definition: BlackoilWellModel.hpp:109
BlackoilWellModel(Simulator &simulator, const NewtonIterationContext &iter_ctx)
Definition: BlackoilWellModel_impl.hpp:72
void initializeWellState(const int timeStepIdx)
Definition: BlackoilWellModel_impl.hpp:799
const Grid & grid() const
Definition: BlackoilWellModel.hpp:385
void updatePrimaryVariables()
Definition: BlackoilWellModel_impl.hpp:2204
void computeWellTemperature()
Definition: BlackoilWellModel_impl.hpp:2310
void addWellPressureEquations(PressureMatrix &jacobian, const BVector &weights, const bool use_well_weights) const
Definition: BlackoilWellModel_impl.hpp:1596
const SimulatorReportSingle & lastReport() const
Definition: BlackoilWellModel_impl.hpp:669
bool updateWellControlsAndNetwork(const bool mandatory_network_balance, const double dt, DeferredLogger &local_deferredLogger)
Definition: BlackoilWellModel_impl.hpp:1285
void addWellContributions(SparseMatrixAdapter &jacobian) const
Definition: BlackoilWellModel_impl.hpp:1573
void assembleWellEq(const double dt)
Definition: BlackoilWellModel_impl.hpp:1462
WellInterfacePtr createWellForWellTest(const std::string &well_name, const int report_step, DeferredLogger &deferred_logger) const
Definition: BlackoilWellModel_impl.hpp:1150
void calculateExplicitQuantities() const
Definition: BlackoilWellModel_impl.hpp:1756
void collectWellSolveStats()
Definition: BlackoilWellModel_impl.hpp:1265
void updateAndCommunicate(const int reportStepIdx)
Definition: BlackoilWellModel_impl.hpp:1869
Dune::BCRSMatrix< Opm::MatrixBlock< Scalar, 1, 1 > > PressureMatrix
Definition: BlackoilWellModel.hpp:307
void updateFailed()
Definition: BlackoilWellModel_impl.hpp:580
void computeTotalRatesForDof(RateVector &rate, unsigned globalIdx) const
Definition: BlackoilWellModel_impl.hpp:762
void beginTimeStep()
Definition: BlackoilWellModel_impl.hpp:339
GetPropType< TypeTag, Properties::RateVector > RateVector
Definition: BlackoilWellModel.hpp:111
bool updateGroupControls(const Group &group, DeferredLogger &deferred_logger, const int reportStepIdx)
Definition: BlackoilWellModel_impl.hpp:1896
void initializeLocalWellStructure(const int reportStepIdx, const bool enableWellPIScaling, const bool initializeWellState)
Definition: BlackoilWellModel_impl.hpp:253
void calcInjResvCoeff(const int fipnum, const int pvtreg, std::vector< Scalar > &resv_coeff) const override
Definition: BlackoilWellModel_impl.hpp:2299
Dune::BlockVector< VectorBlockType > BVector
Definition: BlackoilWellModel.hpp:135
void wellTesting(const int timeStepIdx, const double simulationTime, DeferredLogger &deferred_logger)
Definition: BlackoilWellModel_impl.hpp:595
ConvergenceReport getWellConvergence(const std::vector< Scalar > &B_avg, const bool checkWellGroupControlsAndNetwork=false) const
Definition: BlackoilWellModel_impl.hpp:1705
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:1520
void assembleWellEqWithoutIteration(const double dt)
Definition: BlackoilWellModel_impl.hpp:1488
void updateCellRates()
Definition: BlackoilWellModel_impl.hpp:1508
void assemble(const double dt)
Definition: BlackoilWellModel_impl.hpp:1175
std::size_t local_num_cells_
Definition: BlackoilWellModel.hpp:596
bool alternative_well_rate_init_
Definition: BlackoilWellModel.hpp:599
void timeStepSucceeded(const double simulationTime, const double dt)
Definition: BlackoilWellModel_impl.hpp:679
std::unique_ptr< WellType > createTypedWellPointer(const int wellID, const int time_step) const
Definition: BlackoilWellModel_impl.hpp:1119
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:2015
Simulator & simulator_
Definition: BlackoilWellModel.hpp:568
void createWellContainer(const int report_step) override
Definition: BlackoilWellModel_impl.hpp:842
std::unique_ptr< WellInterface< TypeTag > > WellInterfacePtr
Definition: BlackoilWellModel.hpp:195
void updateWellTestState(const double simulationTime, WellTestState &wellTestState)
upate the wellTestState related to economic limits
Definition: BlackoilWellModel_impl.hpp:1941
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:1582
void addReservoirSourceTerms(GlobalEqVector &residual, const std::vector< typename SparseMatrixAdapter::MatrixBlock * > &diagMatAddress) const
Definition: BlackoilWellModel_impl.hpp:1618
int compressedIndexForInterior(int cartesian_cell_idx) const override
get compressed index for interior cells (-1, otherwise
Definition: BlackoilWellModel.hpp:360
void recoverWellSolutionAndUpdateWellState(const BVector &x)
Definition: BlackoilWellModel_impl.hpp:1668
void addWellPressureEquationsStruct(PressureMatrix &jacobian) const
Definition: BlackoilWellModel_impl.hpp:1648
void calculateProductivityIndexValuesShutWells(const int reportStepIdx, DeferredLogger &deferred_logger) override
Definition: BlackoilWellModel_impl.hpp:2064
void advanceTimeLevel()
Definition: BlackoilWellModel_impl.hpp:588
void endReportStep()
Definition: BlackoilWellModel_impl.hpp:652
Definition: ConvergenceReport.hpp:38
void setWellFailed(const WellFailure &wf)
Definition: ConvergenceReport.hpp:296
void setWellGroupTargetsViolated(const bool wellGroupTargetsViolated)
Definition: ConvergenceReport.hpp:314
const std::vector< WellFailure > & wellFailures() const
Definition: ConvergenceReport.hpp:459
void setNetworkNotYetBalancedForceAnotherNewtonIteration(const bool network_needs_more_balancing_force_another_newton_iteration)
Definition: ConvergenceReport.hpp:319
Definition: DeferredLogger.hpp:57
void info(const std::string &tag, const std::string &message)
void warning(const std::string &tag, const std::string &message)
void debug(const std::string &tag, const std::string &message)
std::map< std::string, std::pair< const Well *, int > > GLiftEclWells
Definition: GasLiftGroupInfo.hpp:65
Class encapsulating some information about parallel wells.
Definition: ParallelWellInfo.hpp:217
Definition: StandardWell.hpp:55
virtual void init(const std::vector< Scalar > &depth_arg, const Scalar gravity_arg, const std::vector< Scalar > &B_avg, const bool changed_to_open_this_step) override
Definition: StandardWell_impl.hpp:77
Definition: WellContributions.hpp:51
void alloc()
Allocate memory for the StandardWells.
void setBlockSize(unsigned int dim, unsigned int dim_wells)
void addNumBlocks(unsigned int numBlocks)
int indexOfWell() const
Index of well in the wells struct and wellState.
Definition: WellInterface.hpp:79
virtual void updateProductivityIndex(const Simulator &simulator, const WellProdIndexCalculator< Scalar > &wellPICalc, WellStateType &well_state, DeferredLogger &deferred_logger) const =0
bool updateWellControl(const Simulator &simulator, const IndividualOrGroup iog, const GroupStateHelperType &groupStateHelper, WellStateType &well_state)
Definition: WellInterface_impl.hpp:192
Definition: WellState.hpp:68
if(!linsolver_)
Definition: FlexibleSolver_impl.hpp:326
ExcEnum
Definition: DeferredLogger.hpp:45
@ NONE
Definition: DeferredLogger.hpp:46
Dune::Communication< MPIComm > Communication
Definition: ParallelCommunication.hpp:30
Definition: blackoilbioeffectsmodules.hh:45
ConvergenceReport gatherConvergenceReport(const ConvergenceReport &local_report, Parallel::Communication communicator)
std::string to_string(const ConvergenceReport::ReservoirFailure::Type t)
#define RESERVOIR_COUPLING_ENABLED
Definition: simulator.hh:32
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