diff --git a/examples/.gitignore b/examples/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..ca6be88315595d88cd8b4d0a09cbfbc336f476b3 --- /dev/null +++ b/examples/.gitignore @@ -0,0 +1 @@ +_sphinx_build diff --git a/examples/Makefile b/examples/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..722b842da7481121e56468628dec1b81e0a6613c --- /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 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..bebe118f655fc55007b721fe4f701b62bb4279ab 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 0000000000000000000000000000000000000000..b2a43666cb53f7329114ab8445cd9e26811c2bba --- /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 0000000000000000000000000000000000000000..f1f2ca36c6c0a1989293dfcc0bad92b3144d47ad --- /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 0000000000000000000000000000000000000000..7b65737eae4207451a75901da2b1858977db908d Binary files /dev/null and b/examples/downloads/PoiseuilleChannel.zip differ diff --git a/examples/index.md b/examples/index.md new file mode 100644 index 0000000000000000000000000000000000000000..79a790ad849fe55a5d08873ba72fa57b931760e4 --- /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 Binary files /dev/null and b/examples/zipped-examples/PoiseuilleChannel.zip differ