## Fluid Simulation with CUDA June 2012-July 2012

## Introduction

In this project I implemented an interactive grid-based fluid simulation with CUDA, which is a parallel programming language. Several interactive elements were added to the program including a Kinect input interface, a controllable sphere and a fish swimming around. Adding these features make the program quite fun to play with.

To implement a parallel fluid simulation, I referred to GPU Gems in which a gpu shader fluid simulation was discussed. I borrowed some ideas from it and implemented the algorithm in CUDA.

To implement a parallel fluid simulation, I referred to GPU Gems in which a gpu shader fluid simulation was discussed. I borrowed some ideas from it and implemented the algorithm in CUDA.

## Fluid Simulation

Water simulation

The fluid simulation part was a standard grid-based fluid simulation. Using CUDA, the simulation can be performed in real-time. In this project, I achieved a frame rate of about 15 fps with a 64*64*64 grid, which wasn't really "real-time" actually.

More details about the simulation, I used the forward Euler time-integration for the advection part and Jacobian iteration for solving the pressure field. To visualize water, a level-set field is used which implicitly represents the surface of the fluid.

More details about the simulation, I used the forward Euler time-integration for the advection part and Jacobian iteration for solving the pressure field. To visualize water, a level-set field is used which implicitly represents the surface of the fluid.

## Rendering

The rendering of water is done by ray-tracing the level-set field. We first map the screen to the 3-D space and get rays that starts from the eye position and directs at each pixels in the resulting image. Then the ray is pushed forward in the level-set field and returns the thickness of the water as well as the reflection and refraction parameters. Combining these informations with a background image and the glass tank, the color of one pixel can be computed.

## Fish

To add more fun into the program, I created a fish that swims randomly in the water tank. The underlying representation of the fish is actually a mass-spring system. I had four mass points and three springs that connects them. With proper force feedback set up, the system can perform fish-like motions. The fish model is then split into four parts and for each a mass point is assigned.