Skip to content

Fix BoundsError in upwind_difference for nonuniform grids (Fixes #340)#533

Open
utkuyilmaz1903 wants to merge 1 commit intoSciML:masterfrom
utkuyilmaz1903:fix-issue-340
Open

Fix BoundsError in upwind_difference for nonuniform grids (Fixes #340)#533
utkuyilmaz1903 wants to merge 1 commit intoSciML:masterfrom
utkuyilmaz1903:fix-issue-340

Conversation

@utkuyilmaz1903
Copy link

This PR resolves Issue #340 where providing a nonuniform grid (as an AbstractVector) to the UpwindScheme resulted in a BoundsError.

Cause of the Bug:
In _upwind_difference for DX <: AbstractVector, the D.offside value defaults to 0. This caused the boundary check (II[j] <= D.offside) to fail at the lower boundary (II[j] == 1). Consequently, the algorithm incorrectly executed the interior stencil logic, attempting to access index 0 and throwing a BoundsError.

Solution:
Replaced the reliance on D.offside with a calculated actual_offside = D.stencil_length - 1. The boundary checks now correctly identify when the stencil approaches the domain edges, appropriately applying the boundary coefficients (low_boundary_coefs and high_boundary_coefs) without out-of-bounds indexing.

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.

1 participant