Skip to content

Add non-uniform grid regression tests for linear advection (UpwindScheme)#562

Merged
ChrisRackauckas merged 3 commits into
SciML:masterfrom
utkuyilmaz1903:test-nonuniform-upwind
Jun 11, 2026
Merged

Add non-uniform grid regression tests for linear advection (UpwindScheme)#562
ChrisRackauckas merged 3 commits into
SciML:masterfrom
utkuyilmaz1903:test-nonuniform-upwind

Conversation

@utkuyilmaz1903

@utkuyilmaz1903 utkuyilmaz1903 commented May 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a regression test suite for linear advection with UpwindScheme() on non-uniform AbstractVector spatial grids. Uniform-grid convection tests already exist; they do not exercise per-point stencil weights, boundary upwinding on irregular spacing, or the non-uniform discretization path in DiscreteSpace.

This PR adds coverage only — no changes to scheme or discretization code.

Motivation

Non-uniform grid support for advection is an existing code path, but it lacked dedicated tests comparable to MOL_1D_Linear_Diffusion_NonUniform.jl. These tests lock in expected behavior before further work on non-uniform upwind (convergence, performance, additional BC types).

What's added

  • test/pde_systems/MOL_1D_Linear_Convection_NonUniform.jl — MMS-based tests for u_t + v u_x = 0 with UpwindScheme()
  • test/runtests.jl — new CI group Convection_NU

Test coverage

Area What is checked
Extreme stretching Symmetric, one-sided, and Chebyshev grids (up to ~1:1000 spacing ratio). Discretization and time integration complete without BoundsError, NaN, or blow-up.
Directional switching Positive and negative constant velocity; spatially varying velocity; inflow Dirichlet + outflow Neumann BCs on clustered grids.
Accuracy & leakage Translating sine MMS (weighted L2); uniform vs non-uniform error comparison (err_n < 5·err_u); short-time Gaussian mass conservation.
Interface integrity AbstractVector grid routing (s.grid, s.dxs), no StepRangeLen fallback, Float32 grids, chebyspace, uniform vs vector dxs typing.

Implementation notes

  • Tests use Dirichlet MMS boundary conditions from the analytical solution. Periodic BCs (u(t, x₀) ~ u(t, x_L)) are not used because non-uniform upwind currently rejects interface/periodic BCs in _upwind_difference. This is documented in-test by design, not a test oversight.
  • Time stepping uses SSPRK33 with a CFL-limited dt based on minimum(diff(xgrid)).
  • Default advection scheme is UpwindScheme(); approx_order = 2 for centered operators on the same grid.

Test plan

julia --project=test test/pde_systems/MOL_1D_Linear_Convection_NonUniform.jl
GROUP=Convection_NU julia --project=test -e 'include("test/runtests.jl")'

Related work

Part of the non-uniform upwind verification effort (proposal weeks 1–2): establish a CI-backed regression baseline for UpwindScheme on AbstractVector grids before convergence/performance suites and any scheme fixes.

@utkuyilmaz1903

Copy link
Copy Markdown
Contributor Author

@ChrisRackauckas @xtalax Here is the regression test suite for the Upwind non-uniform audit.

@utkuyilmaz1903

utkuyilmaz1903 commented May 29, 2026

Copy link
Copy Markdown
Contributor Author

@xtalax @ChrisRackauckas I added a test block to check Periodic BC behavior on non-uniform grids with UpwindScheme

Passing u(t, x0) ~ u(t, xL) fails during the discretize step. The system routes the periodic condition as an interface boundary under the hood, which triggers this specific assertion at upwind_difference.jl:35
AssertionError: Interface boundary conditions are not yet supported for nonuniform dx dimensions

To document this current limitation while keeping the CI green, I wrapped the discretize call in @test_throws AssertionError and left the solve step commented out as a # TODO.

@xtalax

xtalax commented Jun 1, 2026

Copy link
Copy Markdown
Member

Excellent looks good, my mistake. Yes, adding nonuniform support for interface bcs would be a good contribution, just make sure you understand their other use in joining disperate domains with different physics together. See the MOL_1D_Interface_Nonlinear.jl for this use case

@utkuyilmaz1903

Copy link
Copy Markdown
Contributor Author

Thanks @xtalax I will look into it as soon as my final exams are over on Friday.

@utkuyilmaz1903 utkuyilmaz1903 force-pushed the test-nonuniform-upwind branch from eb57bd8 to ff64267 Compare June 5, 2026 08:06
@utkuyilmaz1903

Copy link
Copy Markdown
Contributor Author

@xtalax @ChrisRackauckas I've just rebased the branch. Could you please trigger the CI

@utkuyilmaz1903 utkuyilmaz1903 force-pushed the test-nonuniform-upwind branch from e224873 to 95d3ecf Compare June 10, 2026 16:31
@ChrisRackauckas ChrisRackauckas merged commit b71116c into SciML:master Jun 11, 2026
52 of 66 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.

3 participants