diff --git a/opm/simulators/wells/BlackoilWellModel.hpp b/opm/simulators/wells/BlackoilWellModel.hpp index 813816fb1..6ec598ee5 100644 --- a/opm/simulators/wells/BlackoilWellModel.hpp +++ b/opm/simulators/wells/BlackoilWellModel.hpp @@ -500,14 +500,9 @@ template class WellContributions; // setting the well_solutions_ based on well_state. void updatePrimaryVariables(DeferredLogger& deferred_logger); - void initializeWBPCalculationService(); - data::WellBlockAveragePressures computeWellBlockAveragePressures() const; - typename ParallelWBPCalculation::EvaluatorFactory - makeWellSourceEvaluatorFactory(const std::vector::size_type wellIdx) const; - void updateAverageFormationFactor(); void computePotentials(const std::size_t widx, diff --git a/opm/simulators/wells/BlackoilWellModelGeneric.cpp b/opm/simulators/wells/BlackoilWellModelGeneric.cpp index 5e31fca1f..dbefc6bf2 100644 --- a/opm/simulators/wells/BlackoilWellModelGeneric.cpp +++ b/opm/simulators/wells/BlackoilWellModelGeneric.cpp @@ -2101,6 +2101,80 @@ registerOpenWellsForWBPCalculation() } } +template +typename ParallelWBPCalculation::EvaluatorFactory +BlackoilWellModelGeneric:: +makeWellSourceEvaluatorFactory(const std::vector::size_type wellIdx) const +{ + using Span = typename PAvgDynamicSourceData::template SourceDataSpan; + using Item = typename Span::Item; + + return [wellIdx, this]() -> typename ParallelWBPCalculation::Evaluator + { + if (! this->wbpCalcMap_[wellIdx].openWellIdx_.has_value()) { + // Well is stopped/shut. Return evaluator for stopped wells. + return []([[maybe_unused]] const int connIdx, Span sourceTerm) + { + // Well/connection is stopped/shut. Set all items to + // zero. + + sourceTerm + .set(Item::Pressure , 0.0) + .set(Item::PoreVol , 0.0) + .set(Item::MixtureDensity, 0.0) + .set(Item::Depth , 0.0) + ; + }; + } + + // Well is open. Return an evaluator for open wells/open connections. + return [this, wellPtr = this->well_container_generic_[*this->wbpCalcMap_[wellIdx].openWellIdx_]] + (const int connIdx, Span sourceTerm) + { + // Note: The only item which actually matters for the WBP + // calculation at the well reservoir connection level is the + // mixture density. Set other items to zero. + + const auto& connIdxMap = + this->conn_idx_map_[wellPtr->indexOfWell()]; + + const auto rho = wellPtr-> + connectionDensity(connIdxMap.global(connIdx), + connIdxMap.open(connIdx)); + + sourceTerm + .set(Item::Pressure , 0.0) + .set(Item::PoreVol , 0.0) + .set(Item::MixtureDensity, rho) + .set(Item::Depth , 0.0) + ; + }; + }; +} + +template +void BlackoilWellModelGeneric:: +initializeWBPCalculationService() +{ + this->wbpCalcMap_.clear(); + this->wbpCalcMap_.resize(this->wells_ecl_.size()); + + this->registerOpenWellsForWBPCalculation(); + + auto wellID = std::size_t{0}; + for (const auto& well : this->wells_ecl_) { + this->wbpCalcMap_[wellID].wbpCalcIdx_ = this->wbpCalculationService_ + .createCalculator(well, + this->local_parallel_well_info_[wellID], + this->conn_idx_map_[wellID].local(), + this->makeWellSourceEvaluatorFactory(wellID)); + + ++wellID; + } + + this->wbpCalculationService_.defineCommunication(); +} + template class BlackoilWellModelGeneric; #if FLOW_INSTANTIATE_FLOAT diff --git a/opm/simulators/wells/BlackoilWellModelGeneric.hpp b/opm/simulators/wells/BlackoilWellModelGeneric.hpp index 7ebe73660..893ffc53d 100644 --- a/opm/simulators/wells/BlackoilWellModelGeneric.hpp +++ b/opm/simulators/wells/BlackoilWellModelGeneric.hpp @@ -460,6 +460,11 @@ protected: void registerOpenWellsForWBPCalculation(); + typename ParallelWBPCalculation::EvaluatorFactory + makeWellSourceEvaluatorFactory(const std::vector::size_type wellIdx) const; + + void initializeWBPCalculationService(); + Schedule& schedule_; const SummaryState& summaryState_; const EclipseState& eclState_; diff --git a/opm/simulators/wells/BlackoilWellModel_impl.hpp b/opm/simulators/wells/BlackoilWellModel_impl.hpp index f4706208a..322a2463f 100644 --- a/opm/simulators/wells/BlackoilWellModel_impl.hpp +++ b/opm/simulators/wells/BlackoilWellModel_impl.hpp @@ -2357,34 +2357,6 @@ namespace Opm { - template - void - BlackoilWellModel:: - initializeWBPCalculationService() - { - this->wbpCalcMap_.clear(); - this->wbpCalcMap_.resize(this->wells_ecl_.size()); - - this->registerOpenWellsForWBPCalculation(); - - auto wellID = std::size_t{0}; - for (const auto& well : this->wells_ecl_) { - this->wbpCalcMap_[wellID].wbpCalcIdx_ = this->wbpCalculationService_ - .createCalculator(well, - this->local_parallel_well_info_[wellID], - this->conn_idx_map_[wellID].local(), - this->makeWellSourceEvaluatorFactory(wellID)); - - ++wellID; - } - - this->wbpCalculationService_.defineCommunication(); - } - - - - - template data::WellBlockAveragePressures BlackoilWellModel:: @@ -2431,61 +2403,6 @@ namespace Opm { - template - typename ParallelWBPCalculation::Scalar>::EvaluatorFactory - BlackoilWellModel:: - makeWellSourceEvaluatorFactory(const std::vector::size_type wellIdx) const - { - using Span = typename PAvgDynamicSourceData::template SourceDataSpan; - using Item = typename Span::Item; - - return [wellIdx, this]() -> typename ParallelWBPCalculation::Evaluator - { - if (! this->wbpCalcMap_[wellIdx].openWellIdx_.has_value()) { - // Well is stopped/shut. Return evaluator for stopped wells. - return []([[maybe_unused]] const int connIdx, Span sourceTerm) - { - // Well/connection is stopped/shut. Set all items to - // zero. - - sourceTerm - .set(Item::Pressure , 0.0) - .set(Item::PoreVol , 0.0) - .set(Item::MixtureDensity, 0.0) - .set(Item::Depth , 0.0) - ; - }; - } - - // Well is open. Return an evaluator for open wells/open connections. - return [this, wellPtr = this->well_container_[*this->wbpCalcMap_[wellIdx].openWellIdx_].get()] - (const int connIdx, Span sourceTerm) - { - // Note: The only item which actually matters for the WBP - // calculation at the well reservoir connection level is the - // mixture density. Set other items to zero. - - const auto& connIdxMap = - this->conn_idx_map_[wellPtr->indexOfWell()]; - - const auto rho = wellPtr-> - connectionDensity(connIdxMap.global(connIdx), - connIdxMap.open(connIdx)); - - sourceTerm - .set(Item::Pressure , 0.0) - .set(Item::PoreVol , 0.0) - .set(Item::MixtureDensity, rho) - .set(Item::Depth , 0.0) - ; - }; - }; - } - - - - - template void BlackoilWellModel::