From 024fe9c7b633f0407904e2978397d22cfef22ce9 Mon Sep 17 00:00:00 2001 From: Tor Harald Sandve Date: Wed, 3 Sep 2014 09:59:04 +0200 Subject: [PATCH] Apply threshold pressure for all dp The threshold pressure is applied for all dp. The sign of the threshold pressure is given by the sign of the dp. --- opm/autodiff/FullyImplicitBlackoilSolver_impl.hpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/opm/autodiff/FullyImplicitBlackoilSolver_impl.hpp b/opm/autodiff/FullyImplicitBlackoilSolver_impl.hpp index 94a678b80..45e04b496 100644 --- a/opm/autodiff/FullyImplicitBlackoilSolver_impl.hpp +++ b/opm/autodiff/FullyImplicitBlackoilSolver_impl.hpp @@ -1642,13 +1642,12 @@ namespace { // Create a sparse vector that nullifies the low potential elements. const M keep_high_potential = spdiag(high_potential); - // The threshold modification must have the sign that reduces the - // absolute value of the potential. - const V sign_for_mod = (dp.value() < 0).template cast(); - const V threshold_modification = sign_for_mod * threshold_pressures_by_interior_face_; + // Find the current sign for the threshold modification + const V sign_dp = sign(dp.value()); + const V threshold_modification = sign_dp * threshold_pressures_by_interior_face_; // Modify potential and nullify where appropriate. - dp = keep_high_potential * (dp + threshold_modification); + dp = keep_high_potential * (dp - threshold_modification); }