aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2020-01-20 15:46:53 +0100
committerAnton Khirnov <anton@khirnov.net>2020-01-20 15:46:53 +0100
commite6c975d48f918856396ce4ae6824b9c387930f3f (patch)
treedbc7ff1d0f3e329090cbe5e81f0ec2a76152243b
parent7f88b344adb92434814c82c839a513fc1ccf3b11 (diff)
mg2d: export the residual norm to the caller
-rw-r--r--mg2d.c1
-rw-r--r--mg2d.h10
2 files changed, 10 insertions, 1 deletions
diff --git a/mg2d.c b/mg2d.c
index b669569..95bd1ee 100644
--- a/mg2d.c
+++ b/mg2d.c
@@ -1155,6 +1155,7 @@ int mg2d_solve(MG2DContext *ctx)
fail:
mg2di_log(&priv->logger, MG2D_LOG_ERROR, "The solver failed to converge\n");
finish:
+ ctx->residual_max = s_root->residual_max;
mg2di_timer_stop(&priv->timer_solve);
return ret;
}
diff --git a/mg2d.h b/mg2d.h
index 01698a8..8f48361 100644
--- a/mg2d.h
+++ b/mg2d.h
@@ -239,6 +239,13 @@ typedef struct MG2DContext {
* Set by mg2d_solver_alloc[_mpi]().
*/
size_t local_size[2];
+
+ /**
+ * Maximum of the absolute value of the residual.
+ *
+ * Set by mg2d_solve() if it returns 0 or MG2D_ERR_MAXITER_REACHED.
+ */
+ double residual_max;
} MG2DContext;
/**
@@ -271,7 +278,8 @@ MG2DContext *mg2d_solver_alloc_mpi(MPI_Comm comm, const size_t local_start[2],
* - 0 on success
* - MG2D_ERR_MAXITER_REACHED if desired tolerance was not reached after
* maximum allowed number of iterations were performed. The final
- * value of the solution is still exported in ctx->u.
+ * value of the solution is still exported in ctx->u, ctx->residual_max is
+ * set to the final residual norm.
* - MG2D_ERR_DIVERGE if the iteration process has diverged.
* - another negative error code on other types of failure
*/