refactor: consolidate grid arrays into type(grid_axis) :: x, y, z#1430
refactor: consolidate grid arrays into type(grid_axis) :: x, y, z#1430sbryngelson wants to merge 7 commits into
Conversation
Replace flat allocatable arrays x_cb/y_cb/z_cb, x_cc/y_cc/z_cc,
and dx/dy/dz with a derived type having .cb, .cc, and .spacing
components. All three executables (pre_process, simulation,
post_process) updated across 47 files.
Key design decisions:
- pre_process keeps scalar dx/dy/dz as minimum cell-width scalars;
only x_cb and x_cc are folded into x%cb and x%cc
- OpenMP GPU target uses whole-struct declare target (x, y, z) since
component-level declare target is invalid; OpenACC uses component-level
- 2dHardcodedIC.fpp wraps dx*dy in #ifdef MFC_PRE_PROCESS for the
scalar vs per-cell context difference
Special variable collisions fixed:
- m_chemistry.fpp: local integer x/y/z -> cx/cy/cz
- m_weno.fpp: local real y(1:4) scratch -> ys
- m_viscous.fpp: local real dx(1:3) scratch -> ds
- m_ibm.fpp: local scalar dx/dy/dz -> dx_loc/dy_loc/dz_loc
- m_cbc.fpp: Fypp template d${XYZ}$ -> ${XYZ}$%spacing
Claude Code ReviewHead SHA: 64ca703 Files changed:
Findings[Correctness] Mathematical derivative notation corrupted by mechanical substitution
The rename pass substituted - ! d()/dx
+ ! d()/x%spacing
- ! S_thetatheta += rho * ( -(tau_thetatheta + 2/3*G)*(du/dx + dv/dr + v/r) + ...
+ ! S_thetatheta += rho * ( -(tau_thetatheta + 2/3*G)*(du/x%spacing + dv/dr + v/r) + ...
- ! 1D: d/dx flux only & Bx = Bx0 = const.
+ ! 1D: d/x%spacing flux only & Bx = Bx0 = const.
[Correctness] Non-uniform grid IC inconsistency in RMI case (2dHardcodedIC.fpp, hcid=208)
The PR introduces an +#ifdef MFC_PRE_PROCESS
fsm = 0.5_wp*(1.0_wp + erf(d/(ei*sqrt(dx*dy))))
+#else
+ fsm = 0.5_wp*(1.0_wp + erf(d/(ei*sqrt(x%spacing(i)*y%spacing(j)))))
+#endifIn [GPU Correctness] OpenMP
- $:GPU_DECLARE(create='[x_cb, y_cb, z_cb, x_cc, y_cc, z_cc, dx, dy, dz, dt, m, n, p]')
+#if defined(MFC_OpenACC)
+ $:GPU_DECLARE(create='[x%cb, y%cb, z%cb, x%cc, y%cc, z%cc, x%spacing, y%spacing, z%spacing, dt, m, n, p]')
+#elif defined(MFC_OpenMP)
+ $:GPU_DECLARE(create='[x, y, z, dt, m, n, p]')
+#endifThe new OpenMP |
Implements items 7 and 5 from issue #1427: - x_a/x_b/y_a/y_b/z_a/z_b -> type(bounds_info) :: x_stretch, y_stretch, z_stretch - bf_x/bf_y/bf_z + k_x/w_x/p_x/g_x (and y/z) -> type(body_force_axis) :: bf_x, bf_y, bf_z
Summary
Implements item 1 of #1427: consolidates the nine flat allocatable grid arrays into a
type(grid_axis)derived type across all three executables (47 files).Before:
After:
type grid_axis real(wp), allocatable, dimension(:) :: cb, cc, spacing end type grid_axis type(grid_axis), target :: x, y, z ! usage: x%cc(i), x%cb(i), x%spacing(i)Design decisions
pre_processretains scalardx/dy/dzas minimum cell-width values (not per-cell arrays); onlyx_cb/x_ccare folded intox%cb/x%ccx, y, z) since component-leveldeclare targetis invalid in OpenMP; OpenACC uses component-level declarations2dHardcodedIC.fppuses#ifdef MFC_PRE_PROCESSto handledx*dy(scalar min widths) vsx%spacing(i)*y%spacing(j)(per-cell) contextsVariable collisions fixed
m_chemistry.fpp: local loop integersx, y, z→cx, cy, czm_weno.fpp: local scratchy(1:4)→ysm_viscous.fpp: local scratchdx(1:3)→dsm_ibm.fpp: local cell-size scalarsdx, dy, dz→dx_loc, dy_loc, dz_locm_cbc.fpp: Fypp templated${XYZ}$→${XYZ}$%spacingTest plan
./mfc.sh precheck -j 8)./mfc.sh build -j 8 --no-mpi)