aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2019-06-02 17:27:30 +0200
committerAnton Khirnov <anton@khirnov.net>2019-06-02 17:27:30 +0200
commit21d5c9c6a7bffee18863e0d7c0d21624420ee2f6 (patch)
tree7d8932a2461eb51f8390bbddab2f7ac86a973e03
parent5bd1bccffd411384b02ca772822d87fac126e67f (diff)
egs: handle falloff boundaries properly with multiple components
-rw-r--r--ell_grid_solve.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/ell_grid_solve.c b/ell_grid_solve.c
index 8c37799..94f4d34 100644
--- a/ell_grid_solve.c
+++ b/ell_grid_solve.c
@@ -219,12 +219,14 @@ static const double falloff_bnd_fd_factors[][FD_STENCIL_MAX * 2 + 1] = {
};
static void boundaries_apply_falloff(double *dst, const ptrdiff_t dst_stride[2],
- size_t boundary_size, EGSContext *ctx)
+ size_t boundary_size, EGSContext *ctx, int ci)
{
+ const ptrdiff_t offset = ctx->priv->dg->components[ctx->priv->local_component].interior.start[!ci];
+
for (ptrdiff_t bnd_layer = 1; bnd_layer <= ctx->fd_stencil; bnd_layer++)
for (ptrdiff_t bnd_idx = -(ptrdiff_t)ctx->fd_stencil; bnd_idx < (ptrdiff_t)(boundary_size + ctx->fd_stencil); bnd_idx++) {
- const double x = ctx->step[0] * (ctx->domain_size[0] - 1 + bnd_layer - ctx->fd_stencil);
- const double y = ctx->step[0] * bnd_idx;
+ const double x = ctx->step[0] * (ctx->priv->dg->domain_size[ci] - 1 + bnd_layer - ctx->fd_stencil);
+ const double y = ctx->step[0] * (bnd_idx + offset);
const double r = sqrt(SQR(x) + SQR(y));
double *row = dst + bnd_layer * dst_stride[1] + bnd_idx * dst_stride[0];
@@ -281,7 +283,7 @@ static void boundaries_apply(EGSContext *ctx, NDArray *a_dst, int init)
break;
case MG2D_BC_TYPE_FALLOFF:
mg2di_timer_start(&ctx->timer_bnd_falloff);
- boundaries_apply_falloff(dst, dst_strides, size_boundary, ctx);
+ boundaries_apply_falloff(dst, dst_strides, size_boundary, ctx, ci);
mg2di_timer_stop(&ctx->timer_bnd_falloff);
break;
}