waLBerla 7.2
|
This guide describes the necessary steps to download and compile the waLBerla project sources.
To build waLBerla, you are going to need at least:
WaLBerla also has numerous optional dependencies:
To work with the latest development revision of waLBerla, clone the main Git repository:
If you mean to extend waLBerla's code base for your own purposes, or contribute to waLBerla's development, you should create a fork off the main repository and clone the forked repo instead.
To build a specific released version of waLBerla, you need to download its sources as a Zip archive or tarball from our GitLab and extract that archive into your filesystem.
WaLBerla's CMake build system exposes a large number of configuration options. Also, depending on which of its modules you are using, you may have to populate numerous additional build parameters with values specific to your local machine. In order to document a build setup and to make builds reproducible, we recommend to use CMake Presets.
Create a CMakeUserPresets.json
file in the waLBerla project folder and populate it with the following content:
This defines a CMake configure preset called debug, using the Ninja
generator (swap this for Unix Makefiles
if you don't have Ninja installed). The CMake build type is set to Debug
, and gcc/g++
are used as compilers.
Generate the build system from this preset using the following command:
This will set up the CMake build tree at the build/debug
subfolder.
cmake --preset <preset-name>
again, or execute a regeneration task in your IDE (Delete Cache and Reconfigure in VS Code, Reset Cache and Reload Project in CLion).To validate that the build system was correctly configured, navigate to the newly created subfolder build/debug
. There, run the following command to build the UniformGridBenchmark
target to check if the framework successfully compiles:
The build system of waLBerla is mostly configured through CMake cache variables. If you are working on waLBerla directly, you should set these variables using the cacheVariables
dictionary of your CMake configure preset (see above), e.g.:
Alternatively, cache variables can be set using the -D
flag of the CMake command line.
If you are embedding waLBerla into another project, you can also use a preset or command line flags if you wish to selectively enable certain features. However, if your project needs to always enable or disable some feature, use the option()
CMake function; for instance, to always enable OpenMP in the waLBerla build, add the following to your CMakeLists:
Support for MPI is enabled by default in waLBerla. You may however disable it by setting the WALBERLA_BUILD_WITH_MPI
build option to false
.
OpenMP is used in waLBerla for thread-based parallel computing on CPUs. To enable it, set the WALBERLA_BUILD_WITH_OPENMP
build option to true
.
The waLBerla repository comes with a family of tutorials, benchmarks, and showcase applications, located in the apps
directory. These can be enabled in the build by setting the respective build options:
WALBERLA_BUILD_TUTORIALS
for tutorials;WALBERLA_BUILD_BENCHMARKS
for benchmarks;WALBERLA_BUILD_SHOWCASES
for showcases.Several tutorials, and most of the latest benchmark and showcase apps, require at least code generation and the embedded Python interpreter to be active in the build. Also, CUDA needs to be active for GPU applications.
Most recent benchmark and showcase applications built with waLBerla are making heavy use of automatic code generation using pystencils and lbmpy. Code generation takes place during the build process. To enable it, you need to manually install the required packages into your local Python environment and point waLBerla's build system at the correct Python interpreter.
You are going to need at least Python 3.10. If in doubt, run the query python3 --version
to find out the version of your Python installation.
There are multiple providers for virtual Python environments out there. We recommend using either the built-in venv or the more versatile virtualenv module. However, these only work if you already have an installation of Python 3.10 or newer on your machine; which might not be the case on certain HPC clusters, or on outdated Linux distributions. In that case, you could use Miniconda to manage your Python environment.
Create and activate a new virtual environment inside your project directory (replace -m venv
by -m virtualenv
if using virtualenv
):
Next, install pystencils and lbmpy (version 1.3), as well as jinja2 into that environment:
Create a new Conda environment, using Python 3.10 and pip
, located in the conda-envs
subfolder of your project directory. Then, activate the environment:
Then, use pip
to install pystencils and lbmpy (version 1.3) and jinja2:
pip
. For an overview of pitfalls when using pip
inside conda environment, refer to this page.There are two cache variables you need to set in order to activate build-time code generation in CMake:
WALBERLA_BUILD_WITH_CODEGEN
to true
Python_ROOT_DIR
to the bin
folder of your Python environment.When using venv
or virtualenv
according to the above instructions, Python_ROOT_DIR
will be <project-dir>/.venv/bin
. When using conda
like above, it will be <project-dir>/conda-envs/waLBerla-codegen/bin
.
In the presets file, you can set these options like this:
Here is a minimal working CMake preset for code generation, using venv
:
WaLBerla offers the option to run Python scripts in an embedded Python interpreter to configure and parametrize simulations. This requires that both CPython >= 3.10 and the Python development headers are installed. When this is the case, you may activate the Python coupling by setting the WALBERLA_BUILD_WITH_PYTHON
build option to true
.
To use the embedded Python interpreter, waLBerla needs the Python package pybind11, which is usually fetched automatically.
But there are systems, on which pybind11 can not be fetched automatically, because no network connection is possible. In this case, download the version 2.13.6 of the pybind11 source from https://github.com/pybind/pybind11/tree/v2.13, copy it to the system without internet connection and set the CMake option ’CMAKE_PYBIND11_SOURCE_DIR’ to your local pybind11 source directory.
For a CUDA support in CMake, installing the NVIDIA GPU drivers and the CUDA Toolkit is required. You can verify your installation by running
nvcc
is not found, adding it to PATH
may resolve the issue:The CUDA support in CMake is enabled via WALBERLA_BUILD_WITH_CUDA
. When this flag is set to ON
, waLBerla automates several steps for using CUDA in the CMake project. It attempts to find and configure CUDA, enables compile options, sets up preprocessor macros such as WALBERLA_BUILD_WITH_GPU_SUPPORT
, etc.
It also configures the build pipeline such that the CUDA sources are compiled separately with the compiler specified in CMAKE_CUDA_COMPILER
.
The CMAKE_CUDA_ARCHITECTURES
specifies the compute capability of the target GPU architecture, which is then used by nvcc
to generate hardware-specific code. If you are not sure which compute capability your GPU has, refer to the NVidia Developer Documentation.
CMAKE_CUDA_ARCHITECTURES=XY
, e.g. 8.0 means CMAKE_CUDA_ARCHITECTURES=80
.You can also use CMAKE_CUDA_ARCHITECTURES=native
to have the compute capability determined automatically, based on your local GPU.
To use CUDA with waLBerla, set at least WALBERLA_BUILD_WITH_CUDA
and CMAKE_CUDA_ARCHITECTURES
, e.g. in the CMake presets file:
Or on the command line:
WaLBerla's mesh_common
and mesh
modules couple with OpenMesh, an open-source tool developed at RWTH Aachen, to import and handle surface meshes of geometric objects.
The OpenMesh tool is fetched automatically by CMake, when setting WALBERLA_BUILD_WITH_OPENMESH=ON
.
There are systems, on which OpenMesh can not be fetched automatically, because no network connection is possible. In this case, download the newest OpenMesh source from https://gitlab.vci.rwth-aachen.de:9000/OpenMesh/OpenMesh.git, copy it to the system without internet connection and set the CMake option option ’CMAKE_OPEN_SOURCE_DIR’ to your local OpenMesh source directory.
WaLBerla optionally links against the popular graph partitioning libraries Metis and ParMetis. To activate Metis and ParMetis support, set the respective build options to true
:
WALBERLA_BUILD_WITH_METIS
for MetisWALBERLA_BUILD_WITH_PARMETIS
for ParMetisThe build system will then attempt to find a local installation of either library.