Richard Waller

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:

ρi=∑jmjW(ri−rj,h)\rho_i = \sum_j m_j W(\mathbf{r}_i - \mathbf{r}_j, h)

where WW is the smoothing kernel and hh 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

  1. Spatial Hashing: O(1) neighbor lookup using hash grids
  2. Multi-GPU Support: Distribute particles across multiple GPUs
  3. Adaptive Time Stepping: Adjust timestep based on maximum velocity
  4. 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


Links to this page

Simulation and Reality
The Performance Illusion
Change Log