|
[Sponsors] |
Incorrect pressure readings when implementing a custom SIMPLE algorithm |
![]() |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
![]() |
![]() |
#1 |
New Member
shariq
Join Date: Jul 2022
Posts: 10
Rep Power: 4 ![]() |
Greetings of the time,
I am trying to code a standard SIMPLE algorithm within OpenFOAM. Here's the logic, Start by computing U* (Initialise); I do this outside the main while loop as: Code:
fvVectorMatrix UEqn ( // div(U * phi) - div (nu * grad(phi)) = -div(p) fvm::div(phi,U) - fvm::laplacian(nu,U) == -fvc::grad(p) ); UEqn.solve(); With this, I then enter the while loop, compute the scalar matrix of coefficient A, and interpolate its inverse to the face of the volume: Code:
volScalarField A = UEqn.A(); surfaceScalarField A_inv = fvc::interpolate(1/A); U' = -grad(p)' / A Now we know, U = U* + U', i.e. div(U) = 0 // Continuity equation div(U* + U') = 0 div(grad(p)' / A) = div(U*) // This equation drives the pressure to correct //velocities I do this using, Code:
fvScalarMatrix pEqn ( fvm::laplacian(A_inv,p) == fvc::div(phi) ); pEqn.setReference(pRefCell,pRefValue); // Provided by the user pEqn.solve(); Code:
U = U - 1/A * (fvc::grad(p)); // U = U* + U' phi = fvc::interpolate(U) & mesh.Sf(); Can someone please point out if there's a flaw in my logic? Thank You |
|
![]() |
![]() |
![]() |
![]() |
#3 |
New Member
shariq
Join Date: Jul 2022
Posts: 10
Rep Power: 4 ![]() |
Hey,
Thanks for the input on the odd-odd and even-even checkerboard pattern that is well-known when both the velocities and pressures are stored in a collocated fashion. However, I faced issues (mismatch between OF SIMPLE algorithm) with the previous implementation primarily because I was not updating the pressure field correctly. I managed to fix this. Here's how I implemented the standard SIMPLE algorithm (This is not the same as OF implementation, which is similar to SIMPLEC with a few differences):
|
|
![]() |
![]() |
![]() |
![]() |
#4 |
Senior Member
Join Date: Apr 2020
Location: UK
Posts: 807
Rep Power: 15 ![]() |
Is that any different to what simpleFoam does? (I didn't take the time to read carefully through each of your steps)
|
|
![]() |
![]() |
![]() |
![]() |
#5 | |
New Member
shariq
Join Date: Jul 2022
Posts: 10
Rep Power: 4 ![]() |
Quote:
Indeed, the standard SIMPLE algorithm implemented in simpleFoam, is quite different from the standard SIMPLE algorithm developed by Patankar found here (https://en.wikipedia.org/wiki/SIMPLE_algorithm). Let be briefly highlight the difference Initial step is same for both in which we start by solving for U* (guess velocity); this however will not satisfy the continuity. This is where things start to differ, in the classic SIMPLE algorithm we explicitly define a correction U' to correct the velocity field i.e. (U = U* + U'); and this corrected velocity(U) is what we substitute in continuity to derive the correction U'; mathematically: Notice how because of the presence of U* we get a sink component that is known from the initial guess, intiuitively this could be pictured as continuity error in each control volume i.e. The idea now is to come up with a formulation of U' that can be substituted in the equation above, the correction (U') can very simply be shown to be Now based on the requirement we can ignore the contribution from H' (or neighbouring cells) this leaves with just the pressure correction p' which can be substituted back in the velocity correction equation and by doing this we can solve for p' (Notice that p' is driven by the presence of ![]() In the simpleFoam implementation, we do not define an explicit correction for p, i.e., we solve for the pressure equation directly. This is similar to the SIMPLEC algorithm (can be found here https://en.wikipedia.org/wiki/SIMPLEC_algorithm); mathematically, Solving this gives the corrected pressure p; the next step is to correct the velocity field, and this is where simpleFoam's implementation differs from the SIMPLEC algorithm. The pressure is used to update the velocity field as This process is then repeated in a loop. Clearly, the pressure here is driven by H. Additionally, notice that we have not explicitly included a velocity predictor step of the form (U = U* + U') which is typically seen in SIMPLE. In fact, we are solving for the corrected pressure field first (using the velocities field which would not satisfy the continuity) and then correcting the velocity fields using the same pressure to obtain corrected velocity. This is computationally cheaper when compared to SIMPLEC, where the corrected pressure field is used to solve the momentum equation within the same loop before applying the standard pressure correction to update the velocity. And it is more robust when compared to the SIMPLE algorithm because we are directly solving for the corrected pressure field. Additionally, it's is quite efficient as we do not need to store p*. Let me know if this helps; I can share my implementation for all three algorithms if required. Cheerrss ![]() |
||
![]() |
![]() |
![]() |
![]() |
#6 |
Senior Member
Join Date: Apr 2020
Location: UK
Posts: 807
Rep Power: 15 ![]() |
Thanks for your explanation - I was wondering why you were interested in reimplementing the SIMPLE scheme when there is already a lot of info in the public domain on OpenFOAM's implementation (eg https://openfoamwiki.net/index.php/SimpleFoam).
However - I understand now ![]() |
|
![]() |
![]() |
![]() |
Tags |
c++, programing, simple |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Fail to converge when solving with a fabricated solution | zizhou | FLUENT | 0 | March 22, 2021 07:33 |
SIMPLE algorithm | SamR | Main CFD Forum | 19 | April 26, 2019 14:06 |
About simple algorithm in simpleFoam | JinBiao | OpenFOAM Running, Solving & CFD | 0 | December 15, 2011 03:06 |
Hydrostatic pressure in 2-phase flow modeling (long) | DS & HB | Main CFD Forum | 0 | January 8, 2000 16:00 |
SIMPLE algorithm | Jonathan Castro | Main CFD Forum | 3 | December 10, 1999 05:59 |