CFD Online Logo CFD Online URL
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Running, Solving & CFD

IcoFoam strange behaviour when gravity is included

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree2Likes
  • 2 Post By hjasak

LinkBack Thread Tools Search this Thread Display Modes
Old   April 4, 2008, 02:56
Default Dear OpenFoamers, after som
New Member
Join Date: Mar 2009
Posts: 23
Rep Power: 17
nicasch is on a distinguished road
Dear OpenFoamers,

after some time spent in unsuccessfully trying to implement a relatively simple thing (like gravity) into a relatively simple application (like icoFoam), I decided to post this message.
I want to simulate laminar 2D fluid column at rest in a closed cavity, in order to obtain a hydrostatic pressure distribution with no velocity. I use icoFoam with the standard cavity tutorial. I changed the application and included gravity force into momentum equation. I also changed things for the PISO to account for the additional source in calculating pressure. The code looks like this:

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

solve(UEqn == -fvc::grad(p) + gC); // gC is volVectorField (0 -9.81 0)

// --- PISO loop

for (int corr=0; corr<nCorr; corr++)
volScalarField rUA = 1.0/UEqn.A();

U = rUA*UEqn.H();

phi = (fvc::interpolate(U) & mesh.Sf())
+ fvc::ddtPhiCorr(rUA, U, phi)
+ (fvc::interpolate(rUA*gC) & mesh.Sf()); // gC added to interpolated UEqn.H()

adjustPhi(phi, U, p);

for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
fvScalarMatrix pEqn
fvm::laplacian(rUA, p) == fvc::div(phi)

pEqn.setReference(pRefCell, pRefValue);

if (nonOrth == nNonOrthCorr)
phi -= pEqn.flux();

# include "continuityErrs.H"

U -= rUA*(fvc::grad(p));

The application compiles, but after running on cavity-case I always obtain very strange results of 2 kind:

1. BC: velocity fixedValue = (0 0 0), pressure zeroGradient at all walls. After a couple of time steps I obtain a message of continuity errors ?!

--> FOAM FATAL ERROR : Continuity error cannot be removed by adjusting the outflow.
Please check the velocity boundary conditions and/or run potentialFoam to initialise the outflow.
Specified mass inflow : 3.23118e-06
Specified mass outflow : 3.23187e-06
Difference : 6.90589e-10
Adjustable mass outflow : 0

2. When I change pressure BC on the top Wall to totalPresure, I obtain a suspiciously looking pressure distribution and, more interesting, there is some flow within closed cavity of zero velocity at walls?!

I wonder if anyone would know why this happens? I believe that the implementation of gravity is OK, or not?

Best Regards.
nicasch is offline   Reply With Quote

Old   April 4, 2008, 03:12
Default here are pressure and velocity
New Member
Join Date: Mar 2009
Posts: 23
Rep Power: 17
nicasch is on a distinguished road
here are pressure and velocity distributions after 5 seconds



nicasch is offline   Reply With Quote

Old   April 4, 2008, 03:48
Default No, not that easy. The closes
Senior Member
Hrvoje Jasak
Join Date: Mar 2009
Location: London, England
Posts: 1,905
Rep Power: 33
hjasak will become famous soon enough
No, not that easy. The closest simple solver I can show you is boussinesqBuoyantFoam: nFOAM-1.4.1-dev/applications/solvers/heatTransfer/boussinesqBuoyantFoam/boussine sqBuoyantFoam.C?view=markup

If you start from there and get rid of the energy equation, you will see what happens.

Basically, if you add gravity in incompressible flows in this way, you only added body force and there is no density gradient to counter-act the effect. For example, if you have a closed box with gravity, why would there be flow at all?

Tushar@cfd and mgg like this.
Hrvoje Jasak
Providing commercial FOAM/OpenFOAM and CFD Consulting:
hjasak is offline   Reply With Quote

Old   April 4, 2008, 04:29
Default Hmmm... Thank You Hrv. Well y
New Member
Join Date: Mar 2009
Posts: 23
Rep Power: 17
nicasch is on a distinguished road
Hmmm... Thank You Hrv.
Well yes, of course, there should not be any flow in such situation, that is what bothers me.
I disabled TEqn in boussinesqBuoyantFoam, but it still behaves like icoFoam without gravity. P and U are zero overall.
What I need is a simple static fluid with hydrostatic pressure distribution. I saw in my email-client that I didnot receive the whole message I've posted, there are some parts missing. If you look at the post, the things in my modified icoFoam are (I believe) the same as in boussinesqBuoyantFoam, except that I added the g-term into UEgn and into interpolated UEqn.H() needed by the PISO.
It must be possible to obtain a fine hydrostatic pressure distribution in a closed cavity for incompressible fluid without density gradient.
I must miss something really bad (
nicasch is offline   Reply With Quote

Old   June 24, 2009, 09:45
Julien Schaguene
Join Date: Apr 2009
Location: France
Posts: 55
Rep Power: 17
Schag is on a distinguished road
Hello nicasch,

I wonder if you found the solution to implement such a solver. I'm at the time trying to do quite the same thing with turbFoam, but I need gravity to simulate a flow through a dam.
I don't want to use a multiphase solver because I want to minimise the control volume (and by the way the mesh...).

So, did you found something?

Best regards
Schag is offline   Reply With Quote

Old   August 29, 2014, 10:09
New Member
rama13's Avatar
Damiano Natali
Join Date: Mar 2013
Location: Genova, Italy
Posts: 17
Rep Power: 13
rama13 is on a distinguished road
Don't know if it can help, but I found it easier to start from interFoam and taking away all dependencies on alpha
rama13 is offline   Reply With Quote


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Strange behaviour when using LienCubicKE and NonlinearKEShih hani OpenFOAM Running, Solving & CFD 20 March 6, 2013 10:06
buoyantFoam OF15 very strange behaviour in hotRoom andrea_barbera OpenFOAM Running, Solving & CFD 4 July 30, 2009 09:06
Strange multicomponent source behaviour Zitron CFX 4 July 12, 2007 15:32
Strange Behaviour in CFX-Mesh Kasper CFX 0 May 14, 2007 08:24
Strange behaviour in Coffus Luis Filipe Fabiani Phoenics 0 June 1, 2006 11:23

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