From 7816ecca2650b5c840e348d73541ef5a1cf5fb18 Mon Sep 17 00:00:00 2001 From: Frederik Hennig <frederik.hennig@fau.de> Date: Thu, 19 Dec 2024 12:24:07 +0100 Subject: [PATCH] toward basics guide --- examples/.gitignore | 2 ++ examples/CMakeLists.txt | 1 + .../GeneratorScriptBasics/BasicCodegen.py | 4 +++ examples/GeneratorScriptBasics/CMakeLists.txt | 12 ++++++++ .../GeneratorScriptBasics.md | 28 ++++++++++++++++++ examples/Makefile | 5 +++- examples/downloads/PoiseuilleChannel.zip | Bin 1357 -> 0 bytes examples/examples.mk | 1 + examples/index.md | 3 +- .../zipped-examples/PoiseuilleChannel.zip | Bin 1831 -> 0 bytes 10 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 examples/GeneratorScriptBasics/BasicCodegen.py create mode 100644 examples/GeneratorScriptBasics/CMakeLists.txt create mode 100644 examples/GeneratorScriptBasics/GeneratorScriptBasics.md delete mode 100644 examples/downloads/PoiseuilleChannel.zip create mode 100644 examples/examples.mk delete mode 100644 examples/zipped-examples/PoiseuilleChannel.zip diff --git a/examples/.gitignore b/examples/.gitignore index ca6be88..4741371 100644 --- a/examples/.gitignore +++ b/examples/.gitignore @@ -1 +1,3 @@ _sphinx_build +downloads +zipped-examples diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index dd2f833..56d5261 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -12,5 +12,6 @@ FetchContent_MakeAvailable(walberla) add_subdirectory(${CMAKE_SOURCE_DIR}/.. ${CMAKE_BINARY_DIR}/sfg-walberla) +add_subdirectory( GeneratorScriptBasics ) add_subdirectory( PoiseuilleChannel ) diff --git a/examples/GeneratorScriptBasics/BasicCodegen.py b/examples/GeneratorScriptBasics/BasicCodegen.py new file mode 100644 index 0000000..a23e622 --- /dev/null +++ b/examples/GeneratorScriptBasics/BasicCodegen.py @@ -0,0 +1,4 @@ +from pystencilssfg import SourceFileGenerator + +with SourceFileGenerator() as sfg: + pass diff --git a/examples/GeneratorScriptBasics/CMakeLists.txt b/examples/GeneratorScriptBasics/CMakeLists.txt new file mode 100644 index 0000000..ab855a4 --- /dev/null +++ b/examples/GeneratorScriptBasics/CMakeLists.txt @@ -0,0 +1,12 @@ +add_executable( Ex_GeneratorScriptBasics ) +target_sources( Ex_GeneratorScriptBasics PRIVATE Ex_GeneratorScriptBasics.cpp ) + +pystencilssfg_generate_target_sources( Ex_PoiseuilleChannel + SCRIPTS BasicCodegen.py +) + +target_link_libraries( + Ex_GeneratorScriptBasics + PRIVATE + core blockforest sfg_walberla +) diff --git a/examples/GeneratorScriptBasics/GeneratorScriptBasics.md b/examples/GeneratorScriptBasics/GeneratorScriptBasics.md new file mode 100644 index 0000000..2792411 --- /dev/null +++ b/examples/GeneratorScriptBasics/GeneratorScriptBasics.md @@ -0,0 +1,28 @@ +# Getting Started with Generator Scripts + +This example aims to illustrate the basic code generation features of `sfg-walberla` +by building a force-driven channel flow application. + +## Files + +{download}`GeneratorScriptBasics.zip </zipped-examples/GeneratorScriptBasics.zip>`. + +This example comprises the following files: + + - `GeneratorScriptBasics.cpp`: The demo simulation; + - `BasicCodegen.py`: A sample code generation script; + - `CMakeLists.txt`: The CMake build system configuration. + +## CMake Target Definition + +:::{card} `CMakeLists.txt` +::::{literalinclude} CMakeLists.txt +:language: CMake +:::: +::: + +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 diff --git a/examples/Makefile b/examples/Makefile index 722b842..bfa9099 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -10,6 +10,8 @@ BUILDDIR = _sphinx_build ZIPPED_EXAMPLES := zipped-examples +include examples.mk + MKDIR := mkdir -p dir_guard = $(MKDIR) $(@D) @@ -30,8 +32,9 @@ clean: @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) ZipExamples: $(ZIPPED_EXAMPLES)/PoiseuilleChannel.zip +ZipExamples: $(foreach example, $(EXAMPLES), $(ZIPPED_EXAMPLES)/$(example).zip) -$(ZIPPED_EXAMPLES)/PoiseuilleChannel.zip: PoiseuilleChannel/* +$(ZIPPED_EXAMPLES)/%.zip: %/* @$(dir_guard) @echo Zipping $(<D) @zip -r $@ $(<D) diff --git a/examples/downloads/PoiseuilleChannel.zip b/examples/downloads/PoiseuilleChannel.zip deleted file mode 100644 index 7b65737eae4207451a75901da2b1858977db908d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1357 zcmWIWW@h1H0D<E%lOw?lC?Uik!w`_4S)5v$nUj<1oROH9mztv=8p6rIJoS5W`g9;J zt>9*0WO>2NzyKx!;AZVCnS^4N5>~T(l5!n$(({WlOEPkc^$IG%X6s%^N(W&qW{Ut_ z#=)Q#J2}#(t)OBqkjKc#z@UKDY-iuZ>{Or3;*w&$l8O?r$sRwF(?J-`<ko&$zC#8) zt>5PzQr5Y{7{IR5#-$i`+VhUkRbMUjrBA;t>EKno_T6sp{F&$2!xTm2t8(@h9Fn={ z6F2AcuEvQ|+E{L{QhGi?d|R-Z@}9=3gKEEyu!`E<(`1=;DD_gG@iL2*Proo{>n*?i zFY560&6^+Zm{uEfZ}kyr)vxu3b3)ptSVrh4sNCA8>vifvp^U|AVY!{{SIR6V&-hxJ zS;YtnQi!)Lf!+?>Z<w_m=xs@$x7DzE8zaK>a#O&b&jWfKgwZ^o+kZCeuz^6!`>HO+ z_*>1N8FrdIx#OI_^ug9Wo5WMrUO46X>s#m?hlO9P&YU-wJr`y3eYujjUq!g#Jr%cO zx1BT#OWq|5GT+ZQ>#G{c8+uV^_Eo2;f#SzJ)a2sSkDck9tv5?x#;dR!3mBVQckU08 z+36y6=ST0xw?3271P+}uu$B0eETQ;HbV{+v{_C=HUR%vk-SoHd)2?Ti4&<hDN=1K) zlX-V<aq)|fmVe@^?W}*yX<t9R{%iPmW<*L0FP;?X_*ip>A~0A$Se?jVNiHaWB;~V7 z>Hg<1l3Qk8i9&8-W}Ze_erAfMLN%8H5EP}BlosVF7+7=Fas_xZGRZOH$~h81mw<o( z!&^rXjS(%te8dXLM`#g(Y%XRlf|<*}u%yuktGSqY3TO}3`~-48t{eri2bju$_N>5a z4|@Ir+JYr-L41QN0VCToA7~k7C}D_zlQYmREJ+zT<S<hOvR&Jlh_efvMnKU7Od}Z4 W#L5N?7Y0@!{10@x1+WZcU;qI0)1~wP diff --git a/examples/examples.mk b/examples/examples.mk new file mode 100644 index 0000000..d360745 --- /dev/null +++ b/examples/examples.mk @@ -0,0 +1 @@ +EXAMPLES = GeneratorScriptBasics PoiseuilleChannel diff --git a/examples/index.md b/examples/index.md index 79a790a..7332822 100644 --- a/examples/index.md +++ b/examples/index.md @@ -5,5 +5,6 @@ :caption: Fundamentals :maxdepth: 1 +GeneratorScriptBasics/GeneratorScriptBasics PoiseuilleChannel/PoiseuilleChannel -::: \ No newline at end of file +::: diff --git a/examples/zipped-examples/PoiseuilleChannel.zip b/examples/zipped-examples/PoiseuilleChannel.zip deleted file mode 100644 index 3af55558698f18b309a52e1bcfda5ab6f68699d2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1831 zcmWIWW@h1H0D<E%lOw?lC?Uik!w`_4S)5v$nUj<1oROH9mztv=8p6rIJoS5W`g9;J zt>9*0WO>2NzyKx!;AZVCnS^4N5>~T(l5!n$(({WlOEPkc^$IG%X6s%^N(W&qW{Ut_ z#=$TtVRB^2E^poQKwcpu1A_uqvz>htvr~OCi%W|2N-9dgCLjKroDRZhCihO**muZ) zr|r94t9#x{Ylb9;q!kPs-8^5lt;iFy)Vr{K{}wIba-n-U|Ns5D?O%IKadOxb=k-?p zGp4$vy7}k6u4Mkbn~!m&pUnaP(3jgne>hopnYBn;><JOBJ+??aW~;0EEZMG8g(=-X z<s*y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