From c53cab55049cf667c29a6b4cb7a3b3842a07f04c Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Fri, 21 Jun 2019 12:07:25 +0200 Subject: mg2d: calculate the cfl from continuous diff coeffs --- mg2d.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/mg2d.c b/mg2d.c index 01a6853..e0a83ed 100644 --- a/mg2d.c +++ b/mg2d.c @@ -778,21 +778,6 @@ static int mg_levels_init(MG2DContext *ctx) double diff0_max, diff2_max, tmp; int ret; - diff0_max = findmax(ctx->diff_coeffs[MG2D_DIFF_COEFF_00]->data, priv->root->solver->domain_size, - ctx->diff_coeffs[MG2D_DIFF_COEFF_00]->stride); - diff2_max = findmax(ctx->diff_coeffs[MG2D_DIFF_COEFF_20]->data, priv->root->solver->domain_size, - ctx->diff_coeffs[MG2D_DIFF_COEFF_20]->stride); - tmp = findmax(ctx->diff_coeffs[MG2D_DIFF_COEFF_02]->data, priv->root->solver->domain_size, - ctx->diff_coeffs[MG2D_DIFF_COEFF_02]->stride); - diff2_max = MAX(diff2_max, tmp); - - if (priv->dg->nb_components > 1) { - MPI_Allreduce(MPI_IN_PLACE, &diff0_max, 1, - MPI_DOUBLE, MPI_MAX, priv->mpi_comm); - MPI_Allreduce(MPI_IN_PLACE, &diff2_max, 1, - MPI_DOUBLE, MPI_MAX, priv->mpi_comm); - } - cur = priv->root; prev = NULL; @@ -854,10 +839,6 @@ static int mg_levels_init(MG2DContext *ctx) cur->solver->fd_stencil = ctx->fd_stencil; - cur->solver->relax->relax_factor = ctx->cfl_factor; - cur->solver->relax->relax_multiplier = 1.0 / (diff2_max + cur->solver->step[0] * cur->solver->step[1] * - diff0_max / 8.0); - prev = cur; cur = cur->child; } @@ -902,8 +883,27 @@ static int mg_levels_init(MG2DContext *ctx) cur = cur->child; } + diff0_max = findmax(priv->diff_coeffs_tmp[MG2D_DIFF_COEFF_00]->data, priv->root->solver->domain_size, + ctx->diff_coeffs[MG2D_DIFF_COEFF_00]->stride); + diff2_max = findmax(priv->diff_coeffs_tmp[MG2D_DIFF_COEFF_20]->data, priv->root->solver->domain_size, + ctx->diff_coeffs[MG2D_DIFF_COEFF_20]->stride); + tmp = findmax(priv->diff_coeffs_tmp[MG2D_DIFF_COEFF_02]->data, priv->root->solver->domain_size, + ctx->diff_coeffs[MG2D_DIFF_COEFF_02]->stride); + diff2_max = MAX(diff2_max, tmp); + + if (priv->dg->nb_components > 1) { + MPI_Allreduce(MPI_IN_PLACE, &diff0_max, 1, + MPI_DOUBLE, MPI_MAX, priv->mpi_comm); + MPI_Allreduce(MPI_IN_PLACE, &diff2_max, 1, + MPI_DOUBLE, MPI_MAX, priv->mpi_comm); + } + cur = priv->root; while (cur) { + cur->solver->relax->relax_factor = ctx->cfl_factor; + cur->solver->relax->relax_multiplier = 1.0 / (diff2_max + cur->solver->step[0] * cur->solver->step[1] * + diff0_max / 8.0); + if (cur->depth > 0) { ret = diff_coeffs_fixup(ctx, cur); if (ret < 0) -- cgit v1.2.3