From 91c352d4ca45042055ee0205f46e815b6e89a631 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 29 Jan 2019 12:54:06 +0100 Subject: mg2d: fail when a full multigrid iteration does not reduce the residual --- mg2d.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'mg2d.c') diff --git a/mg2d.c b/mg2d.c index 902c3cc..a65af6c 100644 --- a/mg2d.c +++ b/mg2d.c @@ -527,6 +527,11 @@ int mg2d_solve(MG2DContext *ctx) mg2di_log(&priv->logger, MG2D_LOG_VERBOSE, "finished toplevel iteration %d, residual %g -> %g (%g)\n", i, res_prev, res_cur, res_prev / res_cur); + if (res_cur / res_prev > 1.0) { + mg2di_log(&priv->logger, MG2D_LOG_ERROR, "A multigrid iteration diverged\n"); + ret = MG2D_ERR_DIVERGE; + goto fail; + } res_prev = res_cur; } -- cgit v1.2.3