zoomy_core.transformation.to_openfoam module

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: GenericCppModel

Legacy 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: GenericCppBase

Foam printer for a frozen SystemModel.

Emits Model.H with one kernel per operator matrix. Per-direction kernels (flux_x / _y / _z etc.) match the calling convention of the existing hand-written numerics.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 inherited convert_expression_body() in place of the base’s SimpleArray<T, N> declaration.

wrap_function_signature(name, args_str, body_str, shape)#

Signature wrapper — the body already declares res and 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: GenericCppBase

Foam printer for a symbolic Numerics object (Rusanov, HLL, NonconservativeRusanov, …).

Emits Numerics.H with one kernel per entry in numerics.functions — typically numerical_flux, numerical_fluctuations, local_max_abs_eigenvalue. Body expressions are CSE-optimised by the inherited convert_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: object

Emit numerics::update_aux_variables(Q, Qaux, mesh) from sm.aux_registry.

The output is a flat sequence of numerics::compute_derivative(...) calls — one volScalarField assignment per derivative-kind aux. The solver-side compute_derivative helper does the actual LSQ / Gauss-grad computation on the OpenFOAM mesh.

create_code()#
classmethod write_code(sm, output_path)#