Simulation methods have gained popularity due to large increases in computer power and the development of feasible numerical methods. However, these methods require spatial discretization often represented in the form of a mesh or a point cloud. In CFD the Finite Volume Method (FVM) became popular due to its conservative properties and OpenFOAM was the first code operating on meshes consisting of arbitrary control volumes.
A CFD simulation consists of five steps: geometry preparation, volume mesh generation, simulation setup, a solver run, and post-processing. The first two steps are the most labor-consuming. Most often geometry is exported from a CAD package, and this process quite often results in problems, that are difficult to repair. Volume mesh generation has been a research topic for many decades. Block-structured meshes allow for low memory usage due to the order of cells in the mesh. However, they are difficult to generate in complex geometries without sacrificing geometry details. This has motivated the development of unstructured methods which are more automatic, but still require high-quality input data. Recently, a novel class of methods, so-called inside-out, became popular due to its high level of automation, speed, and simplicity.
cfMesh: A novel library for automatic mesh generation
cfMesh a library for mesh generation implemented within the OpenFOAM framework. The library allows for the simple implementation of new meshing workflows and applications. It is implemented by using a concept of mesh modifiers, which is extensible and allows for efficient parallelization using both shared memory parallelization (SMP) and distributed memory parallelization using MPI. In addition, special care has been taken on memory usage, which is kept low by implementing data containers that do not require any dynamic memory allocation operations as a consequence of mesh modification.
The library supports the generation of meshes of arbitrary cell types, and the currently implemented workflows generate cartesian type of polyhedra in both 2D and 3D space, tetrahedra and arbitrary polyhedra. The available workflows are based on the inside-out method starting from a mesh template adjusted to fit the geometry, and the modifiers are designed to be least sensitive to the input data. The implemented methodology generates meshes with millions of cells within minutes for geometries of industrial interest.
Key facts
– A library of meshing algorithms and meshing workflows (mesher) generating various types of cells
– It relies on mesh modifiers used for common meshing tasks (add cells, remove cells, decompose cells, etc.)
– It is parallelized – both SMP and MPI; No need to use MPI when meshing on a single computer; MPI meshing is intended for large meshes that do not fit into the memory of a single computer
– Inside-out meshing – robust and tolerant to bad-quality input
– Developed by Dr. Franjo Juretić
Background and motivation
– Back in 2004, when the project started, there was no available library for polyhedral mesh generation
– The project was intended as a playground for mesh generation algorithms and various ideas related to meshing
– OpenFOAM was getting mature in terms of solver capabilities, and the pre-processing utilities were still very rudimentary
– Mesh generation is a complex task for industrial problems, and it requires robust tools that are easy to use
– Meshing is a dynamic process in terms of memory allocation, and this adds extra complexity to the problem; The data containers available in OpenFOAM were not suitable
– Generation of large meshes and parallel meshing algorithms were at the early stage of development
Meshing example
Airplane (14.5mn cells, 11GB peak memory usage, meshing time 378s @4CPUs (2.4GHz)/8 cores)
Mesher features
Mesher features
Mesh templates: Cartesian (2D and 3D), tetrahedral, and polyhedral.
Input geometry: Geometry is given as a surface triangulation. Patches are defined on the input geometry and transferred onto the volume mesh. Subsets (point, facets) are used for mesh generation but are not transferred onto the volume mesh. Feature edges are defined by the user before volume meshing.
Refinement settings: Global – maximum cell size and boundary cell size. Automatic mesh refinement based on estimated feature size. Local –patch and subset driven.
Gaps and thin features: Global and local options to preserve or remove cells in thin gaps. Used when a low number of cells is required.
Boundary layers: Global – number of layers, thickness ratio, maximum thickness. Patch-based – various number of layers within a single layer.
Mesh modifiers: Perform topological and geometrical transformations on the mesh. Simple API. Disallow the user to perform low-level operations on the mesh, less prone to bugs.
Parallelization: Multi-threading is implemented by using OpenMP, which is supported by most modern C++ compilers. MPI parallelization is available for most mesh modifiers and the Cartesian template generator. Directives are hidden within modifiers. No need to run MPI if the mesh fits into a single computer.
If you have some cfMesh-related questions, feel free to discuss them in our FB group cfMesh.