zoomy_core.transformation.generic_c module#
Module zoomy_core.transformation.generic_c.
- zoomy_core.transformation.generic_c.flatten_index(indices, shape)#
Flatten index.
- zoomy_core.transformation.generic_c.get_nested_shape(expr)#
Get nested shape.
- class zoomy_core.transformation.generic_c.GenericCppBase(*args, **kwargs)#
Bases:
CXX11CodePrinterGenericCppBase. (class).
- gpu_enabled = True#
- real_type = 'double'#
- math_namespace = 'std::'#
- ARG_MAPPING = {'aux_minus': 'Qaux_minus', 'aux_plus': 'Qaux_plus', 'aux_variables': 'Qaux', 'distance': 'dX', 'dt': 'dt', 'dx': 'dx', 'flux_minus': 'flux_minus', 'flux_plus': 'flux_plus', 'gradient_variables': 'gradQ', 'normal': 'n', 'p': 'p', 'position': 'X', 'q_minus': 'Q_minus', 'q_plus': 'Q_plus', 'source': 'source_term', 'time': 'time', 'variables': 'Q'}#
- 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 GenericCppBase.<lambda>>}#
- register_map(name, keys)#
Register map.
- get_array_type(shape)#
Returns the C++ type string for the array.
- get_array_declaration(target_name, shape, init_zero=False)#
Returns the C++ declaration string for the array.
- format_array_initialization(sym_name, elements)#
Hook to format how local argument arrays are initialized.
- convert_expression_body(expr, shape, target='res')#
Convert expression body.
- get_includes()#
Get includes.
- get_simple_array_def()#
Get simple array def.
- format_accessor(var_name, index)#
Format accessor.
- format_assignment(target_name, indices, value, shape)#
Format assignment.
- get_variable_declaration(variable_name)#
Get variable declaration.
- wrap_function_signature(name, args_str, body_str, shape)#
Wrap function signature.
- doprint(expr, **settings)#
Doprint.
- class zoomy_core.transformation.generic_c.OutParamCodePrinter(*args, **kwargs)#
Bases:
GenericCppBaseShared base for the out-parameter code printers (JS, GLSL).
Generated kernels return
void/ nothing and write their result through a trailingresarray parameter the caller owns — no per-call heap allocation, which is what keeps the browser solver fast. The body-generation, Piecewise handling and kernel/BC wrapping all live here; subclasses supply the language-specific bits via_temp_decl(),_generate_args()andwrap_function_signature().- ARG_MAPPING = {'aux_minus': 'Qaux_minus', 'aux_plus': 'Qaux_plus', 'aux_variables': 'Qaux', 'distance': 'dX', 'dt': 'dt', 'dx': 'dx', 'flux_minus': 'flux_minus', 'flux_plus': 'flux_plus', 'gradient_variables': 'gradQ', 'normal': 'n', 'p': 'p', 'parameters': 'p', 'position': 'X', 'q_minus': 'Q_minus', 'q_plus': 'Q_plus', 'source': 'source_term', 'time': 'time', 'variables': 'Q'}#
- convert_expression_body(expr, shape, target='res')#
Convert an expression into a body that writes
target— the function’s out-parameter array. No local declaration, noreturn.
- generate_boundary_conditions()#
Generate the model’s boundary-condition dispatch kernels —
boundary_conditionsandaux_boundary_conditions, each a Piecewise over the integerbc_idx.
- class zoomy_core.transformation.generic_c.GenericCppModel(model, *args, **kwargs)#
Bases:
GenericCppBaseGenericCppModel. (class).
- classmethod write_code(model, settings, filename='Model.H')#
Write code.
- create_code()#
Create code.
- get_file_header()#
Get file header.
Get file footer.
- get_bc_args()#
Hook to define boundary condition arguments.
- class zoomy_core.transformation.generic_c.GenericCppNumerics(numerics, gpu_enabled=False, *args, **kwargs)#
Bases:
GenericCppBaseGenericCppNumerics. (class).
- classmethod write_code(numerics, settings, filename='Numerics.H', gpu_enabled=False)#
Write code.
- create_code()#
Create code.
- get_file_header()#
Get file header.
Get file footer.
- class zoomy_core.transformation.generic_c.CppModel(model, *args, **kwargs)#
Bases:
GenericCppModelCppModel. (class).
- class zoomy_core.transformation.generic_c.CppNumerics(numerics, *args, **kwargs)#
Bases:
GenericCppNumericsCppNumerics. (class).