diff --git a/opm/simulators/wells/MultisegmentWell.hpp b/opm/simulators/wells/MultisegmentWell.hpp index fede996ef..bad732123 100644 --- a/opm/simulators/wells/MultisegmentWell.hpp +++ b/opm/simulators/wells/MultisegmentWell.hpp @@ -59,15 +59,15 @@ namespace Opm // TODO: we need to have order for the primary variables and also the order for the well equations. // sometimes, they are similar, while sometimes, they can have very different forms. - // TODO: the following system looks not rather flexible. Looking into all kinds of possibilities - static const bool gasoil = numEq == 2 && (Indices::compositionSwitchIdx >= 0); - static const int GTotal = 0; - static const int WFrac = gasoil? -1000: 1; - //For oilwater system the GFrac is set to 2 (the same as SPres) but it is never used - static const int GFrac = gasoil? 1 : 2; - static const int SPres = numEq; + static const bool has_gas = (Indices::compositionSwitchIdx >= 0); + static const bool has_water = (Indices::waterSaturationIdx >= 0); - /// the number of well equations // TODO: it should have a more general strategy for it + static const int GTotal = 0; + static const int WFrac = has_water? 1: -1000; + static const int GFrac = has_gas? has_water + 1 : -1000; + static const int SPres = has_gas + has_water + 1; + + // the number of well equations TODO: it should have a more general strategy for it static const int numWellEq = getPropValue() ? numEq : numEq + 1; using typename Base::Scalar; diff --git a/opm/simulators/wells/MultisegmentWell_impl.hpp b/opm/simulators/wells/MultisegmentWell_impl.hpp index bd85e24ff..47b4dc322 100644 --- a/opm/simulators/wells/MultisegmentWell_impl.hpp +++ b/opm/simulators/wells/MultisegmentWell_impl.hpp @@ -2180,7 +2180,7 @@ namespace Opm resWell_[seg][SPres] -= accelerationPressureLoss.value(); duneD_[seg][seg][SPres][SPres] -= accelerationPressureLoss.derivative(SPres + numEq); duneD_[seg][seg][SPres][GTotal] -= accelerationPressureLoss.derivative(GTotal + numEq); - if (FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx)) { + if (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)) { duneD_[seg][seg_upwind][SPres][WFrac] -= accelerationPressureLoss.derivative(WFrac + numEq); } if (FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx)) {