Repository navigation
Conversation
find_quadtree_cell_by_index had no bounds check and returned i1 - 1 (the last cell of the previous level) when binary_search missed; find_sfincs_cell then indexed index_sfincs_in_quadtree(0) out of bounds. In find_boundary_indices the last valid neighbour wins, so for west-edge msk=6 cells the out-of-grid (n, m-1) lookup overwrote the correct (n, m+1) neighbour. All west-edge cells copied the water level of one unrelated cell, which pumped water into the model and made it unstable. Return 0 for indices outside the grid and for a missed search, and only look up the SFINCS index for a valid quadtree cell. Models without msk=6 cells give bit-identical results. Co-Authored-By: SFINCS <sfincs@deltares.nl>
6 of 12 tasks
Leynse
requested review from
maartenvanormondt
and
a lite review from Copilot
November 19, 2026 14:52
There was a problem hiding this comment.
🔵 Needs a closer look
Approval should be deferred because the boundary-indexing and Neumann-selection changes lack executable regression or build/test evidence, leaving west-edge msk=6 behavior and CPU/GPU consistency unverified.
No open issues 🎉
What changed in this PR
This PR fixes invalid neighbour resolution for Neumann (msk=6) boundary cells on quadtree grids, preventing out-of-grid lookups and incorrect water-level propagation.
Changes:
- Added bounds checks and safe handling of missed searches in
find_quadtree_cell_by_index. - Guarded SFINCS-index lookup when no valid quadtree cell exists.
- Preserved valid neighbour selection for boundary cells.
| File | Description |
|---|---|
| source/src/sfincs_quadtree.F90 | Validates quadtree coordinates and safely handles out-of-grid coordinates and unsuccessful searches. |
| source/src/sfincs_boundaries.f90 | Prevents SFINCS-index lookup when the resolved quadtree cell is invalid. |
Review effort: Lite
Leynse
added a commit
that referenced
this pull request
Nov 19, 2026
Merge the current heads of bugfix/snapwave-wave-force-dissipation (5f349be), fix/boundary-corner-water-level (0073407) and fix/neumann-boundary-robustness (ff5e5bf, includes fix/neumann-neighbour-lookup), on top of #445-#448. In compute_fluxes, keep the array swap of #445 instead of the q0/uv0 copy loop, and add kcs to the present list for the Neumann water level at kcuv = 6 faces. Co-Authored-By: SFINCS <sfincs@deltares.nl>
maartenvanormondt
approved these changes
Nov 19, 2026
maartenvanormondt
left a comment
Contributor
There was a problem hiding this comment.
Looks okay to me (I think).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
find_quadtree_cell_by_index had no bounds check and returned i1 - 1 (the last cell of the previous level) when binary_search missed; find_sfincs_cell then indexed index_sfincs_in_quadtree(0) out of bounds. In find_boundary_indices the last valid neighbour wins, so for west-edge msk=6 cells the out-of-grid (n, m-1) lookup overwrote the correct (n, m+1) neighbour. All west-edge cells copied the water level of one unrelated cell, which pumped water into the model and made it unstable.
Return 0 for indices outside the grid and for a missed search, and only look up the SFINCS index for a valid quadtree cell. Models without msk=6 cells give bit-identical results.
Description
Please briefly describe the purpose of this pull request and the main changes introduced.
Checklist
Before marking this PR as Ready for Review, please confirm:
Compilation
Testing (for additions to the code)
If this PR modifies model functionality:
If this PR adds model functionality:
Documentation
HydroMT-SFINCS
Self Review
Additional Notes