diff options
Generate basic example in plain C++
An attempt to produce a minimal LBM implementation to benchmark various
memory and vectorization schemes on the CPU.
Diffstat (limited to 'standalone_cpp_codegen.py')
-rw-r--r-- | standalone_cpp_codegen.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/standalone_cpp_codegen.py b/standalone_cpp_codegen.py new file mode 100644 index 0000000..b38898a --- /dev/null +++ b/standalone_cpp_codegen.py @@ -0,0 +1,32 @@ +import sympy +from mako.template import Template +from pathlib import Path + +from simulation import Geometry +from symbolic.generator import LBM + +import symbolic.D2Q9 as D2Q9 + +lbm = LBM(D2Q9) + +moments = lbm.moments(optimize = False) +collide = lbm.bgk(f_eq = lbm.equilibrium(), tau = 0.6) + +geometry = Geometry(512, 512) + +program_src = Template(filename = str(Path(__file__).parent/'template/standalone.mako')).render( + descriptor = lbm.descriptor, + geometry = geometry, + + steps = 100, + + moments_subexpr = moments[0], + moments_assignment = moments[1], + collide_subexpr = collide[0], + collide_assignment = collide[1], + + float_type = 'double', + ccode = sympy.ccode +) + +print(program_src) |