Skip to content

Commit 08d34ca

Browse files
committed
toolchain: deregister parameters removed from the derived types
fluid_pp%{mul0,ss,pv,gamma_v,M_v,mu_v,k_v,cp_v,D_v} and lag_params%{T0,Thost,c0,rho0,x0} were removed from the Fortran derived types by upstream #1085/#1093 but remained registered in the toolchain. Setting any of them causes namelist read to abort with a misleading 'datatype mismatch' error. Verified against src/common/m_derived_types.fpp: - physical_parameters has: gamma, pi_inf, Re, cv, qv, qvp, G - bubbles_lagrange_parameters has: solver_approach, cluster_type, pressure_corrector, smooth_type, heatTransfer_model, massTransfer_model, write_bubbles, write_bubbles_stats, nBubs_glb, epsilonb, charwidth, valmaxvoid Also remove the now-dead PATTERNS entries in descriptions.py and update the stale comments in fortran_gen.py (_emit_fluid_pp and _emit_lag_params). Both emitters now walk the registry rather than hardcoding member lists.
1 parent 1965f97 commit 08d34ca

3 files changed

Lines changed: 21 additions & 31 deletions

File tree

toolchain/mfc/params/definitions.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -842,14 +842,13 @@ def _load():
842842
_r(f"{px}sph_har_coeff({ll},{mm})", REAL)
843843

844844
# fluid_pp (10 fluids)
845+
# Members present in physical_parameters: gamma, pi_inf, Re, cv, qv, qvp, G.
846+
# mul0/ss/pv/gamma_v/M_v/mu_v/k_v/cp_v/D_v were removed from the Fortran type
847+
# by upstream #1085/#1093 — they must NOT be registered (namelist read would crash).
845848
for f in range(1, NF + 1):
846849
px = f"fluid_pp({f})%"
847850
for a, sym in [("gamma", r"\f$\gamma_k\f$"), ("pi_inf", r"\f$\pi_{\infty,k}\f$"), ("cv", r"\f$c_{v,k}\f$"), ("qv", r"\f$q_{v,k}\f$"), ("qvp", r"\f$q'_{v,k}\f$")]:
848851
_r(f"{px}{a}", REAL, math=sym)
849-
_r(f"{px}mul0", REAL, {"viscosity"}, math=r"\f$\mu_{l,k}\f$")
850-
_r(f"{px}ss", REAL, {"surface_tension"}, math=r"\f$\sigma_k\f$")
851-
for a in ["pv", "gamma_v", "M_v", "mu_v", "k_v", "cp_v", "D_v"]:
852-
_r(f"{px}{a}", REAL, {"bubbles"})
853852
_r(f"{px}G", REAL, {"elasticity"}, math=r"\f$G_k\f$")
854853
_r(f"{px}Re(1)", REAL, {"viscosity"}, math=r"\f$\mathrm{Re}_k\f$ (shear)")
855854
_r(f"{px}Re(2)", REAL, {"viscosity"}, math=r"\f$\mathrm{Re}_k\f$ (bulk)")
@@ -1049,11 +1048,16 @@ def _load():
10491048
_r(f"simplex_params%perturb_vel_offset({d},{j})", REAL)
10501049

10511050
# lag_params (Lagrangian bubbles)
1051+
# Members present in bubbles_lagrange_parameters: solver_approach, cluster_type,
1052+
# pressure_corrector, smooth_type, heatTransfer_model, massTransfer_model,
1053+
# write_bubbles, write_bubbles_stats, nBubs_glb, epsilonb, charwidth, valmaxvoid.
1054+
# T0/Thost/c0/rho0/x0 were removed from the Fortran type by upstream #1085/#1093
1055+
# — they must NOT be registered (namelist read would crash).
10521056
for a in ["heatTransfer_model", "massTransfer_model", "pressure_corrector", "write_bubbles", "write_bubbles_stats"]:
10531057
_r(f"lag_params%{a}", LOG, {"bubbles"})
10541058
for a in ["solver_approach", "cluster_type", "smooth_type", "nBubs_glb"]:
10551059
_r(f"lag_params%{a}", INT, {"bubbles"})
1056-
for a in ["epsilonb", "valmaxvoid", "charwidth", "c0", "rho0", "T0", "x0", "Thost"]:
1060+
for a in ["epsilonb", "valmaxvoid", "charwidth"]:
10571061
_r(f"lag_params%{a}", REAL, {"bubbles"})
10581062

10591063
# chem_params

