Skip to content

Unify geometry IDs for Immersed Boundaries and ICPP Fixes #1543#1547

Open
Riship749 wants to merge 1 commit into
MFlowCode:masterfrom
Riship749:master
Open

Unify geometry IDs for Immersed Boundaries and ICPP Fixes #1543#1547
Riship749 wants to merge 1 commit into
MFlowCode:masterfrom
Riship749:master

Conversation

@Riship749

Copy link
Copy Markdown

This PR unifies the redundant 2D and 3D geometry integers into single, dimension-agnostic IDs within the pre-processor for both patch_ib and patch_icpp.

Changes:

  • Merged Rectangles (3) and Cuboids (9) -> ID 3.
  • Merged 2D Airfoils (4) and 3D Airfoils (11) -> ID 4.
  • Merged Circles (2), Spheres (8), and Cylinders (10) -> ID 2.

The unified subroutines now dynamically check for 3D constraints (e.g., Z-centroids and Z-lengths) using the p > 0 condition. Legacy compatibility is maintained by routing the old 3D IDs directly to the newly unified subroutines. Obsolete 3D-specific subroutines have been removed to reduce code duplication.

Testing:
Compiled successfully locally and passed the full ./mfc.sh test regression suite.

Fixes #1543

@Riship749 Riship749 requested a review from sbryngelson as a code owner June 9, 2026 18:45

@sbryngelson sbryngelson 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.

Nice dedup direction — collapsing the near-identical 2D/3D check subroutines is worthwhile. But the unification is applied to the validation layer only, while patch generation (m_icpp_patches.fpp, IB equivalent) still dispatches on the original IDs (2/3/8/9/10/11). That mismatch turns several of the simplified checks into silent validation gaps:

  1. 3D IDs no longer rejected in lower-D runs — the original p == 0 prohibits on sphere/cuboid/cylinder/3D-airfoil are gone, so e.g. geometry = 8 in a 2D case passes validation but hits the 3D generator.
  2. ICPP circle dropped its n == 0 guard — a circle in a 1D run is now accepted (IB + rectangle checks still keep this guard, so it looks accidental).
  3. Cylinder length validation weakened — gating "exactly one length" behind "any length > 0" lets a no-length or negative-length cylinder through.

Details inline. The "compiles + ./mfc.sh test passes" result is expected — these are all gaps in rejecting bad input, which a suite of valid cases won't exercise. Worth adding (or confirming) a case that feeds a 3D ID into a 2D run.

Smaller nits (typos / missing space in messages) also inline.

if (patch_icpp(i)%geometry == 1) then
call s_check_line_segment_patch_geometry(i)
else if (patch_icpp(i)%geometry == 2) then
else if (patch_icpp(i)%geometry == 2 .or. patch_icpp(i)%geometry == 8 .or. patch_icpp(i)%geometry == 10) 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.

Dimensionality guards for 3D IDs are dropped (high). Each original check rejected the wrong-dimension case: sphere/cuboid/cylinder all had p == 0 prohibits, and 2D circle/rectangle had p > 0 prohibits. The unified checks only add constraints under if (p > 0) and never reject p == 0.

Crucially, generation was not unifiedm_icpp_patches.fpp:64-73 still dispatches geometry == 8/9/10/11 to the dedicated 3D generators, and :101-104 still generates a 2D circle/rectangle for geometry == 2/3. So:

  • geometry = 8 (sphere) in a 2D run (p == 0) now passes validation as a "circle", then runs the 3D sphere generator on a 2D grid → garbage/OOB instead of the old clear error.
  • geometry = 2 (circle) in 3D passes the new sphere-style validation (requires z_centroid) but still generates a flat 2D circle — so the intended "ID 2 = circle-or-sphere" merge doesn't actually work end-to-end.

Either keep rejecting mismatched dimension/ID combos, or unify generation too so the dimension-agnostic ID picks the generator from p. Right now it's neither.

