# 2D Hydro Code on GPUs

*By CK On April 12, 2011 · Leave a Comment*

I spent couple weeks implementing a simple 2D hydrodynamic code in CUDA C, which is a technology developed by nVidia. The code runs on the GPU instead of CPU. It uses Fourier spectral method with the 2/3 dealiasing rule and 4-th order Runge-Kutta integrator to solve the vorticity equation

where is the vorticity, is the stream function, is the kinematic viscosity, is the Ekman coefficient, and is the Jacobian determinant. When running with resolution and single precision float, the code reaches 130 GFLOPS on an nVidia GeForce GTX 580 card, which is over an order of magnitude faster than CPU codes.

The above movie shows a subdomain of a two-dimensional, incompressible hydrodynamic simulation. The color represents vorticity. The initial condition has two thin layers of vorticity (one not shown) with small random perturbations. The vorticity sheets become unstable due to the Kelvin–Helmholtz instability.

Here is another movie showing a simulation with Kolmogorov forcing.

I would like to thank PDC for providing the Zorn cluster, which makes the development possible. The Zorn cluster is named after a painter Anders Zorn because it has GPUs. The code is now available for download on GitHub.

### Categories

- Astronomy (6)
- Computation (12)
- Data Science (2)
- In the News (2)
- Physics (8)
- Technology (2)