*Disclaimer-The video appears more choppy than the actual solver since it recorded at a lower frame rate. Also, the builds are linked at the bottom.
Saturday, December 29, 2018
Navier-Stokes Solver
Today I'll be showcasing a simple 2D incompressible, inviscid fluid solver coded in Unity (with help from my father in designing some key components, in particular the velocity advection and vorticity confinement. CFD is definitely not easy...). The solver is based off two papers (here and here) written by Jos Stam regarding stable fluids, and also includes extra parameters that allow for the simulation of gravity, friction, and vorticity confinement for "swirlier-looking" fluids, along with the adjustment of solver quality and diffusion/advection parameters. In addition, one can choose to visualize the fluid velocity, density, divergence, and pressure. The project was coded in Unity/C# for maximum simplicity, since the game engine provides a sandbox from which I could focus on quickly prototyping and implementing the code rather than creating an entire application framework from scratch, and includes three separate scripts that form the entire simulation. One is the implementation of the mathematics and voxel grid to visually represent the fluid, the second is the user interface, and the third is an application manager that loads pre-generated scenes that simulate multiple types of fluids (fire, smoke, etc.). The source code will be posted below for those that would like to take a closer look; a downloadable build for Linux and Windows is available along with some video demos of me highlighting some of the more interesting program features. The first fire preset shows how the solver is capable of computing fast simulations without the need to over-sample, which is pretty cool. Then more traditional gas/smoke presets are shown before ending with a so-called abstract fluid that advects density along a non-diffuse velocity field, which creates some funky-looking graphics. That's all for the fluid simulator so-far, and I'll soon be posting about the completion of the airplane as well.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment