From d8a7165ccb82b9646e820010f5f1f5be341b38aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Thu, 14 Aug 2014 14:19:55 +0200 Subject: [PATCH 1/3] Throw if elliptic solve fails. --- opm/autodiff/CPRPreconditioner.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/opm/autodiff/CPRPreconditioner.hpp b/opm/autodiff/CPRPreconditioner.hpp index 327920c72..f55876761 100644 --- a/opm/autodiff/CPRPreconditioner.hpp +++ b/opm/autodiff/CPRPreconditioner.hpp @@ -37,6 +37,7 @@ #include "reenable_warning_pragmas.h" +#include namespace Opm { @@ -161,8 +162,8 @@ namespace Opm // Solve system. Dune::InverseOperatorResult result; linsolve.apply(x, de, result); - if (result.converged) { - // std::cout << "solveElliptic() successful!" << std::endl; + if (!result.converged) { + OPM_THROW(std::runtime_error, "CPRPreconditioner failed to solve elliptic subsystem."); } return x; } From cb2522314d57435407e067fec1377219140a2193 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Thu, 14 Aug 2014 14:20:43 +0200 Subject: [PATCH 2/3] Improve exception message, add (disabled) debugging helpers. --- opm/autodiff/FullyImplicitBlackoilSolver_impl.hpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/opm/autodiff/FullyImplicitBlackoilSolver_impl.hpp b/opm/autodiff/FullyImplicitBlackoilSolver_impl.hpp index 5a204de3b..1fd26d101 100644 --- a/opm/autodiff/FullyImplicitBlackoilSolver_impl.hpp +++ b/opm/autodiff/FullyImplicitBlackoilSolver_impl.hpp @@ -642,6 +642,15 @@ namespace { // Create the primary variables. SolutionState state = variableState(x, xw); + // DISKVAL(state.pressure); + // DISKVAL(state.saturation[0]); + // DISKVAL(state.saturation[1]); + // DISKVAL(state.saturation[2]); + // DISKVAL(state.rs); + // DISKVAL(state.rv); + // DISKVAL(state.qs); + // DISKVAL(state.bhp); + // -------- Mass balance equations -------- // Compute b_p and the accumulation term b_p*s_p for each phase, @@ -1563,8 +1572,10 @@ namespace { for (; quantityIt != endQuantityIt; ++quantityIt) { const double quantityResid = (*quantityIt).value().matrix().norm(); if (!std::isfinite(quantityResid)) { + const int trouble_phase = quantityIt - residual_.material_balance_eq.begin(); OPM_THROW(Opm::NumericalProblem, - "Encountered a non-finite residual"); + "Encountered a non-finite residual in material balance equation " + << trouble_phase); } globalNorm = std::max(globalNorm, quantityResid); } From 69697adb047d2b96e8ca718e7855cdea0e7282c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Thu, 14 Aug 2014 14:21:33 +0200 Subject: [PATCH 3/3] Fix saturation-change bug in updateState(). --- opm/autodiff/FullyImplicitBlackoilSolver_impl.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opm/autodiff/FullyImplicitBlackoilSolver_impl.hpp b/opm/autodiff/FullyImplicitBlackoilSolver_impl.hpp index 1fd26d101..e106cc7bf 100644 --- a/opm/autodiff/FullyImplicitBlackoilSolver_impl.hpp +++ b/opm/autodiff/FullyImplicitBlackoilSolver_impl.hpp @@ -1354,7 +1354,7 @@ namespace { for (int c = 0; c < nc; ++c) { if (ixw[c]) { so[c] = so[c] / (1-sw[c]); - sg[c] = sg[c] / (1-so[c]); + sg[c] = sg[c] / (1-sw[c]); sw[c] = 0; } }