Vortex
A GPU-accelerated fluid dynamics simulator using the Smoothed Particle Hydrodynamics (SPH) method. Capable of simulating millions of particles in real-time with interactive visualization.
Features
- GPU Acceleration: CUDA/OpenCL backend for parallel computation
- Interactive Controls: Real-time parameter adjustment
- Multiple Fluid Types: Support for water, oil, and custom materials
- Boundary Conditions: Solid boundaries, periodic boundaries, and free surfaces
- Visualization: Real-time rendering with particle splatting and surface reconstruction
Algorithm Overview
SPH discretizes the fluid into particles, each carrying properties like density, pressure, and velocity. The Navier-Stokes equations are solved using kernel functions:
where is the smoothing kernel and is the smoothing radius.
Performance
| Particle Count | FPS (RTX 4090) | FPS (RTX 3080) |
|---|---|---|
| 100k | 120 | 85 |
| 500k | 60 | 42 |
| 1M | 30 | 20 |
| 5M | 8 | 5 |
All benchmarks at 1920x1080 resolution with full visualization enabled.
Implementation
The core simulation loop runs entirely on the GPU:
__global__ void computeDensity(
float3* positions,
float* densities,
float mass,
float smoothingRadius,
int numParticles
) {
int i = blockIdx.x * blockDim.x + threadIdx.x;
if (i >= numParticles) return;
float density = 0.0f;
for (int j = 0; j < numParticles; j++) {
float3 r = positions[i] - positions[j];
float dist = length(r);
if (dist < smoothingRadius) {
density += mass * cubicSplineKernel(dist, smoothingRadius);
}
}
densities[i] = density;
}
Optimization Techniques
- Spatial Hashing: O(1) neighbor lookup using hash grids
- Multi-GPU Support: Distribute particles across multiple GPUs
- Adaptive Time Stepping: Adjust timestep based on maximum velocity
- Level-of-Detail: Reduce particle count in distant regions
Applications
Vortex has been used for:
- Game engine integration
- Scientific visualization
- Educational demonstrations
- Film and animation pre-visualization
References
Future Enhancements
Planned features:
- Two-way fluid-solid coupling
- Surface tension effects
- Phase transitions (liquid ↔︎ gas)
- Multi-resolution SPH for large-scale simulations
- WebGPU backend for browser-based simulations