Skip to content
Snippets Groups Projects
Commit b4f36868 authored by Frederik Hennig's avatar Frederik Hennig
Browse files

Decoupled generator and composers

parent 3edfb527
No related merge requests found
......@@ -4,10 +4,12 @@ import sympy as sp
from pystencils import fields, kernel
from pystencilssfg import SourceFileGenerator
from pystencilssfg import SourceFileGenerator, SfgComposer
with SourceFileGenerator() as sfg:
with SourceFileGenerator() as ctx:
sfg = SfgComposer(ctx)
src, dst = fields("src, dst(1) : double[2D]")
@kernel
......
......@@ -4,10 +4,11 @@ import sympy as sp
from pystencils import fields, kernel, Field
from pystencilssfg import SourceFileGenerator
from pystencilssfg import SourceFileGenerator, SfgComposer
with SourceFileGenerator() as ctx:
sfg = SfgComposer(ctx)
with SourceFileGenerator() as sfg:
src: Field = fields("src: double[2D]")
h = sp.Symbol('h')
......
......@@ -4,14 +4,16 @@ import sympy as sp
from pystencils import fields, kernel
from pystencilssfg import SourceFileGenerator, SfgConfiguration
from pystencilssfg import SourceFileGenerator, SfgConfiguration, SfgComposer
from pystencilssfg.source_concepts.cpp import mdspan_ref
sfg_config = SfgConfiguration(
outer_namespace="make_demo"
)
with SourceFileGenerator(sfg_config) as sfg:
with SourceFileGenerator(sfg_config) as ctx:
sfg = SfgComposer(ctx)
sfg.prelude("""Generated by the pystencils Source File Generator.
Author: Frederik Hennig <frederik.hennig@fau.de>""")
......
from pystencilssfg import SourceFileGenerator
from pystencilssfg import SourceFileGenerator, SfgComposer
from lbmpy.advanced_streaming import Timestep
from lbmpy import LBMConfig, create_lb_ast
with SourceFileGenerator() as sfg:
with SourceFileGenerator() as ctx:
sfg = SfgComposer(ctx)
lb_config = LBMConfig(streaming_pattern='esotwist')
......
# type: ignore
from pystencilssfg import SourceFileGenerator, SfgConfiguration
from pystencilssfg import SourceFileGenerator, SfgConfiguration, SfgComposer
from pystencilssfg.configuration import SfgCodeStyle
from pystencilssfg.source_concepts import SrcObject
from pystencilssfg.source_components import SfgClass, SfgMemberVariable, SfgConstructor, SfgMethod, SfgVisibility
......@@ -17,7 +17,8 @@ sfg_config = SfgConfiguration(
f, g = fields("f, g(1): double[2D]")
with SourceFileGenerator(sfg_config) as sfg:
with SourceFileGenerator(sfg_config) as ctx:
sfg = SfgComposer(ctx)
@kernel
def assignments():
......
......@@ -7,7 +7,6 @@ from os import path
from .configuration import SfgConfiguration, config_from_commandline, merge_configurations
from .context import SfgContext
from .composer import SfgComposer
class SourceFileGenerator:
......@@ -35,9 +34,9 @@ class SourceFileGenerator:
if path.exists(file):
os.remove(file)
def __enter__(self):
def __enter__(self) -> SfgContext:
self.clean_files()
return SfgComposer(self._context)
return self._context
def __exit__(self, exc_type, exc_value, traceback):
if exc_type is None:
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment