A configurable application for LBM simulations with complex geometries DISCLAIMER: for this tutorial, you must have built
In this tutorial, the basic LBM setup from Tutorial LBM 1 is extended by the capability of handling complex geometries loaded from mesh files. It has following features:
The LBM routine mostly follows what has been demonstrated in LBM Tutorial 1. However, as our aim to load arbitrary complex geometry from a mesh file, we cannot specify the geometry via the Boundaries Block in the configuration file. We use
mesh module that utilizes OpenMesh for loading, storing and manipulating meshes. Note that you must build waLBerla with OpenMesh capabilities in order to do this tutorial.
In this application, we will again simulate a channel flow around an obstacle. As before, the application will be fully configurable by a configuration file.
In this tutorial, we will use the standard D3Q27 stencil with a SRT collision model.
As this is only the basic LBM setup, other stencils and collision methods can be included to simulate more accurate, stable and complex flows.
When building waLBerla with the CMAKE configuration
WALBERLA_BUILD_WITH_OPENMESH enabled, one can use its capabilities for loading, storing and manipulating meshes. OpenMesh supports many common mesh data formats. We will use an
Reading meshes into waLBerla is relatively straightforward, even for large scale simulations. Firstly, we define a block in our parameter file responsible for the mesh and the domain:
We will comment on the meaning behind these parameters when they are first used in the code snippets.
The name of the file in which our mesh is stored (here:
bunny.obj as we want to simulate a flow around the Stanford Bunny) is parsed as usual:
Afterwards, the mesh is read in on a single process and broadcasted to all other processes with
Note that we have requested vertex colors from the mesh for the purpose of coloring the faces of the object according to its vertices in the next step. Therefore we define a helper function
vertexToFaceColor that iterates over all faces and colors them in their vertex color. If no uniform coloring of the vertices is given, a default color is taken.
After calling this function, we prepare for building the distance octree by precalculating information (e.g. face normals) of the mesh that is required for computing the singed distances from a point to a triangle:
From this information we can finally build the distance octree. It stores information about how close or far boundaries are to each other. Later, this information could be used for e.g. adaptive mesh refinement (note that this will not be covered in this tutorial).
Even though we have successfully loaded the complex geometry and set up the corresponding distance octree, we have not defined our computational LB domain yet. In this tutorial, the LB domain is defined relatively to the loaded geometry. Henceforth, we calculate the axis-aligned bounding box of the geometry and scale it to our needs. Here, we chose our channel to be 10x3x1 times the size of the Stanford Bunny. This scaling is defined in the parameter file (parameter: domainScaling). As the bunny will be placed in the center of the bounding box, we shift the center to the left such that the bunny will be nearer to the inflow.
Finally, we use a convenient built-in data structure that will be responsible for the creation of the structured block forest.
ComplexGeometryStructuredBlockforestCreator takes as arguments the axis-aligned bounding box of the domain, the cell sizes
dx and an exclusion function. In this tutorial, we want to exclude the interior of the Stanford Bunny with a maximum error of
dx. After setting the periodicity obtained from the parameter file
we create the structured block forest on which the sweeps will be performed
The rest of the tutorial mainly follows Tutorial 01 and should therefore be self-explanatory. The only adaption that has to be made is the treatment of the boundaries. Whereas the boundary conditions of the basic domain (inflow, outflow, no-slip) can be again treated by the lbm::DefaultBoundaryHandlingFactory, the no-slip boundary conditions of the bunny need special attention. After the standard routine of the lbm::DefaultBoundaryHandlingFactory
we address the complex geometry. In a first step, the boundaries that we colored in
vertexToFaceColor are equipped with the no-slip boundary UID and the boundary information is added to the mesh.
In order to have the mesh information available at postprocessing, we write this information to a VTK file as
Lastly, the boundary information of the complex geometry is added to the structured block forest and the fluid cells and the boundaries are set accordingly.
Now that you have seen how to load and process complex geometries from a mesh file, you can play around with this tutorial and adapt it to your needs.
Suggestions for further improvement are the already mentioned adaptive refinement of the loaded geometry. Load balancing of the resulting blocks is then recommended. Thin can be done by using functionalities of mesh::ComplexGeometryStructuredBlockforestCreator and mesh::MeshWorkloadMemory, respectively.