feat(Mf6Splitter): weight horizontal flow barrier faces for metis - #2826
Open
jdhughes-dev wants to merge 1 commit into
Open
feat(Mf6Splitter): weight horizontal flow barrier faces for metis#2826jdhughes-dev wants to merge 1 commit into
jdhughes-dev wants to merge 1 commit into
Conversation
optimize_splitting_mask() built the adjacency graph without telling metis where the barriers are, so a partition was free to cut one and the barriers were then put back together by moving cells between models after the partition was built. Moving cells undoes the balance metis produced. Pass edge weights that make a face a barrier crosses expensive to cut, so metis routes the partition around it, and keep the check afterward for any barrier that is still split. On a 40 by 40 model with three barriers the worst imbalance over three seeds and 4, 6, and 8 parts drops from 1.030 to 1.005. Also report the cells the check moves when verbose is set, and correct the spelling of split in the error message.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #2826 +/- ##
===========================================
+ Coverage 55.5% 73.4% +17.8%
===========================================
Files 644 659 +15
Lines 124135 132240 +8105
===========================================
+ Hits 68947 97109 +28162
+ Misses 55188 35131 -20057
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR improves Mf6Splitter.optimize_splitting_mask() partition quality when horizontal flow barriers (HFBs) are present by steering METIS away from cutting across barrier faces, reducing the need for post-partition “fix-up” cell moves and preserving contiguity/balance.
Changes:
- Add METIS edge weights (
eweights) so faces crossed by HFBs are expensive to cut (HFB_EDGE_WEIGHT). - Keep and enhance the post-partition HFB integrity check, including verbose reporting of moved cells, and fix a typo in the AssertionError message.
- Add an integration-style test that asserts HFBs are not split and that reconstructed heads match the original model.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
flopy/mf6/utils/model_splitter.py |
Adds HFB-aware METIS edge weighting and improves post-partition HFB correction messaging/verbosity. |
autotest/test_model_splitter.py |
Adds a new MF6+pymetis test to validate HFB containment within a single partition and correct head reconstruction after splitting. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
optimize_splitting_mask()built the adjacency graph without telling metis where the barriersare, so a partition was free to cut one. The barriers were then put back together by moving
cells between models after the partition was built, which undoes the balance metis produced
and can break contiguity even when
contig=1was passed.eweightsthat make a face a barrier crosses expensive to cut, so metis routes thepartition around it
verboseis set, and correct the spelling of splitin the error message
Worst imbalance (largest part / mean part) on a 40 by 40 model with three barriers, over seeds
42, 7, and 1234:
This is a partition quality change, not a correctness fix: the check after the partition is
built already produced usable partitions, and neither version failed on any configuration I
tried, up to 32 parts. The new test covers what the splitter guarantees — a barrier stays
within one model and the heads reconstruct — and passes with or without the weights, so it
guards the contract rather than the weighting.