From 21d5c9c6a7bffee18863e0d7c0d21624420ee2f6 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sun, 2 Jun 2019 17:27:30 +0200 Subject: egs: handle falloff boundaries properly with multiple components --- ell_grid_solve.c | 10 ++++++---- 1 file 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; } -- cgit v1.2.3