aboutsummaryrefslogtreecommitdiff
path: root/mg2d.c
diff options
context:
space:
mode:
Diffstat (limited to 'mg2d.c')
-rw-r--r--mg2d.c20
1 files changed, 4 insertions, 16 deletions
diff --git a/mg2d.c b/mg2d.c
index 853e9ab..5560681 100644
--- a/mg2d.c
+++ b/mg2d.c
@@ -227,18 +227,6 @@ static int mg_prolong_u(MG2DContext *ctx, MG2DLevel *l)
return 0;
}
-static double mg_resmax_get(MG2DLevel *l)
-{
- double ret = l->solver->residual_max;
-
- if (l->dg->nb_components > 1) {
- MPI_Allreduce(MPI_IN_PLACE, &ret, 1,
- MPI_DOUBLE, MPI_MAX, l->mpi_comm);
- }
-
- return ret;
-}
-
static int mg_solve_subgrid(MG2DContext *ctx, MG2DLevel *level, int allow_exact)
{
enum EGSType solve_type = (allow_exact && level->dg->nb_components == 1 &&
@@ -263,7 +251,7 @@ static int mg_solve_subgrid(MG2DContext *ctx, MG2DLevel *level, int allow_exact)
level->egs_init_flags |= EGS_INIT_FLAG_SAME_DIFF_COEFFS;
}
- res_old = mg_resmax_get(level);
+ res_old = level->solver->residual_max;
/* handle exact solve */
if (solve_type == EGS_SOLVE_EXACT) {
@@ -334,7 +322,7 @@ static int mg_solve_subgrid(MG2DContext *ctx, MG2DLevel *level, int allow_exact)
}
finish:
- res_new = mg_resmax_get(level);
+ res_new = level->solver->residual_max;
if (!isfinite(res_new) ||
(res_new > 1e2 * ctx->tol && res_old / res_new <= 1e-1)) {
mg2di_log(&ctx->priv->logger, MG2D_LOG_ERROR,
@@ -1131,7 +1119,7 @@ int mg2d_solve(MG2DContext *ctx)
root->egs_init_flags |= EGS_INIT_FLAG_SAME_DIFF_COEFFS;
- res_orig = mg_resmax_get(root);
+ res_orig = s_root->residual_max;
res_prev = res_orig;
for (int i = 0; i < ctx->maxiter; i++) {
@@ -1139,7 +1127,7 @@ int mg2d_solve(MG2DContext *ctx)
if (ret < 0)
goto fail;
- res_cur = mg_resmax_get(root);
+ res_cur = s_root->residual_max;
if (res_cur < ctx->tol) {
mg2di_log(&priv->logger, MG2D_LOG_INFO, "converged on iteration %d, residual %g\n",