Skip to content

Rewrite find_enclosing_cells using segment-face intersections - #371

Open
strene wants to merge 2 commits into
mainfrom
trajectory-updates
Open

strene wants to merge 2 commits into
mainfrom
trajectory-updates

Conversation

@strene

@strene strene commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Replace the point-sampling approach with exact intersection of each trajectory segment against the mesh faces. Faces are triangulated as a fan around the face centroid (watertight between neighboring cells) and a uniform bucket grid limits the faces tested per segment. The crossing direction at each intersection determines which cell is entered, so each part of the trajectory between consecutive crossings is assigned to a single cell. Multiple crossings of the same non-planar face are handled.

  • Cells are returned in order of first visit, as before.
  • extra_out lengths are now exact, and a new :centroids entry gives the length-weighted centroid of the subsegments in each cell.
  • Fix :normed_direction using the list index instead of the cell index in cell_dims.
  • n and limit_box are kept for backwards compatibility but no longer have an effect.
  • Roughly 100x faster than the previous version on a 500k-cell mesh.

Replace the point-sampling approach with exact intersection of each
trajectory segment against the mesh faces. Faces are triangulated as a
fan around the face centroid (watertight between neighboring cells) and
a uniform bucket grid limits the faces tested per segment. The crossing
direction at each intersection determines which cell is entered, so each
part of the trajectory between consecutive crossings is assigned to a
single cell. Multiple crossings of the same non-planar face are handled.

- Cells are returned in order of first visit, as before.
- extra_out lengths are now exact, and a new :centroids entry gives the
  length-weighted centroid of the subsegments in each cell.
- Fix :normed_direction using the list index instead of the cell index
  in cell_dims.
- `n` and `limit_box` are kept for backwards compatibility but no longer
  have an effect.
- Roughly 100x faster than the previous version on a 500k-cell mesh.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 93.75000% with 19 lines in your changes missing coverage. Please review.
✅ Project coverage is 57.13%. Comparing base (6616b55) to head (5c12efd).

Files with missing lines Patch % Lines
src/meshes/trajectories.jl 93.75% 19 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #371      +/-   ##
==========================================
- Coverage   57.22%   57.13%   -0.09%     
==========================================
  Files         222      211      -11     
  Lines       29847    29655     -192     
==========================================
- Hits        17079    16944     -135     
+ Misses      12768    12711      -57     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

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

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

This branch has not been deployed

No deployments
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.

3 participants