CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Running, Solving & CFD (
-   -   Trying to figure out the details of simpleFoam (

brooksmoses February 21, 2007 20:53

So, I've been writing up my di
So, I've been writing up my dissertation, which involves some computations done with a variant of simpleFoam, and I'm trying to figure out exactly what it's doing in enough detail to explain it. Unfortunately, after a couple of hours of looking at it and searching through the source code and the OpenFOAM manual, I still have some questions. Perhaps the most useful way for me to ask for help is to post the relevant code with annotations about what parts I understand and what I'm still confused by, so I'll do that. The quoted code is from my version, but fairly close to that in simpleFoam.

fvVectorMatrix UEqn
fvm::div(phi, U)
- fvm::laplacian(nu, U)
- f

My understanding is that this defines a set of coefficients for a linear equation in U, as a function of phi, nu, and f (which is a forcing term I added). So far, so good.


This adjusts the coefficients so as to incorporate the underrelaxation coefficient, such that a solution to UEqn == source will produce a partly-relaxed version of U, yes? And it doesn't do anything to U?

solve(UEqn == -fvc::grad(p));

This computes a solution, and does something with it, but I'm not entirely clear on what. Does it update U? Does it add information to UEqn? Why is grad(p) in here, when the usual form of the predictor-corrector is to add the pressure effect in the corrector step? (My guess: this version adds the old-timestep pressure here, and the corrector step is only adding the effects from the change in pressure.)

volScalarField AU = UEqn.A();
U = UEqn.H()/AU;

This is the part that I'm most confused about -- what, exactly, are A() and H()? It appears from fvMatrix.C that A() is a volume-corrected version of the diagonal terms of the linear equation, but I'm not at all clear on what H() is, and the comment in fvMatrix.H, which describes it as "the H operation source", isn't enlightening me. What does the U that results from this contain as far as updates from the U at the beginning of the timestep?

phi = fvc::interpolate(U) & mesh.Sf();
adjustPhi(phi, U, p);

This calculates the face-normal (flux) velocities, and adjusts them to account for boundary conditions, yes?

fvScalarMatrix pEqn
fvm::laplacian(1.0/AU, p) == fvc::div(phi)

This is, again, a set of coefficients for a linear equation, this time in p. How does the relaxation on UEqn affect the values of 1.0/AU that go into this? (Does that matter any?)


This, again, computes a solution. Again, what does it do with the solution? I presume from later things that it must update p, yes?

phi -= pEqn.flux();

I presume that this is adjusting phi based on the newly-computed p values, and is equivalent to the "U -= fvc::grad(p)/AU" line below? And that this is done before the relaxation step so as to retain the divergenceless nature of phi?


This, I gather, is an explicit relaxation step along the lines of p = alpha p + (1 - alpha) p_old, unlike the UEqn.relax() line above?

// Momentum corrector
U -= fvc::grad(p)/AU;

And then this is doing the corrector step of the timestep, which I'd understand better if I knew what UEqn.A() was.

Thanks, muchly, for whatever enlightment you can offer!

msrinath80 February 22, 2007 10:56

You need to read papers like t
You need to read papers like this[1] one which explains icoFoam for instance. In fact you should be able to cite them as a reference.


alberto February 22, 2007 14:15

You can find details also in t
You can find details also in the Hrvoje's PhD thesis, where the derivation of the discretized equation and the SIMPLE algorithm are explained.


page February 22, 2007 14:36

It may also be useful to look
It may also be useful to look at the icoFoam page on the OpenFOAM wiki

kumar2 February 22, 2007 18:07

>This is the part that I'm mos
>This is the part that I'm most confused about -->what, exactly, are A() and H()?

Hi Brooks,

See page p-157 to 158 ( and few pages both sides ) of henrikrusche's phd thesis available from

Good luck on your thesis


alberto February 22, 2007 18:25

About H and U, from Hrv thesis
About H and U, from Hrv thesis:

if you take the semidiscretised momentum equation in the form:

Ap Up = H(U) - grad(p) <=> Up = H(U)/Ap - grad(p)/Ap

H(U) = - sum_n a_n U_n + Uo/Delta t represents the sum of the matrix coefficient of the neighbouring cells multiplied by the corresponding velocity plus the unsteady term.

H(U) in foam is obtained through UEqn.H(). The coefficient Ap is given by UEqn.A().

You find an almost identical nomenclature in the book:

J. H. Ferziger, M. Péric, "Computational Methods for Fluid Dynamics", 3rd Ed., pp. 167 - 178, Springer, 2002.


brooksmoses February 22, 2007 18:36

Thanks for the suggestions and
Thanks for the suggestions and references, everyone! That looks like enough to get me started; I'll come back with more questions if I still have any once I read all this.

CoenW November 23, 2009 09:41

And again I'm kicking an old topic...

lots of search-work is involved in finding out about OpenFOAM's inner workings, which I've been doing as well lately. To add to the wealth of information presented in this topic I'd like to refer to one of the workshop presentations:

Slides 9-16 give a very succint and clear overview of the workings of the PISO algoritm in icoFOAM and should serve as a good basis for viewing the other papers mentioned in this topic.

Daniele111 January 24, 2012 10:30

Hi all
Why in:

volScalarField AU = UEqn.A();
U = UEqn.H()/AU;

Is it neglected pressure term of semi-discretized momentum equation?


alundilong March 16, 2014 16:19


Originally Posted by Daniele111 (Post 340879)
Hi all
Why in:

volScalarField AU = UEqn.A();
U = UEqn.H()/AU;

Is it neglected pressure term of semi-discretized momentum equation?


Pressure contribution will be added after pressure equation is solved.

All times are GMT -4. The time now is 01:55.