Skip to content

2nd order IBM - #1958

Open
danieljvickers wants to merge 9 commits into
MFlowCode:masterfrom
danieljvickers:mittal-second-order-ibm-velocities
Open

danieljvickers wants to merge 9 commits into
MFlowCode:masterfrom
danieljvickers:mittal-second-order-ibm-velocities

Conversation

@danieljvickers

Copy link
Copy Markdown
Member

Description

For no-slip walls, it was observed that artifacts form on the surface of IB surfaces, which hampers the analysis of surface quantities. I have implemented the 2nd-order method of Mittal et al. (2008), which gets enabled with additional case file parameters.

Improvement

Shown is a plot of the surface quantities of a no-slip airfoil in a mach 0.3 flow with Reynolds number of 1000. On the left is the 1st order method in master, and on the right is the 2nd order method implemented here.
tool_result_3649518664051154708

@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown

Lines of Code

File Lines Diff
src/simulation/m_ibm.fpp 1850 +9
src/simulation/m_global_parameters.fpp 797 +2
src/common/m_derived_types.fpp 483 +1
Directory Lines Diff
common 10449 +1
simulation 28456 +11
total 47438 +12

@danieljvickers

Copy link
Copy Markdown
Member Author

@sbryngelson This will be ready for merge once the test suite runs again

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-14T15:34:04.023868Z 82bd69f Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 82bd69ffab

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/simulation/m_ibm.fpp
if (ib_second_order_vel) then
min_cell_width = min(dx(i), dy(j))
if (p > 0) min_cell_width = min(min_cell_width, dz(k))
ghost_points(q)%ip_dist = max(dist, ib_ip_min_dist*min_cell_width)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Carry the image distance through surface reconstruction

When ib_ip_min_dist*Δ exceeds abs(levelset) in a chemistry run with a prescribed-temperature or reacting IB, this assignment makes the gas-side image-point distance differ from the ghost-point distance, but s_ibm_correct_state still passes abs(gp%levelset) to the surface-flux solve at line 407 and s_blend_ghost_state extrapolates temperature and species with a unit distance ratio at lines 2204-2206. The resulting flux and ghost state no longer recover the requested wall state; use gp%ip_dist for IP-to-wall gradients and d_GP/d_IP for the ghost extrapolation, including the Stefan velocity. The registered second-order cases do not enable chemistry, so this accepted combination is currently unverified.

AGENTS.md reference: AGENTS.md:L5-L5

Useful? React with 👍 / 👎.

Comment thread src/simulation/m_ibm.fpp
end if

! extrapolate linearly through the boundary intercept, Mittal et al. (2008)
if (ib_second_order_vel) vel_GP = vel_GP - abs(gp%levelset)/max(gp%ip_dist, sgm_eps)*(vel_IP - vel_GP)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Use linear-exact interpolation for second-order velocity

For an image point that is not symmetrically placed among its stencil centers, vel_IP comes from s_compute_interpolation_coeffs, whose normalized 1/dist**2 weights at lines 1017-1028 do not reproduce even a linear velocity field. This new no-slip extrapolation therefore propagates an O(h) image-velocity error into the ghost value and cannot provide the advertised second-order surface velocity; use bilinear/trilinear linear-exact weights or an equivalent correction. The added Circle -> second order vel goldens use only one n=49 grid, so they cannot verify the claimed convergence order.

AGENTS.md reference: AGENTS.md:L5-L5

Useful? React with 👍 / 👎.

Comment thread src/simulation/m_ibm.fpp
end if

! extrapolate linearly through the boundary intercept, Mittal et al. (2008)
if (ib_second_order_vel) vel_GP = vel_GP - abs(gp%levelset)/max(gp%ip_dist, sgm_eps)*(vel_IP - vel_GP)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Evaluate rotating wall velocity at the boundary intercept

When ib_second_order_vel is used on a rotating no-slip moving IB (angular_vel != 0), the value in vel_GP before this line is the rigid-body velocity at the ghost center because radial_vector is built from physical_loc at lines 485-492. This extrapolation treats that value as u_BI, so it enforces Ω×(x_GP-C) at the intercept instead of Ω×(x_BI-C), leaving an O(h) tangential slip; build the rotation velocity from the boundary-intercept location before extrapolating. The registered second-order test leaves the body static, so this path is unverified.

AGENTS.md reference: AGENTS.md:L5-L5

Useful? React with 👍 / 👎.

@github-actions

Copy link
Copy Markdown

Claude Code Review

Head SHA: 82bd69f

Files changed:

  • 10
  • docs/documentation/case.md
  • examples/2D_ibm_second_order_airfoil/case.py
  • src/common/m_derived_types.fpp
  • src/simulation/m_global_parameters.fpp
  • src/simulation/m_ibm.fpp
  • toolchain/mfc/case_validator.py
  • toolchain/mfc/params/definitions.py
  • toolchain/mfc/params/descriptions.py
  • toolchain/mfc/params/generators/fortran_gen.py

