aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mg2d.c5
1 files changed, 5 insertions, 0 deletions
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;
}