Skip to content

Conversation

@LasNikas
Copy link
Collaborator

@LasNikas LasNikas commented Sep 29, 2025

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
Copy link

codecov bot commented Sep 29, 2025

Codecov Report

❌ Patch coverage is 81.91489% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.06%. Comparing base (c1db9a3) to head (b19c703).

Files with missing lines Patch % Lines
src/visualization/recipes_plots.jl 0.00% 14 Missing ⚠️
src/preprocessing/geometries/geometries.jl 96.25% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #929      +/-   ##
==========================================
+ Coverage   63.87%   64.06%   +0.19%     
==========================================
  Files         117      117              
  Lines        7842     7931      +89     
==========================================
+ Hits         5009     5081      +72     
- Misses       2833     2850      +17     
Flag Coverage Δ
unit 64.06% <81.91%> (+0.19%) ⬆️

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
11 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