Skip to content

feature: integrate rotations into ICPP patches (#1594)#1612

Draft
SVS87 wants to merge 6 commits into
MFlowCode:masterfrom
SVS87:feature/icpp-patch-rotations
Draft

feature: integrate rotations into ICPP patches (#1594)#1612
SVS87 wants to merge 6 commits into
MFlowCode:masterfrom
SVS87:feature/icpp-patch-rotations

Conversation

@SVS87

@SVS87 SVS87 commented Jun 20, 2026

Copy link
Copy Markdown

Description

Add a rotation framework to initial-condition (ICPP) patches, mirroring the existing immersed-boundary rotation support.

  • Extract the rotation-matrix computation into a new shared module m_patch_geometries, taking angle/matrix arrays as arguments so both ICPP and IB patches can call it (m_ib_patches now uses a thin wrapper).
  • Add angles + rotation_matrix(_inverse) fields to ic_patch_parameters, defaulting angles to zero (identity rotation) so existing cases are unaffected.
  • Apply the inverse-rotation transform in the rectangle inside-test as a proof of concept; remaining geometries are straightforward follow-up.
  • Register patch_icpp(i)%angles in the parameter definitions so the angle is settable from a case file.
  • Add a 2D_rotated_rectangle example demonstrating a 45-degree patch.

Part of #1594

Type of change (delete unused ones)

  • New feature
  • Refactor

Testing

  • Built pre_process and simulation against current master.
  • Full CPU test suite passes; the angles=0 default makes the rotation
    behavior-neutral for all existing cases.
  • IB patch tests pass after routing s_update_ib_rotation_matrix through
    the shared s_compute_rotation_matrix, confirming the extracted routine
    matches the original.
  • Added examples/2D_rotated_rectangle (45-degree patch); pre_process
    output shows the rectangle correctly tilted (image below).
rotated_rectangle_fields

Checklist

Check these like this [x] to indicate which of the below applies.

  • I added or updated tests for new behavior
  • I updated documentation if user-facing behavior changed

See the developer guide for full coding standards.

GPU changes (expand if you modified src/simulation/)
  • GPU results match CPU results
  • Tested on NVIDIA GPU or AMD GPU
    Verified CPU only

AI code reviews

Reviews are not retriggered automatically. To request a review, comment on the PR:

  • @claude full review — Claude full review (also triggers on PR open/reopen/ready)
  • Or add label claude-full-review — Claude full review via label

@SVS87 SVS87 requested a review from sbryngelson as a code owner June 20, 2026 01:04
@SVS87 SVS87 force-pushed the feature/icpp-patch-rotations branch 2 times, most recently from 423d5f1 to f0332b3 Compare June 20, 2026 04:47
Add a rotation framework to initial-condition (ICPP) patches, mirroring
the existing immersed-boundary rotation support.

- Extract the rotation-matrix computation into a new shared module
  m_patch_geometries, taking angle/matrix arrays as arguments so both
  ICPP and IB patches can call it (m_ib_patches now uses a thin wrapper).
- Add angles + rotation_matrix(_inverse) fields to ic_patch_parameters,
  defaulting angles to zero (identity rotation) so existing cases are
  unaffected.
- Apply the inverse-rotation transform in the rectangle inside-test as a
  proof of concept; remaining geometries are straightforward follow-up.
- Register patch_icpp(i)%angles in the parameter definitions so the angle
  is settable from a case file.
- Add a 2D_rotated_rectangle example demonstrating a 45-degree patch.
@SVS87 SVS87 force-pushed the feature/icpp-patch-rotations branch from f0332b3 to c4dea86 Compare June 20, 2026 04:51
@sbryngelson sbryngelson marked this pull request as draft June 20, 2026 05:59
@codecov

codecov Bot commented Jun 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.65517% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 60.53%. Comparing base (b4be438) to head (c4dea86).
⚠️ Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
src/common/m_patch_geometries.fpp 90.90% 0 Missing and 2 partials ⚠️
src/pre_process/m_icpp_patches.fpp 80.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1612      +/-   ##
==========================================
+ Coverage   60.51%   60.53%   +0.01%     
==========================================
  Files          83       83              
  Lines       19905    19913       +8     
  Branches     2950     2950              
==========================================
+ Hits        12046    12054       +8     
  Misses       5866     5866              
  Partials     1993     1993              

☔ 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.

@danieljvickers danieljvickers left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

These are pretty much all the same changes I would have made. Well done. Two notes before this should be merged:

  1. I assume you are still working on integrating this with all of the other icpp patch geometries. This should be integrated with all of them before this can be merged. The STL geometry will require some special attention. Just copy what is in the m_ib_patches.fpp file.
  2. The wrapper function in simulation around the s_compute_rotation_matrix subroutine is necessary. It adds nothing meaningful and should be removed.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not sure about this name, as it could get confused with IB patch code. Maybe speciify it is a fluid patch?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Changing it to 2D_rotated_fluid_rectangle. Would that work?

Comment thread src/common/m_patch_geometries.fpp Outdated
real(wp), dimension(1:3,1:3), intent(out) :: rotation_matrix
real(wp), dimension(1:3,1:3), intent(out) :: rotation_matrix_inverse
real(wp), dimension(3, 3, 3) :: rotation
real(wp) :: angle

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is there a reason to add this additional angle value?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Removed it, it was unnecessary. Updated change just uses angles(1, 2, 3) respectively

real(wp), dimension(1:3), intent(in) :: angles
real(wp), dimension(1:3,1:3), intent(out) :: rotation_matrix
real(wp), dimension(1:3,1:3), intent(out) :: rotation_matrix_inverse
real(wp), dimension(3, 3, 3) :: rotation

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Making this 3x3x3 is a nice touch

! Assign patch vars if cell is covered and patch has write permission
do j = 0, n
do i = 0, m
if (f_is_inside_cuboid(x_cc(i) - x_centroid, y_cc(j) - y_centroid, 0._wp, [length_x, length_y, 0._wp])) then

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I see where you added cuboids. I assume you are in the process of adding this to the remaining geometries? That is fine if so. It just needs to be integrated with all of them before merge.

Comment thread src/simulation/m_ib_patches.fpp Outdated
@@ -415,45 +415,10 @@ contains

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This wrapper function is now unnecessary. You should just modify the code everywhere to take the new rotation matrix subroutine and delete this subroutine all together.

SVS87 added 4 commits June 20, 2026 23:43
…ation wrapper

- Extend rotation transform to ellipse, ellipsoid, cuboid, cylinder, TaylorGreen, and STL (mirroring m_ib_patches.fpp; omits IB-only centroid_offset)
- Skip circle/sphere as rotation-invariant
- Remove unused angle variable in s_compute_rotation_matrix
- Delete s_update_ib_rotation_matrix wrapper; callers now call s_compute_rotation_matrix directly
- Rename example to 2D_rotated_fluid_rectangle to clarify it is an ICPP patch
- Add model_rotate parameter to stl_models (parallel to model_scale/model_translate), applied at model load in s_instantiate_STL_models so STL geometry rotates in world coordinates
- Wire model_rotate through derived type, defaults, MPI broadcast, and toolchain registration
- Verified: a cube rotated 45 degrees about z expands its x/y bounding box by sqrt(2) as expected
- Extend per-cell rotation to remaining ICPP geometries (ellipse, ellipsoid, cuboid, cylinder, TaylorGreen)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants