From 80f3c9d24dd61204a66a9d099c4b74fb818d6daf Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Tue, 22 Jan 2013 20:28:34 +0000 Subject: [PATCH] [1D] Fixed a case where the Newton solver could get stuck Sometimes, while trying to solve the steady-state problem, the Newton solver would get stuck in a loop where it couldn't find a suitable damping ratio even after re-revaluating the Jacobian, causing it to get stuck in an loop where it would keep re-evaluating the Jacobian at the same point (i.e. without having made a successful damped step). This change detects this condition and stops the Newton solver so that the 1D solver can advance the solution by timestepping before trying to solve the steady-state problem again. --- src/oneD/MultiNewton.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/oneD/MultiNewton.cpp b/src/oneD/MultiNewton.cpp index b40ce8185..83fec909c 100644 --- a/src/oneD/MultiNewton.cpp +++ b/src/oneD/MultiNewton.cpp @@ -312,6 +312,7 @@ int MultiNewton::solve(doublereal* x0, doublereal* x1, bool frst = true; doublereal rdt = r.rdt(); int j0 = jac.nEvals(); + int nJacReeval = 0; while (1 > 0) { @@ -370,6 +371,10 @@ int MultiNewton::solve(doublereal* x0, doublereal* x1, else if (m < 0) { if (jac.age() > 1) { forceNewJac = true; + if (nJacReeval > 3) { + goto done; + } + nJacReeval++; if (loglevel > 0) writelog("\nRe-evaluating Jacobian, since no damping " "coefficient\ncould be found with this Jacobian.\n");