diff --git a/opm/autodiff/BlackoilModelBase.hpp b/opm/autodiff/BlackoilModelBase.hpp index 0e8784a81..f9cf5d8fb 100644 --- a/opm/autodiff/BlackoilModelBase.hpp +++ b/opm/autodiff/BlackoilModelBase.hpp @@ -397,11 +397,6 @@ namespace Opm { SolutionState& state, WellState& well_state); - void - updatePerfPhaseRatesAndPressures(const std::vector& cq_s, - const SolutionState& state, - WellState& xw) const; - void addWellFluxEq(const std::vector& cq_s, const SolutionState& state); diff --git a/opm/autodiff/BlackoilModelBase_impl.hpp b/opm/autodiff/BlackoilModelBase_impl.hpp index 079475ee0..ae9dca1cd 100644 --- a/opm/autodiff/BlackoilModelBase_impl.hpp +++ b/opm/autodiff/BlackoilModelBase_impl.hpp @@ -859,7 +859,7 @@ namespace detail { V aliveWells; std::vector cq_s; asImpl().stdWells().computeWellFlux(state, fluid_.phaseUsage(), active_, mob_perfcells, b_perfcells, aliveWells, cq_s); - asImpl().updatePerfPhaseRatesAndPressures(cq_s, state, well_state); + asImpl().stdWells().updatePerfPhaseRatesAndPressures(cq_s, state, well_state); asImpl().addWellFluxEq(cq_s, state); asImpl().addWellContributionToMassBalanceEq(cq_s, state, well_state); asImpl().addWellControlEq(state, well_state, aliveWells); @@ -1024,38 +1024,6 @@ namespace detail { - template - void BlackoilModelBase::updatePerfPhaseRatesAndPressures(const std::vector& cq_s, - const SolutionState& state, - WellState& xw) const - { - if ( !asImpl().localWellsActive() ) - { - // If there are no wells in the subdomain of the proces then - // cq_s has zero size and will cause a segmentation fault below. - return; - } - - // Update the perforation phase rates (used to calculate the pressure drop in the wellbore). - const int np = wells().number_of_phases; - const int nw = wells().number_of_wells; - const int nperf = wells().well_connpos[nw]; - V cq = superset(cq_s[0].value(), Span(nperf, np, 0), nperf*np); - for (int phase = 1; phase < np; ++phase) { - cq += superset(cq_s[phase].value(), Span(nperf, np, phase), nperf*np); - } - xw.perfPhaseRates().assign(cq.data(), cq.data() + nperf*np); - - // Update the perforation pressures. - const V& cdp = asImpl().stdWells().wellPerforationPressureDiffs(); - const V perfpressure = (stdWells().wellOps().w2p * state.bhp.value().matrix()).array() + cdp; - xw.perfPress().assign(perfpressure.data(), perfpressure.data() + nperf); - } - - - - - template void BlackoilModelBase::addWellFluxEq(const std::vector& cq_s, const SolutionState& state) @@ -1436,7 +1404,7 @@ namespace detail { SolutionState wellSolutionState = state0; asImpl().variableStateExtractWellsVars(indices, vars, wellSolutionState); asImpl().stdWells().computeWellFlux(wellSolutionState, fluid_.phaseUsage(), active_, mob_perfcells_const, b_perfcells_const, aliveWells, cq_s); - asImpl().updatePerfPhaseRatesAndPressures(cq_s, wellSolutionState, well_state); + asImpl().stdWells().updatePerfPhaseRatesAndPressures(cq_s, wellSolutionState, well_state); asImpl().addWellFluxEq(cq_s, wellSolutionState); asImpl().addWellControlEq(wellSolutionState, well_state, aliveWells); converged = getWellConvergence(it); diff --git a/opm/autodiff/StandardWells.hpp b/opm/autodiff/StandardWells.hpp index 632ed183d..005cd2fe3 100644 --- a/opm/autodiff/StandardWells.hpp +++ b/opm/autodiff/StandardWells.hpp @@ -116,6 +116,11 @@ namespace Opm { Vector& aliveWells, std::vector& cq_s) const; + template + void updatePerfPhaseRatesAndPressures(const std::vector& cq_s, + const SolutionState& state, + WellState& xw) const; + protected: diff --git a/opm/autodiff/StandardWells_impl.hpp b/opm/autodiff/StandardWells_impl.hpp index c154bf130..1794478a3 100644 --- a/opm/autodiff/StandardWells_impl.hpp +++ b/opm/autodiff/StandardWells_impl.hpp @@ -464,4 +464,38 @@ namespace Opm } } + + + + + template + void + StandardWells:: + updatePerfPhaseRatesAndPressures(const std::vector& cq_s, + const SolutionState& state, + WellState& xw) const + { + if ( !localWellsActive() ) + { + // If there are no wells in the subdomain of the proces then + // cq_s has zero size and will cause a segmentation fault below. + return; + } + + // Update the perforation phase rates (used to calculate the pressure drop in the wellbore). + const int np = wells().number_of_phases; + const int nw = wells().number_of_wells; + const int nperf = wells().well_connpos[nw]; + Vector cq = superset(cq_s[0].value(), Span(nperf, np, 0), nperf*np); + for (int phase = 1; phase < np; ++phase) { + cq += superset(cq_s[phase].value(), Span(nperf, np, phase), nperf*np); + } + xw.perfPhaseRates().assign(cq.data(), cq.data() + nperf*np); + + // Update the perforation pressures. + const Vector& cdp = wellPerforationPressureDiffs(); + const Vector perfpressure = (wellOps().w2p * state.bhp.value().matrix()).array() + cdp; + xw.perfPress().assign(perfpressure.data(), perfpressure.data() + nperf); + } + } diff --git a/opm/polymer/fullyimplicit/BlackoilPolymerModel_impl.hpp b/opm/polymer/fullyimplicit/BlackoilPolymerModel_impl.hpp index 53a81315e..03c1b47ee 100644 --- a/opm/polymer/fullyimplicit/BlackoilPolymerModel_impl.hpp +++ b/opm/polymer/fullyimplicit/BlackoilPolymerModel_impl.hpp @@ -570,7 +570,7 @@ namespace Opm { } stdWells().computeWellFlux(state, fluid_.phaseUsage(), active_, mob_perfcells, b_perfcells, aliveWells, cq_s); - Base::updatePerfPhaseRatesAndPressures(cq_s, state, well_state); + stdWells().updatePerfPhaseRatesAndPressures(cq_s, state, well_state); Base::addWellFluxEq(cq_s, state); addWellContributionToMassBalanceEq(cq_s, state, well_state); addWellControlEq(state, well_state, aliveWells);