Home

HomeEQUATIONS / SOURCE-GROUNDED

Formulas

The relations that keep the fluid incompressible

These equations are taken from the fluid chapter’s solver notes. Nothing here invents results—only the mathematics the Metal solver implements.

EQ. 01

Momentum

Incompressible Navier–Stokes

How velocity changes under advection, pressure, viscosity, and force.

∂u∂t+(u⋅∇)u=−∇p+ν∇2u+f\dfrac{\partial \htmlClass{fs fs--u}{\mathbf{u}}}{\partial t}+\bigl(\htmlClass{fs fs--u}{\mathbf{u}}\cdot\htmlClass{fs fs--grad}{\nabla}\bigr)\htmlClass{fs fs--u}{\mathbf{u}}=-\htmlClass{fs fs--grad}{\nabla}\htmlClass{fs fs--p}{p}+\htmlClass{fs fs--nu}{\nu}\htmlClass{fs fs--grad}{\nabla}^{2}\htmlClass{fs fs--u}{\mathbf{u}}+\htmlClass{fs fs--f}{\mathbf{f}}

RowSim advances a 2-D velocity field with Stam’s stable-fluids decomposition of this equation. Advection moves the field, forces inject stroke energy, and pressure later removes compression so the result stays fluid-like under projection.

SourceThesis, Ch. 3 / Appendix A

EQ. 02

Divergence-free

Incompressibility constraint

The field must not locally expand or compress.

∇⋅u=0\htmlClass{fs fs--div}{\nabla\cdot\mathbf{u}}=\htmlClass{fs fs--zero}{0}

This single constraint is what makes the motion read as fluid. After forces create a tentative velocity, the projection step restores divergence-free flow so room-scale flow stays continuous instead of smearing.

SourceThesis, Ch. 3 / Appendix A

EQ. 03

Projection

Pressure Poisson equation

Find the pressure that cancels measured divergence.

∇2p=∇⋅u~\htmlClass{fs fs--lap}{\nabla^{2}p}=\htmlClass{fs fs--divu}{\nabla\cdot\tilde{\mathbf{u}}}

Divergence of the tentative velocity becomes the right-hand side of a Poisson solve. On Apple Silicon, RowSim uses sixteen red/black Gauss–Seidel pairs; the fragment fallback uses twenty Jacobi sweeps. Subtracting ∇p then yields a divergence-free field.

SourceThesis, Ch. 3 / Appendix A

EQ. 04

Correct

Velocity projection

Remove the compressive part of the tentative velocity.

u=u~−∇p\htmlClass{fs fs--u}{\mathbf{u}}=\htmlClass{fs fs--utilde}{\tilde{\mathbf{u}}}-\htmlClass{fs fs--gradp}{\nabla p}

Once pressure is known, subtracting its gradient projects the field onto an incompressible state. This is the practical heart of the solver: injected stroke energy becomes a fluid instead of a blob.

SourceThesis, Ch. 3 / Appendix A

EQ. 05

Curl

Scalar vorticity estimate

Local rotation recovered from neighbouring velocity samples.

ω≈12[(vi+1,j−vi−1,j)−(ui,j+1−ui,j−1)]\htmlClass{fs fs--omega}{\omega}\approx\tfrac{1}{2}\big[(\htmlClass{fs fs--v}{v}_{i+1,j}-\htmlClass{fs fs--v}{v}_{i-1,j})-(\htmlClass{fs fs--u}{u}_{i,j+1}-\htmlClass{fs fs--u}{u}_{i,j-1})\big]

Semi-Lagrangian advection damps rotation. Estimating curl and feeding a confinement force back into velocity restores visible swirls. RowSim also adds obstacle-edge curl shedding so the hull sheds vortices instead of killing them.

SourceThesis, Ch. 3 / Appendix A

EQ. 06

Ripples

Damped wave / ripple update

A second height field carries wave memory across frames.

ht+1=(2−d) ht−(1−d) ht−1+c2∇2ht\htmlClass{fs fs--h}{h}_{t+1}=(2-\htmlClass{fs fs--d}{d})\,\htmlClass{fs fs--h}{h}_{t}-(1-\htmlClass{fs fs--d}{d})\,\htmlClass{fs fs--h}{h}_{t-1}+\htmlClass{fs fs--c}{c}^{2}\htmlClass{fs fs--lap}{\nabla^{2}}\htmlClass{fs fs--h}{h}_{t}

Ripples live in a separate texture with current and previous height. The explicit damped wave update, plus advection along the carrier flow, lets disturbances drift with the field and couple back into velocity.

SourceThesis, Ch. 3 / Appendix A