## Application - Pressure Poisson Equation

The momentum equation for the velocity field $\vec{u}$ in a fluid is

where $p$ is the pressure, $\nu$ is the fluid viscosity and $\rho$ is the fluid density. With three velocity components, plus the pressure, we have four unknowns but only three equations. For compressible fluids, we have an equation of state to complete the system. In the incompressible case, we don't have an equation of state and we need an additional constraint from somewhere else.

This is what we do: take the divergence of the momentum equation, apply the incompressibility constraint to cancel some terms, and get an equation for the pressure. It's a pretty cool trick.

Conservation of mass for an incompressible fluid requires that the divergence of $\vec{u}$ must be zero:

Writing out the momentum equation in $x$ and $y$ components (for two-dimensional flow), we get

We take the divergence of the momentum equation and then apply the incompressibility constraint. After some wrangling and cancellations, this leaves us with the pressure Poisson equation:

Which is an equation of the form

Imagine we discretize a domain using a uniform mesh of points in each spatial direction, as in the figure below:

Then the left-hand side of the Poisson equation, i.e., the Laplacian differential operator applied to $p$, is discretized using 2nd-order central differences as follows

where subscripts $i,j$ denote the spatial location on a Cartesian coordinate system and superscripts $n$ denote a point in time.

We apply an appropriate finite-difference discretization to the momentum equation (forward-time, backward-space for the 1st-order terms) and also assume a uniform mesh, so $\Delta x = \Delta y$.

Using this discretized form in the Poisson equation, we will leave only the $p_{i,j}$ terms in the left-hand side, and move the other terms to the right. Then we say that we can update all the values of $p_{i,j}$ using the values at the neighboring points for both $p$ and $u, v$. This update, repeated many times, happens to converge to the solution of Poisson's equation.

## Solution procedure

### Initial velocity field

We start with a velocity field in $u$ and $v$ at some timestep $n$.

### Calculate pressure

Then, we iteratively solve the Poisson equation for pressure, as described above. Starting with an initial guess, the values $p_{i,j}$ are updated using the neighboring values of $p$, $u$ and $v$ at $(i+1,j)$ and $(i,j+1)$. The updates can be written as follows, where the $k$ superscript denotes an iteration in 'pseudo-time':

In other words, we repeatedly apply the Poisson equation until the pressure reaches a quasi-steady state.

### Update the velocity

Once the pressure field reaches its quasi-steady state via the Poisson equation, we use that field for the current time step, $p^n$, to solve for the velocity components $u$ and $v$ at the next timestep, $n+1$.

The momentum equation in the $u$ direction:

The momentum equation in the $v$ direction:

Then, rinse and repeat.

## What we left out

There are various subtleties that we left out here, to get quickly to the equations we need in the code. First, there are some variations on the form of the pressure Poisson equation, depending on what terms involving $\nabla\cdot\vec{u}$ one chooses to cancel (this has caused long arguments in the literature!). Second, we say nothing about the boundary conditions, which can cause some trouble (and more arguments!). And third, we show only the simplest iterative method for solving the Poisson equation, which also happens to be the slowest to converge. This is just meant to be a pedagogical example and discussion of these subtleties would be part of a full-fledged CFD course.