From 2c20bb6cde6870fd508b92b420bd8c51b9f1bca2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Thu, 21 Jul 2016 15:28:51 +0200 Subject: [PATCH] Bugfix: take absolute value of residuals for comparison. Also tighten hardcoded tolerance for testing, and update a comment. --- .../BlackoilReorderingTransportModel.hpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/opm/autodiff/BlackoilReorderingTransportModel.hpp b/opm/autodiff/BlackoilReorderingTransportModel.hpp index 69db4071d..08cace767 100644 --- a/opm/autodiff/BlackoilReorderingTransportModel.hpp +++ b/opm/autodiff/BlackoilReorderingTransportModel.hpp @@ -685,10 +685,11 @@ namespace Opm { const int other = from == cell ? to : from; const double vt = (from == cell) ? total_flux_[conn.index] : -total_flux_[conn.index]; - // From this point, we treat everything about this connection as going - // from 'cell' to 'other'. Since we don't want derivatives from the 'other' - // cell to participate in the solution, we must be careful to use .value - // to avoid creating trouble. + // From this point, we treat everything about this + // connection as going from 'cell' to 'other'. Since + // we don't want derivatives from the 'other' cell to + // participate in the solution, we use the constant + // values from cstate_[other]. Eval dh[3]; Eval dh_sat[3]; for (int phase : { Water, Oil, Gas }) { @@ -707,6 +708,9 @@ namespace Opm { {{ m1[Water].value, m1[Oil].value, m1[Gas].value }}, {{ m2[Water], m2[Oil], m2[Gas] }}, tran, vt); + if (upw[0] != upw[1] || upw[1] != upw[2]) { + OpmLog::debug("Detected countercurrent flow between cells " + std::to_string(from) + " and " + std::to_string(to)); + } Eval b[3]; Eval mob[3]; Eval tot_mob = Eval::createConstant(0.0); @@ -749,8 +753,8 @@ namespace Opm { bool getConvergence(const Vec2& res) { - const double tol = 1e-6; - return res[0] < tol && res[1] < tol; + const double tol = 1e-9; + return std::fabs(res[0]) < tol && std::fabs(res[1] < tol); }