You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Extends #679 (grid index bounds, already consolidated into `int_bounds_info`). A survey of the codebase found several more patterns of related variables that should be grouped into derived types for clarity and maintainability. Listed roughly by impact.
type grid_axis
real(wp), target, allocatable, dimension(:) :: cb, cc, spacing
end type grid_axis
type(grid_axis) :: x, y, z
! usage: x%cc(i), x%cb(i), x%spacing(i)
2. x/y/z directional field triplets — `m_riemann_solvers.fpp`, `m_rhs.fpp`, `m_weno.fpp`, `m_muscl.fpp`
The most widespread pattern. Arrays that come in `_x`/`_y`/`_z` variants appear 50+ times across the simulation modules:
As noted in #1426 (Riemann solver refactor), these could be grouped into a `riemann_side_state` type:
type riemann_side_state
real(wp) :: rho, pres, E, H, c, gamma, pi_inf, qv, T, G
real(wp), dimension(num_vels) :: vel
end type riemann_side_state
type(riemann_side_state) :: L, R
This is GPU-safe as long as no allocatables are added (profiling recommended).
`int_bounds_info` started as a simple beg/end integer pair but has grown into a full BC parameter struct. The name is misleading, the internal naming is inconsistent, and `bc_x/bc_y/bc_z` should be `bc%x/bc%y/bc%z` like every other x/y/z grouping in the codebase.
Current state:
type int_bounds_info
integer:: beg, end
real(wp) :: vb1, vb2, vb3 ! wall velocity at beg face — inconsistent with...
real(wp) :: ve1, ve2, ve3
real(wp) :: pres_in, pres_out ! ...same concept named _in/_out here
real(wp), dimension(3) :: vel_in, vel_out
real(wp), dimension(num_fluids_max) :: alpha_rho_in, alpha_in
logical:: grcbc_in, grcbc_out, grcbc_vel_out
logical:: isothermal_in, isothermal_out
real(wp) :: Twall_in, Twall_out
end type int_bounds_info
type(int_bounds_info) :: bc_x, bc_y, bc_z ! should be bc%x, bc%y, bc%z
Proposed:
type bc_face_t
real(wp) :: pres
real(wp), dimension(3) :: vel
real(wp) :: vel_wall_1, vel_wall_2, vel_wall_3 ! scalars for GPU_DECLARE
real(wp), dimension(num_fluids_max) :: alpha_rho, alpha
real(wp) :: T_wall
logical:: grcbc, grcbc_vel, isothermal
end type bc_face_t
type bc_dir_t
integer:: beg, end
type(bc_face_t) :: beg_face, end_face
end type bc_dir_t
type bc_t
type(bc_dir_t) :: x, y, z
end type bc_t
type(bc_t) :: bc
Extends #679 (grid index bounds, already consolidated into `int_bounds_info`). A survey of the codebase found several more patterns of related variables that should be grouped into derived types for clarity and maintainability. Listed roughly by impact.
1. Grid coordinate triplets — `m_global_parameters.fpp`
Nine allocatable arrays currently declared flat:
Could become:
type grid_axis real(wp), target, allocatable, dimension(:) :: cb, cc, spacing end type grid_axis type(grid_axis) :: x, y, z ! usage: x%cc(i), x%cb(i), x%spacing(i)2. x/y/z directional field triplets — `m_riemann_solvers.fpp`, `m_rhs.fpp`, `m_weno.fpp`, `m_muscl.fpp`
The most widespread pattern. Arrays that come in `_x`/`_y`/`_z` variants appear 50+ times across the simulation modules:
These also propagate through subroutine signatures as 3 separate arguments everywhere. A simple wrapper type:
type directional_vf type(scalar_field), allocatable, dimension(:) :: x, y, z end type directional_vfwould reduce many 3-argument subroutine signatures to 1, and make directional splitting loops much cleaner.
3. Left/right Riemann state scalars — `m_riemann_solvers.fpp`
The existing `type(riemann_states)` covers MHD quantities, but ~20 thermodynamic and chemistry scalar pairs are still declared separately:
As noted in #1426 (Riemann solver refactor), these could be grouped into a `riemann_side_state` type:
type riemann_side_state real(wp) :: rho, pres, E, H, c, gamma, pi_inf, qv, T, G real(wp), dimension(num_vels) :: vel end type riemann_side_state type(riemann_side_state) :: L, RThis is GPU-safe as long as no allocatables are added (profiling recommended).
4. Boundary condition types — `m_derived_types.fpp`, `m_global_parameters.fpp`
`int_bounds_info` started as a simple beg/end integer pair but has grown into a full BC parameter struct. The name is misleading, the internal naming is inconsistent, and `bc_x/bc_y/bc_z` should be `bc%x/bc%y/bc%z` like every other x/y/z grouping in the codebase.
Current state:
type int_bounds_info integer :: beg, end real(wp) :: vb1, vb2, vb3 ! wall velocity at beg face — inconsistent with... real(wp) :: ve1, ve2, ve3 real(wp) :: pres_in, pres_out ! ...same concept named _in/_out here real(wp), dimension(3) :: vel_in, vel_out real(wp), dimension(num_fluids_max) :: alpha_rho_in, alpha_in logical :: grcbc_in, grcbc_out, grcbc_vel_out logical :: isothermal_in, isothermal_out real(wp) :: Twall_in, Twall_out end type int_bounds_info type(int_bounds_info) :: bc_x, bc_y, bc_z ! should be bc%x, bc%y, bc%zProposed:
type bc_face_t real(wp) :: pres real(wp), dimension(3) :: vel real(wp) :: vel_wall_1, vel_wall_2, vel_wall_3 ! scalars for GPU_DECLARE real(wp), dimension(num_fluids_max) :: alpha_rho, alpha real(wp) :: T_wall logical :: grcbc, grcbc_vel, isothermal end type bc_face_t type bc_dir_t integer :: beg, end type(bc_face_t) :: beg_face, end_face end type bc_dir_t type bc_t type(bc_dir_t) :: x, y, z end type bc_t type(bc_t) :: bcKey renaming: `bc_x%vb1` → `bc%x%beg_face%vel_wall_1`, `bc_x%pres_in` → `bc%x%beg_face%pres`, `bc_x%pres_out` → `bc%x%end_face%pres`, etc.
Files affected: `m_derived_types.fpp`, `m_boundary_common.fpp` (~50 sites), `m_global_parameters.fpp` (all three components), `m_start_up.fpp`, `m_mpi_proxy.fpp`.
5. Body force parameters — `m_global_parameters.fpp`
12 scalars with a clear x/y/z × {k,w,p,g} structure:
Could become:
type body_force_axis real(wp) :: k, w, p, g logical :: enabled end type body_force_axis type(body_force_axis) :: bf_x, bf_y, bf_z6. Immersed boundary dynamics — `m_data_output.fpp`
15 allocatable arrays in post-processing output:
Could become a single `type(ib_dynamics)` with named vector components.
7. Domain bounds — `m_global_parameters.fpp`
Minor, but straightforward:
→ could use the existing `type(bounds_info)` (already used for `x_domain`, `y_domain`, `z_domain`).
Notes
m_riemann_solvers: reduce duplication, improve structure, add schemes #1426 — coordinate them.Closes #679.