From 575f10c22ded681f6508dea257e6037cca488893 Mon Sep 17 00:00:00 2001
From: Frederik Hennig <frederik.hennig@fau.de>
Date: Wed, 5 Mar 2025 14:07:41 +0100
Subject: [PATCH] refactor sfg_walberla python module to walberla.codegen

---
 .flake8                                              |  2 +-
 .gitattributes                                       |  2 +-
 cmake/CodegenConfig.template.py                      |  4 ++--
 cmake/check_python_env.py                            |  4 ++--
 pyproject.toml                                       | 12 ++++++++----
 src/{sfg_walberla => walberla/codegen}/__init__.py   |  0
 src/{sfg_walberla => walberla/codegen}/_version.py   |  4 ++--
 src/{sfg_walberla => walberla/codegen}/api.py        |  0
 .../codegen}/boundaries/__init__.py                  |  0
 .../codegen}/boundaries/boundary_utils.py            |  0
 .../codegen}/boundaries/freeslip.py                  |  0
 .../codegen}/boundaries/hbb.py                       |  0
 .../codegen}/build_config.py                         |  0
 .../codegen}/postprocessing.py                       |  0
 src/{sfg_walberla => walberla/codegen}/reflection.py |  0
 src/{sfg_walberla => walberla/codegen}/sweep.py      |  0
 src/{sfg_walberla => walberla/codegen}/symbolic.py   |  0
 tests/BlockforestGeometry.py                         |  4 ++--
 tests/FreeSlip/IrregularFreeSlip.py                  |  4 ++--
 tests/Jacobi.py                                      |  2 +-
 .../examples/ForceDrivenChannel/LbmAlgorithms.py     |  4 ++--
 user_manual/examples/FreeSlipBubble/LbmAlgorithms.py |  4 ++--
 user_manual/examples/SparseSpiral/SpiralSweep.py     |  4 ++--
 23 files changed, 27 insertions(+), 23 deletions(-)
 rename src/{sfg_walberla => walberla/codegen}/__init__.py (100%)
 rename src/{sfg_walberla => walberla/codegen}/_version.py (99%)
 rename src/{sfg_walberla => walberla/codegen}/api.py (100%)
 rename src/{sfg_walberla => walberla/codegen}/boundaries/__init__.py (100%)
 rename src/{sfg_walberla => walberla/codegen}/boundaries/boundary_utils.py (100%)
 rename src/{sfg_walberla => walberla/codegen}/boundaries/freeslip.py (100%)
 rename src/{sfg_walberla => walberla/codegen}/boundaries/hbb.py (100%)
 rename src/{sfg_walberla => walberla/codegen}/build_config.py (100%)
 rename src/{sfg_walberla => walberla/codegen}/postprocessing.py (100%)
 rename src/{sfg_walberla => walberla/codegen}/reflection.py (100%)
 rename src/{sfg_walberla => walberla/codegen}/sweep.py (100%)
 rename src/{sfg_walberla => walberla/codegen}/symbolic.py (100%)

diff --git a/.flake8 b/.flake8
index 6998ab8..b631094 100644
--- a/.flake8
+++ b/.flake8
@@ -1,3 +1,3 @@
 [flake8]
 max-line-length=120
-exclude = src/sfg_walberla/_version.py
+exclude = src/walberla/codegen/_version.py
diff --git a/.gitattributes b/.gitattributes
index 745cc9c..7897bc3 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1 +1 @@
-src/sfg_walberla/_version.py export-subst
+src/walberla/codegen/_version.py export-subst
diff --git a/cmake/CodegenConfig.template.py b/cmake/CodegenConfig.template.py
index 07f2999..61533d2 100644
--- a/cmake/CodegenConfig.template.py
+++ b/cmake/CodegenConfig.template.py
@@ -1,5 +1,5 @@
 from pystencilssfg import SfgConfig
-from sfg_walberla import WalberlaBuildConfig
+from walberla.codegen import WalberlaBuildConfig
 
 
 def configure_sfg(cfg: SfgConfig):
@@ -8,7 +8,7 @@ def configure_sfg(cfg: SfgConfig):
 
 
 def project_info() -> WalberlaBuildConfig:
