diff --git a/opm/simulators/wells/MultisegmentWellAssemble.cpp b/opm/simulators/wells/MultisegmentWellAssemble.cpp index 827aa1e0b..f6a7c7254 100644 --- a/opm/simulators/wells/MultisegmentWellAssemble.cpp +++ b/opm/simulators/wells/MultisegmentWellAssemble.cpp @@ -242,6 +242,26 @@ assembleOutflowTerm(const int seg, // pressure derivative should be zero } +template +void MultisegmentWellAssemble:: +assembleInflowTerm(const int seg, + const int inlet, + const int inlet_upwind, + const int comp_idx, + const EvalWell& inlet_rate, + Equations& eqns) const + { + eqns.resWell_[seg][comp_idx] += inlet_rate.value(); + eqns.duneD_[seg][inlet][comp_idx][WQTotal] += inlet_rate.derivative(WQTotal + Indices::numEq); + if (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)) { + eqns.duneD_[seg][inlet_upwind][comp_idx][WFrac] += inlet_rate.derivative(WFrac + Indices::numEq); + } + if (FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx)) { + eqns.duneD_[seg][inlet_upwind][comp_idx][GFrac] += inlet_rate.derivative(GFrac + Indices::numEq); + } + // pressure derivative should be zero +} + #define INSTANCE(...) \ template class MultisegmentWellAssemble,__VA_ARGS__,double>; diff --git a/opm/simulators/wells/MultisegmentWellAssemble.hpp b/opm/simulators/wells/MultisegmentWellAssemble.hpp index 6eb246d44..43e768614 100644 --- a/opm/simulators/wells/MultisegmentWellAssemble.hpp +++ b/opm/simulators/wells/MultisegmentWellAssemble.hpp @@ -116,6 +116,14 @@ public: const EvalWell& segment_rate, Equations& eqns1) const; + //! \brief Assemble inflow term. + void assembleInflowTerm(const int seg, + const int inlet, + const int inlet_upwind, + const int comp_idx, + const EvalWell& inlet_rate, + Equations& eqns) const; + private: const WellInterfaceIndices& well_; //!< Reference to well }; diff --git a/opm/simulators/wells/MultisegmentWell_impl.hpp b/opm/simulators/wells/MultisegmentWell_impl.hpp index 480fbcc43..9e1e3f97a 100644 --- a/opm/simulators/wells/MultisegmentWell_impl.hpp +++ b/opm/simulators/wells/MultisegmentWell_impl.hpp @@ -1583,19 +1583,9 @@ namespace Opm for (const int inlet : this->segment_inlets_[seg]) { for (int comp_idx = 0; comp_idx < this->num_components_; ++comp_idx) { const EvalWell inlet_rate = this->getSegmentRateUpwinding(inlet, comp_idx) * this->well_efficiency_factor_; - const int inlet_upwind = this->upwinding_segments_[inlet]; - // inlet_rate contains the derivatives with respect to WQTotal in inlet, - // and WFrac and GFrac in inlet_upwind - this->linSys_.resWell_[seg][comp_idx] += inlet_rate.value(); - this->linSys_.duneD_[seg][inlet][comp_idx][WQTotal] += inlet_rate.derivative(WQTotal + Indices::numEq); - if (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)) { - this->linSys_.duneD_[seg][inlet_upwind][comp_idx][WFrac] += inlet_rate.derivative(WFrac + Indices::numEq); - } - if (FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx)) { - this->linSys_.duneD_[seg][inlet_upwind][comp_idx][GFrac] += inlet_rate.derivative(GFrac + Indices::numEq); - } - // pressure derivative should be zero + MultisegmentWellAssemble(*this). + assembleInflowTerm(seg, inlet, inlet_upwind, comp_idx, inlet_rate, this->linSys_); } } }