aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2019-06-14 15:52:32 +0200
committerAnton Khirnov <anton@khirnov.net>2019-06-14 16:10:14 +0200
commit3d02e1b61d6aa3e2c4c9be4e0f55dd7d2046dabb (patch)
tree1ffdbe99579020dce05f50b50abe0a5d0fc29b79
parenta1f10a1338e77dd147e7c94f3f401d2703181bca (diff)
egs: simplify reflection boundary handling
-rw-r--r--ell_grid_solve.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/ell_grid_solve.c b/ell_grid_solve.c
index 5047718..57f6340 100644
--- a/ell_grid_solve.c
+++ b/ell_grid_solve.c
@@ -95,7 +95,7 @@ struct EGSInternal {
size_t residual_calc_size[2];
int bnd_zero[4];
- int reflect_disable[4];
+ int reflect_skip;
ResidualCalcContext *rescalc;
@@ -177,10 +177,7 @@ static void residual_calc(EGSContext *ctx, int export_res)
mg2di_timer_stop(&ctx->timer_res_calc);
- 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;
+ priv->reflect_skip = ~0;
}
static void boundaries_apply_fixval(double *dst, const ptrdiff_t dst_stride[2],
@@ -277,7 +274,7 @@ static void boundaries_apply(EGSContext *ctx, NDArray *a_dst, int init)
}
break;
case MG2D_BC_TYPE_REFLECT:
- if (!priv->reflect_disable[i]) {
+ if (!(priv->reflect_skip & (1 << i))) {
mg2di_timer_start(&ctx->timer_bnd_reflect);
boundaries_apply_reflect(dst, dst_strides, size_boundary);
mg2di_timer_stop(&ctx->timer_bnd_reflect);
@@ -387,7 +384,7 @@ static int solve_relax_step(EGSContext *ctx, int export_res)
tp_execute(ctx->tp, ctx->domain_size[1], residual_add_task, ctx);
mg2di_timer_stop(&r->timer_correct);
- memset(priv->reflect_disable, 0, sizeof(priv->reflect_disable));
+ priv->reflect_skip = 0;
boundaries_apply(ctx, ctx->u, 0);
}
@@ -799,7 +796,7 @@ static int solve_exact(EGSContext *ctx)
mg2di_timer_stop(&ec->timer_export);
- memset(priv->reflect_disable, 0, sizeof(priv->reflect_disable));
+ priv->reflect_skip = 0;
boundaries_apply(ctx, ctx->u, 0);
residual_calc(ctx, 1);
@@ -954,7 +951,7 @@ finish:
mg2di_timer_stop(&ctx->timer_init);
if (ret >= 0) {
- memset(priv->reflect_disable, 0, sizeof(priv->reflect_disable));
+ priv->reflect_skip = 0;
boundaries_apply(ctx, ctx->u, 1);
boundaries_apply(ctx, priv->u_next, 1);