Incompressible velocity evolution
Advection carries momentum along, viscosity diffuses velocity gradients, the nozzle and brush supply force, and pressure keeps the flow incompressible.
Fluid dynamics · a numerical flow you can push
What do advection, diffusion and pressure projection each do in a fluid simulation? Advection carries dye and vortices along with the flow, and diffusion smooths them out. Pressure projection subtracts the gradient of a pressure field, which removes divergence so the fluid neither piles up nor thins out anywhere. That pressure is found by iteration, and with a limited number of iterations a small, measurable divergence remains.
Inside a transparent flow chamber, a two-dimensional incompressible velocity field is drawn as glowing particles spread through a shallow depth. Adjust viscosity, dye diffusion, pressure iterations and vorticity enhancement to see how the jet entrains surrounding fluid and leaves a wake behind a cylinder. Drag through the test section with the fluid brush to inject dye and momentum.
Physics tutorial
BackgroundThe simulation stores velocity and dye on a fixed grid. Each time step alternates velocity diffusion, advection and pressure projection, then carries the dye along. The horizontal and vertical cell spacings are used separately, and slow playback does not change the time units of the readouts.
Why it mattersTaking the solver apart step by step makes the swirls more than a visual effect. You can measure the divergence before and after pressure projection and see the trade-off between stability and numerical dissipation.
Start with the essentials
Advection carries momentum along, viscosity diffuses velocity gradients, the nozzle and brush supply force, and pressure keeps the flow incompressible.
From each grid point, trace backward along the velocity and interpolate the old field at the landing point. The step is robust, but repeated interpolation smooths out detail.
The stored quantity is a velocity potential with the time step and density folded in, so it is not a pressure in pascals. The grid cells are rectangular, so the Poisson relaxation weights the horizontal and vertical directions differently. With a finite number of iterations, the projection does not guarantee zero divergence.
The live value is recomputed from the current velocity. The before and after values from the last projection are a saved pair, marked stale once you paint or change a parameter. When the field is zero, the reduction ratio is undefined.
Typical misconceptionIf the algorithm never blows up, every small vortex must be right.
Better mental modelSemi-Lagrangian advection stays stable at large time steps, but its interpolation adds numerical dissipation. Vorticity enhancement puts back visual detail; it cannot recover the true scales that were lost.
Typical misconceptionBecause the particles fill a depth, the solver must resolve three-dimensional turbulence.
Better mental modelEvery particle samples the same two-dimensional velocity slice. The depth makes the structure easier to see, but it cannot produce three-dimensional vortex stretching.
Choose Cylinder wake and let the dye pass the obstacle.
What to observe: The jet slows and splits in front of the cylinder. Behind it is a slow wake with vortices that alternate in rotation.Pause, arm the brush and paint a disturbance. Enable Divergence diagnostic and click Project only. Change the iteration count, then project again.
What to observe: The before value equals the live divergence just before the click, and the after value equals the new live divergence. Time and dye do not advance. More iterations usually shrink the residual, but that still does not prove exact incompressibility.Arm the fluid brush and drag sideways through the wake. Turn it off when you want to orbit the chamber.
What to observe: Dye and velocity change together where you drag. The new disturbance is then advected, diffused and projected again.Conceptual inspiration: FluidMotion. Original simulations and graphics; the model limits are described above.