CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Simple velocity correction difference between ussing grad(p) or pEqn.flux() (https://www.cfd-online.com/Forums/openfoam-programming-development/237111-simple-velocity-correction-difference-between-ussing-grad-p-peqn-flux.html)

Voulet July 1, 2021 02:40

Simple velocity correction difference between ussing grad(p) or pEqn.flux()
 
Hi all.


In the SIMPLE algorithm, after solving the pEqn laplacian equation the velocity is corrected like this :

Code:

U = HbyA - rAU*fvc::grad(p);

In some other solvers i may see this like this :

Code:

U = HbyA + rAU*fvc::reconstruct((-pEqn.flux())/rAUf);
(with rAu being 1/UEqn.A() volScalarField and rAUf the same thing on surfaceScalarField).


According to some of my quick tests these 2 ways provide the same U field.

For me the first form is close to the analytical developpement starting with MU = AU - H = - ∇p
Thus I don't realy undertand why the second form is working. In which form the pEqn.flux is linked to the gradient of pressure ?


Thanks for your help.

Tobermory July 4, 2021 09:37

I don't recognise the second bit of coding you have included in your posting. Maybe it's a better idea to copy the exact coding from the solvers you are interested in, and tell us which ones?

It's fairly standard practice in the solvers to see something like the following:
Code:

phi = phiHbyA - pEqn.flux();
e.g. line 37 in pEqn.H of simpleFoam. This line corrects the face fluxes using the pressure gradient. For the latter, the pressure gradient is taken directly from the fvMatrix for the p equation (using the flux() function), rather than calculating it again - this reduces continuity errors I believe. You can find the function in fvMatrix.C, and remember that the volume integral of the gradient of a scalar is equivalent to the surface integral of the scalar at the boundary (i.e. sum of the face fluxes), in case you are wondering how the gradient is linked to the face fluxes.

Voulet July 9, 2021 01:04

Thanks for your explanation. The second statement is from a custom solver of my advisor.



I've found the same way here in compressibleInterFoam: https://github.com/OpenFOAM/OpenFOAM...terFoam/pEqn.H line 141.


But I'm now convinced why your recall on the fact that a gradient Gauss discretization involve face fluxes. You answered my question.


All times are GMT -4. The time now is 16:27.