From 61d77cf8aa815b456d873ff3c01e54ad21a8fce9 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Tue, 29 Oct 2019 19:38:32 +0100 Subject: Add support for generating custom templates in boltzgen's context --- boltzgen/kernel/generator.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/boltzgen/kernel/generator.py b/boltzgen/kernel/generator.py index 30e2c04..92ceb72 100644 --- a/boltzgen/kernel/generator.py +++ b/boltzgen/kernel/generator.py @@ -50,3 +50,19 @@ class Generator: raise Exception('Geometry dimension must match descriptor dimension') return "\n".join(map(lambda f: self.instantiate(f, geometry, extras), functions)) + + def custom(self, geometry, source): + return Template(text = source).render( + descriptor = self.descriptor, + geometry = geometry, + index = self.index_impl(geometry), + layout = self.layout_impl(self.descriptor, self.index_impl, geometry), + + moments_subexpr = self.moments[0], + moments_assignment = self.moments[1], + collision_subexpr = self.collision[0], + collision_assignment = self.collision[1], + ccode = sympy.ccode, + + float_type = self.float_type, + ) -- cgit v1.2.3