toolchain/mfc/params/descriptions.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -323,15 +323,6 @@
323323
(r"fluid_pp\((\d+)\)%qv", "Heat of formation for fluid {0}"),
324324
(r"fluid_pp\((\d+)\)%qvp", "Heat of formation prime for fluid {0}"),
325325
(r"fluid_pp\((\d+)\)%Re\((\d+)\)", "Reynolds number component {1} for fluid {0}"),
326-
(r"fluid_pp\((\d+)\)%mul0", "Reference liquid viscosity for fluid {0}"),
327-
(r"fluid_pp\((\d+)\)%ss", "Surface tension for fluid {0}"),
328-
(r"fluid_pp\((\d+)\)%pv", "Vapor pressure for fluid {0}"),
329-
(r"fluid_pp\((\d+)\)%gamma_v", "Specific heat ratio of vapor phase for fluid {0}"),
330-
(r"fluid_pp\((\d+)\)%M_v", "Molecular weight of vapor phase for fluid {0}"),
331-
(r"fluid_pp\((\d+)\)%mu_v", "Viscosity of vapor phase for fluid {0}"),
332-
(r"fluid_pp\((\d+)\)%k_v", "Thermal conductivity of vapor phase for fluid {0}"),
333-
(r"fluid_pp\((\d+)\)%cp_v", "Specific heat capacity (const. pressure) of vapor for fluid {0}"),
334-
(r"fluid_pp\((\d+)\)%D_v", "Vapor mass diffusivity for fluid {0}"),
335326
(r"fluid_pp\((\d+)\)%non_newtonian", "Enable Herschel-Bulkley non-Newtonian viscosity for fluid {0}"),
336327
(r"fluid_pp\((\d+)\)%K", "HB consistency index for fluid {0}"),
337328
(r"fluid_pp\((\d+)\)%nn", "HB flow behavior index for fluid {0}"),
@@ -500,11 +491,6 @@
500491
(r"lag_params%epsilonb", "Standard deviation scaling for Gaussian smoothing"),
501492
(r"lag_params%charwidth", "Domain virtual depth for 2D simulations"),
502493
(r"lag_params%valmaxvoid", "Maximum permitted void fraction"),
503-
(r"lag_params%T0", "Initial bubble temperature"),
504-
(r"lag_params%Thost", "Host fluid temperature"),
505-
(r"lag_params%c0", "Initial sound speed"),
506-
(r"lag_params%rho0", "Initial density"),
507-
(r"lag_params%x0", "Initial bubble position"),
508494
(r"lag_params%(\w+)", "Lagrangian tracking parameter: {0}"),
509495
# chem_params patterns - specific fields first
510496
(r"chem_params%diffusion", "Enable species diffusion for chemistry"),

toolchain/mfc/params/generators/fortran_gen.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -318,15 +318,16 @@ def _emit_bcast_group(lines: List[str], vars_list: List[str], mpi_type: str) ->
318318
def _emit_fluid_pp(lines: List[str], target: str) -> None:
319319
"""Emit the fluid_pp(i) member-loop broadcast block.
320320
321-
Members broadcast: the 13 REAL members (EOS core plus the Herschel-Bulkley
322-
non-Newtonian set) and the LOGICAL non_newtonian flag, matching the manual
323-
lists this generator replaces. Sim additionally: Re(1) with count=2.
321+
Members broadcast: all REAL registry members of fluid_pp (gamma, pi_inf, G, cv, qv,
322+
qvp) derived from physical_parameters. Sim additionally: Re(1) with count=2.
323+
mul0/ss/pv/gamma_v/M_v/mu_v/k_v/cp_v/D_v were removed from the Fortran type by
324+
upstream #1085/#1093 and are no longer registered.
324325
"""
325-
fp_real_members = ["gamma", "pi_inf", "G", "cv", "qv", "qvp", "K", "nn", "tau0", "hb_m", "mu_min", "mu_max", "mu_bulk"]
326+
# Walk the registry for fluid_pp REAL members (Re handled separately; exclude).
327+
fp_real_members = sorted(k.split("%", 1)[1] for k in REGISTRY.all_params if k.startswith("fluid_pp(1)%") and not k.startswith("fluid_pp(1)%Re("))
326328
lines.append(" do i = 1, num_fluids_max")
327329
for mem in fp_real_members:
328330
lines.append(f" call MPI_BCAST(fluid_pp(i)%{mem}, 1, mpi_p, 0, MPI_COMM_WORLD, ierr)")
329-
lines.append(" call MPI_BCAST(fluid_pp(i)%non_newtonian, 1, MPI_LOGICAL, 0, MPI_COMM_WORLD, ierr)")
330331
if target == "sim":
331332
lines.append(" call MPI_BCAST(fluid_pp(i)%Re(1), 2, mpi_p, 0, MPI_COMM_WORLD, ierr)")
332333
lines.append(" end do")
@@ -347,14 +348,13 @@ def _emit_bub_pp(lines: List[str]) -> None:
347348
def _emit_lag_params(lines: List[str]) -> None:
348349
"""Emit the lag_params member broadcast block (sim-only, under bubbles_lagrange guard).
349350
350-
Subset of lag_params members that are actually broadcast: the fields that appear in the
351-
existing simulation m_mpi_proxy.fpp lag_params block. The registry has additional
352-
members (T0, Thost, c0, rho0, x0) that are not broadcast (rank-0-only).
351+
All registered lag_params members are broadcast. T0/Thost/c0/rho0/x0 were removed
352+
from the Fortran type by upstream #1085/#1093 and are no longer in the registry.
353353
"""
354-
# Hardcoded broadcast subset — matches the existing sim m_mpi_proxy exactly.
355-
lag_log = ["heatTransfer_model", "massTransfer_model", "pressure_corrector", "write_bubbles", "write_bubbles_stats"]
356-
lag_int = ["cluster_type", "nBubs_glb", "smooth_type", "solver_approach"]
357-
lag_real = ["charwidth", "epsilonb", "valmaxvoid"]
354+
# Walk the registry for lag_params members, split by type.
355+
lag_log = sorted(k.split("%", 1)[1] for k in REGISTRY.all_params if k.startswith("lag_params%") and REGISTRY.all_params[k].param_type == ParamType.LOG)
356+
lag_int = sorted(k.split("%", 1)[1] for k in REGISTRY.all_params if k.startswith("lag_params%") and REGISTRY.all_params[k].param_type in (ParamType.INT, ParamType.ANALYTIC_INT))
357+
lag_real = sorted(k.split("%", 1)[1] for k in REGISTRY.all_params if k.startswith("lag_params%") and REGISTRY.all_params[k].param_type in _REAL_TYPES)
358358
lines.append(" if (bubbles_lagrange) then")
359359
for mem in sorted(lag_log):
360360
lines.append(f" call MPI_BCAST(lag_params%{mem}, 1, MPI_LOGICAL, 0, MPI_COMM_WORLD, ierr)")

0 commit comments

Comments
 (0)