From 554f114d1d042e2475a0bbb9fb7dcb3a824cac1e Mon Sep 17 00:00:00 2001
From: Frederik Hennig <frederik.hennig@fau.de>
Date: Thu, 19 Dec 2024 12:13:53 +0100
Subject: [PATCH] started writing poiseuille channel example

---
 examples/.gitignore                           |   1 +
 examples/Makefile                             |  37 ++++++++++++++++++
 examples/PoiseuilleChannel/CMakeLists.txt     |  14 +++++++
 .../PoiseuilleChannel/PoiseuilleChannel.md    |  33 ++++++++++++++++
 examples/conf.py                              |  37 ++++++++++++++++++
 examples/downloads/PoiseuilleChannel.zip      | Bin 0 -> 1357 bytes
 examples/index.md                             |   9 +++++
 .../zipped-examples/PoiseuilleChannel.zip     | Bin 0 -> 1831 bytes
 8 files changed, 131 insertions(+)
 create mode 100644 examples/.gitignore
 create mode 100644 examples/Makefile
 create mode 100644 examples/PoiseuilleChannel/PoiseuilleChannel.md
 create mode 100644 examples/conf.py
 create mode 100644 examples/downloads/PoiseuilleChannel.zip
 create mode 100644 examples/index.md
 create mode 100644 examples/zipped-examples/PoiseuilleChannel.zip

