Repository navigation
Home
shaia edited this page Oct 5, 2026
·
4 revisions
Welcome to the CFD Library wiki! This is a 2D/3D Computational Fluid Dynamics framework implemented in C. These pages describe version 0.4.0; see the CHANGELOG for what changed in each release.
- Getting Started - Installation and first simulation
- Solver Guide - Available solvers and when to use them
- Output System - VTK and CSV output, checkpoint/restart
- Examples - Walkthrough of example programs
- Architecture - Library design and internals
- 2D/3D structured grids - Uniform and stretched grid generation
- Multiple solvers - Explicit Euler, Projection Method, RK2 (Heun's method), RK4 (classical), with scalar, SIMD (AVX2), OpenMP, and GPU variants
- Linear solvers - Jacobi, SOR, Red-Black SOR, CG/PCG, BiCGSTAB, GMRES(m), and geometric multigrid (also as a CG preconditioner and as the projection pressure solver)
- Discretization options - Central or first-order upwind convection; explicit or implicit (backward Euler, Crank-Nicolson) viscous time stepping
- Heat transfer - Energy equation with Boussinesq buoyancy and thermal boundary conditions
- RANS turbulence - k-epsilon and Spalart-Allmaras with wall functions (2D uniform grids; scalar, OpenMP, and AVX2 backends)
-
Checkpoint/restart - Versioned binary
.cfdchkfiles that save and restore the full simulation state -
Neural-network inference - Pure-C evaluator for small
.cfdnnmodels, used for learned turbulence closures - Flexible output - VTK for visualization, CSV for data analysis
- Pluggable architecture - Easy to add new solvers
- Cross-platform - Windows, Linux, macOS support
#include "cfd/api/simulation_api.h"
int main() {
// Create 100x100 2D simulation on unit square (nz=1 for 2D)
simulation_data* sim = init_simulation(100, 100, 1, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0);
// Register VTK output every 10 steps
simulation_register_output(sim, OUTPUT_VELOCITY_MAGNITUDE, 10, "velocity");
// Run 100 time steps
for (int step = 0; step < 100; step++) {
run_simulation_step(sim);
simulation_write_outputs(sim, step);
}
free_simulation(sim);
return 0;
}| Solver | Type | Best For |
|---|---|---|
explicit_euler |
CPU | Learning, debugging |
explicit_euler_optimized |
CPU+SIMD (AVX2) | Large grids on modern CPUs |
explicit_euler_omp |
CPU+OpenMP | Multi-core CPU acceleration |
explicit_euler_gpu |
GPU | Very large grids with NVIDIA GPU |
projection |
CPU | Accurate pressure-velocity coupling |
projection_optimized |
CPU+SIMD (AVX2) | Production simulations |
projection_omp |
CPU+OpenMP | Multi-core production simulations |
projection_gpu |
GPU | High-performance GPU simulations |
rk2 |
CPU | Second-order temporal accuracy |
rk2_optimized |
CPU+SIMD (AVX2) | High-accuracy large grids |
rk2_omp |
CPU+OpenMP | High-accuracy multi-core |
rk2_gpu |
GPU | High-accuracy on NVIDIA GPU |
rk4 |
CPU | Fourth-order temporal accuracy |
rk4_optimized |
CPU+SIMD (AVX2) | Fourth-order accuracy, large grids |
rk4_omp |
CPU+OpenMP | Fourth-order accuracy, multi-core |
rk4_gpu |
GPU | Fourth-order accuracy on NVIDIA GPU |
The *_optimized solvers are AVX2 only (there are no NEON Navier-Stokes kernels). They need a build with -DCFD_ENABLE_AVX2=ON (off by default) and a CPU with AVX2 and FMA; otherwise their init returns CFD_ERROR_UNSUPPORTED. The *_gpu solvers are registered only in a -DCFD_ENABLE_CUDA=ON build, and the *_omp solvers only when OpenMP is found.
- API Reference: Available on GitHub Pages (Doxygen-generated)
- Code Coverage: Available on GitHub Pages
- Check the Examples for common use cases
- Review the API documentation
- Open an issue on GitHub for bugs or questions