-    from sfg_walberla.build_config import cmake_parse_bool
+    from walberla.codegen.build_config import cmake_parse_bool
 
     return WalberlaBuildConfig(
         c_compiler_id="${CMAKE_C_COMPILER_ID}",
diff --git a/cmake/check_python_env.py b/cmake/check_python_env.py
index 7d00009..7901b56 100644
--- a/cmake/check_python_env.py
+++ b/cmake/check_python_env.py
@@ -20,9 +20,9 @@ except ImportError:
     error("pystencils-sfg is not installed in the current Python environment.")
 
 try:
-    import sfg_walberla
+    import walberla.codegen
 except ImportError:
-    error("sfg_walberla is not installed in the current Python environment.")
+    error("walberla-codegen is not installed in the current Python environment.")
 
 print("found required packages pystencils, pystencils-sfg, sfg-walberla", end="")
 
diff --git a/pyproject.toml b/pyproject.toml
index 10b9a0f..ecf2f4d 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,5 +1,5 @@
 [project]
-name = "sfg_walberla"
+name = "walberla-codegen"
 description = "Code Generation Utilities for walBerla"
 authors = [
     {name = "Frederik Hennig", email = "frederik.hennig@fau.de"},
@@ -20,10 +20,14 @@ requires = [
 ]
 build-backend = "setuptools.build_meta"
 
+[tool.setuptools.packages.find]
+where = ["src/"]
+include = ["walberla.codegen", "walberla.codegen.*"]
+
 [tool.versioneer]
 VCS = "git"
 style = "pep440"
-versionfile_source = "src/sfg_walberla/_version.py"
-versionfile_build = "sfg_walberla/_version.py"
+versionfile_source = "src/walberla/codegen/_version.py"
+versionfile_build = "walberla/codegen/_version.py"
 tag_prefix = "v"
-parentdir_prefix = "sfg_walberla-"
+parentdir_prefix = "walberla-codegen-"
diff --git a/src/sfg_walberla/__init__.py b/src/walberla/codegen/__init__.py
similarity index 100%
rename from src/sfg_walberla/__init__.py
rename to src/walberla/codegen/__init__.py
diff --git a/src/sfg_walberla/_version.py b/src/walberla/codegen/_version.py
similarity index 99%
rename from src/sfg_walberla/_version.py
rename to src/walberla/codegen/_version.py
index b1d2924..c6263f5 100644
--- a/src/sfg_walberla/_version.py
+++ b/src/walberla/codegen/_version.py
@@ -52,8 +52,8 @@ def get_config() -> VersioneerConfig:
     cfg.VCS = "git"
     cfg.style = "pep440"
     cfg.tag_prefix = "v"
-    cfg.parentdir_prefix = "sfg_walberla-"
-    cfg.versionfile_source = "src/sfg_walberla/_version.py"
+    cfg.parentdir_prefix = "walberla-codegen-"
+    cfg.versionfile_source = "src/walberla/codegen/_version.py"
     cfg.verbose = False
     return cfg
 
diff --git a/src/sfg_walberla/api.py b/src/walberla/codegen/api.py
similarity index 100%
rename from src/sfg_walberla/api.py
rename to src/walberla/codegen/api.py
diff --git a/src/sfg_walberla/boundaries/__init__.py b/src/walberla/codegen/boundaries/__init__.py
similarity index 100%
rename from src/sfg_walberla/boundaries/__init__.py
rename to src/walberla/codegen/boundaries/__init__.py
diff --git a/src/sfg_walberla/boundaries/boundary_utils.py b/src/walberla/codegen/boundaries/boundary_utils.py
similarity index 100%
rename from src/sfg_walberla/boundaries/boundary_utils.py
rename to src/walberla/codegen/boundaries/boundary_utils.py
diff --git a/src/sfg_walberla/boundaries/freeslip.py b/src/walberla/codegen/boundaries/freeslip.py
similarity index 100%
rename from src/sfg_walberla/boundaries/freeslip.py
rename to src/walberla/codegen/boundaries/freeslip.py
diff --git a/src/sfg_walberla/boundaries/hbb.py b/src/walberla/codegen/boundaries/hbb.py
similarity index 100%
rename from src/sfg_walberla/boundaries/hbb.py
rename to src/walberla/codegen/boundaries/hbb.py
diff --git a/src/sfg_walberla/build_config.py b/src/walberla/codegen/build_config.py
similarity index 100%
rename from src/sfg_walberla/build_config.py
rename to src/walberla/codegen/build_config.py
diff --git a/src/sfg_walberla/postprocessing.py b/src/walberla/codegen/postprocessing.py
similarity index 100%
rename from src/sfg_walberla/postprocessing.py
rename to src/walberla/codegen/postprocessing.py
diff --git a/src/sfg_walberla/reflection.py b/src/walberla/codegen/reflection.py
similarity index 100%
rename from src/sfg_walberla/reflection.py
rename to src/walberla/codegen/reflection.py
diff --git a/src/sfg_walberla/sweep.py b/src/walberla/codegen/sweep.py
similarity index 100%
rename from src/sfg_walberla/sweep.py
rename to src/walberla/codegen/sweep.py
diff --git a/src/sfg_walberla/symbolic.py b/src/walberla/codegen/symbolic.py
similarity index 100%
rename from src/sfg_walberla/symbolic.py
rename to src/walberla/codegen/symbolic.py
diff --git a/tests/BlockforestGeometry.py b/tests/BlockforestGeometry.py
index 09445e9..ad29fc4 100644
--- a/tests/BlockforestGeometry.py
+++ b/tests/BlockforestGeometry.py
@@ -1,7 +1,7 @@
 from pystencils.session import *
 from pystencilssfg import SourceFileGenerator, SfgConfiguration
-from sfg_walberla import Sweep
-from sfg_walberla.symbolic import cell
+from walberla.codegen import Sweep
+from walberla.codegen.symbolic import cell
 
 cfg = SfgConfiguration(
     output_directory="out"
diff --git a/tests/FreeSlip/IrregularFreeSlip.py b/tests/FreeSlip/IrregularFreeSlip.py
index 3fa69cf..b197a32 100644
--- a/tests/FreeSlip/IrregularFreeSlip.py
+++ b/tests/FreeSlip/IrregularFreeSlip.py
@@ -6,8 +6,8 @@ from lbmpy import LBStencil, Stencil, LBMConfig, LBMOptimisation, create_lb_upda
 from lbmpy.macroscopic_value_kernels import macroscopic_values_setter
 
 
-from sfg_walberla import Sweep
-from sfg_walberla.boundaries import FreeSlip
+from walberla.codegen import Sweep
+from walberla.codegen.boundaries import FreeSlip
 
 with SourceFileGenerator() as sfg:
     sfg.namespace("TestIrregularFreeSlip::gen")
diff --git a/tests/Jacobi.py b/tests/Jacobi.py
index 0a07ca8..c7f1fbe 100644
--- a/tests/Jacobi.py
+++ b/tests/Jacobi.py
@@ -3,7 +3,7 @@ import sympy as sp
 from pystencils import fields, kernel
 
 from pystencilssfg import SourceFileGenerator, SfgConfiguration
-from sfg_walberla import Sweep
+from walberla.codegen import Sweep
 
 cfg = SfgConfiguration(output_directory="out")
 with SourceFileGenerator(cfg) as sfg:
diff --git a/user_manual/examples/ForceDrivenChannel/LbmAlgorithms.py b/user_manual/examples/ForceDrivenChannel/LbmAlgorithms.py
index c468a8d..af4285a 100644
--- a/user_manual/examples/ForceDrivenChannel/LbmAlgorithms.py
+++ b/user_manual/examples/ForceDrivenChannel/LbmAlgorithms.py
@@ -2,8 +2,8 @@ import sympy as sp
 import pystencils as ps
 
 from pystencilssfg import SourceFileGenerator
-from sfg_walberla import Sweep
-from sfg_walberla.boundaries import SimpleHbbBoundary
+from walberla.codegen import Sweep
+from walberla.codegen.boundaries import SimpleHbbBoundary
 
 from lbmpy import (
     LBStencil,
diff --git a/user_manual/examples/FreeSlipBubble/LbmAlgorithms.py b/user_manual/examples/FreeSlipBubble/LbmAlgorithms.py
index a2975f2..dddace0 100644
--- a/user_manual/examples/FreeSlipBubble/LbmAlgorithms.py
+++ b/user_manual/examples/FreeSlipBubble/LbmAlgorithms.py
@@ -6,7 +6,7 @@ from lbmpy import LBStencil, Stencil, LBMConfig, LBMOptimisation, create_lb_upda
 from lbmpy.macroscopic_value_kernels import macroscopic_values_setter
 
 
-from sfg_walberla import Sweep
+from walberla.codegen import Sweep
 
 with SourceFileGenerator() as sfg:
     sfg.namespace("FreeSlipBubble::gen")
@@ -46,7 +46,7 @@ with SourceFileGenerator() as sfg:
     sfg.generate(lb_init_sweep)
 
     #   begin irregular-freeslip
-    from sfg_walberla.boundaries import FreeSlip
+    from walberla.codegen.boundaries import FreeSlip
 
     freeslip = FreeSlip(
         "FreeSlip",
diff --git a/user_manual/examples/SparseSpiral/SpiralSweep.py b/user_manual/examples/SparseSpiral/SpiralSweep.py
index e573c81..41747b4 100644
--- a/user_manual/examples/SparseSpiral/SpiralSweep.py
+++ b/user_manual/examples/SparseSpiral/SpiralSweep.py
@@ -1,6 +1,6 @@
 from pystencilssfg import SourceFileGenerator
-from sfg_walberla import Sweep
-from sfg_walberla.symbolic import cell
+from walberla.codegen import Sweep
+from walberla.codegen.symbolic import cell
 from pystencils import fields, Assignment
 
 with SourceFileGenerator() as sfg:
-- 
GitLab