diff --git a/opm/simulators/wells/BlackoilWellModelGeneric.cpp b/opm/simulators/wells/BlackoilWellModelGeneric.cpp index 6f4726a4b..eefc88b1d 100644 --- a/opm/simulators/wells/BlackoilWellModelGeneric.cpp +++ b/opm/simulators/wells/BlackoilWellModelGeneric.cpp @@ -386,13 +386,6 @@ wellsActive() const return wells_active_; } -bool -BlackoilWellModelGeneric:: -localWellsActive() const -{ - return numLocalWells() > 0; -} - bool BlackoilWellModelGeneric:: anyMSWellOpenLocal() const @@ -670,13 +663,6 @@ initFromRestartFile(const RestartValue& restartValues, initial_step_ = false; } -void -BlackoilWellModelGeneric:: -setWellsActive(const bool wells_active) -{ - wells_active_ = wells_active; -} - std::vector BlackoilWellModelGeneric:: getLocalWells(const int timeStepIdx) const @@ -2142,10 +2128,6 @@ void BlackoilWellModelGeneric:: calculateEfficiencyFactors(const int reportStepIdx) { - if ( !localWellsActive() ) { - return; - } - for (auto& well : well_container_generic_) { const Well& wellEcl = well->wellEcl(); double well_efficiency_factor = wellEcl.getEfficiencyFactor(); diff --git a/opm/simulators/wells/BlackoilWellModelGeneric.hpp b/opm/simulators/wells/BlackoilWellModelGeneric.hpp index b8ca50227..56433b863 100644 --- a/opm/simulators/wells/BlackoilWellModelGeneric.hpp +++ b/opm/simulators/wells/BlackoilWellModelGeneric.hpp @@ -90,8 +90,7 @@ public: /// return true if wells are available in the reservoir bool wellsActive() const; bool hasWell(const std::string& wname); - /// return true if wells are available on this process - bool localWellsActive() const; + // whether there exists any multisegment well open on this process bool anyMSWellOpenLocal() const; @@ -143,8 +142,6 @@ public: const size_t numCells, bool handle_ms_well); - void setWellsActive(const bool wells_active); - /* Will assign the internal member last_valid_well_state_ to the current value of the this->active_well_state_. The state stored diff --git a/opm/simulators/wells/BlackoilWellModel_impl.hpp b/opm/simulators/wells/BlackoilWellModel_impl.hpp index 7c88e58dc..5034b28eb 100644 --- a/opm/simulators/wells/BlackoilWellModel_impl.hpp +++ b/opm/simulators/wells/BlackoilWellModel_impl.hpp @@ -202,11 +202,6 @@ namespace Opm { this->initializeWellPerfData(); this->initializeWellState(timeStepIdx, summaryState); - // Wells are active if they are active wells on at least - // one process. - wells_active_ = localWellsActive() ? 1 : 0; - wells_active_ = grid.comm().max(wells_active_); - // handling MS well related if (param_.use_multisegment_well_&& anyMSWellOpenLocal()) { // if we use MultisegmentWell model this->wellState().initWellStateMSWell(wells_ecl_, &this->prevWellState()); @@ -270,6 +265,11 @@ namespace Opm { // create the well container createWellContainer(reportStepIdx); + // Wells are active if they are active wells on at least one process. + const Grid& grid = ebosSimulator_.vanguard().grid(); + wells_active_ = !this->well_container_.empty(); + wells_active_ = grid.comm().max(wells_active_); + // do the initialization for all the wells // TODO: to see whether we can postpone of the intialization of the well containers to // optimize the usage of the following several member variables @@ -1142,10 +1142,6 @@ namespace Opm { BlackoilWellModel:: apply( BVector& r) const { - if ( ! localWellsActive() ) { - return; - } - for (auto& well : well_container_) { well->apply(r); } @@ -1158,11 +1154,6 @@ namespace Opm { BlackoilWellModel:: apply(const BVector& x, BVector& Ax) const { - // TODO: do we still need localWellsActive()? - if ( ! localWellsActive() ) { - return; - } - for (auto& well : well_container_) { well->apply(x, Ax); } @@ -1214,7 +1205,7 @@ namespace Opm { BlackoilWellModel:: applyScaleAdd(const Scalar alpha, const BVector& x, BVector& Ax) const { - if ( ! localWellsActive() ) { + if (this->well_container_.empty()) { return; } @@ -1342,10 +1333,8 @@ namespace Opm { DeferredLogger local_deferredLogger; OPM_BEGIN_PARALLEL_TRY_CATCH(); { - if (localWellsActive()) { - for (auto& well : well_container_) { - well->recoverWellSolutionAndUpdateWellState(x, this->wellState(), local_deferredLogger); - } + for (auto& well : well_container_) { + well->recoverWellSolutionAndUpdateWellState(x, this->wellState(), local_deferredLogger); } } @@ -1753,7 +1742,13 @@ namespace Opm { int BlackoilWellModel::numComponents() const { - if (wellsActive() && numPhases() < 3) { + // The numComponents here does not reflect the actual number of the components in the system. + // It more or less reflects the number of mass conservation equations for the well equations. + // For example, in the current formulation, we do not have the polymer conservation equation + // in the well equations. As a result, for an oil-water-polymer system, this function will return 2. + // In some way, it makes this function appear to be confusing from its name, and we need + // to revisit/revise this function again when extending the variants of system that flow can simulate. + if (numPhases() < 3) { return numPhases(); } int numComp = FluidSystem::numComponents;