Skip to content

Add OrientedBoundingBox for spatial region analysis and particle selection - #929

Open
LasNikas wants to merge 24 commits into
trixi-framework:mainfrom
LasNikas:oriented-bbox
Open

Add OrientedBoundingBox for spatial region analysis and particle selection#929
LasNikas wants to merge 24 commits into
trixi-framework:mainfrom
LasNikas:oriented-bbox

Conversation

@LasNikas

@LasNikas LasNikas commented Sep 29, 2025

Copy link
Copy Markdown
Collaborator

This PR adds an OrientedBoundingBox that enables analysis of arbitrarily oriented rectangular regions within computational domains.
For example: use is_in_oriented_box(coords, box) to define measurement windows for calculating flow rates through specific cross-sections.

Or for particle selection: using intersect(ic::InitialCondition, box::OrientedBoundingBox...) - particularly useful for creating clamped particles for the TLSPH system.

2D

using TrixiParticles
using Plots

data_dir = pkgdir(TrixiParticles, "examples", "preprocessing", "data")
geometry = load_geometry(joinpath(data_dir, "potato.asc"))

box_1 = OrientedBoundingBox(geometry)
box_2 = OrientedBoundingBox(geometry, local_axis_scale=(1.5, 2))
box_3 = OrientedBoundingBox(geometry, local_axis_scale=(3, 0.5))

plot(geometry, label="geometry", color=:black)
plot!(box_1, label="box: no scaling")
plot!(box_2, label="box: local_axis_scale=(1.5, 2)")
plot!(box_3, label="box: local_axis_scale=(3, 0.5)")
image
# Create a point cloud from a spherical shape (quarter circle sector)
shape = SphereShape(0.1, 1.5, (0.2, 0.4), 1.0, n_layers=4,
                    sphere_type=RoundSphere(; start_angle=0, end_angle=π/4))
box = OrientedBoundingBox(shape.coordinates)
image

3D

(hard to visualize but it's working)

file = pkgdir(TrixiParticles, "test", "preprocessing", "data")
geometry = load_geometry(joinpath(file, "inflow.stl"))
box_3d = OrientedBoundingBox(geometry)

trixi2vtk(stack(box_3d.spanning_vectors) .+ box_3d.box_origin)
image

@codecov

codecov Bot commented Sep 29, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 81.44330% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.48%. Comparing base (6b3a068) to head (459a382).
⚠️ Report is 41 commits behind head on main.

Files with missing lines Patch % Lines
src/visualization/recipes_plots.jl 0.00% 14 Missing ⚠️
src/preprocessing/geometries/geometries.jl 95.18% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #929      +/-   ##
==========================================
- Coverage   89.58%   89.48%   -0.10%     
==========================================
  Files         120      120              
  Lines        8628     8720      +92     
==========================================
+ Hits         7729     7803      +74     
- Misses        899      917      +18     
Flag Coverage Δ
total 89.48% <81.44%> (-0.10%) ⬇️
unit 64.95% <81.44%> (+0.16%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 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.

@LasNikas LasNikas changed the title Add OrientedBoundingBox Add OrientedBoundingBox for spatial region analysis and particle selection Sep 29, 2025
@LasNikas LasNikas self-assigned this Sep 29, 2025
@svchb svchb added the enhancement New feature or request label Sep 30, 2025
svchb
svchb previously approved these changes Oct 2, 2025
@LasNikas
LasNikas requested a review from efaulhaber October 2, 2025 09:14
@LasNikas LasNikas mentioned this pull request Oct 13, 2025
19 tasks
svchb
svchb previously approved these changes Oct 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants