This repository provides a High-Order GPU-Accelerated 3D Compressible Navier-Stokes Solver. The solver employs high-order finite difference methods to solve the 3D compressible Navier-Stokes equations on curvilinear structured meshes. Developed in C++ with CUDA, it leverages GPU acceleration to significantly enhance computational efficiency.
This code is derived from my research experience in numerical methods for CFD, and it emphasizes clarity and maintainability, prioritizing transparent algorithmic logic over micro-level code optimization.
- High-Order Finite Difference Schemes: Implements a 5th-order WENO scheme for inviscid fluxes and a 4th-order central finite difference scheme for viscous fluxes, ensuring high accuracy in simulations.
- Curvilinear Structured Mesh Support: Flexible support for non-Cartesian geometries.
- CUDA Acceleration: Leverages GPU computing to significantly enhance computational efficiency.
- CMake Build System: Simplified build and cross-platform compatibility.
- Unit Testing: Developed with Google Test to ensure code reliability.
- C++14 or higher
- CMake 3.15 or higher
- C++ compiler (e.g.,
g++
) - CUDA compiler (e.g.,
nvcc
) - Python (for running scripts)
To get started, clone the repository:
git clone https://github.com/chenbei102/cbns3d_cuda.git
-
Create a build directory and navigate into it:
mkdir build cd build
-
Generate the build files using CMake:
cmake -D CMAKE_CUDA_ARCHITECTURES=<value> <path/to/source/code>
Replace with the appropriate CUDA architecture for your GPU hardware. This step involves specifying the correct CMAKE_CUDA_ARCHITECTURES value in the configuration to match your GPU's compute capability.
You can also set optional flags:
-D INVIS_MODE=ON
for an inviscid simulation.-D INVIS_MODE=OFF
for a viscous simulation.-D BUILD_TESTS=ON
to enable building unit tests.
-
Compile the project:
make
If you enabled unit tests (BUILD_TESTS=ON
), you can run them with:
ctest
-
Prepare the mesh file: The mesh file should be in the Plot3D format for a 3D single-grid.
-
Edit the .ini configuration file: Edit the
.ini
file to configure the simulation parameters. Refer to thepython/rae2822.ini
file for an example configuration. -
Parse the .ini file: Use the
parser_ini.py
script to parse the configuration file:python <path/to/source/code>/python/parser_ini.py <ini_file_name>
-
Run the solver executable: Execute the solver with the following command:
./cbns3d_cuda
Once the simulation is complete, the resulting flow field data will be saved in a file named output.vtk
in legacy VTK format. You can visualize and postprocess the data using ParaView or other compatible software.