This is a simple course project I did a while ago. It's a simulation of two-dimensional incompressible fluid with an immersed solid, visualized with marker particles, running at interactive rates on a typical workstation (the mouse controls the immersed solid).
Download source code
From the README:
When you run it, a window is popped up showing (massless) particles suspended in a 2D incompressible fluid. A purple disc immersed in the fluid follows the mouse, stirring it up. Press any key to exit.
Running "main -help" displays options you can pass in to the program (the size of the Eulerian grid, the number of particles, etc.).
The program uses a semi-lagrangian method combined with a pressure correction on a MAC grid for the fluid flow, with open outer boundaries (p=0, u=0) and solid boundaries around the disc (normal derivative of p is zero, u = velocity of disc). There are a number of things left to be implemented:
1. The semi-lagrangian advection ignores solid boundaries
2. The particles are advanced with just forward Euler and no collision detection with the disc; as a result they frequently can go through it when they shouldn't
3. The conjugate gradient iteration for pressure is unpreconditioned
4. It could be extended to 3D - the simulation is straightforward (but a little tedious to make 3D) but the visualization and interaction need to be rethought.
5. The numerical scheme is too dissipative; vorticity confinement or some other method could help maintain the small scale detail better
6. The code needs to be optimized
Back to my home page