aboutsummaryrefslogtreecommitdiff
path: root/ell_grid_solve.c
diff options
context:
space:
mode:
Diffstat (limited to 'ell_grid_solve.c')
-rw-r--r--ell_grid_solve.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/ell_grid_solve.c b/ell_grid_solve.c
index 6f1a029..5047718 100644
--- a/ell_grid_solve.c
+++ b/ell_grid_solve.c
@@ -152,12 +152,18 @@ static void residual_calc(EGSContext *ctx, int export_res)
{
EGSInternal *priv = ctx->priv;
const double *diff_coeffs[MG2D_DIFF_COEFF_NB];
+ int reflect_flags = 0;
mg2di_timer_start(&ctx->timer_res_calc);
for (int i = 0; i < ARRAY_ELEMS(diff_coeffs); i++)
diff_coeffs[i] = NDPTR2D(priv->diff_coeffs[i], priv->residual_calc_offset[1], priv->residual_calc_offset[0]);
+ for (int bnd_idx = 0; bnd_idx < 4; bnd_idx++)
+ if (ctx->boundaries[bnd_idx]->type == MG2D_BC_TYPE_REFLECT &&
+ priv->dg->components[priv->local_component].bnd_is_outer[bnd_idx])
+ reflect_flags |= 1 << bnd_idx;
+
mg2di_residual_calc(priv->rescalc, priv->residual_calc_size, &ctx->residual_max,
NDPTR2D(export_res ? ctx->residual : priv->u_next, priv->residual_calc_offset[1], priv->residual_calc_offset[0]),
export_res ? ctx->residual->stride[0] : priv->u_next->stride[0],
@@ -167,18 +173,14 @@ static void residual_calc(EGSContext *ctx, int export_res)
ctx->rhs->stride[0],
diff_coeffs, priv->diff_coeffs[0]->stride[0],
export_res ? 0.0 : 1.0, export_res ? 1.0 : priv->r.relax_factor,
- export_res ? 0 :
- ((ctx->boundaries[MG2D_BOUNDARY_0L]->type == MG2D_BC_TYPE_REFLECT) << 0) |
- ((ctx->boundaries[MG2D_BOUNDARY_0U]->type == MG2D_BC_TYPE_REFLECT) << 1) |
- ((ctx->boundaries[MG2D_BOUNDARY_1L]->type == MG2D_BC_TYPE_REFLECT) << 2));
+ reflect_flags, FD_STENCIL_MAX);
mg2di_timer_stop(&ctx->timer_res_calc);
- if (!export_res) {
- priv->reflect_disable[MG2D_BOUNDARY_0L] = 1;
- priv->reflect_disable[MG2D_BOUNDARY_0U] = 1;
- priv->reflect_disable[MG2D_BOUNDARY_1L] = 1;
- }
+ priv->reflect_disable[MG2D_BOUNDARY_0L] = 1;
+ priv->reflect_disable[MG2D_BOUNDARY_0U] = 1;
+ priv->reflect_disable[MG2D_BOUNDARY_1L] = 1;
+ priv->reflect_disable[MG2D_BOUNDARY_1U] = 1;
}
static void boundaries_apply_fixval(double *dst, const ptrdiff_t dst_stride[2],