Unify geometry IDs for Immersed Boundaries and ICPP Fixes #1543#1547
Unify geometry IDs for Immersed Boundaries and ICPP Fixes #1543#1547Riship749 wants to merge 1 commit into
Conversation
sbryngelson
left a comment
There was a problem hiding this comment.
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:
- 3D IDs no longer rejected in lower-D runs — the original
p == 0prohibits on sphere/cuboid/cylinder/3D-airfoil are gone, so e.g.geometry = 8in a 2D case passes validation but hits the 3D generator. - ICPP circle dropped its
n == 0guard — a circle in a 1D run is now accepted (IB + rectangle checks still keep this guard, so it looks accidental). - 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 |
There was a problem hiding this comment.
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 unified — m_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 (requiresz_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") |
There was a problem hiding this comment.
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.
| ! 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 & |
There was a problem hiding this comment.
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(or0) 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 |
There was a problem hiding this comment.
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).
| @: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)) |
There was a problem hiding this comment.
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.
Codecov Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
This PR unifies the redundant 2D and 3D geometry integers into single, dimension-agnostic IDs within the pre-processor for both
patch_ibandpatch_icpp.Changes:
The unified subroutines now dynamically check for 3D constraints (e.g., Z-centroids and Z-lengths) using the
p > 0condition. 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 testregression suite.Fixes #1543