Skip to content

Get nearest patch#106

Open
chraibi wants to merge 4 commits intoFireDynamics:masterfrom
chraibi:get_nearest_patch
Open

Get nearest patch#106
chraibi wants to merge 4 commits intoFireDynamics:masterfrom
chraibi:get_nearest_patch

Conversation

@chraibi
Copy link
Copy Markdown

@chraibi chraibi commented Mar 24, 2026

Addresses two bugs in the original get_nearest_patch. (#84)

@JSoini: Could you check your simulation with this PR?

Copilot AI review requested due to automatic review settings March 24, 2026 10:33
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes Obstruction.get_nearest_patch so it correctly returns the nearest boundary patch (instead of frequently defaulting to the same patch), and adds an acceptance test to validate orientation selection around an obstruction (per Issue #84).

Changes:

  • Reworked get_nearest_patch minimum-distance tracking and tie handling.
  • Added an acceptance test covering nearest-patch orientation selection for several probe points.
  • Made test_bndf use a path derived from the test file location.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
fdsreader/bndf/obstruction.py Updates nearest-patch selection logic to track only true minima and introduces deterministic tie sorting.
tests/acceptance_tests/test_bndf.py Adds acceptance coverage for get_nearest_patch and adjusts case-path resolution for BNDF tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 571 to 574
def get_nearest_patch(self, x: float = None, y: float = None, z: float = None):
"""Gets the patch of the :class:`SubObstruction` that has the least distance to the given point.
If there are multiple patches with the same distance, a random one will be selected.
"""
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

The docstring says that if multiple patches have the same distance, a random one will be selected, but the implementation is deterministic (it sorts/takes the first element). Please update the docstring to describe the actual tie-breaking behavior (or implement true randomness if that is the intended contract).

Copilot uses AI. Check for mistakes.
chraibi and others added 2 commits March 24, 2026 13:06
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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