Skip to content

feat(Mf6Splitter): weight horizontal flow barrier faces for metis - #2826

Open
jdhughes-dev wants to merge 1 commit into
modflowpy:developfrom
jdhughes-dev:feat-hfb-eweights
Open

feat(Mf6Splitter): weight horizontal flow barrier faces for metis#2826
jdhughes-dev wants to merge 1 commit into
modflowpy:developfrom
jdhughes-dev:feat-hfb-eweights

Conversation

@jdhughes-dev

Copy link
Copy Markdown
Contributor

optimize_splitting_mask() built the adjacency graph without telling metis where the barriers
are, 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=1 was passed.

  • pass eweights that make a face a barrier crosses expensive to cut, so metis routes the
    partition around it
  • keep the check after the partition is built for any barrier that is still split
  • report the cells that check moves when verbose is set, and correct the spelling of split
    in the error message

Worst imbalance (largest part / mean part) on a 40 by 40 model with three barriers, over seeds
42, 7, and 1234:

parts before after
4 1.015 1.000
6 1.027 1.001
8 1.030 1.005

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.

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

codecov Bot commented Aug 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.61538% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.4%. Comparing base (556c088) to head (74d9b59).
⚠️ Report is 211 commits behind head on develop.

Files with missing lines Patch % Lines
flopy/mf6/utils/model_splitter.py 84.6% 4 Missing ⚠️
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     
Files with missing lines Coverage Δ
flopy/mf6/utils/model_splitter.py 67.7% <84.6%> (-7.2%) ⬇️

... and 584 files with indirect coverage changes

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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