Enables user-defined code in generated files
In some applications (i.e. Turbulent Channel) the user might want to read/update variables in the code-generated files as they might be time-dependent.
Any code-generation that uses generate_sweep_collection() i.e. generate_lbm_package(), by default creates a file with private member variables. This merger allows the user to define custom functions to access member variables.
I.e. for Turbulent Channel example:
force_updater = """void updateForce(double F_x) { F_x_ = F_x;}"""
generate_lbm_package(ctx, ..., additional_code=force_updater)
or
counter_get_set = [
"""double getCounter() { return counter_;}""",
"""void setCounter(double counter) { counter_ = counter;}"""
]
tke_welford_update = welford_assignments(field=sgs_tke, mean_field=mean_sgs_tke)
tke_welford_update_fct = function_generator(ctx , ... )
generate_sweep_collection(ctx, ..., additional_code=counter_get_set)
Edited by brendan-waters