@:PROHIBIT(f_is_default(patch_icpp(patch_id)%y_centroid), "Circle patch "//trim(iStr)//": y_centroid must be set")
! Core checks for all (Circle, Sphere, Cylinder)
@:PROHIBIT(f_is_default(patch_icpp(patch_id)%x_centroid), &
& "Circle/Sphere/Cylinder patch "//trim(iStr)//": x_centroid must be set")

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.

The n == 0 guard was dropped (high). The old circle check had @:PROHIBIT(n == 0, "Circle patch ...: n must be zero"), but it's gone here. A circle (geometry = 2) in a 1D run (n == 0) is now accepted and then generated on a 1D grid.

This looks accidental rather than intended: the IB circle check (m_check_ib_patches.fpp:75) and the rectangle check below (:174) both still keep their n-guard. Please re-add @:PROHIBIT(n == 0, ...) here.

Comment on lines +157 to +158
! If any extrusion length is set, it's a Cylinder. Verify exactly ONE length axis is defined.
if (patch_icpp(patch_id)%length_x > 0._wp .or. patch_icpp(patch_id)%length_y > 0._wp &

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.

Cylinder length validation is weakened (medium). The old s_check_cylinder_patch_geometry required count([length_x>0, length_y>0, length_z>0]) == 1 (exactly one length), plus a positivity check on any defined length. Gating the check behind if (length_x > 0 .or. length_y > 0 .or. length_z > 0) loses two cases:

  • No length set: a cylinder (geometry = 10) with all lengths default passes here as a "sphere", but generation still runs the cylinder generator with the default length -1e6.
  • Explicit non-positive length: length_x = -5 (or 0) makes the trigger false, so all length validation is skipped — the old code caught .not. f_is_default(length_x) .and. length_x <= 0.

Suggest restoring the original count(...) == 1 form (it's clearer than the copied nested f_is_default expression) and re-adding the positivity check. Same applies to the IB copy of this block.


! Constraints on the geometric initial condition patch parameters
if (patch_ib(i)%geometry == 2) then
if (patch_ib(i)%geometry == 2 .or. patch_ib(i)%geometry == 8 .or. patch_ib(i)%geometry == 10) 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.

Same dimensionality-guard concern as the ICPP file applies here: the old sphere/cuboid/cylinder/3D-airfoil IB checks each rejected p == 0, and that rejection is gone in the unified subroutines. A 3D IB ID (8/9/10/11) used in a 2D run now passes validation but is generated by the corresponding 3D IB generator. Please confirm the intended dimensional contract and reject mismatches (or unify generation accordingly).

Comment on lines +75 to +76
@:PROHIBIT(n == 0 .or. patch_ib(patch_id)%radius <= 0._wp .or. f_is_default(patch_ib(patch_id)%x_centroid) &
& .or. f_is_default(patch_ib(patch_id)%y_centroid), 'in circle/cylilder/sphere IB patch ' // trim(iStr))

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.

Nit: typos in the error messages — cylilder here, and cyilinder on line 80 (plus the related cyilders comment). Also line 80 is missing a space before trim(iStr): 'in 3D sphere/cyilinder IB patch' //trim(iStr) renders as ...IB patch3. Add a trailing space inside the string.

@danieljvickers danieljvickers mentioned this pull request Jun 9, 2026
4 tasks
@codecov

codecov Bot commented Jun 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 19.04762% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 60.57%. Comparing base (1f02a6f) to head (6f9ba91).
⚠️ Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
src/pre_process/m_check_ib_patches.fpp 15.38% 7 Missing and 4 partials ⚠️
src/pre_process/m_check_patches.fpp 25.00% 5 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1547      +/-   ##
==========================================
- Coverage   60.57%   60.57%   -0.01%     
==========================================
  Files          73       73              
  Lines       20264    20230      -34     
  Branches     2949     2954       +5     
==========================================
- Hits        12275    12254      -21     
+ Misses       6000     5983      -17     
- Partials     1989     1993       +4     

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

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.

Unify 2D and 3D Patch Geometries

2 participants