Skip to content

Commit a80bb8a

Browse files
sbryngelsonclaude
andcommitted
Add attribute-based annotations for BC, fluid_pp, and simplex families
Extend doc generator with compound-name attribute annotation maps for indexed parameter families. Covers bc_x/y/z sub-params (GRCBC inflow/ outflow, boundary velocities), patch_bc geometry attributes, simplex perturbation params, and fluid_pp EOS properties. BC families: 5% → 100%, simplex_params: 0% → 100%, fluid_pp: 69% → 100%. Overall pattern-row coverage: 89.4%. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent e438581 commit a80bb8a

1 file changed

Lines changed: 82 additions & 1 deletion

File tree

toolchain/mfc/params/generators/docs_gen.py

Lines changed: 82 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,13 +241,89 @@ def _get_reverse_deps():
241241
("ic_", "Initial condition parameter"),
242242
]
243243

244+
# BC sub-parameter attribute → usage annotation
245+
# Keyed by the attribute name after % (without index suffix)
246+
_BC_ATTR_ANNOTATIONS = {
247+
"grcbc_in": "Enables GRCBC subsonic inflow (bc type -7)",
248+
"grcbc_out": "Enables GRCBC subsonic outflow (bc type -8)",
249+
"grcbc_vel_out": "GRCBC velocity outlet (requires `grcbc_out`)",
250+
"vel_in": "Inlet velocity component (used with `grcbc_in`)",
251+
"vel_out": "Outlet velocity component (used with `grcbc_vel_out`)",
252+
"pres_in": "Inlet pressure (used with `grcbc_in`)",
253+
"pres_out": "Outlet pressure (used with `grcbc_out`)",
254+
"alpha_rho_in": "Inlet partial density per fluid (used with `grcbc_in`)",
255+
"alpha_in": "Inlet volume fraction per fluid (used with `grcbc_in`)",
256+
"vb1": "Boundary velocity component 1 at domain begin",
257+
"vb2": "Boundary velocity component 2 at domain begin",
258+
"vb3": "Boundary velocity component 3 at domain begin",
259+
"ve1": "Boundary velocity component 1 at domain end",
260+
"ve2": "Boundary velocity component 2 at domain end",
261+
"ve3": "Boundary velocity component 3 at domain end",
262+
}
263+
264+
# patch_bc attribute → usage annotation
265+
_PATCH_BC_ANNOTATIONS = {
266+
"geometry": "Patch shape: 1=line, 2=circle, 3=rectangle",
267+
"type": "BC type applied within patch region",
268+
"dir": "Patch normal direction (1=x, 2=y, 3=z)",
269+
"loc": "Domain boundary (-1=begin, 1=end)",
270+
"centroid": "Patch center coordinate",
271+
"length": "Patch dimension",
272+
"radius": "Patch radius (geometry=2)",
273+
}
274+
275+
# simplex_params attribute → usage annotation
276+
_SIMPLEX_ANNOTATIONS = {
277+
"perturb_dens": "Enable simplex density perturbation",
278+
"perturb_dens_freq": "Density perturbation frequency",
279+
"perturb_dens_scale": "Density perturbation amplitude",
280+
"perturb_dens_offset": "Density perturbation offset seed",
281+
"perturb_vel": "Enable simplex velocity perturbation",
282+
"perturb_vel_freq": "Velocity perturbation frequency",
283+
"perturb_vel_scale": "Velocity perturbation amplitude",
284+
"perturb_vel_offset": "Velocity perturbation offset seed",
285+
}
286+
287+
# fluid_pp attribute → usage annotation (EOS params only)
288+
_FLUID_PP_ANNOTATIONS = {
289+
"gamma": "Specific heat ratio (EOS)",
290+
"pi_inf": "Stiffness pressure (EOS)",
291+
"cv": "Specific heat at constant volume",
292+
"qv": "Heat of formation",
293+
"qvp": "Heat of formation derivative",
294+
}
295+
296+
297+
def _get_attr_annotation(param_name: str) -> str:
298+
"""Look up annotation for compound param names (e.g. bc_x%vel_in(1) → 'Inlet velocity')."""
299+
if '%' not in param_name:
300+
return ""
301+
# Extract attribute after last %: "bc_x%vel_in(1)" → "vel_in(1)"
302+
attr_full = param_name.split('%')[-1]
303+
# Strip index suffix: "vel_in(1)" → "vel_in", "centroid(2)" → "centroid"
304+
attr_base = re.match(r'^([a-zA-Z_0-9]+)', attr_full)
305+
if not attr_base:
306+
return ""
307+
attr_key = attr_base.group(1)
308+
# Determine family prefix: "bc_x%..." → "bc_", "patch_bc(1)%..." → "patch_bc"
309+
prefix = param_name.split('%')[0]
310+
if re.match(r'bc_[xyz]', prefix):
311+
return _BC_ATTR_ANNOTATIONS.get(attr_key, "")
312+
if prefix.startswith("patch_bc"):
313+
return _PATCH_BC_ANNOTATIONS.get(attr_key, "")
314+
if prefix.startswith("simplex_params"):
315+
return _SIMPLEX_ANNOTATIONS.get(attr_key, "")
316+
if prefix.startswith("fluid_pp"):
317+
return _FLUID_PP_ANNOTATIONS.get(attr_key, "")
318+
return ""
319+
244320

245321
def _format_tag_annotation(param_name: str, param) -> str: # pylint: disable=too-many-locals
246322
"""
247323
Return a short annotation for params with no schema constraints and no AST rules.
248324
249325
Checks (in order): own DEPENDENCIES, output flag tags, reverse dependencies,
250-
feature tag labels, and prefix-group labels.
326+
feature tag labels, prefix-group labels, and compound-name attribute annotations.
251327
"""
252328
# 1. Own DEPENDENCIES info
253329
if param.dependencies:
@@ -294,6 +370,11 @@ def _format_tag_annotation(param_name: str, param) -> str: # pylint: disable=to
294370
if param_name.startswith(prefix):
295371
return label
296372

373+
# 6. Compound-name attribute annotations (bc_x%vel_in, patch_bc%geometry, etc.)
374+
attr_ann = _get_attr_annotation(param_name)
375+
if attr_ann:
376+
return attr_ann
377+
297378
return ""
298379

299380

0 commit comments

Comments
 (0)