Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Issue #1414 add cleanup hfb #1426

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Feb 28, 2025
Merged

Conversation

JoerivanEngelen
Copy link
Contributor

@JoerivanEngelen JoerivanEngelen commented Feb 13, 2025

Fixes #1414

Description

  • Adds cleanup_hfb function to clip barrier lines/Z polygons outside the active domain. This unfortunately cannot deal with the edge case where a hfb line is snapped to the outer edge of the active domain. (These edges are filtered out when calling to_mf6_pkg, but a ValidationError is thrown when strict_hfb_validation is switched on).
  • Adds HorizontalFlowBarrierBase.cleanup method
  • Moves some utility functions from imod.mf6.utilities to imod.prepare.hfb and imod.util.hfb, to avoid circular imports.

Checklist

  • Links to correct issue
  • Update changelog, if changes affect users
  • PR title starts with Issue #nr, e.g. Issue #737
  • Unit tests were added
  • If feature added: Added/extended example

@JoerivanEngelen JoerivanEngelen marked this pull request as ready for review February 13, 2025 13:56
@@ -217,3 +222,55 @@ def linestring_to_trapezoid_zpolygons(
_line_to_trapezoid_zpolygon(x, y, zt, zb)
for x, y, zt, zb in zip(x_pairs, y_pairs, zt_pairs, zb_pairs)
]


def _clip_linestring(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why did you move these method to this class?
The original intent of moving them to a separate clip class was to keep the package classes small while keeping the similar functionality grouped. Which also makes it easier to unit test. This was done using the Visitor Pattern.

I wouldn't move this to the hfb class because we now get a mix of clip methods being in a separate clip class and clip methods being in classes specificly related to a certain package class

Copy link
Contributor Author

@JoerivanEngelen JoerivanEngelen Feb 17, 2025

Choose a reason for hiding this comment

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

The main reason is that I ran into circular imports, as the logic was put in the imod/mf6/utilities namespace. The cleanup was in the imod/prepare/cleanup namespace, which is imported in the imod/mf6/hfb.py namespace.

So probably what is required is moving imod/mf6/utilties/clip.py to imod/util/clip.py. This, however is heavily depending on imod/mf6/interfaces, so these probably have to be moved one level up as well. That is probably better.

@@ -336,3 +337,31 @@ def cleanup_wel(
cleaned_wells, minimum_thickness
)
return cleaned_wells


def cleanup_hfb(
Copy link
Collaborator

Choose a reason for hiding this comment

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

This could also be called clean_linedata or remove_inactive_hfb_data

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is public API, so I think I keep this to the MODFLOW6 package names, which is what users are familiar with.

Copy link

@JoerivanEngelen JoerivanEngelen merged commit 9aee143 into master Feb 28, 2025
5 of 7 checks passed
@JoerivanEngelen JoerivanEngelen deleted the issue_#1414_add_cleanup_hfb branch February 28, 2025 09:11
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.

Expose functionality to clip HorizontalFlowBarrier class
2 participants