diff options
-rw-r--r-- | ell_grid_solve.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/ell_grid_solve.c b/ell_grid_solve.c index fdbce7d..63aed59 100644 --- a/ell_grid_solve.c +++ b/ell_grid_solve.c @@ -178,13 +178,16 @@ static void boundaries_apply_falloff(double *dst, const ptrdiff_t dst_stride[2], static void boundaries_apply(EGSContext *ctx) { + static const enum MG2DBCType bnd_type_order[] = { MG2D_BC_TYPE_FIXVAL, MG2D_BC_TYPE_REFLECT, MG2D_BC_TYPE_FALLOFF }; EGSInternal *priv = ctx->priv; const ptrdiff_t strides[2] = { 1, priv->stride }; int64_t start; start = gettime(); - for (int tmp = 0; tmp < 2; tmp++) + for (int order_idx = 0; order_idx < ARRAY_ELEMS(bnd_type_order); order_idx++) { for (int i = 0; i < ARRAY_ELEMS(ctx->boundaries); i++) { + MG2DBoundary *bnd = ctx->boundaries[i]; + const int ci = mg2d_bnd_coord_idx(i); const ptrdiff_t stride_boundary = strides[!ci]; const ptrdiff_t stride_offset = strides[ci]; @@ -194,21 +197,25 @@ static void boundaries_apply(EGSContext *ctx) double *dst = ctx->u->data + mg2d_bnd_is_upper(i) * ((size_offset - 1) * stride_offset); const ptrdiff_t dst_strides[] = { stride_boundary, mg2d_bnd_out_dir(i) * stride_offset }; - switch (ctx->boundaries[i]->type) { + if (bnd->type != bnd_type_order[order_idx]) + continue; + + switch (bnd->type) { case MG2D_BC_TYPE_FIXVAL: - boundaries_apply_fixval(dst, dst_strides, ctx->boundaries[i]->val, - ctx->boundaries[i]->val_stride, size_boundary); + boundaries_apply_fixval(dst, dst_strides, bnd->val, + bnd->val_stride, size_boundary); break; case MG2D_BC_TYPE_REFLECT: - boundaries_apply_reflect(dst, dst_strides, ctx->boundaries[i]->val, - ctx->boundaries[i]->val_stride, size_boundary); + boundaries_apply_reflect(dst, dst_strides, bnd->val, + bnd->val_stride, size_boundary); break; case MG2D_BC_TYPE_FALLOFF: - boundaries_apply_falloff(dst, dst_strides, ctx->boundaries[i]->val, - ctx->boundaries[i]->val_stride, size_boundary, ctx); + boundaries_apply_falloff(dst, dst_strides, bnd->val, + bnd->val_stride, size_boundary, ctx); break; } } + } /* fill in the corner ghosts */ for (int pos_y = 0; pos_y < 2; pos_y++) { |