Findings:

  • medium examples/2D_ibm_second_order_airfoil/case.py: The docstring says "Env: RE, T_STOP, T_SAVE, SECOND_ORDER=1 (PR branch only ...)", but only RE is read. t_stop and t_save are hard-coded (6.0 and 0.2), and ib_second_order_vel is always enabled through case.update(...) at the end. The comment also refers to a "PR branch", which will be meaningless after merge. Fix: drop the unused env names and the PR-branch wording, or implement them.
  • medium src/simulation/m_ibm.fpp: In s_compute_ghost_point_velocity the extrapolation is vel_GP - |levelset|/max(ip_dist, sgm_eps)*(vel_IP - vel_GP). It is correct only if vel_GP holds the wall (boundary-intercept) velocity at that point. I could not open the full m_ibm.fpp (it is not in the context directory). The diff shows vel_GP being modified by the blowing term just above. Please confirm that the extrapolation applies to the slip case (normal component only, as the docs claim) and that vel_GP is the BI velocity in every branch. Confidence: low to moderate, because I could not see the surrounding code.

Checked in step 4 (partial): fortran_gen.py and m_global_parameters.fpp (the new parameters are in SIM_GPU_DECL_VARS and initialised to defaults). The m_ibm.fpp hunks (ip_dist, the pressure GP formula and the image-point location) are consistent with each other and reduce to the old 2*dist behaviour when ib_second_order_vel is off.

@codecov

codecov Bot commented Oct 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 81.81818% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 61.90%. Comparing base (a6add01) to head (82bd69f).
⚠️ Report is 16 commits behind head on master.

Files with missing lines Patch % Lines
src/simulation/m_ibm.fpp 77.77% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1958      +/-   ##
==========================================
+ Coverage   61.75%   61.90%   +0.14%     
==========================================
  Files          86       86              
  Lines       22787    22893     +106     
  Branches     3357     3372      +15     
==========================================
+ Hits        14073    14172      +99     
+ Misses       6225     6221       -4     
- Partials     2489     2500      +11     

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

BCKim55 added a commit to BCKim55/MFC_BCKim that referenced this pull request Oct 16, 2026
…(upstream PR MFlowCode#1958, 82bd69f)

Re-applies Dan Vickers' PR MFlowCode#1958 unchanged on top of sync-upstream, where buried image points are already handled by upstream MFlowCode#1792 (interp_valid + averaging over corrected ghost points), so the local guard of fb84365 is no longer needed. The single-gas isothermal reflection uses the same d_GP/d_IP ratio so ib_ip_min_dist keeps the wall temperature consistent.
@sbryngelson

Copy link
Copy Markdown
Member

can you make a convergence plot for a curved interface (sphere/torus) and show 2nd order convergence of face and face flux values? that's what really validates the implementation (not smoother airfoil surfaces)

sbryngelson added a commit to sbryngelson/MFC that referenced this pull request Oct 18, 2026
…image-point distance (ib_ip_min_dist)

Two new settings; the defaults (ib_ip_interp = 1, ib_ip_min_dist = 0) leave every existing case unchanged.

ib_ip_interp = 2 interpolates the image-point state with triangular-shaped-cloud (quadratic B-spline) weights on the 3x3(x3)
cells around the nearest cell (Ezra, Peles & Kozak 2025, Int. J. Heat Mass Transf. 252:127314) instead of inverse-distance
weights over 2x2(x2). The kernel is a partition of unity and smooth across cell boundaries, so the interpolation error that
limits wall-flux convergence drops by an order; the weights use the fractional position at integer offsets, so they stay
exact on a stretched grid. Solid cells in the stencil carry the ghost values of the last correction (staged, MFlowCode#1901); a point
buried in a body gets no fluid weight and takes the neighbour average as before. The stencil is clamped to the halo.

ib_ip_min_dist holds the image point at least that many cell widths (along the normal) off the wall so its stencil clears the
body; the rule of MFlowCode#1958, which is still open, so expect a conflict when that lands.

The ghost point now stores the stencil's lower corner and a 3x3x3 coefficient array; the consumer loops over ib_ip_width
cells, which is 2 for inverse distance, so the default path does the same arithmetic as before.

Tests: eight new cases (Circle and Sphere with each option, plus viscous TSC). IBM suite on CPU and GPU: 77 passed, and the same
five tests fail as on the unmodified base d48284f (B7A6CC79 B0CE19C5 0387594F F2F0B673 4646053A).
sbryngelson added a commit to sbryngelson/MFC that referenced this pull request Oct 18, 2026
Reconciled with the campaign's image-point work: ib_ip_min_dist and ip_dist already existed, so the PR's duplicate registrations and field are dropped,
ib_ip_dmin is replaced by the PR's ib_second_order_vel/ib_ip_min_dist (min(dx,dy,dz) width; equal to the normal-projected width on uniform grids),
and the PR's explicit velocity extrapolation is omitted because the ghost velocity already extrapolates through the intercept (theta = |levelset|/d).
sbryngelson added a commit to sbryngelson/MFC that referenced this pull request Oct 18, 2026
…he campaign's image-point sample distance

Differences from the PR's goldens are at most 2.2e-5 absolute (6.7% relative in a small field): the campaign sets ip_dist to the actual sampled distance after interpolation.

This branch has not been deployed

No deployments
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.

4 participants