From f1d308e6c7a394256d8ede2979c80d57e3868efa Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Fri, 8 Feb 2019 08:48:28 +0100 Subject: Rename fixdiff boundary condition to reflect. This is what it actually does, we do not support setting arbitrary derivative values. API bump. --- ell_grid_solve.c | 22 ++++++++-------------- libmg2d.v | 2 +- mg2d.c | 2 +- mg2d_boundary.h | 7 ++----- mg2d_test.c | 2 +- 5 files changed, 13 insertions(+), 22 deletions(-) diff --git a/ell_grid_solve.c b/ell_grid_solve.c index 0cefdfd..f992186 100644 --- a/ell_grid_solve.c +++ b/ell_grid_solve.c @@ -128,7 +128,7 @@ static void boundaries_apply_fixval(double *dst, const ptrdiff_t dst_stride[2], } } -static void boundaries_apply_fixdiff(double *dst, const ptrdiff_t dst_stride[2], +static void boundaries_apply_reflect(double *dst, const ptrdiff_t dst_stride[2], const double *src, ptrdiff_t src_stride, size_t boundary_size) { @@ -162,8 +162,8 @@ static void boundaries_apply(EGSContext *ctx) boundaries_apply_fixval(dst, dst_strides, ctx->boundaries[i]->val, ctx->boundaries[i]->val_stride, size_boundary); break; - case MG2D_BC_TYPE_FIXDIFF: - boundaries_apply_fixdiff(dst, dst_strides, ctx->boundaries[i]->val, + case MG2D_BC_TYPE_REFLECT: + boundaries_apply_reflect(dst, dst_strides, ctx->boundaries[i]->val, ctx->boundaries[i]->val_stride, size_boundary); break; } @@ -185,9 +185,9 @@ static void boundaries_apply(EGSContext *ctx) + mg2d_bnd_is_upper(loc_y) * ((ctx->domain_size[1] - 1) * priv->stride) + mg2d_bnd_is_upper(loc_x) * (ctx->domain_size[0] - 1); - if (bnd_y->type == MG2D_BC_TYPE_FIXDIFF) + if (bnd_y->type == MG2D_BC_TYPE_REFLECT) fact_y *= -1; - else if (bnd_x->type == MG2D_BC_TYPE_FIXDIFF) + else if (bnd_x->type == MG2D_BC_TYPE_REFLECT) fact_x *= -1; else continue; @@ -380,7 +380,7 @@ static int solve_exact(EGSContext *ctx) if (!bnd_fixval) { /* apply the boundary conditions to eliminate the ghostpoint values */ - // fixdiff + // reflect for (int bnd_loc = 0; bnd_loc < ARRAY_ELEMS(ctx->boundaries); bnd_loc++) { MG2DBoundary *bnd = ctx->boundaries[bnd_loc]; @@ -393,7 +393,7 @@ static int solve_exact(EGSContext *ctx) double *dst = mat_row + mg2d_bnd_is_upper(bnd_loc) * ((bnd_len[1] - 1) * bnd_stride[1]); - if (!is_bnd[bnd_loc] || bnd->type != MG2D_BC_TYPE_FIXDIFF) + if (!is_bnd[bnd_loc] || bnd->type != MG2D_BC_TYPE_REFLECT) continue; for (ptrdiff_t bnd_layer = 1; bnd_layer <= ctx->fd_stencil; bnd_layer++) @@ -545,13 +545,7 @@ int mg2di_egs_init(EGSContext *ctx) for (int i = 0; i < ARRAY_ELEMS(ctx->boundaries); i++) { MG2DBoundary *bnd = ctx->boundaries[i]; const int ci = mg2d_bnd_coord_idx(i); - if (bnd->type == MG2D_BC_TYPE_FIXDIFF) { - for (int k = 0; k < ctx->domain_size[!ci]; k++) - if (bnd->val[k] != 0.0) { - mg2di_log(&ctx->logger, 0, "Only zero boundary derivative supported\n"); - return -ENOSYS; - } - } else if (bnd->type == MG2D_BC_TYPE_FIXVAL) { + if (bnd->type == MG2D_BC_TYPE_FIXVAL) { priv->residual_calc_size[ci]--; } } diff --git a/libmg2d.v b/libmg2d.v index 7fb72b7..f4dd528 100644 --- a/libmg2d.v +++ b/libmg2d.v @@ -1,4 +1,4 @@ -LIBMG2D_8 { +LIBMG2D_9 { global: mg2d_*; local: *; }; diff --git a/mg2d.c b/mg2d.c index 0cb9dd8..5522ed5 100644 --- a/mg2d.c +++ b/mg2d.c @@ -456,7 +456,7 @@ static int mg_levels_init(MG2DContext *ctx) else bnd_zero(bdst, ctx->fd_stencil, cur->solver->domain_size[0]); break; - case MG2D_BC_TYPE_FIXDIFF: + case MG2D_BC_TYPE_REFLECT: bnd_zero(bdst, ctx->fd_stencil, cur->solver->domain_size[0]); break; default: diff --git a/mg2d_boundary.h b/mg2d_boundary.h index 12c897f..910249f 100644 --- a/mg2d_boundary.h +++ b/mg2d_boundary.h @@ -32,12 +32,9 @@ enum MG2DBCType { */ MG2D_BC_TYPE_FIXVAL, /** - * The normal derivative of the unkown function is fixed on the boundary. - * - * TODO: the only supported value of the derivative is currently zero, i.e. - * periodic boundary conditions. + * The unknown function is mirrored across the boundary */ - MG2D_BC_TYPE_FIXDIFF, + MG2D_BC_TYPE_REFLECT, }; /** diff --git a/mg2d_test.c b/mg2d_test.c index a60c5b2..23e52bb 100644 --- a/mg2d_test.c +++ b/mg2d_test.c @@ -75,7 +75,7 @@ static double sol_11(double x, double y) { return M_PI * M_PI * sin(M_PI * x) * sin(M_PI * y); } -#define BC_TYPE MG2D_BC_TYPE_FIXDIFF +#define BC_TYPE MG2D_BC_TYPE_REFLECT #endif static double (*sol[MG2D_DIFF_COEFF_NB])(double x, double y) = { -- cgit v1.2.3