Fluid Simulation (2007) [pdf]
cs.ubc.ca
cs.ubc.ca
https://m.youtube.com/watch?v=KcLz3yAqqyI
https://m.youtube.com/watch?v=jWu7yWw_jBQ
https://m.youtube.com/watch?v=G9l1PP0-rDY
It’s up on the unity asset store too under “physics based flames”. I was thinking about doing a writeup on it for hn since it was a pretty interesting journey making it..
I know this is well known among scientists and a lot of software engineers, and I should have remembered it from my math classes in college, but: It was new to me that just because you have a set of differential equations, a computer, and (relatively) unlimited time to evaluate them doesn't mean you can get a useful or stable solution
I eventually got it working thanks to the book by Bridson and Müller-Fischer and a few other papers I read through, but it took about 5 times as long to implement as I expected. Also I couldn't use it in my game, since I couldn't figure out how to handle my special boundary conditions and ran out of time, so there were a lot of situations where the water in the game would explode and fly everywhere. Hoo whee
Robert Bridson does a great job on explaining fluid concepts, and there's a useful appendix on the basics of vector math, but it's definitely still a lot of work to build up a good understanding of the equations.
I own the second edition of the book, released in 2015, though I haven't read too much of it, as I already went through the first in detail. However, I did notice that the second edition emphasizes some important points that were a little subtle in the first edition. That would have made implementing it easier [1].
The other thing about the second edition is that fluid simulation has advanced since 2007. The foundations are still the same, and the pressure solve remains unchanged, but advection has been made both simpler to implement and more accurate by using a particle representation for that portion of the algorithm.
IIRC, the 2nd edition covers FLIP, which is one of those newer techniques, though not the most current. The APIC paper[2] was also released in 2015 (with a video [3]), and it was a bit of a breakthrough. APIC is pretty much better in every way. Fortunately, Bridson's book prepares you well for reading the APIC paper (which assumes you know the standard fluid simulation techniques already).
In short: this free material is a great introduction to fluid simulation. If you want to implement your own simulation, read the second edition of the book, then read the APIC paper.
[1]: The greatest weakness of the notes/book IMO, was the lack of a reference implementation. I never got around to cleaning up the code after I got it working, but here's my implementation. Please forgive the mess: https://github.com/cgmb/euler
[2]: The affine particle-in-cell method (2015) - https://disney-animation.s3.amazonaws.com/uploads/production...
It's for computer graphics. Fluid simulation for, for example, simulating air pressure on an aircraft in development is more precise and numerical methods are more complex.
What does the CFD community do? Something like the Finite Element Method? I sat in on a grad course on continuum mechanics from the mech eng. department, but we never strayed from abstract mathematics.
The literature on DL + cfd is growing steadily with some interesting papers at machine learning conferences. We are seeing the first set of applications in industry as well, very exciting !
Another smaller recommendation. What they call a "MAC grid" is called a staggered grid or mesh by CFD folks in my experience, so it might be better to use this terminology instead. The reference they cite is also out of date. I'd recommend something like this instead: https://www.sciencedirect.com/science/article/pii/S002199919...
This newer paper has higher order extensions of the method the 1965 paper uses and as I recall goes into much more detail about the properties of the schemes.
Physical simulations need to preserve entropy, maximum principle, energy conservation and other kinds of conservation, preservation of consistent states, convergence in case of finer mesh.
There are multiple equations which model different forms of fluid: 1. Incompressible Euler (For liquid) 2. Compressible Euler (For non-viscous gases) 3. Navier Stokes Equations (For viscous liquids)
There are multiple solver methods: 1. Finite Difference 2. Finite Element 3. Discontiguous Galerkin Finite Element 4. Finite Volume Method
There are multiple equation methods: 1. equation splitting is just one of the many methods possible.
Just because the equation is unique does not mean that the solution is unique. Single equation provably have multiple and even infinite solution for the same initial condition. Computer graphics fluid simulation does not care (with a good reason) about this and hence, often their simulations even though they look kind of nice, are often incorrect since they do not demonstrate various physical characteristics that must be preserved.
In contrast, the qualitative/quantitative constraint in physical simulations are very strict. You need to know a lot of theoretical math to even understand if you are even computing the correct solution.
Other folks have already discussed differences in numerical methods, so I'll discuss the other major difference: turbulence modeling.
I don't think that turbulence modeling is addressed in computer graphics, as physical accuracy does not seem to be a major priority. The word "turbulence" or variants of it does not seem to be in the linked notes.
From an equations perspective, the "raw" Navier-Stokes equations are used for "direct numerical simulation" (DNS). The resolution requirements (e.g., grid size and time step) to accurately simulate turbulent flows makes the computational cost very high for all but the most trivial flows. Using a larger grids and time steps reduces the accuracy far too much. So instead of solving the Navier-Stokes equations, typically one of two different sets of equations that are derived from the Navier-Stokes equations are solved. These are the Reynolds-averaged Navier-Stokes equations (RANS equations; a statistical approach) dating back to the 19th century and the Large eddy simulation (LES; applying spatial filters instead of averages) equations, dating back to the 1960s. The RANS equations compute time or "ensemble" averaged quantities typically. The LES equations compute a filtered version of the fields, including only the large scales on the grid. These equations have lower computational requirements, but include new "unclosed" terms that require modeling. LES is typically viewed as more credible, though in my experience RANS computes the quantities you typically want. Well designed LES schemes will converge to DNS as the grid is refined; this is not true for RANS.
Turbulence modeling unfortunately has not proved to be as successful as it needs to be. Turbulence modeling might be impossible in some sense, as there's no reason to believe that the information one has available can be used to estimate the information one needs to accurately model turbulence. I view these models as requiring empirical data and not generalizing well.
I've been reading some of the research papers on waves and fluids from the late-1800s. One I went through a couple weeks ago was Reynold's 1883 paper on turbulent flow [1]. It's interesting going through old papers. They're a lot more casual and meandering than modern ones, and I feel like I get more insight into how the sausage is made that way.
I still wonder about some things, though. I'm familiar with the main CG fluid techniques, and it seems that they are used in real scientific simulations on occasion. For example, Smoothed-Particle Hydrodynamics have been used in ocean wave simulations, and they appear to validate against wave tank experiments. I actually was going to use them myself for simulations of wave-swept environments.
But, aside from bumping into Bridson at a conference, I haven't gotten many chances to speak to someone who really knows fluids well. I was wondering if you'd be willing to answer some more questions of mine about how the CG methods compare to DNS, LES and RANS. If so, send me an email and maybe we can chat about it. My address is just my HN username at gmail.com.
[1]: https://royalsocietypublishing.org/doi/abs/10.1098/rspl.1883...