aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2019-06-21 12:07:25 +0200
committerAnton Khirnov <anton@khirnov.net>2019-07-06 11:18:54 +0200
commitc53cab55049cf667c29a6b4cb7a3b3842a07f04c (patch)
treebaa1194f799596b9761f2bf25ae61bf72a06a892
parent4f33b227486b40b68c7e5f9ed8fc9015277457bc (diff)
mg2d: calculate the cfl from continuous diff coeffs
-rw-r--r--mg2d.c38
1 files 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)