zoomy_core.transformation.to_js module#
Module zoomy_core.transformation.to_js.
SymPy → JavaScript code printer for generating Model2D-compatible kernels from any Zoomy symbolic model.
Subclasses OutParamCodePrinter — generated kernels write their
result through a trailing res array parameter the caller owns,
instead of returning a freshly-allocated Float64Array. That keeps
the browser solver’s hot loop allocation-free; the body generation,
Piecewise handling and kernel/BC wrapping are shared with the GLSL
printer. Only the JS-specific output formatting lives here.
Usage:
from zoomy_core.transformation.to_js import JsModel
print(JsModel(model).generate())
- class zoomy_core.transformation.to_js.GenericJsBase(*args, **kwargs)#
Bases:
OutParamCodePrinterJavaScript code printer.
Inherits the out-parameter body generation, Piecewise handling and kernel / boundary-condition wrapping from
OutParamCodePrinter; overrides only the JS-specific output formatting.- math_namespace = 'Math.'#
- c_functions = {'Abs': <function GenericJsBase.<lambda>>, 'Max': <function GenericJsBase.<lambda>>, 'Min': <function GenericJsBase.<lambda>>, 'clamp_momentum': <function GenericJsBase.<lambda>>, 'clamp_positive': <function GenericJsBase.<lambda>>, 'conditional': <function GenericJsBase.<lambda>>}#
- wrap_function_signature(name, args_str, body_str, shape)#
Wrap a JS body in a function declaration.
- get_includes()#
No includes needed for JS.
- get_simple_array_def()#
No SimpleArray struct needed for JS.
- class zoomy_core.transformation.to_js.JsModel(model)#
Bases:
GenericJsBaseGenerate JavaScript Model2D kernels from a Zoomy symbolic model.
Produces standalone JS functions for
flux,source,eigenvalues, etc. Each takes the model’s flat argument arrays plus a trailingresout-parameter the caller owns.- KERNEL_NAMES = ['flux', 'source', 'eigenvalues', 'source_jacobian_wrt_variables', 'quasilinear_matrix']#
- generate()#
Generate all JS kernels as a single code string.
- class zoomy_core.transformation.to_js.JsNumerics(numerics)#
Bases:
GenericJsBaseGenerate JavaScript kernels from a Zoomy symbolic
Numerics.Produces
numerical_flux(andnumerical_fluctuations/local_max_abs_eigenvalue) as standalone JS functions taking the per-faceQ_minus/Q_plusstates plus a trailingresout-parameter. Mirrorszoomy_core.transformation.generic_c.GenericCppNumerics.- generate()#
Generate all numerics kernels as a single JS code string.