zoomy_core.transformation.to_openfoam module#
Foam printer for the SystemModel contract.
Trusts that the incoming SystemModel is complete and well-shaped
(emitted by Zoomy’s own pipeline) — no defensive checks, no fallback
machinery. Options that affect the content of the emitted C++ live as
printer flags, not as branching in the printer’s plumbing.
- class zoomy_core.transformation.to_openfoam.FoamModel(model, *args, **kwargs)#
Bases:
GenericCppModelLegacy Foam printer — consumes a pre-SystemModel
Model.- get_includes()#
Get includes.
- format_accessor(var_name, index)#
Format accessor.
- format_assignment(target_name, indices, value, shape)#
Format assignment.
- get_variable_declaration(v)#
Get variable declaration.
- wrap_function_signature(name, args_str, body_str, shape)#
Wrap function signature.
- class zoomy_core.transformation.to_openfoam.FoamSystemModelPrinter(sm, **opts)#
Bases:
GenericCppBaseFoam printer for a frozen
SystemModel.Emits
Model.Hwith one kernel per operator matrix. Per-direction kernels (flux_x/_y/_zetc.) match the calling convention of the existing hand-writtennumerics.H.- analytical_eigenvaluesbool, default False
If True, emit the SystemModel’s symbolic eigenvalue spectrum. If False, emit a zero placeholder — the solver computes eigenvalues numerically from
quasilinear_matrix.
- real_type = 'Foam::scalar'#
- math_namespace = 'Foam::'#
- analytical_eigenvalues = False#
- format_accessor(var, idx)#
Format accessor.
- format_assignment(target, indices, value, shape)#
Format assignment.
- get_array_declaration(target, shape, init_zero=False)#
Foam-flavoured
auto res = Foam::List<...>(...);decl, used by the inheritedconvert_expression_body()in place of the base’sSimpleArray<T, N>declaration.
- wrap_function_signature(name, args_str, body_str, shape)#
Signature wrapper — the body already declares
resand returns it, so we only emit the surrounding function.
- create_code()#
- classmethod write_code(sm, output_path, **opts)#
- class zoomy_core.transformation.to_openfoam.FoamNumericsPrinter(numerics, **opts)#
Bases:
GenericCppBaseFoam printer for a symbolic
Numericsobject (Rusanov, HLL, NonconservativeRusanov, …).Emits
Numerics.Hwith one kernel per entry innumerics.functions— typicallynumerical_flux,numerical_fluctuations,local_max_abs_eigenvalue. Body expressions are CSE-optimised by the inheritedconvert_expression_body(); signatures use the Foam type aliases above.- real_type = 'Foam::scalar'#
- math_namespace = 'Foam::'#
- c_functions = {'Abs': <function GenericCppBase.<lambda>>, 'Max': <function GenericCppBase.<lambda>>, 'Min': <function GenericCppBase.<lambda>>, 'clamp_momentum': <function GenericCppBase.<lambda>>, 'clamp_positive': <function GenericCppBase.<lambda>>, 'conditional': <function GenericCppBase.<lambda>>, 'max_wavespeed': <function FoamNumericsPrinter._emit_max_wavespeed>}#
- format_accessor(var, idx)#
Format accessor.
- format_assignment(target, indices, value, shape)#
Format assignment.
- get_array_declaration(target, shape, init_zero=False)#
Returns the C++ declaration string for the array.
- wrap_function_signature(name, args_str, body_str, shape)#
Wrap function signature.
- create_code()#
- classmethod write_code(numerics, output_path, **opts)#
- class zoomy_core.transformation.to_openfoam.FoamUpdateAuxPrinter(sm)#
Bases:
objectEmit
numerics::update_aux_variables(Q, Qaux, mesh)fromsm.aux_registry.The output is a flat sequence of
numerics::compute_derivative(...)calls — onevolScalarFieldassignment per derivative-kind aux. The solver-sidecompute_derivativehelper does the actual LSQ / Gauss-grad computation on the OpenFOAM mesh.- create_code()#
- classmethod write_code(sm, output_path)#