Skip to content

fix(cvfdutil): preserve conforming shared faces during grid conversion - #2867

Merged
jlarsen-usgs merged 1 commit into
modflowpy:developfrom
oscarfasanchez:fix/cvfd-shared-face
Oct 16, 2026
Merged

jlarsen-usgs merged 1 commit into
modflowpy:developfrom
oscarfasanchez:fix/cvfd-shared-face

Conversation

@oscarfasanchez

Copy link
Copy Markdown
Contributor

to_cvfd() can add spurious hanging nodes to conforming Voronoi cells, changing the connection geometry passed to DISV. This also affects meshes imported through shapefile_to_cvfd(), which delegates to to_cvfd().

shared_face() compares a one-element slice with the two vertex IDs of an edge, so it always returns False. Read both consecutive IDs to restore the existing guard that skips segmentation when cells already share a complete face.

Add regression coverage for shared edges (including the closing edge), vertex-only contact, and disjoint cells in both argument orders. A four-cell conforming Voronoi fixture with a legitimate 0.205 m edge checks that every cell's complete coordinate ring is preserved. Before the fix, two cells incorrectly gain an extra vertex (6 → 7 and 5 → 6).

Validation:

  • Confirmed the new tests fail before the source correction: 3 failed, 2 passed.
  • Focused CVFD tests: 12 passed, including the existing hanging-node and generated Voronoi checks.
  • test_grid.py, test_gridutil.py, and test_lgrutil.py: 115 passed, 2 xfailed, 1 failed. The failure is the existing test_voronoi_grid[voronoi_polygon] Triangle cell-count mismatch (3737 versus expected 3803); it also reproduces with the original shared_face() implementation.
  • Repository-wide ruff check and ruff format --check pass; spelling and whitespace checks pass for the patch.

Full-suite validation remains incomplete locally. The initial attempt stopped at 463 passed, 90 skipped, 2 xfailed, and 6 failures: five unavailable notebook commands in the temporary test environment and the same baseline Triangle mismatch. A subsequent broader non-notebook run was interrupted after further failures and did not produce a completed report.

@codecov

codecov Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.8%. Comparing base (556c088) to head (aa2c3c2).
⚠️ Report is 243 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2867      +/-   ##
===========================================
+ Coverage     55.5%    73.8%   +18.2%     
===========================================
  Files          644      659      +15     
  Lines       124135   132511    +8376     
===========================================
+ Hits         68947    97816   +28869     
+ Misses       55188    34695   -20493     
Files with missing lines Coverage Δ
flopy/utils/cvfdutil.py 81.8% <100.0%> (-0.7%) ⬇️

... and 585 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jlarsen-usgs
jlarsen-usgs self-requested a review October 16, 2026 16:12
@jlarsen-usgs

jlarsen-usgs commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

@oscarfasanchez
This looks good. The previous implementation's indexing was incorrectly and the shared_faces() method would never return True. Thanks for fixing this!

@jlarsen-usgs
jlarsen-usgs merged commit f21293a into modflowpy:develop Oct 16, 2026
24 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