From 92f20c60403bd6957d4a0b25d1fbd8f872fc1834 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Thu, 17 Jul 2014 14:34:07 +0200 Subject: [PATCH] Update phase condition vector from primary variables. This is necessary as an interim measure, since the phase condition vectors are still used in property calculations. --- opm/autodiff/FullyImplicitBlackoilSolver.hpp | 4 ++ .../FullyImplicitBlackoilSolver_impl.hpp | 38 +++++++++++++++++-- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/opm/autodiff/FullyImplicitBlackoilSolver.hpp b/opm/autodiff/FullyImplicitBlackoilSolver.hpp index 381204b64..f5ee0e3b9 100644 --- a/opm/autodiff/FullyImplicitBlackoilSolver.hpp +++ b/opm/autodiff/FullyImplicitBlackoilSolver.hpp @@ -291,6 +291,10 @@ namespace Opm { void updatePrimalVariableFromState(const BlackoilState& state); + /// Update the phaseCondition_ member based on the primalVariable_ member. + void + updatePhaseCondFromPrimalVariable(); + /// Compute convergence based on total mass balance (tol_mb) and maximum /// residual mass balance (tol_cnv). bool getConvergence(const double dt); diff --git a/opm/autodiff/FullyImplicitBlackoilSolver_impl.hpp b/opm/autodiff/FullyImplicitBlackoilSolver_impl.hpp index 88c03bb7a..af8bc092a 100644 --- a/opm/autodiff/FullyImplicitBlackoilSolver_impl.hpp +++ b/opm/autodiff/FullyImplicitBlackoilSolver_impl.hpp @@ -1330,9 +1330,6 @@ namespace { const V rsSat0 = fluidRsSat(p_old, cells_); const V rsSat = fluidRsSat(p, cells_); - // reset the phase conditions - std::vector cond(nc); - std::fill(primalVariable_.begin(), primalVariable_.end(), PrimalVariables::Sg); if (has_disgas_) { @@ -1448,6 +1445,8 @@ namespace { const V bhp = bhp_old - dbhp_limited; std::copy(&bhp[0], &bhp[0] + bhp.size(), well_state.bhp().begin()); + // Update phase conditions used for property calculations. + updatePhaseCondFromPrimalVariable(); } @@ -2115,9 +2114,40 @@ namespace { if (so[c] <= 0 && sg[c] > 0) {primalVariable_[c] = PrimalVariables::RV; } } } - + updatePhaseCondFromPrimalVariable(); } + + + /// Update the phaseCondition_ member based on the primalVariable_ member. + template + void + FullyImplicitBlackoilSolver::updatePhaseCondFromPrimalVariable() + { + const int nc = primalVariable_.size(); + for (int c = 0; c < nc; ++c) { + phaseCondition_[c] = PhasePresence(); // No free phases. + phaseCondition_[c].setFreeWater(); // Not necessary for property calculation usage. + switch (primalVariable_[c]) { + case PrimalVariables::Sg: + phaseCondition_[c].setFreeOil(); + phaseCondition_[c].setFreeGas(); + break; + case PrimalVariables::RS: + phaseCondition_[c].setFreeOil(); + break; + case PrimalVariables::RV: + phaseCondition_[c].setFreeGas(); + break; + default: + OPM_THROW(std::logic_error, "Unknown primary variable enum value in cell " << c << ": " << primalVariable_[c]); + } + } + } + + + + } // namespace Opm