Skip to content

Introduction to real time computational fluid dynamics

Šimon Tupý edited this page Nov 3, 2022 · 13 revisions

Computational Fluid Dynamics (CFD)

CFD by itself is a branch of fluid mechanics that uses numerical analysis and data structures to analyze and solve problems that involve fluid flows, however, when we talk about real time CFD, we move away from numerical methods towards approximations of said methods, since traditional numerical methods tend to slow things down quite a bit. The fact that we use approximations instead of precise (or mostly precise) numerical methods does decrease the overall accuracy of the resulting simulation, making them unsuitable for applications with low levels of tolerance, but, on the other hand, makes them perfect for applications requiring high iteration counts and frequent reworks (ie. an animated movie).

Navier-Stokes Equations

Fluids are governed by the incompressible Navier-Stokes equations, however, in order to understand them we need to know a little bit more about how fluids work and what their properties look like.

Advection

Advection is the process of transferring a property of our fluid (such as heat or velocity) via the circulation of movement of the fluid through the simulation domain. Keep in mind that the individual properties affect eachother at the same time.

Divergence

Since we're not using numerical methods, but their approximations we have to keep in mind that there is a growing difference between the approximated and real, numerically-calculated values - divergence. In most cases we only attempt to minimize divergence through increasing the accuracy of our approximations, however, there is also another method - removing divergence altogether (see DFSPH for more info), which substantially increases the stability of the resulting simulation.

Density

Density is a parameter determining how far our particles can get apart from each other.

Viscosity

Viscosity is a property of our simulation that determines the thickness and thinness of a given fluid, and how resistant to external granular forces it is. There are multiple commonly used viscosity models, however, the most frequently used one is dynamic viscosity (the other models include kinematic and apparent viscosities, note that we'll delve deeper into viscosity in a later section). An example of a highly viscous fluid would be honey or oil, while a fluid with lower viscosity would be water.

Now we can finally take a look at the incompressible Navier-Stokes equations, the most common formulation looks like this:

${\partial \vec{u} \over \partial t} + \vec{u} \times \nabla \vec{u} + {1 \over \rho} = \vec{g} + v \nabla \times \nabla \vec{u}$ (Acceleration = Advection + External force + Viscosity - Pressure)

$\nabla \times \vec{u} = 0$ (Divergence has to be equal to 0 in order to enforce incompressibility)

Equation Description
$\vec{u} = (x, y, z)$ Velocity of the fluid $[m / s]$
$\rho$ Density of the fluid $[Kg / m^{3} ]$
$p = {\vec{F} \over A} $ Pressure exerted by the fluid $[Pa]$
$\vec{g} = (x, y, z)$ Gravitational force applied to the fluid $[m/s^{-2}]$
$v$ Viscosity of the fluid.

This might seem a little complex at first, but we can refolmulate these equations and format them as a number of rules our simulation has the abide by, these rules look like this:

Rule Description
Conservation of Energy The amount of energy in our fluid must remain the same over time (or at the very least not deviate by a large margin).
Conservation of Mass The total mass of our fluid must remain the same over time (or at the very least not deviate by a large margin).
Balance of Momentum The momentum of the fluid can only be changed by external force.
Incompressibility The fluid's volume should never change on its own. ( $\nabla \times \vec{u} = 0$ )