diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index bf5e6fa193d4df6336eee83fc8a1def861ae5c46..b9c0b73f092dd9c1b669114538e2bc1d66b4b2cc 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,8 +1,22 @@ stages: + - Test - Documentation - Deploy +build-examples: + image: i10git.cs.fau.de:5005/pycodegen/pycodegen/nox:alpine + tags: + - docker + stage: "Test" + needs: [] + script: + - cd user_manual/examples + - cmake -S . -B build + - cd build + - cmake --build . --target Examples + + build-user-manual: image: i10git.cs.fau.de:5005/pycodegen/pycodegen/nox:alpine tags: diff --git a/cmake/codegen-requirements.txt b/cmake/codegen-requirements.txt index 95d6c04fc10cdd717a06aeef4f273572b483aae3..15fffb4ef00e73c7effbc4b7a1eb0ebbf1482905 100644 --- a/cmake/codegen-requirements.txt +++ b/cmake/codegen-requirements.txt @@ -1,8 +1,8 @@ # pystencils 2.0 Development Branch -git+https://i10git.cs.fau.de/pycodegen/pystencils.git@fhennig/config-fix +git+https://i10git.cs.fau.de/pycodegen/pystencils.git@v2.0-dev # lbmpy: feature branch for pystencils-2.0 compatibility git+https://i10git.cs.fau.de/pycodegen/lbmpy.git@fhennig/pystencils2.0-compat # pystencils-sfg: (development branch with updated CMake modules and cpptypes) -git+https://i10git.cs.fau.de/pycodegen/pystencils-sfg.git@fhennig/devel +git+https://i10git.cs.fau.de/pycodegen/pystencils-sfg.git@master diff --git a/user_manual/CMakeLists.txt b/user_manual/CMakeLists.txt deleted file mode 100644 index fa52a83142e2873531d9438f09e31c4c2a86e7bb..0000000000000000000000000000000000000000 --- a/user_manual/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -cmake_minimum_required( VERSION 3.24 ) -project( walberla-codegen-examples ) - -include(FetchContent) - -FetchContent_Declare( - walberla - GIT_REPOSITORY https://i10git.cs.fau.de/walberla/walberla.git -) - -message( STATUS "Fetching waLBerla sources (this might take a while)..." ) -FetchContent_MakeAvailable(walberla) - -add_subdirectory(${CMAKE_SOURCE_DIR}/.. ${CMAKE_BINARY_DIR}/sfg-walberla) - -add_subdirectory( examples ) diff --git a/user_manual/examples/CMakeLists.txt b/user_manual/examples/CMakeLists.txt index b1419920a911b2eff471d98ad8429d8fc44c51fd..f498cc3603a44d597f611da0530ef297a238f97a 100644 --- a/user_manual/examples/CMakeLists.txt +++ b/user_manual/examples/CMakeLists.txt @@ -1,3 +1,26 @@ +cmake_minimum_required( VERSION 3.24 ) +project( walberla-codegen-examples ) + +include(FetchContent) + +FetchContent_Declare( + walberla + GIT_REPOSITORY https://i10git.cs.fau.de/walberla/walberla.git +) + +message( STATUS "Fetching waLBerla sources (this might take a while)..." ) +FetchContent_MakeAvailable(walberla) + +add_subdirectory(${CMAKE_SOURCE_DIR}/../.. ${CMAKE_BINARY_DIR}/sfg-walberla) + add_subdirectory( GeneratorScriptBasics ) add_subdirectory( ForceDrivenChannel ) -add_subdirectory( SparseSpiral ) \ No newline at end of file +add_subdirectory( SparseSpiral ) + +add_custom_target( Examples ) +add_dependencies( + Examples + Ex_GeneratorScriptBasics + Ex_ForceDrivenChannel + SparseSpiral +) diff --git a/user_manual/examples/ForceDrivenChannel/CMakeLists.txt b/user_manual/examples/ForceDrivenChannel/CMakeLists.txt index 4fbb89077b6d17f564cad91113e1f74cc0cd81b6..3e21d3e157882b198cb7099828e15beade497ac6 100644 --- a/user_manual/examples/ForceDrivenChannel/CMakeLists.txt +++ b/user_manual/examples/ForceDrivenChannel/CMakeLists.txt @@ -3,7 +3,7 @@ waLBerla_link_files_to_builddir( Channel.prm ) add_executable( Ex_ForceDrivenChannel ) target_sources( Ex_ForceDrivenChannel PRIVATE ForceDrivenChannel.cpp ) -pystencilssfg_generate_target_sources( Ex_ForceDrivenChannel +walberla_generate_sources( Ex_ForceDrivenChannel SCRIPTS LbmAlgorithms.py ) diff --git a/user_manual/examples/ForceDrivenChannel/ForceDrivenChannel.cpp b/user_manual/examples/ForceDrivenChannel/ForceDrivenChannel.cpp index 52238a70a2ebcb079d0f61257174e7aef82102bf..2871b8d363703cba9fb93bddb69469b3e5ae103a 100644 --- a/user_manual/examples/ForceDrivenChannel/ForceDrivenChannel.cpp +++ b/user_manual/examples/ForceDrivenChannel/ForceDrivenChannel.cpp @@ -17,7 +17,7 @@ #include "vtk/all.h" -#include "gen/Ex_ForceDrivenChannel/LbmAlgorithms.hpp" +#include "gen/LbmAlgorithms.hpp" namespace Ex_ForceDrivenChannel { diff --git a/user_manual/examples/ForceDrivenChannel/ForceDrivenChannel.md b/user_manual/examples/ForceDrivenChannel/ForceDrivenChannel.md index 1cc8d1481dd7767d6e111bceebb60646890b77e0..b0df8092ec1701b06ad7a2e621757e9489c6e99d 100644 --- a/user_manual/examples/ForceDrivenChannel/ForceDrivenChannel.md +++ b/user_manual/examples/ForceDrivenChannel/ForceDrivenChannel.md @@ -25,10 +25,7 @@ This example comprises the following files: ::: The CMake target setup for this example is quite straight-forward. -We create a new executable called `Ex_PoiseuilleChannel` -and add to it the single C++ source file `PoiseuilleChannel.cpp`. +We create a new executable called `Ex_ForceDrivenChannel` +and add to it the single C++ source file `ForceDrivenChannel.cpp`. Then, we register our code generator script `LbmAlgorithms.py` via the -[`pystencilssfg_generate_target_sources`][sfg_add_gen_scripts] CMake function. - - -[sfg_add_gen_scripts]: https://pycodegen.pages.i10git.cs.fau.de/pystencils-sfg/usage/project_integration.html#add-generator-scripts "pystencils-sfg Documentation" \ No newline at end of file +`walberla_generate_sources` CMake function. diff --git a/user_manual/examples/ForceDrivenChannel/LbmAlgorithms.py b/user_manual/examples/ForceDrivenChannel/LbmAlgorithms.py index fe9b7c1c314090e88db71ee82afe01311e6983c4..c468a8da68a1f2152afb2e5773e881b1d34cbe2c 100644 --- a/user_manual/examples/ForceDrivenChannel/LbmAlgorithms.py +++ b/user_manual/examples/ForceDrivenChannel/LbmAlgorithms.py @@ -1,11 +1,10 @@ import sympy as sp +import pystencils as ps from pystencilssfg import SourceFileGenerator from sfg_walberla import Sweep from sfg_walberla.boundaries import SimpleHbbBoundary -from pystencils import Target, fields -import pystencils.codegen.config as cfg from lbmpy import ( LBStencil, Stencil, @@ -21,8 +20,8 @@ from lbmpy.macroscopic_value_kernels import macroscopic_values_setter stencil = LBStencil(Stencil.D3Q19) dim = stencil.D -f, f_tmp, rho, u = fields( - f"f({stencil.Q}), f_tmp({stencil.Q}), rho(1), u({dim}): [{dim}D]", layout="fzyx" +f, f_tmp, rho, u = ps.fields( + f"f({stencil.Q}), f_tmp({stencil.Q}), rho(1), u({dim}): double[{dim}D]", layout="fzyx" ) omega = sp.Symbol("omega") force = sp.symbols(f"F_:{dim}") @@ -47,9 +46,9 @@ with SourceFileGenerator() as sfg: lbm_opt = LBMOptimisation(symbolic_field=f, symbolic_temporary_field=f_tmp) - gen_config = cfg.CreateKernelConfig( - target=Target.CPU, cpu_optim=cfg.CpuOptimConfig(openmp=True) - ) + gen_config = ps.CreateKernelConfig() + gen_config.target = ps.Target.CPU + gen_config.cpu.openmp.enable = True lb_update = create_lb_update_rule(lbm_config=lbm_config, lbm_optimisation=lbm_opt) lb_update_sweep = Sweep("LbStreamCollide", lb_update, gen_config) diff --git a/user_manual/examples/GeneratorScriptBasics/BasicCodegenApp.cpp b/user_manual/examples/GeneratorScriptBasics/BasicCodegenApp.cpp index 0cb852b61fda67ad65a4ba18612acf40f23f7882..8e95a89d58c5b889719198311cf493f6b86b16cd 100644 --- a/user_manual/examples/GeneratorScriptBasics/BasicCodegenApp.cpp +++ b/user_manual/examples/GeneratorScriptBasics/BasicCodegenApp.cpp @@ -1,4 +1,4 @@ -#include "gen/Ex_GeneratorScriptBasics/BasicCodegen.hpp" +#include "gen/BasicCodegen.hpp" #include <iostream> int main(void) { diff --git a/user_manual/examples/GeneratorScriptBasics/GeneratorScriptBasics.md b/user_manual/examples/GeneratorScriptBasics/GeneratorScriptBasics.md index f0577069ae5cf79de01ddeafaf49ca2dd9439178..0c69e15956a7b76e69f81b7966db6d5b617e1768 100644 --- a/user_manual/examples/GeneratorScriptBasics/GeneratorScriptBasics.md +++ b/user_manual/examples/GeneratorScriptBasics/GeneratorScriptBasics.md @@ -82,8 +82,8 @@ Generating sfg_sources/gen/Ex_GeneratorScriptBasics/BasicCodegen.hpp, sfg_source ``` This indicates that the generator script was executed and produced exactly two files below the `sfg_sources` directory: -- a header file `gen/Ex_GeneratorScriptBasics/BasicCodegen.hpp`, which is the one we included into our application, and -- a source file `gen/Ex_GeneratorScriptBasics/BasicCodegen.cpp`, which at this time is still empty +- a header file `gen/BasicCodegen.hpp`, which is the one we included into our application, and +- a source file `gen/BasicCodegen.cpp`, which at this time is still empty because we haven't defined any kernels or functions yet. The `walberla_generate_sources` CMake command made sure that the `sfg_sources` directory was placed in your diff --git a/user_manual/examples/SparseSpiral/SparseSpiral.cpp b/user_manual/examples/SparseSpiral/SparseSpiral.cpp index f2b469b62870376f3b9aa47f5afc823a458b4dc7..2234ba1e74e7d8b51f241c1cd6be3edad86f0863 100644 --- a/user_manual/examples/SparseSpiral/SparseSpiral.cpp +++ b/user_manual/examples/SparseSpiral/SparseSpiral.cpp @@ -7,7 +7,7 @@ #include <array> -#include "gen/SparseSpiral/SparseSweep.hpp" +#include "gen/SpiralSweep.hpp" namespace SparseSpiral { diff --git a/user_manual/examples/SparseSpiral/SpiralSweep.py b/user_manual/examples/SparseSpiral/SpiralSweep.py index f9808a5ad79fdfa5b9444e6035e7b5773460b0ab..e573c812b9499d58abdc5a28557bdef0a394c2a1 100644 --- a/user_manual/examples/SparseSpiral/SpiralSweep.py +++ b/user_manual/examples/SparseSpiral/SpiralSweep.py @@ -5,7 +5,7 @@ from pystencils import fields, Assignment with SourceFileGenerator() as sfg: sfg.namespace("SparseSpiral::gen") - f = fields("f(3): [3D]", layout="fzyx") + f = fields("f(3): double[3D]", layout="fzyx") asms = [ Assignment(f.center(0), cell.x()),