This work has been published as "Fast Distance Fields for Fluid Dynamics Mesh Generation on Graphics Hardware".
The article is also available on arXiv.
Embedded geometries in CFD
As part of my research I developed a CUDA implementation of a signed distance field (SDF) generator to reduce preprocessing times in CFD simulations. Simulating fluid interaction with objects requires a description of the surface geometry. While body fitted meshes accurately represent complex surfaces, they can have large generation overheads and may produce highly deformed computational cells. An alternative approach is to maintain discrete cut cells at boundaries inside a regular Cartesian grid. The generation of the cut cells requires information about the intersection of objects and the computational mesh. SDFs offer implicit descriptions of geometric information.
The main aims were increased generation speeds and improved robustness compared with existing methodologies. A near-exact SDF field can be constructed from closed orientable STL geometries where the precision is limited only by the resolution of the target computational mesh.
Figure 1: Detail of the DrivAer car geometry [2]. The input is an STL file that lists the triangular faces of a tessellated surface (left). From the unordered set, we quickly construct unique features which are used to build extrusions. The limited extent of these regions is one of the main benefits of the underlying algorithm - work is only done in a small subset of the domain. The resulting SDF and implicit surface information (right) can then be used to construct cut cells in the regular computational domain. Almost all work, from feature sorting to distance calculations, is done in parallel on GPUs using the CUDA platform, leading to low runtimes for the preprocessing and mesh generation phases of fluid simulations.
An improved CSC algorithm on GPUs
An extended Characteristics/Scan Conversion (CSC) algorithm [1] is used to generate a narrow band SDF from triangulated surfaces (figure 1). 3D extrusions are generated from the features of the input shape. The computational mesh vertices inside these volumes are assigned the minimum distance to the features.
Introduced improvements of our implementation are:
- Appropriate handling of saddle vertices (figure 2)
- High performance edge and vertex generation from unordered triangle data (table 1)
- Generation of simpler vertex extrusions
- 3D work scheduling on GPUs
Figure 2: Detail of Stanford rabbit geometry [3]. Many sufficiently complex geometries feature saddle vertices. Leaving these unaddressed in the extrusion phase leads to a erroneous SDF (left). By introducing vertex extrusions to both sides of the saddle regions, we reconstruct the input geometry accurately (right). This results in higher workload but produced correct results in all test cases.
Robust generation of complex geometries
Geometries in industry and research often feature high curvature topography with multiple saddle regions and ruff vertices. Our implementation was tested with several geometries with varying feature counts and complexities (figure 3). The produced code is able to handle intricate details and captures everything from smooth curves to sharp corners. The robust implementation can be used to quickly generate detailed meshes for numerical simulations.
Figure 3: Surface plots and SDF slices of selected test geometries: Orion [4], Stanford Lucy [3], XYZ RGB Dragon [3] and DrivAer [2]. The software captures intricate details and quickly produces robust and high resolution SDFs which can be imported into a mesh generator.
CUDA implementation
The CUDA implementation quickly builds an internal geometry representation from unordered surface features and generated an SDF around a boundary to a user defined maximum distance. Based on a testing set of STL files ranging from ~52,000 to ~2,800,000 faces, the resulting pipeline from reading in the file to handing over to a CFD solver takes on the order of seconds for low distance bands (tables 1 and 2).
Geometry | Faces | Time(s) |
---|---|---|
Orion | 51,770 | 0.095 |
Stanford Rabbit | 69,664 | 0.114 |
Stanford Dragon | 100,000 | 0.154 |
XYZ RGB Dragon | 721,788 | 0.951 |
Stanford Lucy | 2,529,647 | 3.105 |
DrivAer | 2,854,762 | 3.601 |
Table 1: Feature construction on Nvidia Tesla K20 GPU. The highly parallel implementation sorts and matches face, edge and vertex data quickly to combine them into usable surface features. The processing time depends on both the configuration of the geometry and the number and size variation of the triangles.
Geometry | Cell size | Width | Time(s) |
---|---|---|---|
Orion | 0.08 | 0.4 | 0.234 |
Stanford Rabbit | 0.25 | 2.0 | 0.072 |
Stanford Dragon | 0.16 | 2.0 | 0.123 |
XYZ RGB Dragon | 0.53 | 5.0 | 0.143 |
Stanford Lucy | 4.0 | 20.0 | 0.071 |
DrivAer | 11.4e-3 | 0.06 | 0.078 |
Table 2: SDF generation on Nvidia Tesla K20 GPU. The runtime mostly depends on the computational mesh cell size and the distance of the SDF band. A distance of 5 cells is sufficient to generate a field with no gaps. The workload is also dependent on the orientation of the geometry and triangle sizes.