Skip to content

Skip zero-extent BC extrapolation on small grids - #708

Merged
ChrisRackauckas merged 3 commits into
SciML:masterfrom
ChrisRackauckas-Claude:agent/677-bc-extrap-small
Oct 13, 2026
Merged

ChrisRackauckas merged 3 commits into
SciML:masterfrom
ChrisRackauckas-Claude:agent/677-bc-extrap-small

Conversation

@ChrisRackauckas-Claude

@ChrisRackauckas-Claude ChrisRackauckas-Claude commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

Please ignore until reviewed by @ChrisRackauckas.

Summary

For pure reaction PDEs (no spatial derivatives / BCs), stencil extents are zero, but generate_extrap_eqs! still entered its inclusive while ninterp >= vlower/vupper loops once and evaluated the fixed 6-point boundary extrapolator — which BoundsErrors on a 4-point grid. Guard both loops with lowerextents[j] > 0 / upperextents[j] > 0 so padding only runs when there is something outside the BC-truncated interior to pad, preserving the WENO-motivated >= behavior from 3c34574 when extents are nonzero.

Fixes #677

Fail-before / pass-after (strengthened regression)

Regression solves the DAE from discretize and compares to exact (1+x)*exp(-t) at t=0.2 (tol < 1e-9; measured max error ~1e-11 at abstol=reltol=1e-10; no spatial truncation). Uses existing test dep OrdinaryDiffEq (no new [extras]).

export TMPDIR=/home/crackauc/sandbox/goals/issue-backlog/ibd/MethodOfLines.jl/jobs/677-cursor/tmp
export JULIA_DEPOT_PATH=.../scratch/depot
# BEFORE: master src
git show origin/master:src/discretization/generate_bc_eqs.jl > src/discretization/generate_bc_eqs.jl
julia +1.12 --project=scratch/testenv --check-bounds=yes -e '
using Test, MethodOfLines, ModelingToolkitBase, SciMLBase, OrdinaryDiffEq
include("test/Components/bc_extrap_zero_extent.jl")'

Fail-before (intervals=5 ok; intervals=3 BoundsError):

BoundsError: attempt to access 4-element Vector{...SymReal} at index [CartesianIndex{1}[..., CartesianIndex(6,)]]
...
generate_extrap_eqs! ... generate_bc_eqs.jl:364
Test Summary:                               | Pass  Error  Total     Time
Zero-extent BC extrapolation on small grids |    4      1      5  2m20.0s

Pass-after (fix restored):

Test Summary:                               | Pass  Total     Time
Zero-extent BC extrapolation on small grids |    8      8  2m18.6s
TEST_DONE

WENO regression (commit 3c34574)

GROUP=Convection_WENO julia +1.12 --startup-file=no --project=. -e 'using Pkg; Pkg.test(coverage=false)'
Test Summary:             | Pass  Total     Time
1D Linear Convection WENO |  309    309  8m41.6s
Test Summary:                           | Pass  Total     Time
WENO Pipeline Spatial Convergence (MMS) |   20     20  2m29.9s
Test Summary:                       | Pass  Total     Time
WENO Non-Uniform Interface/Periodic |   31     31  4m12.3s
     Testing MethodOfLines tests passed

Independent review also reports Components and Burgers groups pass; generated equations byte-identical to master for previously-working cases.

Runic --check and typos clean on changed files.

Not verified (this agent)

  • Full Components / Discretization / Burgers groups locally in this session (reviewer ran Components + Burgers).
  • Alternate fix of restoring pre-3c345749 > comparisons.
  • mindomsize defense-in-depth in interior_map.jl.

Reviewer pushback

  • Whether extent guards are the right predicate vs restoring > (triage tried both; both fix the repro).
  • Whether mindomsize should also account for the 6-point extrapolator when the extrapolation path can run.

Risk assessment

  • Risk: low
  • Blast radius: only generate_extrap_eqs! padding loops; equations with nonzero stencil extents keep the existing >= iterations
  • Evidence: fail-before BoundsError / pass-after 8/8 with exact-solution check; Convection_WENO 360/360; reviewer: Components + Burgers pass, equations identical to master for prior-working cases
  • Independent review: Claude Code (Opus 5.5) rated it low — MERGE, low / high confidence — guard only skips extrapolation equations that were discarded as interior overlap; generated equations identical to master for all previously-working cases; Components and Burgers groups pass; solutions match (1+x)e^{-t} to ~1e-11
  • Merge: auto-merge candidate (independent MERGE verdict; residual risk is BC-padding predicate choice)

Please ignore this draft until reviewed by @ChrisRackauckas.

Harness: Cursor Agent CLI 2026.09.28-64d2043; model: auto; transcript: /home/crackauc/sandbox/goals/issue-backlog/ibd/MethodOfLines.jl/jobs/677-cursor/log.txt on amdci2.julia.csail.mit.edu

ChrisRackauckas and others added 3 commits September 30, 2026 10:40
When stencil extents are zero (pure reaction PDEs), the inclusive
extrapolation loops still fired once and evaluated the 6-point
boundary stencil on grids too small to support it.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Cursor Agent <[email protected]>
Agent-Harness: Cursor Agent CLI 2026.09.28-64d2043
Agent-Model: auto
Agent-Session: local session, transcript at /home/crackauc/sandbox/goals/issue-backlog/ibd/MethodOfLines.jl/jobs/677-cursor/log.txt on amdci2.julia.csail.mit.edu
Covers pure reaction PDE symbolic_discretize on 4- and 6-point grids.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Cursor Agent <[email protected]>
Agent-Harness: Cursor Agent CLI 2026.09.28-64d2043
Agent-Model: auto
Agent-Session: local session, transcript at /home/crackauc/sandbox/goals/issue-backlog/ibd/MethodOfLines.jl/jobs/677-cursor/log.txt on amdci2.julia.csail.mit.edu
Solve the DAE and compare to (1+x)*exp(-t) at t=0.2 so the
test checks correctness, not only that discretize returns.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Cursor Agent <[email protected]>
Agent-Harness: Cursor Agent CLI 2026.09.28-64d2043
Agent-Model: auto
Agent-Session: local session, transcript at /home/crackauc/sandbox/goals/issue-backlog/ibd/MethodOfLines.jl/jobs/677-cursor/log.txt on amdci2.julia.csail.mit.edu
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.

Pure reaction equation on a four-point grid triggers unnecessary six-point boundary extrapolation

2 participants