# Simple methods for solving 2D steady incompressible flow?

I'm trying to make a CFD model where I can place a source and a sink anywhere in a grid and get the fluid flow rate across each cell boundary between those locations. I'm starting simple with a 3x3 grid and solving continuity for each grid element, but that leaves me a few equations short (9 equations, 12 unknowns). In general I'd like to be able to raise that to a 64x64 grid with multiple flow inputs.

Is there a way to constrain the system such that I can solve it with continuity equations or is this more difficult than I had initially thought?

Below is a simple diagram of my 3x3 grid (o = source, x = drain):

-------
|o| | |
-------
| | | |
-------
| | |x|
-------


within the above grid is 9 cells and 12 cell boundaries. How do I fully constrain the system to solve for the flow?

edit: doing some reading on CFD, it would seem that storing the velocity for the CENTRE of each cell is advantageous and the boundary velocities would be calculated based on the centre values for surrounding cells... Although I still don't entirely know how my equations would look with that.

I cannot comment, so as an answer may I recommend looking at something like:

http://lorenabarba.com/blog/cfd-python-12-steps-to-navier-stokes/ form start to finish?

This takes the reader from basic discretisation of convective and diffusive terms in 1d and 2d, over a way of dealing with incompressibility via an equation for pressure derived from the continuity equation, to finally a basic lid-driven cavity code. All is done in the context of finite differences with easy to interpret code samples.

I followed the above course myself and found if very helpful in getting started.

• Once, you have enough reputation you can comment. – nicoguaro Jan 13 '17 at 18:22

With the continuity eqn only, you are missing all the mechanical balance: viscous and/or inertial effects will decide of the streamlines of such a flow.

If your major aim is to keep it as simple as possible, I would go for a lubrication approximation. If you consider that your fluid is seeping between two flat plates with a very narrow gap, in the end the equations will be:

$c v = -\nabla p$

$\nabla \cdot v = 0$

$c$ is a friction coefficient.

You don't say how you currently solve for continuity equation, so it's a bit difficult to say how you should extend the method for this system. Let's just say that quite likely you'll want a finite volume type of grid, with pressures in cell centers and velocities in each direction at midpoint of cell edges orthogonal to this direction.

Ironically, there is an iterative method called "SIMPLE" (semi-implicit method for pressure-linked equations) designed to resolve the steady state navier-stokes equations based on a predictor-corrector scheme. It works by solving a linearized form of the momentum equation (predictor step) which produces a velocity field which generally does not satisfy continuity. The predicted velocity is used to obtain an equation for pressure which is constrained by the continuity equation. The result of this equation is a pressure field which roughly satisfies the continuity equation (corrector step). Using the updated pressure field, one can easily update the velocity field again so that it satisfies continuity with less error. One repeats this process iteratively until a steady state is reached.

For an example of its implementation, you may want to look at OpenFOAM's simpleFoam solver for an example of such an implementation:

https://github.com/OpenFOAM/OpenFOAM-2.3.x/tree/master/applications/solvers/incompressible/simpleFoam

Admittedly, OpenFOAM is not the easiest software to read and understand, but it shows all of the aforentioned steps (predictor in UEqn.H and corrector in pEqn.H). It may help you as a guide to developing your own implementation. For a more detailed explanation of the terms in the software, you may consider looking at some of the tutorials from Chalmers. In particular, I recommend "A look inside icoFoam (and pisoFoam)": http://www.tfd.chalmers.se/~hani/kurser/OS_CFD_2013/aLookInsideIcoFoam.pdf

You can only have 9 unknowns as you have 9 equations. Use of a staggered grid introduces more unknowns then equations, hence you have to use a collocated grid. Hence applying the continuity equation for a cell having center $(i,j)$ you get

$u|_{i-\frac{1}{2},j}^{i+\frac{1}{2},j}+v|_{i,j-\frac{1}{2}}^{i,j+\frac{1}{2}}=0$

The edge velocities can be approximated by geometric avergae of values in adjacent cells.

eg.

$u_{i+\frac{1}{2},j}=\frac{u_{i+1,j}+u_{i,j}}{2}$

Applying in a such a manner, should enable you to discretize with 9 unknowns, 9 equations. Add a source term wherever needed.