
Fluid Simulation (2007) [pdf] - strangecasts
https://www.cs.ubc.ca/~rbridson/fluidsimulation/fluids_notes.pdf
======
fallingfrog
I created a fluid simulation in unity last year, with the goal being to use it
to simulate flowing flames. I had to write my own fft on the gpu to get it to
work. You can see the results here:

[https://m.youtube.com/watch?v=KcLz3yAqqyI](https://m.youtube.com/watch?v=KcLz3yAqqyI)

[https://m.youtube.com/watch?v=jWu7yWw_jBQ](https://m.youtube.com/watch?v=jWu7yWw_jBQ)

[https://m.youtube.com/watch?v=G9l1PP0-rDY](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..

------
VRay
I slogged through implementing this for a game earlier this year. Man oh man,
I bit off way more than I could chew comfortably..

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

~~~
lasagnaphil
Yep, Eulerian fluid simulations are pretty hard to control. I’ve also tried
implementing a fluid sim for my undergraduate thesis (mainly looking at the
Bridson book), but you have to play around with the parameters a lot to get a
smooth result. Fiddling with timestep size, handling numerical instability,
etc... I think that is why games use particle-based methods a lot more,
because it is less finicky and works better in extreme conditions (well, the
players seem to really love doing extreme things in the game...)

------
slavik81
I worked through these course notes with my lab last year. As someone else
commented, Bridson expanded these notes into a book, "Fluid Simulation for
Computer Graphics." The first edition is basically the free PDF with fixes for
things like typos (e.g. the unlabeled variable, rho, in the Conjugate Gradient
algorithm).

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](https://github.com/cgmb/euler)

[2]: The affine particle-in-cell method (2015) - [https://disney-
animation.s3.amazonaws.com/uploads/production...](https://disney-
animation.s3.amazonaws.com/uploads/production/publication_asset/104/asset/apic-
aselle-final.pdf)

[3]: [https://youtu.be/rPPW_1M8nRA](https://youtu.be/rPPW_1M8nRA)

------
mishurov
They wrote a book based on that course and notes.
[https://www.cs.ubc.ca/~rbridson/fluidsimulation/](https://www.cs.ubc.ca/~rbridson/fluidsimulation/)

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.

~~~
slavik81
I'm kind of curious about those models. Are there any major differences aside
from the assumption of incompresssibility? I suppose they probably don't do
equation splitting either?

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.

~~~
lasagnaphil
In CG fluid simulations, one either use grid-based Eulerian methods (Bridson’s
book uses a thing called a MAC grid), or use particled-based Lagrangian
methods such as SPH (smoothed particle hydrodynamics). They all use the
Navier-Stokes equations and the incompressibility condition; the difference is
how you approximate it (with tradeoff between realism/performance). Each
method has its own quirks (such as the PIC method suffering from unwanted
viscosity, and FLIP suffering from numerical instability.) Nowadays the grid-
based people use APIC a lot, because it seems to solve both the disadvantages
of the two (you can see the links in the comment above)

~~~
pilooch
There's a new trend of using deeplearning to replace and mix the solvers. Some
ongoing research looks at tackling the compressible flows. Accelerating
lattice boltzman methods with DL is also under study at various labs. See
[https://github.com/jolibrain/fluidnet_cxx](https://github.com/jolibrain/fluidnet_cxx)
for a reimplementation of fluidnet with aten/Pytorch tensors.

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 !

~~~
btrettel
Fluid dynamicist here. I wasn't aware of the machine learning work you've
mentioned. They're addressing an important problem, but I'm disappointed in
the paper based on a brief look. I see no comparison against experimental data
(validation). Indeed, the cases the authors compute most likely have no
corresponding experiments, but do look cool. I'd recommend that the authors
learn more about verification, validation, and uncertainty quantification for
fluid dynamics. And I'd encourage all machine learning folks approaching CFD
to present your work at both fluids and machine learning conferences. I think
problems like this would be reduced or fixed entirely by more interactions
with fluid dynamicists.

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...](https://www.sciencedirect.com/science/article/pii/S0021999198959629)

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.

~~~
pilooch
There are many recent works originating from the CFD community now. Too many
to list here, you can PM me if you don't find them easily online for some
reason.