diff --git a/examples/.gitignore b/examples/.gitignore
new file mode 100644
index 0000000..ca6be88
--- /dev/null
+++ b/examples/.gitignore
@@ -0,0 +1 @@
+_sphinx_build
diff --git a/examples/Makefile b/examples/Makefile
new file mode 100644
index 0000000..722b842
--- /dev/null
+++ b/examples/Makefile
@@ -0,0 +1,37 @@
+# Minimal makefile for Sphinx documentation
+#
+
+# You can set these variables from the command line, and also
+# from the environment for the first two.
+SPHINXOPTS    ?=
+SPHINXBUILD   ?= sphinx-build
+SOURCEDIR     = .
+BUILDDIR      = _sphinx_build
+
+ZIPPED_EXAMPLES := zipped-examples
+
+MKDIR := mkdir -p
+dir_guard = $(MKDIR) $(@D)
+
+# Put it first so that "make" without argument is like "make help".
+help:
+	@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
+
+.PHONY: help html clean Makefile ZipExamples
+
+# Catch-all target: route all unknown targets to Sphinx using the new
+# "make mode" option.  $(O) is meant as a shortcut for $(SPHINXOPTS).
+html: Makefile ZipExamples
+	@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
+
+clean:
+	@echo "Removing generated downloadable files"
+	@rm -rf $(ZIPPED_EXAMPLES)
+	@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
+
+ZipExamples: $(ZIPPED_EXAMPLES)/PoiseuilleChannel.zip
+
+$(ZIPPED_EXAMPLES)/PoiseuilleChannel.zip: PoiseuilleChannel/*
+	@$(dir_guard)
+	@echo Zipping $(<D)
+	@zip -r $@ $(<D)
diff --git a/examples/PoiseuilleChannel/CMakeLists.txt b/examples/PoiseuilleChannel/CMakeLists.txt
index e69de29..bebe118 100644
--- a/examples/PoiseuilleChannel/CMakeLists.txt
+++ b/examples/PoiseuilleChannel/CMakeLists.txt
@@ -0,0 +1,14 @@
+waLBerla_link_files_to_builddir( Channel.prm )
+
+add_executable( Ex_PoiseuilleChannel )
+target_sources( Ex_PoiseuilleChannel PRIVATE PoiseuilleChannel.cpp )
+
+pystencilssfg_generate_target_sources( Ex_PoiseuilleChannel 
+    SCRIPTS LbmAlgorithms.py
+)
+
+target_link_libraries(
+    Ex_PoiseuilleChannel
+    PRIVATE 
+    core stencil blockforest geometry vtk sfg_walberla 
+)
diff --git a/examples/PoiseuilleChannel/PoiseuilleChannel.md b/examples/PoiseuilleChannel/PoiseuilleChannel.md
new file mode 100644
index 0000000..b2a4366
--- /dev/null
+++ b/examples/PoiseuilleChannel/PoiseuilleChannel.md
@@ -0,0 +1,33 @@
+# Force-Driven Poiseuille Channel
+
+This example aims to illustrate the basic code generation features of `sfg-walberla`
+by building a force-driven channel flow application.
+
+## Files
+
+{download}`PoiseuilleChannel.zip </zipped-examples/PoiseuilleChannel.zip>`.
+
+This example comprises the following files:
+
+ - `PoiseuilleChannel.cpp`: The main simulation application;
+ - `LbmAlgorithms.py`: The code generation script producing the lattice Boltzmann algorithms;
+ - `CMakeLists.txt`: The CMake build system configuration;
+ - `Channel.prm`: the parameter file describing the channel.
+
+
+## CMake Target Definition
+
+:::{card} `CMakeLists.txt`
+::::{literalinclude} CMakeLists.txt
+:language: CMake
+::::
+:::
+
+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`.
+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/conf.py b/examples/conf.py
new file mode 100644
index 0000000..f1f2ca3
--- /dev/null
+++ b/examples/conf.py
@@ -0,0 +1,37 @@
+# Configuration file for the Sphinx documentation builder.
+#
+# For the full list of built-in configuration values, see the documentation:
+# https://www.sphinx-doc.org/en/master/usage/configuration.html
+
+# -- Project information -----------------------------------------------------
+# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
+
+project = 'waLBerla codegen by example'
+copyright = '2024, Frederik Hennig'
+author = 'Frederik Hennig'
+
+
+# -- General configuration ---------------------------------------------------
+# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
+
+extensions = [
+    "myst_parser",
+    "sphinx_design",
+    "sphinx_copybutton",
+]
+
+# templates_path = ['_templates']
+exclude_patterns = ["build"]
+
+myst_enable_extensions = [
+    "colon_fence",
+    "dollarmath",
+    "attrs_inline"
+]
+
+# -- Options for HTML output -------------------------------------------------
+# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
+
+html_theme = 'sphinx_book_theme'
+html_static_path = ['zipped-examples']
+html_title = "waLBerla codegen by example"
diff --git a/examples/downloads/PoiseuilleChannel.zip b/examples/downloads/PoiseuilleChannel.zip
new file mode 100644
index 0000000000000000000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00001

diff --git a/examples/index.md b/examples/index.md
new file mode 100644
index 0000000..79a790a
--- /dev/null
+++ b/examples/index.md
@@ -0,0 +1,9 @@
+# waLBerla Code Generation by Example
+
+
+:::{toctree}
+:caption: Fundamentals
+:maxdepth: 1
+
+PoiseuilleChannel/PoiseuilleChannel
+:::
\ No newline at end of file
diff --git a/examples/zipped-examples/PoiseuilleChannel.zip b/examples/zipped-examples/PoiseuilleChannel.zip
new file mode 100644
index 0000000000000000000000000000000000000000..3af55558698f18b309a52e1bcfda5ab6f68699d2
GIT binary patch
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*yj?rpoyTvL)Y`_djA-$;W9f6H<|OP&)^0ky2_7aU2gw==uWJ?G2@Rq>mrYfqHU
zTE!HvdHU`X-t2Fz+j{=8#z^HK_fAq)Uc+`UU`uVdR^)+1nShF>_Adt3^;t%rCog>S
zmlYHVkbqj8I60EXC2VFq69dCm76t}2tO11)#d^6Z;NUv=KRF$Q(SoZq*gOA<fxy1s
z;XOB!J(;dIOjxjVxl-YZBMVoV#Z^z@vDo%;@$KBJ|Ib-?-hV3O`t3|j|Ia;*!Qvue
z>W%9z9P)P;G?r{Gu<^>i$Wdq)#Ik4F<mbVj!7Wc3yo-Ds)mluH-lV9op2}=t)cs^>
z$!&XT3bR{*ZOKOYReMdWdECm9${S=KXKZ5jc#+Om^>Be$!i(P9&0p?Kn05TBQ;u1I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