23#ifndef OPM_BLACKOILWELLMODEL_IMPL_HEADER_INCLUDED
24#define OPM_BLACKOILWELLMODEL_IMPL_HEADER_INCLUDED
27#ifndef OPM_BLACKOILWELLMODEL_HEADER_INCLUDED
29#include <opm/simulators/wells/BlackoilWellModel.hpp>
32#include <opm/grid/utility/cartesianToCompressed.hpp>
33#include <opm/common/utility/numeric/RootFinders.hpp>
35#include <opm/input/eclipse/Schedule/Network/Balance.hpp>
36#include <opm/input/eclipse/Schedule/Network/ExtNetwork.hpp>
37#include <opm/input/eclipse/Schedule/Well/PAvgDynamicSourceData.hpp>
38#include <opm/input/eclipse/Schedule/Well/WellMatcher.hpp>
39#include <opm/input/eclipse/Schedule/Well/WellTestConfig.hpp>
41#include <opm/input/eclipse/Units/UnitSystem.hpp>
43#include <opm/simulators/wells/BlackoilWellModelConstraints.hpp>
44#include <opm/simulators/wells/BlackoilWellModelNldd.hpp>
45#include <opm/simulators/wells/ParallelPAvgDynamicSourceData.hpp>
46#include <opm/simulators/wells/ParallelWBPCalculation.hpp>
47#include <opm/simulators/wells/VFPProperties.hpp>
48#include <opm/simulators/wells/WellBhpThpCalculator.hpp>
49#include <opm/simulators/wells/WellGroupControls.hpp>
50#include <opm/simulators/wells/WellGroupHelpers.hpp>
51#include <opm/simulators/wells/TargetCalculator.hpp>
53#include <opm/simulators/utils/DeferredLoggingErrorHelpers.hpp>
54#include <opm/simulators/utils/MPIPacker.hpp>
55#include <opm/simulators/utils/phaseUsageFromDeck.hpp>
58#include <opm/simulators/linalg/gpubridge/WellContributions.hpp>
67#include <fmt/format.h>
70 template<
typename TypeTag>
71 BlackoilWellModel<TypeTag>::
72 BlackoilWellModel(Simulator& simulator,
const PhaseUsage&
phase_usage)
73 : WellConnectionModule(*
this, simulator.gridView().comm())
74 , BlackoilWellModelGeneric<Scalar>(simulator.vanguard().schedule(),
76 simulator.vanguard().summaryState(),
77 simulator.vanguard().eclState(),
79 simulator.gridView().comm())
80 , simulator_(simulator)
81 , gaslift_(
this->terminal_output_,
this->phase_usage_)
83 local_num_cells_ = simulator_.gridView().size(0);
86 global_num_cells_ = simulator_.vanguard().globalNumCells();
89 auto& parallel_wells = simulator.vanguard().parallelWells();
91 this->parallel_well_info_.reserve(parallel_wells.size());
92 for(
const auto& name_bool : parallel_wells) {
93 this->parallel_well_info_.emplace_back(name_bool, grid().comm());
97 this->alternative_well_rate_init_ =
98 Parameters::Get<Parameters::AlternativeWellRateInit>();
100 using SourceDataSpan =
101 typename PAvgDynamicSourceData<Scalar>::template SourceDataSpan<Scalar>;
103 this->wbp_.initializeSources(
104 [
this](
const std::size_t globalIndex)
105 {
return this->compressedIndexForInterior(globalIndex); },
106 [
this](
const int localCell, SourceDataSpan sourceTerms)
108 using Item =
typename SourceDataSpan::Item;
110 const auto* intQuants = this->simulator_.model()
111 .cachedIntensiveQuantities(localCell, 0);
112 const auto& fs = intQuants->fluidState();
115 .set(Item::PoreVol, intQuants->porosity().value() *
116 this->simulator_.model().dofTotalVolume(localCell))
117 .set(Item::Depth, this->depth_[localCell]);
119 constexpr auto io = FluidSystem::oilPhaseIdx;
120 constexpr auto ig = FluidSystem::gasPhaseIdx;
121 constexpr auto iw = FluidSystem::waterPhaseIdx;
124 const auto haveOil = FluidSystem::phaseIsActive(io);
125 const auto haveGas = FluidSystem::phaseIsActive(ig);
126 const auto haveWat = FluidSystem::phaseIsActive(iw);
128 auto weightedPhaseDensity = [&fs](
const auto ip)
130 return fs.saturation(ip).value() * fs.density(ip).value();
133 if (haveOil) { sourceTerms.set(Item::Pressure, fs.pressure(io).value()); }
134 else if (haveGas) { sourceTerms.set(Item::Pressure, fs.pressure(ig).value()); }
135 else { sourceTerms.set(Item::Pressure, fs.pressure(iw).value()); }
139 if (haveOil) { rho += weightedPhaseDensity(io); }
140 if (haveGas) { rho += weightedPhaseDensity(ig); }
141 if (haveWat) { rho += weightedPhaseDensity(iw); }
143 sourceTerms.set(Item::MixtureDensity, rho);
148 template<
typename TypeTag>
149 BlackoilWellModel<TypeTag>::
150 BlackoilWellModel(Simulator& simulator) :
155 template<
typename TypeTag>
157 BlackoilWellModel<TypeTag>::
160 extractLegacyCellPvtRegionIndex_();
161 extractLegacyDepth_();
163 gravity_ = simulator_.problem().gravity()[2];
165 this->initial_step_ =
true;
168 simulator_.model().addAuxiliaryModule(
this);
170 is_cell_perforated_.resize(local_num_cells_,
false);
174 template<
typename TypeTag>
176 BlackoilWellModel<TypeTag>::
177 initWellContainer(
const int reportStepIdx)
179 const uint64_t effective_events_mask = ScheduleEvents::WELL_STATUS_CHANGE
180 + ScheduleEvents::NEW_WELL;
181 const auto& events = this->schedule()[reportStepIdx].wellgroup_events();
182 for (
auto& wellPtr : this->well_container_) {
183 const bool well_opened_this_step = this->report_step_starts_ &&
184 events.hasEvent(wellPtr->name(),
185 effective_events_mask);
186 wellPtr->init(&this->phase_usage_, this->depth_, this->gravity_,
187 this->B_avg_, well_opened_this_step);
191 template<
typename TypeTag>
193 BlackoilWellModel<TypeTag>::
194 beginReportStep(
const int timeStepIdx)
196 DeferredLogger local_deferredLogger{};
198 this->report_step_starts_ =
true;
199 this->report_step_start_events_ = this->schedule()[timeStepIdx].wellgroup_events();
201 this->rateConverter_ = std::make_unique<RateConverterType>
202 (this->phase_usage_, std::vector<int>(this->local_num_cells_, 0));
206 const auto enableWellPIScaling =
true;
207 this->initializeLocalWellStructure(timeStepIdx, enableWellPIScaling);
210 this->initializeGroupStructure(timeStepIdx);
212 const auto& comm = this->simulator_.vanguard().grid().comm();
214 OPM_BEGIN_PARALLEL_TRY_CATCH()
218 this->rateConverter_->template defineState<ElementContext>(this->simulator_);
222 const auto& sched_state = this->schedule()[timeStepIdx];
224 this->vfp_properties_ = std::make_unique<VFPProperties<Scalar>>
225 (sched_state.vfpinj(), sched_state.vfpprod(), this->wellState());
228 OPM_END_PARALLEL_TRY_CATCH_LOG(local_deferredLogger,
229 "beginReportStep() failed: ",
230 this->terminal_output_, comm)
234 this->commitWGState();
236 this->wellStructureChangedDynamically_ =
false;
243 template <
typename TypeTag>
247 const bool enableWellPIScaling)
251 const auto& comm = this->simulator_.vanguard().grid().comm();
254 this->wells_ecl_ = this->getLocalWells(reportStepIdx);
255 this->local_parallel_well_info_ =
256 this->createLocalParallelWellInfo(this->wells_ecl_);
261 OPM_BEGIN_PARALLEL_TRY_CATCH()
263 this->initializeWellPerfData();
264 this->initializeWellState(reportStepIdx);
265 this->wbp_.initializeWBPCalculationService();
267 if (this->param_.use_multisegment_well_ && this->anyMSWellOpenLocal()) {
268 this->wellState().initWellStateMSWell(this->wells_ecl_, &this->prevWellState());
271 this->initializeWellProdIndCalculators();
273 if (enableWellPIScaling && this->schedule()[reportStepIdx].events()
274 .hasEvent(ScheduleEvents::Events::WELL_PRODUCTIVITY_INDEX))
276 this->runWellPIScaling(reportStepIdx, local_deferredLogger);
279 OPM_END_PARALLEL_TRY_CATCH_LOG(local_deferredLogger,
280 "Failed to initialize local well structure: ",
281 this->terminal_output_, comm)
288 template <
typename TypeTag>
295 const auto& comm = this->simulator_.vanguard().grid().comm();
297 OPM_BEGIN_PARALLEL_TRY_CATCH()
299 const auto& fieldGroup =
300 this->schedule().getGroup(
"FIELD", reportStepIdx);
304 this->summaryState(),
310 if (this->schedule()[reportStepIdx].has_gpmaint()) {
315 this->eclState_.fieldProps(),
317 this->regionalAveragePressureCalculator_);
320 OPM_END_PARALLEL_TRY_CATCH_LOG(local_deferredLogger,
321 "Failed to initialize group structure: ",
322 this->terminal_output_, comm)
330 template<
typename TypeTag>
335 OPM_TIMEBLOCK(beginTimeStep);
337 this->updateAverageFormationFactor();
341 this->switched_prod_groups_.clear();
342 this->switched_inj_groups_.clear();
344 if (this->wellStructureChangedDynamically_) {
349 const auto reportStepIdx =
350 this->simulator_.episodeIndex();
354 const auto enableWellPIScaling =
false;
356 this->initializeLocalWellStructure(reportStepIdx, enableWellPIScaling);
357 this->initializeGroupStructure(reportStepIdx);
359 this->commitWGState();
365 this->wellStructureChangedDynamically_ =
false;
368 this->resetWGState();
370 const int reportStepIdx = simulator_.episodeIndex();
371 this->updateAndCommunicateGroupData(reportStepIdx,
372 simulator_.model().newtonMethod().numIterations(),
373 param_.nupcol_group_rate_tolerance_,
374 local_deferredLogger);
376 this->wellState().updateWellsDefaultALQ(this->schedule(), reportStepIdx, this->summaryState());
377 this->wellState().gliftTimeStepInit();
379 const double simulationTime = simulator_.time();
380 OPM_BEGIN_PARALLEL_TRY_CATCH();
383 wellTesting(reportStepIdx, simulationTime, local_deferredLogger);
386 createWellContainer(reportStepIdx);
389 const Grid& grid = simulator_.vanguard().grid();
390 this->wells_active_ = grid.comm().max(!this->well_container_.empty());
395 this->initWellContainer(reportStepIdx);
398 std::fill(is_cell_perforated_.begin(), is_cell_perforated_.end(),
false);
399 for (
auto& well : well_container_) {
400 well->updatePerforatedCell(is_cell_perforated_);
404 this->calculateEfficiencyFactors(reportStepIdx);
406 if constexpr (has_polymer_)
408 if (PolymerModule::hasPlyshlog() || getPropValue<TypeTag, Properties::EnablePolymerMW>() ) {
409 this->setRepRadiusPerfLength();
414 OPM_END_PARALLEL_TRY_CATCH_LOG(local_deferredLogger,
"beginTimeStep() failed: ",
415 this->terminal_output_, simulator_.vanguard().grid().comm());
417 for (
auto& well : well_container_) {
418 well->setVFPProperties(this->vfp_properties_.get());
419 well->setGuideRate(&this->guideRate_);
422 this->updateFiltrationModelsPreStep(local_deferredLogger);
425 for (
auto& well : well_container_) {
426 well->closeCompletions(this->wellTestState());
432 const auto& summaryState = simulator_.vanguard().summaryState();
433 if (alternative_well_rate_init_) {
438 for (
const auto& well : well_container_) {
439 const bool zero_target = well->stoppedOrZeroRateTarget(simulator_, this->wellState(), local_deferredLogger);
440 if (well->isProducer() && !zero_target) {
441 well->updateWellStateRates(simulator_, this->wellState(), local_deferredLogger);
446 for (
const auto& well : well_container_) {
447 if (well->isVFPActive(local_deferredLogger)){
448 well->setPrevSurfaceRates(this->wellState(), this->prevWellState());
454 this->updateWellPotentials(reportStepIdx,
456 simulator_.vanguard().summaryConfig(),
457 local_deferredLogger);
458 }
catch ( std::runtime_error& e ) {
459 const std::string msg =
"A zero well potential is returned for output purposes. ";
460 local_deferredLogger.warning(
"WELL_POTENTIAL_CALCULATION_FAILED", msg);
464 const auto& comm = simulator_.vanguard().grid().comm();
465 std::vector<Scalar> pot(this->numPhases(), 0.0);
466 const Group& fieldGroup = this->schedule().getGroup(
"FIELD", reportStepIdx);
467 WellGroupHelpers<Scalar>::updateGuideRates(fieldGroup,
478 local_deferredLogger);
480 auto exc_type = ExceptionType::NONE;
482 if (this->schedule_[reportStepIdx].has_gpmaint()) {
483 for (
const auto& calculator : regionalAveragePressureCalculator_) {
484 calculator.second->template defineState<ElementContext>(simulator_);
486 const double dt = simulator_.timeStepSize();
487 WellGroupHelpers<Scalar>::updateGpMaintTargetForGroups(fieldGroup,
489 regionalAveragePressureCalculator_,
497 for (
auto& well : well_container_) {
498 const uint64_t effective_events_mask = ScheduleEvents::WELL_STATUS_CHANGE
499 + ScheduleEvents::INJECTION_TYPE_CHANGED
500 + ScheduleEvents::WELL_SWITCHED_INJECTOR_PRODUCER
501 + ScheduleEvents::NEW_WELL;
503 const auto& events = this->schedule()[reportStepIdx].wellgroup_events();
504 const bool event = this->report_step_starts_ && events.hasEvent(well->name(), effective_events_mask);
505 const bool dyn_status_change = this->wellState().well(well->name()).status
506 != this->prevWellState().well(well->name()).status;
508 if (event || dyn_status_change) {
510 well->updateWellStateWithTarget(simulator_, this->groupState(), this->wellState(), local_deferredLogger);
511 well->calculateExplicitQuantities(simulator_, this->wellState(), local_deferredLogger);
512 well->solveWellEquation(simulator_, this->wellState(), this->groupState(), local_deferredLogger);
513 }
catch (
const std::exception& e) {
514 const std::string msg =
"Compute initial well solution for new well " + well->name() +
" failed. Continue with zero initial rates";
515 local_deferredLogger.warning(
"WELL_INITIAL_SOLVE_FAILED", msg);
521 OPM_PARALLEL_CATCH_CLAUSE(exc_type, exc_msg);
523 if (exc_type != ExceptionType::NONE) {
524 const std::string msg =
"Compute initial well solution for new wells failed. Continue with zero initial rates";
525 local_deferredLogger.warning(
"WELL_INITIAL_SOLVE_FAILED", msg);
528 logAndCheckForExceptionsAndThrow(local_deferredLogger,
529 exc_type,
"beginTimeStep() failed: " + exc_msg, this->terminal_output_, comm);
533 template<
typename TypeTag>
535 BlackoilWellModel<TypeTag>::wellTesting(
const int timeStepIdx,
536 const double simulationTime,
537 DeferredLogger& deferred_logger)
539 for (
const std::string& well_name : this->getWellsForTesting(timeStepIdx, simulationTime)) {
540 const Well& wellEcl = this->schedule().getWell(well_name, timeStepIdx);
541 if (wellEcl.getStatus() == Well::Status::SHUT)
544 WellInterfacePtr well = createWellForWellTest(well_name, timeStepIdx, deferred_logger);
546 well->init(&this->phase_usage_, depth_, gravity_, B_avg_,
true);
548 Scalar well_efficiency_factor = wellEcl.getEfficiencyFactor() *
549 this->wellState().getGlobalEfficiencyScalingFactor(well_name);
550 WellGroupHelpers<Scalar>::accumulateGroupEfficiencyFactor(this->schedule().getGroup(wellEcl.groupName(),
554 well_efficiency_factor);
556 well->setWellEfficiencyFactor(well_efficiency_factor);
557 well->setVFPProperties(this->vfp_properties_.get());
558 well->setGuideRate(&this->guideRate_);
561 if (well->isProducer()) {
562 well->updateWellStateRates(simulator_, this->wellState(), deferred_logger);
564 if (well->isVFPActive(deferred_logger)) {
565 well->setPrevSurfaceRates(this->wellState(), this->prevWellState());
568 const auto& network = this->schedule()[timeStepIdx].network();
569 if (network.active() && !this->node_pressures_.empty()) {
570 if (well->isProducer()) {
571 const auto it = this->node_pressures_.find(well->wellEcl().groupName());
572 if (it != this->node_pressures_.end()) {
575 const Scalar nodal_pressure = it->second;
576 well->setDynamicThpLimit(nodal_pressure);
581 using GLiftEclWells =
typename GasLiftGroupInfo<Scalar>::GLiftEclWells;
582 GLiftEclWells ecl_well_map;
583 gaslift_.initGliftEclWellMap(well_container_, ecl_well_map);
584 well->wellTesting(simulator_,
588 this->wellTestState(),
591 this->well_open_times_,
593 }
catch (
const std::exception& e) {
594 const std::string msg = fmt::format(
"Exception during testing of well: {}. The well will not open.\n Exception message: {}", wellEcl.name(), e.what());
595 deferred_logger.warning(
"WELL_TESTING_FAILED", msg);
605 template<
typename TypeTag>
607 BlackoilWellModel<TypeTag>::
611 for (
auto&& pinfo : this->local_parallel_well_info_)
622 template<
typename TypeTag>
623 const SimulatorReportSingle&
624 BlackoilWellModel<TypeTag>::
625 lastReport()
const {
return last_report_; }
632 template<
typename TypeTag>
634 BlackoilWellModel<TypeTag>::
635 timeStepSucceeded(
const double simulationTime,
const double dt)
637 this->closed_this_step_.clear();
640 this->report_step_starts_ =
false;
641 const int reportStepIdx = simulator_.episodeIndex();
643 DeferredLogger local_deferredLogger;
644 for (
const auto& well : well_container_) {
645 if (getPropValue<TypeTag, Properties::EnablePolymerMW>() && well->isInjector()) {
646 well->updateWaterThroughput(dt, this->wellState());
650 for (
const auto& well : well_container_) {
651 well->updateConnectionTransmissibilityFactor(simulator_, this->wellState().well(well->indexOfWell()));
652 well->updateConnectionDFactor(simulator_, this->wellState().well(well->indexOfWell()));
655 if (Indices::waterEnabled) {
656 this->updateFiltrationModelsPostStep(dt, FluidSystem::waterPhaseIdx, local_deferredLogger);
660 this->updateInjMult(local_deferredLogger);
663 for (
const auto& well : well_container_) {
664 well->reportWellSwitching(this->wellState().well(well->indexOfWell()), local_deferredLogger);
667 if (this->terminal_output_) {
668 this->reportGroupSwitching(local_deferredLogger);
672 rateConverter_->template defineState<ElementContext>(simulator_);
676 this->updateWellPotentials(reportStepIdx,
678 simulator_.vanguard().summaryConfig(),
679 local_deferredLogger);
680 }
catch ( std::runtime_error& e ) {
681 const std::string msg =
"A zero well potential is returned for output purposes. ";
682 local_deferredLogger.warning(
"WELL_POTENTIAL_CALCULATION_FAILED", msg);
685 updateWellTestState(simulationTime, this->wellTestState());
688 const Group& fieldGroup = this->schedule_.getGroup(
"FIELD", reportStepIdx);
689 this->checkGEconLimits(fieldGroup, simulationTime,
690 simulator_.episodeIndex(), local_deferredLogger);
691 this->checkGconsaleLimits(fieldGroup, this->wellState(),
692 simulator_.episodeIndex(), local_deferredLogger);
694 this->calculateProductivityIndexValues(local_deferredLogger);
696 this->commitWGState();
698 const Opm::Parallel::Communication& comm = grid().comm();
700 if (this->terminal_output_) {
701 global_deferredLogger.logMessages();
705 this->computeWellTemperature();
709 template<
typename TypeTag>
711 BlackoilWellModel<TypeTag>::
712 computeTotalRatesForDof(RateVector& rate,
713 unsigned elemIdx)
const
717 if (!is_cell_perforated_[elemIdx]) {
721 for (
const auto& well : well_container_)
722 well->addCellRates(rate, elemIdx);
726 template<
typename TypeTag>
727 template <
class Context>
729 BlackoilWellModel<TypeTag>::
730 computeTotalRatesForDof(RateVector& rate,
731 const Context& context,
733 unsigned timeIdx)
const
736 int elemIdx = context.globalSpaceIndex(spaceIdx, timeIdx);
738 if (!is_cell_perforated_[elemIdx]) {
742 for (
const auto& well : well_container_)
743 well->addCellRates(rate, elemIdx);
748 template<
typename TypeTag>
750 BlackoilWellModel<TypeTag>::
751 initializeWellState(
const int timeStepIdx)
753 const auto pressIx = []()
755 if (Indices::oilEnabled) {
return FluidSystem::oilPhaseIdx; }
756 if (Indices::waterEnabled) {
return FluidSystem::waterPhaseIdx; }
758 return FluidSystem::gasPhaseIdx;
761 auto cellPressures = std::vector<Scalar>(this->local_num_cells_, Scalar{0});
762 auto cellTemperatures = std::vector<Scalar>(this->local_num_cells_, Scalar{0});
764 auto elemCtx = ElementContext { this->simulator_ };
765 const auto& gridView = this->simulator_.vanguard().gridView();
767 OPM_BEGIN_PARALLEL_TRY_CATCH();
768 for (
const auto& elem : elements(gridView, Dune::Partitions::interior)) {
769 elemCtx.updatePrimaryStencil(elem);
770 elemCtx.updatePrimaryIntensiveQuantities(0);
772 const auto ix = elemCtx.globalSpaceIndex(0, 0);
773 const auto& fs = elemCtx.intensiveQuantities(0, 0).fluidState();
775 cellPressures[ix] = fs.pressure(pressIx).value();
776 cellTemperatures[ix] = fs.temperature(0).value();
778 OPM_END_PARALLEL_TRY_CATCH(
"BlackoilWellModel::initializeWellState() failed: ",
779 this->simulator_.vanguard().grid().comm());
781 this->wellState().init(cellPressures, cellTemperatures, this->schedule(), this->wells_ecl_,
782 this->local_parallel_well_info_, timeStepIdx,
783 &this->prevWellState(), this->well_perf_data_,
784 this->summaryState(), simulator_.vanguard().enableDistributedWells());
791 template<
typename TypeTag>
793 BlackoilWellModel<TypeTag>::
794 createWellContainer(
const int report_step)
796 DeferredLogger local_deferredLogger;
798 const int nw = this->numLocalWells();
800 well_container_.clear();
803 well_container_.reserve(nw);
805 const auto& wmatcher = this->schedule().wellMatcher(report_step);
806 const auto& wcycle = this->schedule()[report_step].wcycle.get();
810 std::for_each(this->wells_ecl_.begin(), this->wells_ecl_.end(),
811 [
this, &wg_events = this->report_step_start_events_](
const auto& well_ecl)
813 if (!well_ecl.hasConnections()) {
818 constexpr auto events_mask = ScheduleEvents::WELL_STATUS_CHANGE |
819 ScheduleEvents::REQUEST_OPEN_WELL;
820 const bool well_status_change =
821 this->report_step_starts_ &&
822 wg_events.hasEvent(well_ecl.name(), events_mask);
823 if (well_status_change) {
824 if (well_ecl.getStatus() == WellStatus::OPEN) {
825 this->well_open_times_.insert_or_assign(well_ecl.name(),
826 this->simulator_.time());
827 this->well_close_times_.erase(well_ecl.name());
828 }
else if (well_ecl.getStatus() == WellStatus::SHUT) {
829 this->well_close_times_.insert_or_assign(well_ecl.name(),
830 this->simulator_.time());
831 this->well_open_times_.erase(well_ecl.name());
837 const auto cycle_states = wcycle.wellStatus(this->simulator_.time(),
839 this->well_open_times_,
840 this->well_close_times_);
842 for (
int w = 0; w < nw; ++w) {
843 const Well& well_ecl = this->wells_ecl_[w];
845 if (!well_ecl.hasConnections()) {
850 const std::string& well_name = well_ecl.name();
851 const auto well_status = this->schedule()
852 .getWell(well_name, report_step).getStatus();
854 if ((well_ecl.getStatus() == Well::Status::SHUT) ||
855 (well_status == Well::Status::SHUT))
858 if (well_ecl.getStatus() != Well::Status::SHUT) {
859 this->closed_this_step_.insert(well_name);
860 this->wellState().shutWell(w);
863 this->well_open_times_.erase(well_name);
864 this->well_close_times_.erase(well_name);
869 if (this->wellTestState().well_is_closed(well_name)) {
874 const bool closed_this_step = (this->wellTestState().lastTestTime(well_name) == simulator_.time());
877 auto& events = this->wellState().well(w).events;
878 if (events.hasEvent(ScheduleEvents::REQUEST_OPEN_WELL)) {
879 if (!closed_this_step) {
880 this->wellTestState().open_well(well_name);
881 this->wellTestState().open_completions(well_name);
882 this->well_open_times_.insert_or_assign(well_name,
883 this->simulator_.time());
884 this->well_close_times_.erase(well_name);
886 events.clearEvent(ScheduleEvents::REQUEST_OPEN_WELL);
892 bool wellIsStopped =
false;
893 if (this->wellTestState().well_is_closed(well_name))
895 if (well_ecl.getAutomaticShutIn()) {
897 this->wellState().shutWell(w);
898 this->well_close_times_.erase(well_name);
899 this->well_open_times_.erase(well_name);
902 if (!well_ecl.getAllowCrossFlow()) {
905 this->wellState().shutWell(w);
906 this->well_close_times_.erase(well_name);
907 this->well_open_times_.erase(well_name);
911 this->wellState().stopWell(w);
912 wellIsStopped =
true;
917 if (!well_ecl.getAllowCrossFlow()) {
918 const bool any_zero_rate_constraint = well_ecl.isProducer()
919 ? well_ecl.productionControls(this->summaryState_).anyZeroRateConstraint()
920 : well_ecl.injectionControls(this->summaryState_).anyZeroRateConstraint();
921 if (any_zero_rate_constraint) {
923 local_deferredLogger.debug(fmt::format(
" Well {} gets shut due to having zero rate constraint and disallowing crossflow ", well_ecl.name()) );
924 this->wellState().shutWell(w);
925 this->well_close_times_.erase(well_name);
926 this->well_open_times_.erase(well_name);
931 if (well_status == Well::Status::STOP) {
932 this->wellState().stopWell(w);
933 this->well_close_times_.erase(well_name);
934 this->well_open_times_.erase(well_name);
935 wellIsStopped =
true;
938 if (!wcycle.empty()) {
939 const auto it = cycle_states.find(well_name);
940 if (it != cycle_states.end()) {
942 this->wellState().shutWell(w);
945 this->wellState().openWell(w);
950 well_container_.emplace_back(this->createWellPointer(w, report_step));
953 well_container_.back()->stopWell();
954 this->well_close_times_.erase(well_name);
955 this->well_open_times_.erase(well_name);
959 if (!wcycle.empty()) {
960 const auto schedule_open =
961 [&wg_events = this->report_step_start_events_](
const std::string& name)
963 return wg_events.hasEvent(name, ScheduleEvents::REQUEST_OPEN_WELL);
965 for (
const auto& [wname, wscale] : wcycle.efficiencyScale(this->simulator_.time(),
966 this->simulator_.timeStepSize(),
968 this->well_open_times_,
971 this->wellState().updateEfficiencyScalingFactor(wname, wscale);
972 this->schedule_.add_event(ScheduleEvents::WELLGROUP_EFFICIENCY_UPDATE, report_step);
979 const Opm::Parallel::Communication& comm = grid().comm();
981 if (this->terminal_output_) {
982 global_deferredLogger.logMessages();
985 this->well_container_generic_.clear();
986 for (
auto& w : well_container_)
987 this->well_container_generic_.push_back(w.get());
989 const auto& network = this->schedule()[report_step].network();
990 if (network.active() && !this->node_pressures_.empty()) {
991 for (
auto& well: this->well_container_generic_) {
995 if (well->isProducer()) {
996 const auto it = this->node_pressures_.find(well->wellEcl().groupName());
997 if (it != this->node_pressures_.end()) {
1000 const Scalar nodal_pressure = it->second;
1001 well->setDynamicThpLimit(nodal_pressure);
1007 this->wbp_.registerOpenWellsForWBPCalculation();
1014 template <
typename TypeTag>
1015 typename BlackoilWellModel<TypeTag>::WellInterfacePtr
1016 BlackoilWellModel<TypeTag>::
1017 createWellPointer(
const int wellID,
const int report_step)
const
1019 const auto is_multiseg = this->wells_ecl_[wellID].isMultiSegment();
1021 if (! (this->param_.use_multisegment_well_ && is_multiseg)) {
1022 return this->
template createTypedWellPointer<StandardWell<TypeTag>>(wellID, report_step);
1025 return this->
template createTypedWellPointer<MultisegmentWell<TypeTag>>(wellID, report_step);
1033 template <
typename TypeTag>
1034 template <
typename WellType>
1035 std::unique_ptr<WellType>
1036 BlackoilWellModel<TypeTag>::
1037 createTypedWellPointer(
const int wellID,
const int time_step)
const
1040 const auto& perf_data = this->well_perf_data_[wellID];
1043 const auto pvtreg = perf_data.empty()
1044 ? 0 : this->pvt_region_idx_[perf_data.front().cell_index];
1046 const auto& parallel_well_info = this->local_parallel_well_info_[wellID].get();
1047 const auto global_pvtreg = parallel_well_info.broadcastFirstPerforationValue(pvtreg);
1049 return std::make_unique<WellType>(this->wells_ecl_[wellID],
1053 *this->rateConverter_,
1055 this->numComponents(),
1065 template<
typename TypeTag>
1066 typename BlackoilWellModel<TypeTag>::WellInterfacePtr
1067 BlackoilWellModel<TypeTag>::
1068 createWellForWellTest(
const std::string& well_name,
1069 const int report_step,
1070 DeferredLogger& deferred_logger)
const
1073 const auto it = std::find_if(this->wells_ecl_.begin(),
1074 this->wells_ecl_.end(),
1075 [&well_name](
const auto& w)
1076 { return well_name == w.name(); });
1078 if (it == this->wells_ecl_.end()) {
1079 OPM_DEFLOG_THROW(std::logic_error,
1080 fmt::format(
"Could not find well {} in wells_ecl ", well_name),
1084 const int pos =
static_cast<int>(std::distance(this->wells_ecl_.begin(), it));
1085 return this->createWellPointer(pos, report_step);
1090 template<
typename TypeTag>
1092 BlackoilWellModel<TypeTag>::
1093 doPreStepNetworkRebalance(DeferredLogger& deferred_logger)
1096 const double dt = this->simulator_.timeStepSize();
1098 auto& well_state = this->wellState();
1100 const bool changed_well_group = updateWellControlsAndNetwork(
true, dt, deferred_logger);
1101 assembleWellEqWithoutIteration(dt, deferred_logger);
1102 const bool converged = this->getWellConvergence(this->B_avg_,
true).converged() && !changed_well_group;
1104 OPM_BEGIN_PARALLEL_TRY_CATCH();
1105 for (
auto& well : this->well_container_) {
1106 well->solveEqAndUpdateWellState(simulator_, well_state, deferred_logger);
1108 OPM_END_PARALLEL_TRY_CATCH(
"BlackoilWellModel::doPreStepNetworkRebalance() failed: ",
1109 this->simulator_.vanguard().grid().comm());
1112 const std::string msg = fmt::format(
"Initial (pre-step) network balance did not converge.");
1113 deferred_logger.warning(msg);
1120 template<
typename TypeTag>
1122 BlackoilWellModel<TypeTag>::
1123 assemble(
const int iterationIdx,
1127 DeferredLogger local_deferredLogger;
1129 if constexpr (BlackoilWellModelGasLift<TypeTag>::glift_debug) {
1130 if (gaslift_.terminalOutput()) {
1131 const std::string msg =
1132 fmt::format(
"assemble() : iteration {}" , iterationIdx);
1133 gaslift_.gliftDebug(msg, local_deferredLogger);
1136 last_report_ = SimulatorReportSingle();
1137 Dune::Timer perfTimer;
1139 this->closed_offending_wells_.clear();
1142 const int episodeIdx = simulator_.episodeIndex();
1143 const auto& network = this->schedule()[episodeIdx].network();
1144 if (!this->wellsActive() && !network.active()) {
1149 if (iterationIdx == 0 && this->wellsActive()) {
1150 OPM_TIMEBLOCK(firstIterationAssmble);
1155 OPM_BEGIN_PARALLEL_TRY_CATCH();
1157 calculateExplicitQuantities(local_deferredLogger);
1158 prepareTimeStep(local_deferredLogger);
1160 OPM_END_PARALLEL_TRY_CATCH_LOG(local_deferredLogger,
1161 "assemble() failed (It=0): ",
1162 this->terminal_output_, grid().comm());
1165 const bool well_group_control_changed = updateWellControlsAndNetwork(
false, dt, local_deferredLogger);
1169 if ( ! this->wellsActive() ) {
1173 assembleWellEqWithoutIteration(dt, local_deferredLogger);
1177 last_report_.well_group_control_changed = well_group_control_changed;
1178 last_report_.assemble_time_well += perfTimer.stop();
1184 template<
typename TypeTag>
1186 BlackoilWellModel<TypeTag>::
1187 updateWellControlsAndNetwork(
const bool mandatory_network_balance,
1189 DeferredLogger& local_deferredLogger)
1193 bool do_network_update =
true;
1194 bool well_group_control_changed =
false;
1195 Scalar network_imbalance = 0.0;
1197 const std::size_t iteration_to_relax = param_.network_max_strict_outer_iterations_;
1199 const std::size_t max_iteration = param_.network_max_outer_iterations_;
1200 std::size_t network_update_iteration = 0;
1201 while (do_network_update) {
1202 if (network_update_iteration >= max_iteration ) {
1204 const int episodeIdx = simulator_.episodeIndex();
1205 const int iterationIdx = simulator_.model().newtonMethod().numIterations();
1206 if (this->shouldBalanceNetwork(episodeIdx, iterationIdx + 1)) {
1207 const std::string msg = fmt::format(
"Maximum of {:d} network iterations has been used and we stop the update, \n"
1208 "and try again after the next Newton iteration (imbalance = {:.2e} bar, ctrl_change = {})",
1209 max_iteration, network_imbalance*1.0e-5, well_group_control_changed);
1210 local_deferredLogger.debug(msg);
1212 if (this->terminal_output_) {
1213 const std::string msg = fmt::format(
"Maximum of {:d} network iterations has been used and we stop the update. \n"
1214 "The simulator will continue with unconverged network results (imbalance = {:.2e} bar, ctrl_change = {})",
1215 max_iteration, network_imbalance*1.0e-5, well_group_control_changed);
1216 local_deferredLogger.info(msg);
1221 if (this->terminal_output_ && (network_update_iteration == iteration_to_relax) ) {
1222 local_deferredLogger.debug(
"We begin using relaxed tolerance for network update now after " + std::to_string(iteration_to_relax) +
" iterations ");
1224 const bool relax_network_balance = network_update_iteration >= iteration_to_relax;
1226 const bool optimize_gas_lift = ( (network_update_iteration + 1) < std::max(max_iteration,
static_cast<std::size_t
>(2)) );
1227 std::tie(well_group_control_changed, do_network_update, network_imbalance) =
1228 updateWellControlsAndNetworkIteration(mandatory_network_balance, relax_network_balance, optimize_gas_lift, dt,local_deferredLogger);
1229 ++network_update_iteration;
1231 return well_group_control_changed;
1237 template<
typename TypeTag>
1238 std::tuple<bool, bool, typename BlackoilWellModel<TypeTag>::Scalar>
1239 BlackoilWellModel<TypeTag>::
1240 updateWellControlsAndNetworkIteration(
const bool mandatory_network_balance,
1241 const bool relax_network_tolerance,
1242 const bool optimize_gas_lift,
1244 DeferredLogger& local_deferredLogger)
1247 auto [well_group_control_changed, more_inner_network_update, network_imbalance] =
1248 updateWellControls(mandatory_network_balance,
1249 local_deferredLogger,
1250 relax_network_tolerance);
1252 bool alq_updated =
false;
1253 OPM_BEGIN_PARALLEL_TRY_CATCH();
1255 if (optimize_gas_lift) alq_updated = gaslift_.maybeDoGasLiftOptimize(simulator_,
1259 local_deferredLogger);
1261 prepareWellsBeforeAssembling(dt, local_deferredLogger);
1263 OPM_END_PARALLEL_TRY_CATCH_LOG(local_deferredLogger,
1264 "updateWellControlsAndNetworkIteration() failed: ",
1265 this->terminal_output_, grid().comm());
1268 const int reportStepIdx = simulator_.episodeIndex();
1269 if (alq_updated || BlackoilWellModelGuideRates(*this).
1270 guideRateUpdateIsNeeded(reportStepIdx)) {
1271 const double simulationTime = simulator_.time();
1272 const auto& comm = simulator_.vanguard().grid().comm();
1273 const auto& summaryState = simulator_.vanguard().summaryState();
1274 std::vector<Scalar> pot(this->numPhases(), 0.0);
1275 const Group& fieldGroup = this->schedule().getGroup(
"FIELD", reportStepIdx);
1276 WellGroupHelpers<Scalar>::updateGuideRates(fieldGroup,
1287 local_deferredLogger);
1291 const int iterationIdx = simulator_.model().newtonMethod().numIterations();
1292 const bool more_network_update = this->shouldBalanceNetwork(reportStepIdx, iterationIdx) &&
1293 (more_inner_network_update || well_group_control_changed || alq_updated);
1294 return {well_group_control_changed, more_network_update, network_imbalance};
1300 template <
typename TypeTag>
1302 BlackoilWellModel<TypeTag>::
1303 computeWellGroupThp(
const double dt, DeferredLogger& local_deferredLogger)
1306 const int reportStepIdx = this->simulator_.episodeIndex();
1307 const auto& network = this->schedule()[reportStepIdx].network();
1308 const auto& balance = this->schedule()[reportStepIdx].network_balance();
1309 const Scalar thp_tolerance = balance.thp_tolerance();
1311 if (!network.active()) {
1315 auto& well_state = this->wellState();
1316 auto& group_state = this->groupState();
1318 bool well_group_thp_updated =
false;
1319 for (
const std::string& nodeName : network.node_names()) {
1320 const bool has_choke = network.node(nodeName).as_choke();
1322 const auto& summary_state = this->simulator_.vanguard().summaryState();
1323 const Group& group = this->schedule().getGroup(nodeName, reportStepIdx);
1325 const auto pu = this->phase_usage_;
1327 std::vector<Scalar> resv_coeff(pu.num_phases, 1.0);
1328 Scalar gratTargetFromSales = 0.0;
1329 if (group_state.has_grat_sales_target(group.name()))
1330 gratTargetFromSales = group_state.grat_sales_target(group.name());
1332 const auto ctrl = group.productionControls(summary_state);
1333 auto cmode_tmp = ctrl.cmode;
1334 Scalar target_tmp{0.0};
1335 bool fld_none =
false;
1336 if (cmode_tmp == Group::ProductionCMode::FLD || cmode_tmp == Group::ProductionCMode::NONE) {
1340 const Scalar efficiencyFactor = 1.0;
1341 const Group& parentGroup = this->schedule().getGroup(group.parent(), reportStepIdx);
1342 auto target = WellGroupControls<Scalar>::getAutoChokeGroupProductionTargetRate(
1354 local_deferredLogger);
1355 target_tmp = target.first;
1356 cmode_tmp = target.second;
1358 const auto cmode = cmode_tmp;
1359 WGHelpers::TargetCalculator tcalc(cmode, pu, resv_coeff,
1360 gratTargetFromSales, nodeName, group_state,
1361 group.has_gpmaint_control(cmode));
1365 target_tmp = tcalc.groupTarget(ctrl, local_deferredLogger);
1368 const Scalar orig_target = target_tmp;
1370 auto mismatch = [&] (
auto group_thp) {
1371 Scalar group_rate(0.0);
1373 for (
auto& well : this->well_container_) {
1374 std::string well_name = well->name();
1375 auto& ws = well_state.well(well_name);
1376 if (group.hasWell(well_name)) {
1377 well->setDynamicThpLimit(group_thp);
1378 const Well& well_ecl = this->wells_ecl_[well->indexOfWell()];
1379 const auto inj_controls = Well::InjectionControls(0);
1380 const auto prod_controls = well_ecl.productionControls(summary_state);
1381 well->iterateWellEqWithSwitching(this->simulator_, dt, inj_controls, prod_controls, well_state, group_state, local_deferredLogger,
false,
false);
1382 rate = -tcalc.calcModeRateFromRates(ws.surface_rates);
1386 return (group_rate - orig_target)/orig_target;
1389 const auto upbranch = network.uptree_branch(nodeName);
1390 const auto it = this->node_pressures_.find((*upbranch).uptree_node());
1391 const Scalar nodal_pressure = it->second;
1392 Scalar well_group_thp = nodal_pressure;
1394 std::optional<Scalar> autochoke_thp;
1395 if (
auto iter = this->well_group_thp_calc_.find(nodeName); iter != this->well_group_thp_calc_.end()) {
1396 autochoke_thp = this->well_group_thp_calc_.at(nodeName);
1400 std::array<Scalar, 2> range_initial;
1401 if (!autochoke_thp.has_value()){
1402 Scalar min_thp, max_thp;
1404 std::string node_name = nodeName;
1405 while (!network.node(node_name).terminal_pressure().has_value()) {
1406 auto branch = network.uptree_branch(node_name).value();
1407 node_name = branch.uptree_node();
1409 min_thp = network.node(node_name).terminal_pressure().value();
1410 WellBhpThpCalculator<Scalar>::bruteForceBracketCommonTHP(mismatch, min_thp, max_thp);
1413 std::array<Scalar, 2> range = {Scalar{0.9}*min_thp, Scalar{1.1}*max_thp};
1414 std::optional<Scalar> appr_sol;
1415 WellBhpThpCalculator<Scalar>::bruteForceBracketCommonTHP(mismatch, range, low1, high1, appr_sol, 0.0, local_deferredLogger);
1418 range_initial = {min_thp, max_thp};
1421 if (!autochoke_thp.has_value() || autochoke_thp.value() > nodal_pressure) {
1423 std::array<Scalar, 2> range = autochoke_thp.has_value() ?
1424 std::array<Scalar, 2>{Scalar{0.9} * autochoke_thp.value(),
1425 Scalar{1.1} * autochoke_thp.value()} : range_initial;
1427 std::optional<Scalar> approximate_solution;
1428 const Scalar tolerance1 = thp_tolerance;
1429 local_deferredLogger.debug(
"Using brute force search to bracket the group THP");
1430 const bool finding_bracket = WellBhpThpCalculator<Scalar>::bruteForceBracketCommonTHP(mismatch, range, low, high, approximate_solution, tolerance1, local_deferredLogger);
1432 if (approximate_solution.has_value()) {
1433 autochoke_thp = *approximate_solution;
1434 local_deferredLogger.debug(
"Approximate group THP value found: " + std::to_string(autochoke_thp.value()));
1435 }
else if (finding_bracket) {
1436 const Scalar tolerance2 = thp_tolerance;
1437 const int max_iteration_solve = 100;
1439 autochoke_thp = RegulaFalsiBisection<ThrowOnError>::
1440 solve(mismatch, low, high, max_iteration_solve, tolerance2, iteration);
1441 local_deferredLogger.debug(
" bracket = [" + std::to_string(low) +
", " + std::to_string(high) +
"], " +
1442 "iteration = " + std::to_string(iteration));
1443 local_deferredLogger.debug(
"Group THP value = " + std::to_string(autochoke_thp.value()));
1445 autochoke_thp.reset();
1446 local_deferredLogger.debug(
"Group THP solve failed due to bracketing failure");
1449 if (autochoke_thp.has_value()) {
1450 well_group_thp_calc_[nodeName] = autochoke_thp.value();
1453 well_group_thp = std::max(autochoke_thp.value(), nodal_pressure);
1456 for (
auto& well : this->well_container_) {
1457 std::string well_name = well->name();
1459 if (well->isInjector() || !well->wellEcl().predictionMode())
1462 if (group.hasWell(well_name)) {
1463 well->setDynamicThpLimit(well_group_thp);
1465 const auto& ws = this->wellState().well(well->indexOfWell());
1466 const bool thp_is_limit = ws.production_cmode == Well::ProducerCMode::THP;
1468 well->prepareWellBeforeAssembling(this->simulator_, dt, this->wellState(), this->groupState(), local_deferredLogger);
1473 const auto& current_well_group_thp = group_state.is_autochoke_group(nodeName) ? group_state.well_group_thp(nodeName) : 1e30;
1474 if (std::abs(current_well_group_thp - well_group_thp) > balance.pressure_tolerance()) {
1475 well_group_thp_updated =
true;
1476 group_state.update_well_group_thp(nodeName, well_group_thp);
1480 return well_group_thp_updated;
1483 template<
typename TypeTag>
1485 BlackoilWellModel<TypeTag>::
1486 assembleWellEq(
const double dt, DeferredLogger& deferred_logger)
1489 for (
auto& well : well_container_) {
1490 well->assembleWellEq(simulator_, dt, this->wellState(), this->groupState(), deferred_logger);
1495 template<
typename TypeTag>
1497 BlackoilWellModel<TypeTag>::
1498 prepareWellsBeforeAssembling(
const double dt, DeferredLogger& deferred_logger)
1501 for (
auto& well : well_container_) {
1502 well->prepareWellBeforeAssembling(simulator_, dt, this->wellState(), this->groupState(), deferred_logger);
1507 template<
typename TypeTag>
1509 BlackoilWellModel<TypeTag>::
1510 assembleWellEqWithoutIteration(
const double dt, DeferredLogger& deferred_logger)
1515 OPM_BEGIN_PARALLEL_TRY_CATCH();
1517 for (
auto& well: well_container_) {
1518 well->assembleWellEqWithoutIteration(simulator_, dt, this->wellState(), this->groupState(),
1521 OPM_END_PARALLEL_TRY_CATCH_LOG(deferred_logger,
"BlackoilWellModel::assembleWellEqWithoutIteration failed: ",
1522 this->terminal_output_, grid().comm());
1526#if COMPILE_GPU_BRIDGE
1527 template<
typename TypeTag>
1529 BlackoilWellModel<TypeTag>::
1530 getWellContributions(WellContributions<Scalar>& wellContribs)
const
1533 wellContribs.setBlockSize(StandardWell<TypeTag>::Indices::numEq, StandardWell<TypeTag>::numStaticWellEq);
1535 for(
unsigned int i = 0; i < well_container_.size(); i++){
1536 auto& well = well_container_[i];
1537 std::shared_ptr<StandardWell<TypeTag> > derived = std::dynamic_pointer_cast<StandardWell<TypeTag> >(well);
1539 wellContribs.addNumBlocks(derived->linSys().getNumBlocks());
1544 wellContribs.alloc();
1546 for(
unsigned int i = 0; i < well_container_.size(); i++){
1547 auto& well = well_container_[i];
1549 auto derived_std = std::dynamic_pointer_cast<StandardWell<TypeTag>>(well);
1551 derived_std->linSys().extract(derived_std->numStaticWellEq, wellContribs);
1553 auto derived_ms = std::dynamic_pointer_cast<MultisegmentWell<TypeTag> >(well);
1555 derived_ms->linSys().extract(wellContribs);
1557 OpmLog::warning(
"Warning unknown type of well");
1564 template<
typename TypeTag>
1566 BlackoilWellModel<TypeTag>::
1567 addWellContributions(SparseMatrixAdapter& jacobian)
const
1569 for (
const auto& well: well_container_ ) {
1570 well->addWellContributions(jacobian);
1574 template<
typename TypeTag>
1576 BlackoilWellModel<TypeTag>::
1577 addWellPressureEquations(PressureMatrix& jacobian,
1578 const BVector& weights,
1579 const bool use_well_weights)
const
1581 int nw = this->numLocalWellsEnd();
1582 int rdofs = local_num_cells_;
1583 for (
int i = 0; i < nw; i++ ) {
1584 int wdof = rdofs + i;
1585 jacobian[wdof][wdof] = 1.0;
1588 for (
const auto& well : well_container_) {
1589 well->addWellPressureEquations(jacobian,
1597 template <
typename TypeTag>
1598 void BlackoilWellModel<TypeTag>::
1599 addReservoirSourceTerms(GlobalEqVector& residual,
1600 const std::vector<typename SparseMatrixAdapter::MatrixBlock*>& diagMatAddress)
const
1605 for (
const auto& well : well_container_) {
1606 if (!well->isOperableAndSolvable() && !well->wellIsStopped()) {
1609 const auto& cells = well->cells();
1610 const auto& rates = well->connectionRates();
1611 for (
unsigned perfIdx = 0; perfIdx < rates.size(); ++perfIdx) {
1612 unsigned cellIdx = cells[perfIdx];
1613 auto rate = rates[perfIdx];
1615 VectorBlockType res(0.0);
1616 using MatrixBlockType =
typename SparseMatrixAdapter::MatrixBlock;
1617 MatrixBlockType bMat(0.0);
1618 simulator_.model().linearizer().setResAndJacobi(res, bMat, rate);
1619 residual[cellIdx] += res;
1620 *diagMatAddress[cellIdx] += bMat;
1626 template<
typename TypeTag>
1628 BlackoilWellModel<TypeTag>::
1629 addWellPressureEquationsStruct(PressureMatrix& jacobian)
const
1631 int nw = this->numLocalWellsEnd();
1632 int rdofs = local_num_cells_;
1633 for (
int i = 0; i < nw; ++i) {
1634 int wdof = rdofs + i;
1635 jacobian.entry(wdof,wdof) = 1.0;
1637 const auto wellconnections = this->getMaxWellConnections();
1638 for (
int i = 0; i < nw; ++i) {
1639 const auto& perfcells = wellconnections[i];
1640 for (
int perfcell : perfcells) {
1641 int wdof = rdofs + i;
1642 jacobian.entry(wdof, perfcell) = 0.0;
1643 jacobian.entry(perfcell, wdof) = 0.0;
1649 template<
typename TypeTag>
1651 BlackoilWellModel<TypeTag>::
1652 recoverWellSolutionAndUpdateWellState(
const BVector& x)
1654 DeferredLogger local_deferredLogger;
1655 OPM_BEGIN_PARALLEL_TRY_CATCH();
1657 for (
const auto& well : well_container_) {
1658 const auto& cells = well->cells();
1659 x_local_.resize(cells.size());
1661 for (
size_t i = 0; i < cells.size(); ++i) {
1662 x_local_[i] = x[cells[i]];
1664 well->recoverWellSolutionAndUpdateWellState(simulator_, x_local_,
1665 this->wellState(), local_deferredLogger);
1668 OPM_END_PARALLEL_TRY_CATCH_LOG(local_deferredLogger,
1669 "recoverWellSolutionAndUpdateWellState() failed: ",
1670 this->terminal_output_, simulator_.vanguard().grid().comm());
1674 template<
typename TypeTag>
1676 BlackoilWellModel<TypeTag>::
1677 recoverWellSolutionAndUpdateWellStateDomain(
const BVector& x,
const int domainIdx)
1680 OPM_THROW(std::logic_error,
"Attempt to call NLDD method without a NLDD solver");
1683 return nldd_->recoverWellSolutionAndUpdateWellState(x, domainIdx);
1687 template<
typename TypeTag>
1689 BlackoilWellModel<TypeTag>::
1690 getWellConvergence(
const std::vector<Scalar>& B_avg,
bool checkWellGroupControls)
const
1693 DeferredLogger local_deferredLogger;
1695 ConvergenceReport local_report;
1696 const int iterationIdx = simulator_.model().newtonMethod().numIterations();
1697 for (
const auto& well : well_container_) {
1698 if (well->isOperableAndSolvable() || well->wellIsStopped()) {
1699 local_report += well->getWellConvergence(
1700 simulator_, this->wellState(), B_avg, local_deferredLogger,
1701 iterationIdx > param_.strict_outer_iter_wells_);
1703 ConvergenceReport report;
1704 using CR = ConvergenceReport;
1705 report.setWellFailed({CR::WellFailure::Type::Unsolvable, CR::Severity::Normal, -1, well->name()});
1706 local_report += report;
1710 const Opm::Parallel::Communication comm = grid().comm();
1715 if (checkWellGroupControls) {
1716 report.setWellGroupTargetsViolated(this->lastReport().well_group_control_changed);
1719 if (this->terminal_output_) {
1720 global_deferredLogger.logMessages();
1723 for (
const auto& f : report.wellFailures()) {
1724 if (f.severity() == ConvergenceReport::Severity::NotANumber) {
1725 OpmLog::debug(
"NaN residual found with phase " + std::to_string(f.phase()) +
" for well " + f.wellName());
1726 }
else if (f.severity() == ConvergenceReport::Severity::TooLarge) {
1727 OpmLog::debug(
"Too large residual found with phase " + std::to_string(f.phase()) +
" for well " + f.wellName());
1738 template<
typename TypeTag>
1744 for (
auto& well : well_container_) {
1753 template<
typename TypeTag>
1754 std::tuple<bool, bool, typename BlackoilWellModel<TypeTag>::Scalar>
1758 const bool relax_network_tolerance)
1761 const int episodeIdx = simulator_.episodeIndex();
1762 const auto& network = this->schedule()[episodeIdx].network();
1763 if (!this->wellsActive() && !network.active()) {
1764 return {
false,
false, 0.0};
1767 const int iterationIdx = simulator_.model().newtonMethod().numIterations();
1768 const auto& comm = simulator_.vanguard().grid().comm();
1769 this->updateAndCommunicateGroupData(episodeIdx, iterationIdx, param_.nupcol_group_rate_tolerance_, deferred_logger);
1772 Scalar network_imbalance = 0.0;
1773 bool more_network_update =
false;
1774 if (this->shouldBalanceNetwork(episodeIdx, iterationIdx) || mandatory_network_balance) {
1775 OPM_TIMEBLOCK(BalanceNetowork);
1776 const double dt = this->simulator_.timeStepSize();
1778 bool well_group_thp_updated = computeWellGroupThp(dt, deferred_logger);
1779 const int max_number_of_sub_iterations = param_.network_max_sub_iterations_;
1780 const Scalar network_pressure_update_damping_factor = param_.network_pressure_update_damping_factor_;
1781 const Scalar network_max_pressure_update = param_.network_max_pressure_update_in_bars_ * unit::barsa;
1782 bool more_network_sub_update =
false;
1783 for (
int i = 0; i < max_number_of_sub_iterations; i++) {
1784 const auto local_network_imbalance = this->updateNetworkPressures(episodeIdx, network_pressure_update_damping_factor, network_max_pressure_update);
1785 network_imbalance = comm.max(local_network_imbalance);
1786 const auto& balance = this->schedule()[episodeIdx].network_balance();
1787 constexpr Scalar relaxation_factor = 10.0;
1788 const Scalar tolerance = relax_network_tolerance ? relaxation_factor * balance.pressure_tolerance() : balance.pressure_tolerance();
1789 more_network_sub_update = this->networkActive() && network_imbalance > tolerance;
1790 if (!more_network_sub_update)
1793 for (
const auto& well : well_container_) {
1794 if (well->isInjector() || !well->wellEcl().predictionMode())
1797 const auto it = this->node_pressures_.find(well->wellEcl().groupName());
1798 if (it != this->node_pressures_.end()) {
1799 const auto& ws = this->wellState().well(well->indexOfWell());
1800 const bool thp_is_limit = ws.production_cmode == Well::ProducerCMode::THP;
1802 well->prepareWellBeforeAssembling(this->simulator_, dt, this->wellState(), this->groupState(), deferred_logger);
1806 this->updateAndCommunicateGroupData(episodeIdx, iterationIdx, param_.nupcol_group_rate_tolerance_, deferred_logger);
1808 more_network_update = more_network_sub_update || well_group_thp_updated;
1811 bool changed_well_group =
false;
1813 const Group& fieldGroup = this->schedule().getGroup(
"FIELD", episodeIdx);
1814 changed_well_group = updateGroupControls(fieldGroup, deferred_logger, episodeIdx, iterationIdx);
1817 bool changed_well_to_group =
false;
1819 OPM_TIMEBLOCK(UpdateWellControls);
1822 OPM_BEGIN_PARALLEL_TRY_CATCH()
1823 for (const auto& well : well_container_) {
1824 const auto mode = WellInterface<TypeTag>::IndividualOrGroup::Group;
1825 const bool changed_well = well->updateWellControl(simulator_, mode, this->wellState(), this->groupState(), deferred_logger);
1827 changed_well_to_group = changed_well || changed_well_to_group;
1830 OPM_END_PARALLEL_TRY_CATCH(
"BlackoilWellModel: updating well controls failed: ",
1831 simulator_.gridView().comm());
1834 changed_well_to_group = comm.sum(
static_cast<int>(changed_well_to_group));
1835 if (changed_well_to_group) {
1836 updateAndCommunicate(episodeIdx, iterationIdx, deferred_logger);
1837 changed_well_group =
true;
1841 bool changed_well_individual =
false;
1845 OPM_BEGIN_PARALLEL_TRY_CATCH()
1846 for (const auto& well : well_container_) {
1847 const auto mode = WellInterface<TypeTag>::IndividualOrGroup::Individual;
1848 const bool changed_well = well->updateWellControl(simulator_, mode, this->wellState(), this->groupState(), deferred_logger);
1850 changed_well_individual = changed_well || changed_well_individual;
1853 OPM_END_PARALLEL_TRY_CATCH(
"BlackoilWellModel: updating well controls failed: ",
1854 simulator_.gridView().comm());
1857 changed_well_individual = comm.sum(
static_cast<int>(changed_well_individual));
1858 if (changed_well_individual) {
1859 updateAndCommunicate(episodeIdx, iterationIdx, deferred_logger);
1860 changed_well_group =
true;
1864 this->updateWsolvent(fieldGroup, episodeIdx, this->nupcolWellState());
1866 return { changed_well_group, more_network_update, network_imbalance };
1869 template<
typename TypeTag>
1871 BlackoilWellModel<TypeTag>::
1872 updateAndCommunicate(
const int reportStepIdx,
1873 const int iterationIdx,
1874 DeferredLogger& deferred_logger)
1876 this->updateAndCommunicateGroupData(reportStepIdx,
1878 param_.nupcol_group_rate_tolerance_,
1883 OPM_BEGIN_PARALLEL_TRY_CATCH()
1885 for (const auto& well : well_container_) {
1887 const auto& ws = this->wellState().well(well->indexOfWell());
1888 if (ws.production_cmode == Well::ProducerCMode::GRUP ||
1889 ws.injection_cmode == Well::InjectorCMode::GRUP)
1891 well->updateWellStateWithTarget(simulator_, this->groupState(),
1892 this->wellState(), deferred_logger);
1895 OPM_END_PARALLEL_TRY_CATCH(
"BlackoilWellModel::updateAndCommunicate failed: ",
1896 simulator_.gridView().comm())
1897 this->updateAndCommunicateGroupData(reportStepIdx,
1899 param_.nupcol_group_rate_tolerance_,
1903 template<typename TypeTag>
1905 BlackoilWellModel<TypeTag>::
1906 updateGroupControls(const Group& group,
1907 DeferredLogger& deferred_logger,
1908 const
int reportStepIdx,
1909 const
int iterationIdx)
1912 bool changed =
false;
1914 const int nupcol = this->schedule()[reportStepIdx].nupcol();
1915 const int max_number_of_group_switches = iterationIdx < nupcol ? 9999 : param_.max_number_of_group_switches_;
1916 bool changed_hc = this->checkGroupHigherConstraints( group, deferred_logger, reportStepIdx, max_number_of_group_switches);
1919 updateAndCommunicate(reportStepIdx, iterationIdx, deferred_logger);
1922 bool changed_individual =
1923 BlackoilWellModelConstraints(*this).
1924 updateGroupIndividualControl(group,
1926 max_number_of_group_switches,
1927 this->switched_inj_groups_,
1928 this->switched_prod_groups_,
1929 this->closed_offending_wells_,
1934 if (changed_individual) {
1936 updateAndCommunicate(reportStepIdx, iterationIdx, deferred_logger);
1939 for (
const std::string& groupName : group.groups()) {
1940 bool changed_this = updateGroupControls( this->schedule().getGroup(groupName, reportStepIdx), deferred_logger, reportStepIdx,iterationIdx);
1941 changed = changed || changed_this;
1946 template<
typename TypeTag>
1953 for (
const auto& well : well_container_) {
1954 const auto& wname = well->name();
1955 const auto wasClosed = wellTestState.well_is_closed(wname);
1956 well->checkWellOperability(simulator_,
1958 local_deferredLogger);
1959 const bool under_zero_target =
1960 well->wellUnderZeroGroupRateTarget(this->simulator_,
1962 local_deferredLogger);
1963 well->updateWellTestState(this->wellState().well(wname),
1968 local_deferredLogger);
1970 if (!wasClosed && wellTestState.well_is_closed(wname)) {
1971 this->closed_this_step_.insert(wname);
1975 for (
const auto& [group_name, to] : this->closed_offending_wells_) {
1976 if (this->hasOpenLocalWell(to.second) &&
1977 !this->wasDynamicallyShutThisTimeStep(to.second))
1979 wellTestState.close_well(to.second,
1980 WellTestConfig::Reason::GROUP,
1982 this->updateClosedWellsThisStep(to.second);
1983 const std::string msg =
1984 fmt::format(
"Procedure on exceeding {} limit is WELL for group {}. "
1990 local_deferredLogger.info(msg);
1994 const Opm::Parallel::Communication comm = grid().comm();
1998 if (this->terminal_output_) {
2004 template<
typename TypeTag>
2008 std::string& exc_msg,
2009 ExceptionType::ExcEnum& exc_type,
2013 const int np = this->numPhases();
2014 std::vector<Scalar> potentials;
2015 const auto& well = well_container_[widx];
2016 std::string cur_exc_msg;
2017 auto cur_exc_type = ExceptionType::NONE;
2019 well->computeWellPotentials(simulator_, well_state_copy, potentials, deferred_logger);
2022 OPM_PARALLEL_CATCH_CLAUSE(cur_exc_type, cur_exc_msg);
2023 if (cur_exc_type != ExceptionType::NONE) {
2024 exc_msg += fmt::format(
"\nFor well {}: {}", well->name(), cur_exc_msg);
2026 exc_type = std::max(exc_type, cur_exc_type);
2030 auto& ws = this->wellState().well(well->indexOfWell());
2031 for (
int p = 0; p < np; ++p) {
2033 ws.well_potentials[p] = std::max(Scalar{0.0}, potentials[p]);
2039 template <
typename TypeTag>
2041 BlackoilWellModel<TypeTag>::
2042 calculateProductivityIndexValues(DeferredLogger& deferred_logger)
2044 for (
const auto& wellPtr : this->well_container_) {
2045 this->calculateProductivityIndexValues(wellPtr.get(), deferred_logger);
2053 template <
typename TypeTag>
2055 BlackoilWellModel<TypeTag>::
2056 calculateProductivityIndexValuesShutWells(
const int reportStepIdx,
2057 DeferredLogger& deferred_logger)
2064 for (
const auto& shutWell : this->local_shut_wells_) {
2065 if (!this->wells_ecl_[shutWell].hasConnections()) {
2070 auto wellPtr = this->
template createTypedWellPointer
2071 <StandardWell<TypeTag>>(shutWell, reportStepIdx);
2073 wellPtr->init(&this->phase_usage_, this->depth_, this->gravity_, this->B_avg_,
true);
2075 this->calculateProductivityIndexValues(wellPtr.get(), deferred_logger);
2083 template <
typename TypeTag>
2085 BlackoilWellModel<TypeTag>::
2086 calculateProductivityIndexValues(
const WellInterface<TypeTag>* wellPtr,
2087 DeferredLogger& deferred_logger)
2089 wellPtr->updateProductivityIndex(this->simulator_,
2090 this->prod_index_calc_[wellPtr->indexOfWell()],
2097 template<
typename TypeTag>
2099 BlackoilWellModel<TypeTag>::
2100 prepareTimeStep(DeferredLogger& deferred_logger)
2103 const auto episodeIdx = simulator_.episodeIndex();
2104 this->updateNetworkActiveState(episodeIdx);
2108 const bool do_prestep_network_rebalance = param_.pre_solve_network_ && this->needPreStepNetworkRebalance(episodeIdx);
2110 for (
const auto& well : well_container_) {
2111 auto& events = this->wellState().well(well->indexOfWell()).events;
2112 if (events.hasEvent(WellState<Scalar>::event_mask)) {
2113 well->updateWellStateWithTarget(simulator_, this->groupState(), this->wellState(), deferred_logger);
2114 well->updatePrimaryVariables(simulator_, this->wellState(), deferred_logger);
2117 events.clearEvent(WellState<Scalar>::event_mask);
2120 if (events.hasEvent(ScheduleEvents::REQUEST_OPEN_WELL)) {
2121 events.clearEvent(ScheduleEvents::REQUEST_OPEN_WELL);
2124 if (param_.solve_welleq_initially_ && well->isOperableAndSolvable()) {
2126 well->solveWellEquation(simulator_, this->wellState(), this->groupState(), deferred_logger);
2127 }
catch (
const std::exception& e) {
2128 const std::string msg =
"Compute initial well solution for " + well->name() +
" initially failed. Continue with the previous rates";
2129 deferred_logger.warning(
"WELL_INITIAL_SOLVE_FAILED", msg);
2134 well->resetWellOperability();
2136 updatePrimaryVariables(deferred_logger);
2139 if (do_prestep_network_rebalance) doPreStepNetworkRebalance(deferred_logger);
2142 template<
typename TypeTag>
2144 BlackoilWellModel<TypeTag>::
2145 updateAverageFormationFactor()
2147 std::vector< Scalar > B_avg(numComponents(), Scalar() );
2148 const auto& grid = simulator_.vanguard().grid();
2149 const auto& gridView = grid.leafGridView();
2150 ElementContext elemCtx(simulator_);
2152 OPM_BEGIN_PARALLEL_TRY_CATCH();
2153 for (
const auto& elem : elements(gridView, Dune::Partitions::interior)) {
2154 elemCtx.updatePrimaryStencil(elem);
2155 elemCtx.updatePrimaryIntensiveQuantities(0);
2157 const auto& intQuants = elemCtx.intensiveQuantities(0, 0);
2158 const auto& fs = intQuants.fluidState();
2160 for (
unsigned phaseIdx = 0; phaseIdx < FluidSystem::numPhases; ++phaseIdx)
2162 if (!FluidSystem::phaseIsActive(phaseIdx)) {
2166 const unsigned compIdx = Indices::canonicalToActiveComponentIndex(FluidSystem::solventComponentIndex(phaseIdx));
2167 auto& B = B_avg[ compIdx ];
2169 B += 1 / fs.invB(phaseIdx).value();
2171 if constexpr (has_solvent_) {
2172 auto& B = B_avg[solventSaturationIdx];
2173 B += 1 / intQuants.solventInverseFormationVolumeFactor().value();
2176 OPM_END_PARALLEL_TRY_CATCH(
"BlackoilWellModel::updateAverageFormationFactor() failed: ", grid.comm())
2179 grid.comm().sum(B_avg.data(), B_avg.size());
2180 for (auto& bval : B_avg)
2182 bval /= global_num_cells_;
2191 template<
typename TypeTag>
2193 BlackoilWellModel<TypeTag>::
2194 updatePrimaryVariables(DeferredLogger& deferred_logger)
2196 for (
const auto& well : well_container_) {
2197 well->updatePrimaryVariables(simulator_, this->wellState(), deferred_logger);
2201 template<
typename TypeTag>
2203 BlackoilWellModel<TypeTag>::extractLegacyCellPvtRegionIndex_()
2205 const auto& grid = simulator_.vanguard().grid();
2206 const auto& eclProblem = simulator_.problem();
2207 const unsigned numCells = grid.size(0);
2209 this->pvt_region_idx_.resize(numCells);
2210 for (
unsigned cellIdx = 0; cellIdx < numCells; ++cellIdx) {
2211 this->pvt_region_idx_[cellIdx] =
2212 eclProblem.pvtRegionIndex(cellIdx);
2217 template<
typename TypeTag>
2219 BlackoilWellModel<TypeTag>::numComponents()
const
2227 int numComp = this->numPhases() < 3 ? this->numPhases() : FluidSystem::numComponents;
2228 if constexpr (has_solvent_) {
2234 template<
typename TypeTag>
2236 BlackoilWellModel<TypeTag>::extractLegacyDepth_()
2238 const auto& eclProblem = simulator_.problem();
2239 depth_.resize(local_num_cells_);
2240 for (
unsigned cellIdx = 0; cellIdx < local_num_cells_; ++cellIdx) {
2241 depth_[cellIdx] = eclProblem.dofCenterDepth(cellIdx);
2245 template<
typename TypeTag>
2246 typename BlackoilWellModel<TypeTag>::WellInterfacePtr
2247 BlackoilWellModel<TypeTag>::
2248 getWell(
const std::string& well_name)
const
2251 auto well = std::find_if(well_container_.begin(),
2252 well_container_.end(),
2253 [&well_name](
const WellInterfacePtr& elem)->bool {
2254 return elem->name() == well_name;
2257 assert(well != well_container_.end());
2262 template <
typename TypeTag>
2264 BlackoilWellModel<TypeTag>::
2265 reportStepIndex()
const
2267 return std::max(this->simulator_.episodeIndex(), 0);
2274 template<
typename TypeTag>
2276 BlackoilWellModel<TypeTag>::
2277 calcResvCoeff(
const int fipnum,
2279 const std::vector<Scalar>& production_rates,
2280 std::vector<Scalar>& resv_coeff)
2282 rateConverter_->calcCoeff(fipnum, pvtreg, production_rates, resv_coeff);
2285 template<
typename TypeTag>
2287 BlackoilWellModel<TypeTag>::
2288 calcInjResvCoeff(
const int fipnum,
2290 std::vector<Scalar>& resv_coeff)
2292 rateConverter_->calcInjCoeff(fipnum, pvtreg, resv_coeff);
2296 template <
typename TypeTag>
2298 BlackoilWellModel<TypeTag>::
2299 computeWellTemperature()
2301 if constexpr (has_energy_) {
2302 int np = this->numPhases();
2303 Scalar cellInternalEnergy;
2306 Scalar perfPhaseRate;
2307 const int nw = this->numLocalWells();
2308 for (
auto wellID = 0*nw; wellID < nw; ++wellID) {
2309 const Well& well = this->wells_ecl_[wellID];
2310 auto& ws = this->wellState().well(wellID);
2311 if (well.isInjector()) {
2312 if (ws.status != WellStatus::STOP) {
2313 this->wellState().well(wellID).temperature = well.inj_temperature();
2318 std::array<Scalar,2> weighted{0.0,0.0};
2319 auto& [weighted_temperature, total_weight] = weighted;
2321 auto& well_info = this->local_parallel_well_info_[wellID].get();
2322 auto& perf_data = ws.perf_data;
2323 auto& perf_phase_rate = perf_data.phase_rates;
2325 using int_type =
decltype(this->well_perf_data_[wellID].size());
2326 for (int_type perf = 0, end_perf = this->well_perf_data_[wellID].size(); perf < end_perf; ++perf) {
2327 const int cell_idx = this->well_perf_data_[wellID][perf].cell_index;
2328 const auto& intQuants = simulator_.model().intensiveQuantities(cell_idx, 0);
2329 const auto& fs = intQuants.fluidState();
2332 Scalar cellTemperatures = fs.temperature(0).value();
2334 Scalar weight_factor = 0.0;
2335 for (
unsigned phaseIdx = 0; phaseIdx < FluidSystem::numPhases; ++phaseIdx) {
2336 if (!FluidSystem::phaseIsActive(phaseIdx)) {
2339 cellInternalEnergy = fs.enthalpy(phaseIdx).value() -
2340 fs.pressure(phaseIdx).value() / fs.density(phaseIdx).value();
2341 cellBinv = fs.invB(phaseIdx).value();
2342 cellDensity = fs.density(phaseIdx).value();
2343 perfPhaseRate = perf_phase_rate[perf*np + phaseIdx];
2344 weight_factor += cellDensity * perfPhaseRate / cellBinv * cellInternalEnergy / cellTemperatures;
2346 weight_factor = std::abs(weight_factor) + 1e-13;
2347 total_weight += weight_factor;
2348 weighted_temperature += weight_factor * cellTemperatures;
2350 well_info.communication().sum(weighted.data(), 2);
2351 this->wellState().well(wellID).temperature = weighted_temperature / total_weight;
Class for handling the blackoil well model.
Definition BlackoilWellModel.hpp:94
void calculateExplicitQuantities(DeferredLogger &deferred_logger) const
Calculating the explict quantities used in the well calculation.
Definition BlackoilWellModel_impl.hpp:1741
Definition DeferredLogger.hpp:57
void logMessages()
Log all messages to the OpmLog backends, and clear the message container.
Definition DeferredLogger.cpp:85
Definition WellGroupHelpers.hpp:50
The state of a set of wells, tailored for use by the fully implicit blackoil simulator.
Definition WellState.hpp:66
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition blackoilboundaryratevector.hh:37
Opm::DeferredLogger gatherDeferredLogger(const Opm::DeferredLogger &local_deferredlogger, Opm::Parallel::Communication)
Create a global log combining local logs.
Definition gatherDeferredLogger.cpp:168
ConvergenceReport gatherConvergenceReport(const ConvergenceReport &local_report, Parallel::Communication mpi_communicator)
Create a global convergence report combining local (per-process) reports.
Definition gatherConvergenceReport.cpp:171
constexpr auto getPropValue()
get the value data member of a property
Definition propertysystem.hh:242
PhaseUsage phaseUsageFromDeck(const EclipseState &eclipseState)
Looks at presence of WATER, OIL and GAS keywords in state object to determine active phases.
Definition phaseUsageFromDeck.cpp:137