Repository navigation
Cylindrical viscous operator: 1/r of the theta divergence and hoop terms, 2D axisymmetric stress, GPU face bounds (fixes #1910) - #2515
Conversation
|
Hand test of 61627e6 on Phoenix (GT). Cylindrical/axisymmetric set: the 55 tests whose names match Cylindrical, Axisymmetric or cyl, including FB822062, 27A13E25 and the new 872A4241.
The 872A4241 golden was generated on the CPU lane above. Before the bounds fix (50fefd1), the same GPU lane failed FB822062, 27A13E25 and 872A4241. AI-assisted (Claude Code). |
|
Claude Code Review Head SHA: 61627e6 Files changed:
Summary: The PR makes four changes:
I checked each metric term, the axis-cell flux cancellation on both grid types, the GPU-bounds diagnosis and the MMS exact rates (cases A3, B3 and E2 re-derived by hand). All are consistent with the code. The one code defect is a shape mismatch in the newly reached 2D path, in AMD flang builds without case optimization. The rest are test-coverage gaps and limits that are not documented. Findings:
Coverage:
|
|
Claude Code Review Head SHA: 6acc8a9 Files changed:
Summary: The PR makes four changes to the cylindrical operator:
I checked every term against the cylindrical Navier-Stokes operator, plus the r = 0 face cancellation on both axis grids, the conduction refactor (unchanged to round-off) and the GPU-bounds diagnosis. All are correct. What remains:
Findings:
Coverage:
|
61627e6 to
67a8bc3
Compare
|
Rebased onto master 10e1299 (after #2491); head is now 67a8bc3.
AI-assisted (Claude Code). |
|
GPU rerun on the exact head 67a8bc3, i.e. on master 10e1299 after #2491's device-side time-stepping change. Phoenix gpu-rtx6000, Quadro RTX 6000 (driver 580.178.04), NVHPC 25.11 (CUDA 12.9), OpenACC, double, built fresh. Result on the same 55 cylindrical/axisymmetric tests as the CPU run: 55 passed / 0 failed. This includes 872A4241, FB822062 and 27A13E25, and the three goldens #2491 regenerated (9C9B2CBC, B85C5AB6, C0127FD0). AI-assisted (Claude Code). |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #2515 +/- ##
==========================================
- Coverage 66.59% 66.59% -0.01%
==========================================
Files 112 112
Lines 31558 31602 +44
Branches 4856 4869 +13
==========================================
+ Hits 21015 21044 +29
- Misses 6561 6566 +5
- Partials 3982 3992 +10 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…rms, 2D axisymmetric stress (fixes MFlowCode#1910) 3D cylindrical (theta = z, dz in radians): - m_rhs: the theta divergence of the viscous, conduction, species and surface-tension fluxes is (1/r) dF/dtheta (was dF/dtheta), as in the advection path; the hoop sources -tau_thth/r and +tau_rth/r carry their 1/r. - m_conduction: the theta face gradient carries one 1/r (was r^2 folded in), the divergence the other; unchanged to round-off. - m_chemistry: the theta face gradient of the species diffusion carries 1/r. Cylindrical species diffusion (2D and 3D): the radial geometric term F/r for the species rows, and the radial species divergence on the axis-BC branch, which skipped it. 2D axisymmetric viscous: the face fluxes use the cylindrical stress (div u with u_r/r), and s_compute_axisym_viscous_hoop adds -tau_thth/r. Verified against manufactured solutions (examples/3D_cyl_viscous_mms): every component converges at second order; before, the errors stay O(1) and match the defective operator. New test 3D -> Cylindrical -> Viscous -> Azimuthal.
…reports a failed run
…/isz bounds The kernel looped over its dummy bounds (m_rhs irx/iry/irz, GPU_DECLARE create, never updated to the device), so on GPUs the first face (j/k/l = -1) was skipped. The Cartesian routine already uses isx/isy/isz; the unused bounds arguments are dropped.
…dation page: GPU reproduces the CPU errors
…e radius, 2D axisymmetric radial-flow and cylindrical species-diffusion tests, species MMS cases (S2, S3), MFlowCode#2513 noted
…eal-gas fix; goldens for the four new cylindrical tests; validation page species results
6acc8a9 to
a82b66d
Compare
|
Review addressed at a82b66d, rebased onto master c158eee (#2505, #2514, #2508). The rebase had two trivial conflicts: master's E-row condition in the theta divergence, and master's new
Evidence, on the pre-rebase head 1112d3b6 (same Fortran except the rebase resolutions):
The CPU rerun of the 59 tests on a82b66d is still running; I will post its result here when it finishes. This push touches Fortran in AI-assisted (Claude Code). |
Lines of Code
|
|
CPU rerun on the pushed head a82b66d: Phoenix cpu-small, GNU 12.3 + OpenMPI 4.1.5, double, clean build. All 59 cylindrical/axisymmetric tests (including the 5 new ones) pass against the committed goldens: 59 passed / 0 failed. AI-assisted (Claude Code). |
…C central tangential velocity); their MFlowCode#2515 goldens predate it
…, TSC image points and ib_visc_compact by default (#2486) * Tests: generic configurations for degenerate tests; tolerances from measured spreads * IBM: ib_wall_order = 2 by default (1 with ib_second_order_vel) * IBM: ib_ip_interp = 2 (TSC) by default (1 with ib_second_order_vel) * Docs: TSC image points and the quadratic no-slip ghost are the defaults * Viscous IB: ib_visc_compact by default with weno_Re_flux, so the viscous flux no longer reads unfilled solid cells (#2041) * Tests: tolerances measured with the new defaults on more lanes * Tests: cold-wall twin and flux-wall tolerances from the measured GNU/GPU spread * Tests: override_tol_single for the single-precision lane; tolerances from the measured CI spread * Review: explicit IB options in the validation examples, ib_visc_compact = F tests, wording of the old defaults * Tests: regenerate the changed goldens (Phoenix, GNU 12.3, OpenMPI 4.1.5) * Format the wall_fill comment * Tests: goldens that move on the new base (09FDDC81, and the overlap-cell seam test from #2514) * Tests: C1F0BCB1 tolerance 1e-7 (GitHub ubuntu GNU differs from the Phoenix GNU golden by 4e-9 relative) * Tests: goldens that move on the new base (master 946d1e5; Tuolumne, GNU 13.3.1 CPU) * Tests: regenerate 872A4241 and F1BD319C on top of #2517 (HLLC central tangential velocity); their #2515 goldens predate it
Closes #1910
Summary
The cylindrical viscous operator was missing metric terms. In 3D cylindrical coordinates (z = theta,
dzin radians), the theta divergence of the viscous, conduction, species and surface-tension fluxes lacked a 1/r, and so did both hoop terms. The 2D axisymmetric path used the Cartesian (x, r) stress, so div u had no u_r/r term and the radial momentum had no -tau_thth/r hoop term. Cylindrical species diffusion also skipped its radial geometric term. This PR fixes all of these.It also fixes a GPU-only defect found while testing:
s_compute_cylindrical_viscous_source_fluxlooped over bounds that were never updated to the device, so on GPUs it skipped the first face of every sweep.Term-by-term map
MFC: x = axial, y = r, z = theta. tau = mu (grad u + grad u^T) + (mu_b - 2 mu/3)(div u) I.
s_compute_cylindrical_viscous_source_flux,norm_dir = 3s_compute_additional_physics_rhs,idir = 3(m_rhs.fpp)1/(dz*y_cc), as in the advection pathgrid_geometry == 3blockidir = 2+ geometric sourcem_conduction.fppm_chemistry.fppm_rhs.fppidir = 2s_compute_viscous_source_fluxnow takes the cylindrical path for anycyl_coords_compute_axisym_viscous_hoop(cell-centred gradients)GPU defect (found and fixed here)
s_compute_cylindrical_viscous_source_fluxlooped over its dummy boundsix/iy/iz. These are m_rhs'sirx/iry/irz, which areGPU_DECLARE(create)and set on the host only, so the device kernel ran with stale bounds and skipped face -1 in the sweep direction.s_compute_cartesian_viscous_source_fluxalready loops overisx/isy/isz, whichs_populate_riemann_states_variables_bufferscopies from the same bounds and updates to the device. The cylindrical routine now does the same, and the unused bounds arguments are removed froms_compute_viscous_source_fluxand its four callers.The defect was already in master's 3D cylindrical viscous path. There it skipped the x-face at j = -1 and the theta seam face at l = -1. Routing 2D axisymmetric through the same routine is what exposed it: on the GPU, FB822062 and 27A13E25 grew an axial momentum of 2.5e-11 in the first x column, where it should be exactly 0. A debug print of the x-face axial-momentum viscous flux in FB822062 (third call, k = 3, faces j = -1, 0, 1, 2):
All inputs at face -1 (u_r, its derivatives, Re) agree between CPU and GPU; that face was simply not computed. No tolerance was changed. With the fix, the GPU reproduces the CPU results.
Verification: manufactured solutions
examples/3D_cyl_viscous_mmsruns one RK3 step of a manufactured velocity field on r in [0, 2] with the axis BC and mu = mu_b = 1. The viscous rate, (q with viscosity - q without)/dt, is compared with exact sympy rates at the cell centres. Errors are max norms over the interior rings, relative to the largest exact rate. Cases: (a)u_x = A (r/R)^2 cos th; (b) Taylor-Couetteu_th = A (r + 0.5/r), exact force 0; (c) all three components with shear and bulk viscosity; (d) 2D axisymmetricu_x = A (r/R)^2,u_r = A (r/R)^3.Before the fix, the errors stay O(1) and match the rates of the defective operator. For example, case (a) gives (4 - r) mu A cos th / R^2 instead of 3 mu A cos th / R^2. Species diffusion (
--case S2,S3: h2o2 at rest, uniform T and p, unity Lewis,Y_H2 = Y0 + 1e-3 (r/R)^2, timescos thin 3D). The script compares the rate of rho Y_H2 with its exact value. That value uses rho D = k/cp from Cantera; in 2D it includes the2 r d(rho D)/drterm, because rho D follows the local composition. The errors are max norms relative to the exact mean:The N = 32 and 64 runs were repeated on this exact branch, on Phoenix:
Tests and goldens
New tests. Goldens were generated on Phoenix with GNU 12.3 + OpenMPI 4.1.5 (double, CPU), from the committed branch. Master's source, run against these goldens, fails every one of them (tolerance mismatch):
3D -> Cylindrical -> Viscous -> Azimuthal2D -> Axisymmetric -> Viscous -> Radialu_r/rin div u and the 2D hoop term-tau_thth/r(the existing 2D tests start at rest and cannot detect it)Cylindrical Species Diffusion -> 2D AxisymmetricCylindrical Species Diffusion -> 3D CylindricalCylindrical Species Diffusion -> 3D Cylindrical -> Unity Lewisexamples/3D_cyl_viscous_mmsis excluded from the example-case test, becauserun_mms.pywrites its initial state between pre_process and simulation. The tests above cover its code paths.Floating-point traps at the axis face (#2510)
The radial sweep evaluated
/r_effat the axis face, wherer_eff = y_cb(-1) = 0. That face's flux is never used, so ordinary builds were unaffected, but a trapping build stopped there. The kernel now uses a unit radius on that face. Two tests, built with GNU 12.3 on Phoenix with traps for invalid, divide-by-zero and overflow turned on afterMPI_Init(anLD_PRELOADfeenableexcept):3D -> Cylindrical -> Viscous... -> weno_Re_flux -> weno_avgThis covers the axis-face part of #2510 for these two tests; the AMD flang checked build is being handled in #2510 itself.
Review fixes
not MFC_CASE_OPTIMIZATION and USING_AMD,vel_src_inthas dimension 3. It is now assigned asvel_src_int(1:num_dims), which keeps the size-2 slice in 2D conforming.derive_rates.pyoutput path is now relative to the script.Not covered
This PR was made with Claude Code (AI).