Skip to content

Fix off-by-one in moving_wall_bc ghost fill (stegoton_1d)#757

Merged
ketch merged 2 commits into
clawpack:masterfrom
bypire:fix-stegoton-ghost-717
Jun 25, 2026
Merged

Fix off-by-one in moving_wall_bc ghost fill (stegoton_1d)#757
ketch merged 2 commits into
clawpack:masterfrom
bypire:fix-stegoton-ghost-717

Conversation

@bypire

@bypire bypire commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Fixes #717.

moving_wall_bc fills the lower ghost cells with for ibc in range(num_ghost-1),
which writes ghost indices num_ghost-1 down to 1, so the outermost lower ghost
cell (index 0) never gets set. range(num_ghost) lets ibc reach num_ghost-1,
which writes index 0 too.

Quick check of just that loop (ghost cells marked NaN so an unwritten one shows up):

num_ghost = 2
  before  range(num_ghost-1): qbc[1, :2] = [nan -1.]
  after   range(num_ghost)  : qbc[1, :2] = [-2. -1.]

Before the change the outermost ghost cell is left unset; after, all num_ghost
cells are filled (the reflection pairs index num_ghost-ibc-1 with interior
num_ghost+ibc).

Fill the outermost lower ghost cell (range(num_ghost-1) -> range(num_ghost)). Closes clawpack#717.
@bypire

bypire commented Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

Heads up on the failing checks: they're the stegoton_1d regression tests, which
compare the example's final strain against a stored expected_sols.npy at L1 < 1e-6.
The fix changes that output (L1 ~ 2e-3 for classic, ~2e-2 for sharpclaw), so the
outermost lower ghost cell does feed into the stencil and the stored reference was
generated with the old behavior.

So expected_sols.npy needs regenerating with the fix in place. Happy to do that
and push it here if you'd like, or if you'd rather double-check the boundary
behavior first and regenerate it on your side, that's fine too.

@ketch

ketch commented Jun 23, 2026

Copy link
Copy Markdown
Member

Thanks! Yes, please go ahead and push an updated reference solution.

The moving_wall_bc fix changes the example output, so the stored reference solution is regenerated for all four configs (the tests pass against it).
@bypire

bypire commented Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

Pushed the regenerated expected_sols.npy (all four configs; the stegoton tests pass against it locally). Thanks!

@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 47.07%. remained the same — bypire:fix-stegoton-ghost-717 into clawpack:master

@ketch ketch merged commit f522337 into clawpack:master Jun 25, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Possible bug in filling ghost cell in stegoton_1d example

3 participants