Skip to content

refactor: consolidate grid, stretch, and body force params into derived types#1432

Open
sbryngelson wants to merge 12 commits into
masterfrom
refactor/derived-types
Open

refactor: consolidate grid, stretch, and body force params into derived types#1432
sbryngelson wants to merge 12 commits into
masterfrom
refactor/derived-types

Conversation

@sbryngelson
Copy link
Copy Markdown
Member

Summary

  • Consolidates grid coordinate arrays (x_cc, x_cb, x_cb_s and y/z equivalents) into type(grid_axis) :: x, y, z
  • Consolidates grid stretching reference points (x_a/x_b, y_a/y_b, z_a/z_b) into type(bounds_info) :: x_stretch, y_stretch, z_stretch
  • Consolidates body force parameters (bf_x/k_x/w_x/p_x/g_x and y/z) into type(body_force_axis) :: bf_x, bf_y, bf_z
  • Fixes analytical IC codegen in toolchain/mfc/case.py to use x%cc(i) after grid_axis refactor
  • Includes ffmt v0.4.0 pin and formatting (builds on style: apply ffmt v0.4.0 formatting #1431)

Implements items 1, 5, and 7 from issue #1427.

Test plan

  • ./mfc.sh precheck passes (all 6 checks)
  • Body force tests pass (6 tests)
  • Grid stretching tests pass (2 tests)
  • CI green

@qodo-code-review
Copy link
Copy Markdown
Contributor

ⓘ You've reached your Qodo monthly free-tier limit. Reviews pause until next month — upgrade your plan to continue now, or link your paid account if you already have one.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 12, 2026

Codecov Report

❌ Patch coverage is 68.64952% with 195 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.94%. Comparing base (28863b1) to head (eb90ba8).

Files with missing lines Patch % Lines
src/post_process/m_data_output.fpp 41.81% 32 Missing ⚠️
src/pre_process/m_icpp_patches.fpp 38.46% 23 Missing and 1 partial ⚠️
src/pre_process/m_start_up.fpp 39.39% 16 Missing and 4 partials ⚠️
src/simulation/m_bubbles_EL.fpp 37.50% 14 Missing and 1 partial ⚠️
src/simulation/m_data_output.fpp 46.42% 15 Missing ⚠️
src/simulation/m_ibm.fpp 67.64% 11 Missing ⚠️
src/common/m_chemistry.fpp 52.38% 10 Missing ⚠️
src/post_process/m_mpi_proxy.fpp 0.00% 9 Missing ⚠️
src/common/m_mpi_common.fpp 33.33% 8 Missing ⚠️
src/pre_process/m_boundary_conditions.fpp 0.00% 8 Missing ⚠️
... and 17 more
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1432      +/-   ##
==========================================
- Coverage   64.95%   64.94%   -0.02%     
==========================================
  Files          72       72              
  Lines       18879    18875       -4     
  Branches     1571     1572       +1     
==========================================
- Hits        12263    12258       -5     
  Misses       5640     5640              
- Partials      976      977       +1     

☔ View full report in Codecov by Sentry.
📢 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.

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
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
@sbryngelson sbryngelson force-pushed the refactor/derived-types branch from 882206f to 3f9f382 Compare May 12, 2026 20:38
@sbryngelson sbryngelson force-pushed the refactor/derived-types branch from 15f3a64 to eb90ba8 Compare May 12, 2026 23:24
Remove module-level dx, dy, dz scalars from pre_process m_global_parameters.
Add min_spacing field to the grid_axis derived type so each axis carries its
own minimum cell width. Update all call sites in m_grid, m_start_up,
m_icpp_patches, m_mpi_common, and 2dHardcodedIC.
After reading grid data from files, compute and store min_spacing on each
axis in both serial and parallel paths. Matches the pre_process pattern
so min_spacing is consistent across all three executables.
Group the three directional boundary condition variables (bc_x, bc_y,
bc_z of type bc_dir_t) into a single bc_xyz_info struct accessed as
bc%x, bc%y, bc%z. Updates all Fortran source, Fypp macros, Python
toolchain, example cases, and documentation.
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.

1 participant