From affbafbcffddb44e5a3d24639b465f13c09a5725 Mon Sep 17 00:00:00 2001
From: Frederik Hennig <frederik.hennig@fau.de>
Date: Wed, 19 Mar 2025 19:44:09 +0100
Subject: [PATCH] fix codegen config setup in boundary condition generators

---
 .../codegen/boundaries/boundary_utils.py      |  3 +-
 src/walberla/codegen/boundaries/linkwise.py   | 42 +++----------------
 2 files changed, 6 insertions(+), 39 deletions(-)

diff --git a/src/walberla/codegen/boundaries/boundary_utils.py b/src/walberla/codegen/boundaries/boundary_utils.py
index e3ce6b0..a151259 100644
--- a/src/walberla/codegen/boundaries/boundary_utils.py
+++ b/src/walberla/codegen/boundaries/boundary_utils.py
@@ -1,5 +1,4 @@
 from functools import cache
-from typing import Any
 from abc import abstractmethod
 
 from pystencils import Field, FieldType, TypedSymbol, Assignment
@@ -37,7 +36,7 @@ class WalberlaLbmBoundary:
             (TypedSymbol("indexVectorLength", BoundaryIndexType), 1),
             (1, 1),
         )
-    
+
     @abstractmethod
     def boundary_obj(self) -> LbBoundary: ...
 
diff --git a/src/walberla/codegen/boundaries/linkwise.py b/src/walberla/codegen/boundaries/linkwise.py
index 2f0b959..6d81dc1 100644
--- a/src/walberla/codegen/boundaries/linkwise.py
+++ b/src/walberla/codegen/boundaries/linkwise.py
@@ -1,10 +1,7 @@
 from pystencils import (
     Field,
     Assignment,
-    CreateKernelConfig,
-    Target,
     AssignmentCollection,
-    FieldType,
 )
 from pystencils.types import PsStructType
 
@@ -18,6 +15,7 @@ from .boundary_utils import BoundaryIndexType, GenericHbbWrapper
 from .boundary_utils import WalberlaLbmBoundary
 from ..sweep import Sweep
 from ..api import SparseIndexList, MemTags
+from ..build_config import get_build_config
 
 __all__ = ["FreeSlip"]
 
@@ -41,7 +39,6 @@ class NoSlip(GenericLinkwiseBoundary):
         pdf_field: Symbolic LBM PDF field
         wall_orientation: Vector :math:`\\vec{n} \\in \\{ -1, 0, 1 \\}^d` pointing from the fluid to the wall,
             or `NoSlip.IRREGULAR` to indicate a non-grid-aligned boundary
-        target: Target architecture for the code generator
     """
 
     def __init__(
@@ -56,14 +53,6 @@ class NoSlip(GenericLinkwiseBoundary):
         self._pdf_field = pdf_field
         self._wall_normal = wall_orientation
 
-    @property
-    def target(self) -> Target | None:
-        return self._target
-
-    @target.setter
-    def target(self, t: Target | None):
-        self._target = t
-
     def generate(self, sfg: SfgComposer) -> None:
         if self._wall_normal == self.IRREGULAR:
             self._generate_irregular(sfg)
@@ -75,8 +64,7 @@ class NoSlip(GenericLinkwiseBoundary):
 
     def _generate_regular(self, sfg: SfgComposer):
         bc_asm = self._grid_aligned_assignments()
-        bc_cfg = CreateKernelConfig()
-        bc_sweep = Sweep(self._name, bc_asm, bc_cfg)
+        bc_sweep = Sweep(self._name, bc_asm)
         sfg.generate(bc_sweep)
 
     def _grid_aligned_assignments(self):
@@ -111,7 +99,6 @@ class GenericHBB(GenericLinkwiseBoundary):
         bc: LbBoundary,
         lb_method: AbstractLbMethod,
         pdf_field: Field,
-        target: Target | None = None,
     ):
         if bc.additional_data:
             raise ValueError(
@@ -124,15 +111,6 @@ class GenericHBB(GenericLinkwiseBoundary):
         self._lb_method = lb_method
         self._pdf_field = pdf_field
         self._stencil = lb_method.stencil
-        self._target = target
-
-    @property
-    def target(self) -> Target | None:
-        return self._target
-
-    @target.setter
-    def target(self, t: Target | None):
-        self._target = t
 
     def generate(self, sfg: SfgComposer) -> None:
         return self._generate_irregular(sfg)
@@ -145,7 +123,7 @@ class GenericHBB(GenericLinkwiseBoundary):
         bc_asm = bc_obj.get_assignments(self._lb_method, self._pdf_field)
 
         #   Build generator config
-        bc_cfg = CreateKernelConfig(target=self._target)
+        bc_cfg = get_build_config(sfg).get_pystencils_config()
         bc_cfg.index_dtype = BoundaryIndexType
         index_field = bc_obj.get_index_field()
         bc_cfg.index_field = index_field
@@ -209,7 +187,6 @@ class FreeSlip(GenericLinkwiseBoundary):
         pdf_field: Symbolic LBM PDF field
         wall_orientation: Vector :math:`\\vec{n} \\in \\{ -1, 0, 1 \\}^d` pointing from the wall into the fluid,
             or `FreeSlip.IRREGULAR` to indicate a non-grid-aligned boundary
-        target: Target architecture for the code generator
     """
 
     def __init__(
@@ -224,14 +201,6 @@ class FreeSlip(GenericLinkwiseBoundary):
         self._pdf_field = pdf_field
         self._wall_normal = wall_orientation
 
-    @property
-    def target(self) -> Target | None:
-        return self._target
-
-    @target.setter
-    def target(self, t: Target | None):
-        self._target = t
-
     def generate(self, sfg: SfgComposer) -> None:
         if self._wall_normal == self.IRREGULAR:
             self._generate_irregular(sfg)
@@ -246,7 +215,7 @@ class FreeSlip(GenericLinkwiseBoundary):
         bc_asm = bc_obj.get_assignments(self._lb_method, self._pdf_field)
 
         #   Build generator config
-        bc_cfg = CreateKernelConfig()
+        bc_cfg = get_build_config(sfg).get_pystencils_config()
         bc_cfg.index_dtype = BoundaryIndexType
         index_field = bc_obj.get_index_field()
         bc_cfg.index_field = index_field
@@ -295,8 +264,7 @@ class FreeSlip(GenericLinkwiseBoundary):
 
     def _generate_regular(self, sfg: SfgComposer):
         bc_asm = self._grid_aligned_assignments()
-        bc_cfg = CreateKernelConfig()
-        bc_sweep = Sweep(self._name, bc_asm, bc_cfg)
+        bc_sweep = Sweep(self._name, bc_asm)
         sfg.generate(bc_sweep)
 
     def _grid_aligned_assignments(self):
-- 
GitLab