Skip to content

IBM: opt-in sub-grid wall conduction column for isothermal walls (patch_ib%wall_column) - #2329

Merged
sbryngelson merged 4 commits into
MFlowCode:masterfrom
sbryngelson:ib-wall-conduction-column
Nov 22, 2026
Merged

sbryngelson merged 4 commits into
MFlowCode:masterfrom
sbryngelson:ib-wall-conduction-column

Conversation

@sbryngelson

Copy link
Copy Markdown
Member

Follow-up to #2248 (merged): one commit on current master. No existing golden moves with the option off.

Summary

At an isothermal immersed wall the ghost carries a linear-mirror conduction temperature, so the wall heat flux the gas sees is at most about 2 lambda dT / h. When the thermal layer is thinner than a cell (a cold body in hot gas at low resolution) the body takes up far too little heat. This adds an opt-in sub-grid model:

  • patch_ib(i)%wall_column (new m_ib_wall_column). Each first-layer ghost of a fixed, inert, thermal_bc = 1 circle or sphere carries a 1D low-Mach conduction column along the wall normal: 96 stretched cells from the wall (Twall) to max(3h, wall_column_len) (default 0.15 R), curvature, frozen composition, per-step lambda(T) and c_p(T) tables, 16 L-stable SDIRK2 substeps per flow step. The column's top state comes from the gas through a Lagrange probe (s_lag3_weights). It advances once per step, from the state of the first stage.
  • Coupling. The column's step-mean wall flux enters the gas as the ghost's conduction temperature (the quantity IBM: wall conduction through the unbounded mirror temperature for chemistry walls #2248 introduced), chosen so the gas faces carry that flux with the diffusion flux's own face conductivity and the steady radial weight of each face. A one-sided guard cuts the drain of a gas cell colder than the column averaged over its own area (zero in steady state). With ib_heat_wrt the body books the column's flux, that is the gas faces' flux plus the guard's cut.
  • wall_column_dt_frac (default 0.1) adds a time-step candidate WCOL: a step's column drain may take at most this fraction of a near-wall cell's heat span. At a step start the column's flux is the singular one, and without the limit an impulsively started flow emptied a near-wall cell in one stage.
  • Validator: needs chemistry, chem_params%diffusion, chem_params%transport_model = 1, thermal_bc = 1, surface_reaction = 0, a circle or sphere, every body fixed, no AMR, and cfl_adap_dt or cfl_const_dt. Documentation in case.md; parameters registered in definitions.py and descriptions.py. Default off.

Evidence

Case: the cold cylinder of #2248 (thermal_bc = 1, Twall = 300 K, R = 1 mm, quiescent 1500 K air, 11-species mechanism, diffusion on, reactions off, inviscid, closed box of half-width 3R), heat taken by the body per unit depth, the time integral of ib_heat_wrt column 5, at t = 0.02 and 0.1 R^2/alpha (alpha of the 1500 K gas).

Reference (independent of MFC). A separate 1D radial solver: variable-property low-Mach conduction about the cylinder, rho c_p (T_t + u T_r) = (1/r)(r lambda T_r)_r + p_t, div u = (1/r)(r lambda T_r)_r/(rho c_p T) - p_t/(gamma p), u = 0 at the wall and at the outer wall of an annulus of the box's gas area (this fixes p(t); p falls to 0.965 p0 at 0.02 and 0.920 p0 at 0.1), lambda(T) and c_p(T) from Cantera for the same composition, BDF in time on 312 stretched cells (unchanged to 3e-5 under doubling). Reference heat: 0.36600 J/m at 0.02, 0.82807 J/m at 0.1. Without the pressure fall the 1D value is 0.3725 (+1.8 %), so the box matters at that level. The 2D runs of #2248 at 128 cells/R (0.3611 master, 0.3641 branch) are within 1.3 % and 0.5 % of it. The 1D script, the cylinder case file and the table scripts are not part of the diff; I can add them if wanted.

All 2D runs: A100, nvfortran 25.11, OpenACC, 1 rank, wall column off (this is #2248; the off column reproduces the values in its table) and on.

Heat the body books, t = 0.02 R^2/alpha (error against 0.3660 J/m):

cells / R off [J/m] off error on [J/m] on error
6 0.2361 -35.5 % 0.3775 +3.1 %
8 0.2378 -35.0 % 0.3780 +3.3 %
12 0.3101 -15.3 % 0.3769 +3.0 %
16 0.3057 -16.5 % 0.3753 +2.6 %
24 0.3445 -5.9 % 0.3736 +2.1 %
32 0.3387 -7.5 % 0.3729 +1.9 %
48 0.3577 -2.3 % 0.3720 +1.6 %
64 0.3527 -3.6 % 0.3713 +1.4 %

t = 0.1 R^2/alpha (reference 0.8281 J/m):

cells / R off [J/m] off error on [J/m] on error
8 0.6848 -17.3 % 0.8583 +3.6 %
16 0.7709 -6.9 % 0.8434 +1.9 %
32 0.8029 -3.0 % 0.8417 +1.6 %
64 0.8150 -1.6 % 0.8397 +1.4 %

With the column the booked heat is within 3.6 % of the reference from 6 cells/R up, and the error falls slowly from there; without it #2248 needs 64 cells/R to be within 3.6 %. The column overshoots by a nearly resolution-independent 1.4-3 % that I did not trace to a cause (the reference is not the limit: the off runs approach it from below).

What the gas gives up is a different number. The booked heat includes the guard's cut, heat the column takes from the wall side but the gas cells are not drained of. Without that term the body books what the gas faces carry, which is the gas's energy loss in this closed box. I measured that on the same case before adding the cut to the booking (same dynamics, only the booking differs; t = 0.02):

cells / R gas loses [J/m] error booked [J/m] cut share of booked
6 0.3473 -5.1 % 0.3775 8 %
8 0.3021 -17.4 % 0.3780 20 %
12 0.3533 -3.5 % 0.3769 6 %
16 0.3348 -8.5 % 0.3753 11 %
24 0.3570 -2.5 % 0.3736 4 %
32 0.3503 -4.3 % 0.3729 6 %

The gas-side error is smaller than #2248's at every resolution (it is about what #2248 reaches at twice the resolution: -8.5 % at 16 against -7.5 % at 32) but it is not monotone in resolution (n = 8 is worse than n = 6 and 12), so the part of the gain that reaches the gas field is modest and grid dependent. The gain is mainly in the wall heat that is reported (ib_heat), which is what a Nusselt number or a heat-load diagnostic uses; the gas near the wall is still left somewhat too warm at coarse resolution. The column length does not matter: at 16 cells/R a 0.3 R column gives 0.3341 against 0.3348 for the default (gas side).

Two ranks (the body straddles the rank boundary), 16 cells/R: the booked heat is the same as on one rank to all printed digits (0.37534 J/m, 1493 steps on both); at 32 cells/R two ranks give 0.37291 J/m in 2992 steps, the one-rank value. The two new tests at 60 x 60 cells on one and two ranks: the same step count (62 and 342) and the same booked heat to ten digits, with the columns of ib_heat.dat differing by at most 3e-10 relative.

Cost (A100, 64 cells/R, 384 x 384, 1194-1218 steps, 3 repeats each): ns/gp/eq/rhs 1.772 / 1.772 / 1.775 off, 1.802 / 1.802 / 1.798 on (+1.6 %). That metric is the minimum stage time, which excludes the stage that advances the columns; the wall time per step is 12.8-13.0 ms off and 21.3 ms on (three repeats), +65 % at this grid size. The columns are advanced one ghost per thread, so the added time (about 8 ms per step) depends on the ghost count, not on the grid; it is a smaller fraction on a larger grid or one with fewer ghosts.

Tests

After the rebase onto current master (b08da8d) and the column-ghost compaction (see Scaling): Cray CCE (ftn) CPU build with MPI, 1 rank, no GPU: 48CC6F65 and DF9526DB pass against their committed goldens (generated on the A100, unchanged), so the compaction does not change the results. ./mfc.sh format and ./mfc.sh precheck pass. The A100 and MI300A results below were obtained before the rebase and before the compaction and were not rerun; the CI of this PR (GitHub GNU/Intel/macOS, NVHPC, Frontier CCE and AMD) and the Phoenix NVIDIA-GPU run (ci:phoenix) cover the rebased code.

./mfc.sh format and ./mfc.sh precheck pass. Before the rebase, labels run separately, --no-build after a dry-run build, A100 (nvhpc 25.11, OpenACC) and MI300A (amdflang, OpenMP offload):

Label A100 MI300A
IBM (existing goldens, option off) 112 / 112 pass 112 / 112 pass
Chemistry (51 tests, new ones included) 50 pass, 1 fail 50 pass, 1 fail

The IBM label does not contain the new tests (their names say "IBM Reacting Surface", not "IBM"); they carry the Chemistry label. The failure:

Scaling

The column state is stored only for the first-layer ghosts of wall_column bodies (wc_gp(c) lists their indices into ghost_points; setup counts them once). A ghost of a body without the option holds nothing, and a run without the option allocates one-element arrays.

  • Memory: 936 B per column ghost (96 temperatures, three 6-face arrays, flux, guard and state), none for other ghosts. For example 1e3 ghosts per body gives about 0.9 MB per column body: 1e4 column bodies 9.4 GB in total, 1e5 column bodies 94 GB in total, spread over the ranks that own them (the same per-rank figure as the bodies' share of the domain). Before this form every ghost of the rank held the columns, whether or not its body had one.
  • Per step: the column advance, the conduction-temperature update and the time-step limit loop over the rank's column ghosts only; nothing is proportional to the global body count. The booked guard heat goes into the sharded ib_part sums that master's ib_heat uses (no single-address atomic).
  • Limitation for particle clouds: the validator allows only fixed circles and spheres with thermal_bc = 1, so moving or mixed-body clouds cannot use the column. A cloud of 1e5 fixed isothermal spheres can, and then pays the memory above.
  • The column advance is one ghost per thread with a few kilobytes of private arrays, so its per-step cost scales with the column ghosts per GPU, not with the body count. The measured case (about 1e3 column ghosts) adds about 8 ms per step on an A100; that was measured before the compaction and is not remeasured here.

GPU notes

All new kernels follow the patterns in gpuParallelization.md: element and component stores only (wc_T(k, i), wc_q(i), ghost_points(i)%T_cond), no whole-array stores into ghost_points; the 1D solve is a seq routine on tabulated lambda(T) and c_p(T), and the thermochemistry calls (get_mixture_*) are made from the kernel bodies, not from a GPU_ROUTINE; private arrays are sized by constants and num_species through the usual fypp bound; the time-step limit is a min reduction. Each thread holds a few kilobytes of private arrays.

Limitations and not run

  • Not run: Cray CCE, GNU, Intel, CPU builds, more than two ranks, 3D (the sphere path is written and unrun), restart (columns start from the gas field at the first step of every run, restarts included), combination with ib_flux_wall.
  • Not supported (prohibited by the validator): moving bodies, AMR, thermal_bc other than 1, surface reactions, transport models other than mixture-averaged.
  • ib_heat under the option is the column's flux, which is not the energy the gas lost (table above, 4-20 % at the resolutions shown). Lumped walls (thermal_bc = 3) are excluded for that reason.
  • The guard strength (4) and the column size (96 cells, ratio 1.08, 16 substeps, 8 property-table points) are fixed constants I did not tune.
  • The demonstration is one geometry and one temperature ratio against a 1D reference whose pressure model is global; the +1.4-3 % overshoot is unexplained.

This PR was made with Claude Code (AI).

@sbryngelson sbryngelson added the ci:phoenix Run the Phoenix (NVHPC GPU) jobs on this PR; push after adding label Nov 19, 2026
@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Claude Code Review

Head SHA: 01a90a6

Files changed:

  • 16
  • docs/documentation/case.md
  • docs/module_categories.json
  • src/common/m_derived_types.fpp
  • src/pre_process/m_global_parameters.fpp
  • src/simulation/m_global_parameters.fpp
  • src/simulation/m_ib_wall_column.fpp
  • src/simulation/m_ibm.fpp
  • src/simulation/m_mpi_proxy.fpp
  • src/simulation/m_sim_helpers.fpp
  • src/simulation/m_start_up.fpp

Findings:

  • medium toolchain/mfc/case_validator.py: the range check not 0 < (self.get("wall_column_dt_frac", 0.1) or 0.1) <= 1 turns an explicit wall_column_dt_frac = 0.0 into 0.1 through or 0.1, so the validator accepts it. Fortran reads the 0.0 as given. f_wall_column_dt then returns lim = frac*... = 0 and dt = minval(dt_candidates_glb) becomes 0, so the run stalls or aborts at the dt floor. Use self.get("wall_column_dt_frac", 0.1), falling back to 0.1 only when the value is None, so that 0 is rejected. Confidence: high that the validator accepts 0. The runtime consequence is inferred from the hunk.
  • medium src/simulation/m_ibm.fpp (f_wall_column_dt): with cfl_const_dt, s_perform_time_step calls s_compute_dt only at t_step == 0, when wc_ready is false. The limit then comes from the semi-infinite-start estimate and is frozen into the constant dt for the whole run. The validator accepts cfl_const_dt and the docs describe WCOL as a per-step limit using "the last step's flux", which does not hold in this mode. The estimate is conservative, so this is not a correctness failure. It may make a constant-dt run far smaller than needed, and the docs should say so. Confidence: medium.
  • medium src/simulation/m_ibm.fpp (s_wall_column_setup, finalize): n_wc and wc_ready are not reset in finalize, and wc_slot is freed in setup while its GPU_DECLARE stays. If setup or finalize ever runs twice in one process (for example a test harness, or a restart that re-runs s_ibm_setup), wc_ready stays true and the next run skips the column initialization from the gas. Reset both in finalize. Confidence: low to medium; I did not find a second caller.

@sbryngelson
sbryngelson force-pushed the ib-wall-conduction-column branch from 38a9e6e to 01a90a6 Compare November 19, 2026 17:42
@sbryngelson
sbryngelson marked this pull request as ready for review November 19, 2026 19:46
@sbryngelson
sbryngelson requested a review from a team as a code owner November 19, 2026 19:46
@sbryngelson
sbryngelson requested review from danieljvickers and removed request for a team November 19, 2026 19:46
@codecov

codecov Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 81.46214% with 71 lines in your changes missing coverage. Please review.
✅ Project coverage is 65.99%. Comparing base (4264341) to head (b338d6a).
⚠️ Report is 26 commits behind head on master.

Files with missing lines Patch % Lines
src/simulation/m_ibm.fpp 78.71% 24 Missing and 29 partials ⚠️
src/simulation/m_ib_wall_column.fpp 87.60% 3 Missing and 12 partials ⚠️
src/simulation/m_time_steppers.fpp 40.00% 0 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2329      +/-   ##
==========================================
+ Coverage   65.72%   65.99%   +0.27%     
==========================================
  Files         111      112       +1     
  Lines       30549    31064     +515     
  Branches     4673     4748      +75     
==========================================
+ Hits        20079    20502     +423     
- Misses       6699     6716      +17     
- Partials     3771     3846      +75     

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

…ch_ib%wall_column)

Each first-layer ghost of a fixed, inert, thermal_bc = 1 circle or sphere carries a 1D low-Mach
conduction column along the wall normal (m_ib_wall_column), advanced once per step; its step-mean
wall flux enters the gas as the ghost's conduction temperature, with a one-sided drain guard and a
Lagrange column-top probe. wall_column_dt_frac adds a time-step limit (WCOL). With ib_heat_wrt the
body books the column's flux. Off by default: no existing golden moves. Two new chemistry tests
with goldens generated on an A100 (nvhpc) and checked on an MI300A (amdflang).
@sbryngelson
sbryngelson force-pushed the ib-wall-conduction-column branch from 895ac8e to 7a6db65 Compare November 20, 2026 14:35
@sbryngelson

Copy link
Copy Markdown
Member Author

CI follow-up for the one failing lane (Intel ifx, release, CPU): test DF9526DB (Wall Column -> Time-Step Limit).

Lane / run vs golden (generated on NVHPC A100)
Intel release (CI) fails at 1e-4: max abs 1.54e-4, max rel 7.7e-4 (near-zero entry), first failing entry 1.08e-4 abs
Intel reldebug, GNU (ubuntu, macOS; release and reldebug), NVHPC 25.5 (cpu, gpu-acc, gpu-omp), NVHPC 26.9 gpu-omp pass at 1e-4
CCE 20 CPU, 1 rank (hand run, Tuolumne) max abs 1.2e-5 (energy), max rel 1.5e-10

Sensitivity (CCE CPU, same case): a 1e-12 relative change of the freestream velocity changes the output by under the 7-digit output resolution (<1e-7), so roundoff is not amplified much. A 0.1 % change of wall_column_dt_frac moves a momentum entry by 1.6e-3 abs, i.e. with the limit binding the end state follows the step sequence to first order.

Change: override_tol for this test 1e-4 -> 1e-3 (cases.py comment states the spread). The golden is not regenerated and no other test is touched. The 1e-3 band still separates the limit being active (0.1 % in step gives ~1e-3) from it being off (default fraction 0.1, O(1) change).

Not verified: the cause of the Intel difference. A 1.5e-4 gap implies a step-sequence difference of about 1e-4 relative on Intel release, which pure roundoff does not explain given the measurement above; I had no ifx to reproduce it, and did not get a debug/fastmath CCE comparison (the build did not configure). Pure roundoff amplified by the chemistry is not supported by the data; a compiler-specific code path in the limiter remains possible. Frontier and remaining NVHPC 26.9 cpu lanes were still pending when this was written.

This PR was made with Claude Code (AI).

@sbryngelson

Copy link
Copy Markdown
Member Author

Merged current master into this branch (head 900327e, normal merge commit).

  • Conflict: src/simulation/m_time_steppers.fpp, at the ghost-correction call. Resolved by keeping master's new AMR-level argument on s_ibm_correct_state and the wall-column advance/conduction-temperature calls after it. The time-step limit call merged without conflict.
  • Checked for semantic conflicts git does not flag: the other s_ibm_correct_state caller (AMR) already passes the new argument, and the patch_ib(1:num_ibs) GPU updates are already in the slice form.
  • Hardening: in s_accumulate_ib_face_fluxes, the wall-column heat-booking loop assigned its private scalars only under an if, which NVHPC GPU builds can leave undefined. They are now assigned unconditionally, and only the atomic update stays conditional. Other new kernels assign privates unconditionally or after a guarding cycle.
  • Local checks: precheck passes.

MI300A and A100 runs of the wall-column and IBM tests are pending; results will follow here.

This PR was made with Claude Code (AI).

@sbryngelson

Copy link
Copy Markdown
Member Author

NVIDIA hand test of this head (900327ece): NVIDIA A100 80GB (Georgia Tech wingtip), NVHPC 25.5, OpenACC (--gpu acc), CI-style fat build (cc70,75,80,89,90), --max-attempts 1.

Mapping Tests Result
one GPU (-g 0) 17 wall-column and reacting-surface tests 17 passed, 0 failed
two GPUs (-g 0 1) same 17 17 passed, 0 failed

The set is the wall-column tests (including DF9526DB and 48CC6F65) and the other reacting-surface tests (surface output, thermal layer, flux wall, heat output, lumped wall, thermostat). DF9526DB passed within its 1e-3 tolerance. The runs also had the fix from #2371 (device num_procs/proc_rank updated after the rank is bound to its GPU) applied locally, because 2-rank GPU tests with the ranks on two GPUs are affected by the bug it fixes.

Not run: AMD (the Frontier CI lanes are the AMD check), the OpenMP offload path on NVIDIA, and H100/H200.

AI-assisted (Claude Code).

@github-actions

Copy link
Copy Markdown

Lines of Code

File Lines Diff
src/simulation/m_ibm.fpp 4269 +411
src/simulation/m_ib_wall_column.fpp 224 +224
src/simulation/m_time_steppers.fpp 1020 +6
src/simulation/m_global_parameters.fpp 965 +3
src/common/m_derived_types.fpp 553 +2
src/pre_process/m_global_parameters.fpp 407 +2
src/simulation/m_mpi_proxy.fpp 451 +2
src/simulation/m_start_up.fpp 1537 +2
Directory Lines Diff
common 12520 +2
pre_process 3718 +2
simulation 41817 +648
total 61891 +652

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:phoenix Run the Phoenix (NVHPC GPU) jobs on this PR; push after adding

Development

Successfully merging this pull request may close these issues.

1 participant