zoomy_core.transformation.to_glsl module#
Module zoomy_core.transformation.to_glsl.
SymPy → GLSL ES 3.00 (WebGL2) code printer for generating kernels from any Zoomy symbolic model.
Subclasses OutParamCodePrinter — generated kernels return
void and write their result through a trailing out float res[N]
parameter, so the body generation, Piecewise handling and kernel/BC
wrapping are shared with the JS printer. Only the GLSL-specific output
formatting lives here.
Two GLSL ES 3.00 facts shape the output:
No array return types. Kernels write through
out float res[N]. The result is laid out row-major in the natural shape of the symbolic definition (e.g.fluxis(n_variables, dimension)→res[var * dimension + dim]).No implicit int→float conversion. Every numeric literal is emitted in float form (
0→0.0). The one exception is comparisons between integer quantities (e.g. a boundary-condition index), which are detected and printed with plain int literals.
Usage:
from zoomy_core.transformation.to_glsl import GlslModel
print(GlslModel(model).generate())
- class zoomy_core.transformation.to_glsl.GenericGlslBase(*args, **kwargs)#
Bases:
OutParamCodePrinterGLSL ES 3.00 code printer.
Inherits the out-parameter body generation, Piecewise handling and kernel / boundary-condition wrapping from
OutParamCodePrinter; overrides the GLSL-specific output: static types, a bare math namespace, explicit float literals andout float res[N]result parameters.- math_namespace = ''#
- real_type = 'float'#
- gpu_enabled = False#
- c_functions = {'Abs': <function GenericGlslBase.<lambda>>, 'Max': <function GenericGlslBase.<lambda>>, 'Min': <function GenericGlslBase.<lambda>>, 'clamp_momentum': <function GenericGlslBase.<lambda>>, 'clamp_positive': <function GenericGlslBase.<lambda>>, 'conditional': <function GenericGlslBase.<lambda>>, 'max_wavespeed': <function GenericGlslBase.<lambda>>}#
- wrap_function_signature(name, args_str, body_str, shape)#
Wrap a GLSL body in a
voidfunction declaration.
- get_includes()#
No includes needed for GLSL.
- get_simple_array_def()#
No SimpleArray struct needed for GLSL.
- class zoomy_core.transformation.to_glsl.GlslModel(model)#
Bases:
GenericGlslBaseGenerate GLSL ES 3.00 kernels from a Zoomy symbolic model.
Produces standalone
voidfunctions forflux,source,eigenvalues, etc. Each takes the model’s flatfloat[]argument arrays plus anout float res[N]result parameter. Mirrorszoomy_core.transformation.to_js.JsModel.- KERNEL_NAMES = ['flux', 'source', 'eigenvalues', 'source_jacobian_wrt_variables', 'quasilinear_matrix']#
- generate()#
Generate all GLSL kernels as a single code string.
- class zoomy_core.transformation.to_glsl.GlslNumerics(numerics)#
Bases:
GenericGlslBaseGenerate GLSL ES 3.00 kernels from a Zoomy symbolic
Numerics.Produces
numerical_flux(andnumerical_fluctuations/local_max_abs_eigenvalue) asvoidfunctions taking the per-faceQ_minus/Q_plusstates plus anout float res[N]result. Mirrorszoomy_core.transformation.generic_c.GenericCppNumerics.- generate()#
Generate all numerics kernels as a single GLSL code string.