Skip to content

Fix hash-order-dependent IV indexing in nonlinear Laplacian discretization - #647

Merged
ChrisRackauckas merged 1 commit into
SciML:masterfrom
utkuyilmaz1903:fix/2d-diffusion-test
Aug 20, 2026
Merged

ChrisRackauckas merged 1 commit into
SciML:masterfrom
utkuyilmaz1903:fix/2d-diffusion-test

Conversation

@utkuyilmaz1903

Copy link
Copy Markdown
Member

Summary

2D_Diffusion Test 01 (Dt(u) ~ Dx(a Dx(u)) + Dy(a Dy(u))) errors during discretize on master and on unrelated PRs, including both Tests / 2D_Diffusion (julia lts) and Downgrade / Downgrade Tests. The two CI jobs share the same failure.

The crash is a BoundsError on the 11-point y grid at index 12. That index is an interior x index (dx = 0.1 → 21 points) applied to y (dy = 0.2 → 11 points).

Root cause

cartesian_nonlinear_laplacian interpolated the transverse coordinates with

[s.x̄[k] => s.grid[s.x̄[k]][II[k]] for k in setdiff(1:N, [j])]

II and j = x2i(s, u, x) are argument-ordered (u(t, x, y) → [x, y]). s.x̄ is not: PDEBase VariableMap builds it from a Set union whose iteration order depends on SymbolicUtils hashing. Under SymbolicUtils v4 this can be x̄ = [y, x]. The y-direction rule then reads s.grid[y][i_x], which throws when i_x > length(y).

When dx == dy the same mix-up does not throw; it silently substitutes the wrong coordinate.

Fix

  • Nonlinear Laplacian: transverse IV substitutions go through ivs(u, s) and x2i(s, u, x_), never s.x̄ position.
  • Spherical Laplacian: the same convention (I[s.x2i[x]] / (s.x2i[r], r) were s.x̄-ordered).
  • Remove unused, broken map_symbolic_to_discrete (s.grid[j] with an Int key).

A PDEBase change to make VariableMap.x̄ deterministic is left for a follow-up. This PR is sufficient to make MOL correct regardless of x̄ permutation.

Tests

test/Components/nonlinear_laplacian_ivs.jl checks the mapping for:

  • equal grids (dx == dy), where the old code would silently swap coordinates
  • unequal grids (dx ≠ dy), the CI BoundsError
  • a forced reversed s.x̄, so the test does not depend on Set iteration order

@ChrisRackauckas
ChrisRackauckas marked this pull request as ready for review August 20, 2026 09:16
@ChrisRackauckas
ChrisRackauckas merged commit c5bf73d into SciML:master Aug 20, 2026
69 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.

2 participants