CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

single phase, incompressible, flow with gravity

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By Houthuys
  • 1 Post By jherb

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 28, 2017, 12:20
Default single phase, incompressible, flow with gravity
  #1
New Member
 
rik houthuys
Join Date: Jan 2017
Posts: 27
Rep Power: 9
Houthuys is on a distinguished road
Hi All,

I've read several discussions in this forum about including the gravity body force in pisoFoam or similar solvers. The most successful approach seems to be the one implemented in interFoam, i.e. using the following term in UEqn:
Code:
 ghf*fvc::grad(rho)
However, this approach obviously not suitable for the case of single phase incompressible flow with constant density.

So, I tried to get through this problem and I've modified icoFoam using two approaches and I want to discuss them here and see if there's any better approach or if we can modify them to get better.

In the first approach I've just add the gravity body force to the UEqn and I didn't change any other parts in the code. The new UEqn will be like:

Code:
        fvVectorMatrix UEqn 
        (
            fvm::ddt(U)
          + fvm::div(phi, U)
          - fvm::laplacian(nu, U)==fvc::grad(gh)
        );
I didn't change the pressure equation since the H(U) now includes the contribution from the gravity body force. Then I test using cavity tutorial by setting the moving wall boundary conditions as p: fixedValue = 0, U: fixedValue = 0 0 0, since I want to reproduce hydro-static pressure.

The results for the pressure was almost like the analytical solution (hydro-static pressure distribution) while unfortunately I get some velocities near the upper and lower walls while velocities should be zero everywhere. You can see the results in the attachment.

In the second approach I just combined the gravity force with pressure and called it p_gh where:
Code:
p_gh = p-gh
-grad(p)+grad(gh) = -grad(p-gh)=-fvc::grad(p_gh)
So, basically I didn't change anything in the code. I only I dded one line at the end of the time loop to calculate p from P_gh. The code looks like:
Code:
 while (runTime.loop())
    {
        Info<< "Time = " << runTime.timeName() << nl << endl;

        #include "CourantNo.H"  

        // Momentum predictor
        fvVectorMatrix UEqn 
        (
            fvm::ddt(U)
          + fvm::div(phi, U)
          - fvm::laplacian(nu, U)
        );

        if (piso.momentumPredictor()) 
        {
            solve(UEqn == -fvc::grad(p_gh)); 
        } 

        // --- PISO loop starts here
        while (piso.correct())
        {

	   volScalarField rAU(1.0/UEqn.A()); 
           
            volVectorField HbyA(constrainHbyA(rAU*UEqn.H(), U, p_gh));
            surfaceScalarField phiHbyA
            (
                "phiHbyA",
                fvc::flux(HbyA)
              + fvc::interpolate(rAU)*fvc::ddtCorr(U, phi)
            );

            adjustPhi(phiHbyA, U, p_gh);

            // Update the pressure BCs to ensure flux consistency
            constrainPressure(p_gh, U, phiHbyA, rAU);

            // Non-orthogonal pressure corrector loop
            while (piso.correctNonOrthogonal())
            {
                // Pressure corrector

                fvScalarMatrix pEqn
                (
                    fvm::laplacian(rAU, p_gh) == fvc::div(phiHbyA)
                );

                pEqn.setReference(pRefCell, pRefValue);

                pEqn.solve(mesh.solver(p.select(piso.finalInnerIter())));

                if (piso.finalNonOrthogonalIter())
                {
                    phi = phiHbyA - pEqn.flux();
                }
            }

            #include "continuityErrs.H"

            U = HbyA - rAU*fvc::grad(p_gh);
            U.correctBoundaryConditions();
	    p = p_gh + gh;
        }
The result in this case for p and U are perfect (now U is zero everywhere), you can see this results also in the attachments.
The only problem with this approach is that you have to set the pressure b.c carefully for p_gh.

So, in your opinion, is the second approach is suitable in general? does it need improvement? or should we use totally different approach?
Attached Images
File Type: jpg first approach.jpg (27.3 KB, 144 views)
File Type: jpg second approach.jpg (21.9 KB, 129 views)
ashvinc9 likes this.
Houthuys is offline   Reply With Quote

Old   March 1, 2017, 14:05
Default
  #2
Senior Member
 
Joachim Herb
Join Date: Sep 2010
Posts: 650
Rep Power: 22
jherb is on a distinguished road
Did you look at the implementation of buoyantBoussinesqSimpleFoam (buoyantBoussinesqPimpleFoam)? This should do what you want. Or perhaps twoLiquidMixingFoam.
jherb is offline   Reply With Quote

Old   March 6, 2017, 11:40
Default
  #3
New Member
 
rik houthuys
Join Date: Jan 2017
Posts: 27
Rep Power: 9
Houthuys is on a distinguished road
Quote:
Originally Posted by jherb View Post
Did you look at the implementation of buoyantBoussinesqSimpleFoam (buoyantBoussinesqPimpleFoam)? This should do what you want. Or perhaps twoLiquidMixingFoam.
Thanks Joachim for the reply.

Actually both solvers use density gradient to introduce the gravity body force, e.g.:
Code:
- ghf*fvc::snGrad(rho)
In my case I have constant density. So, how can we add that effect in this case?
Houthuys is offline   Reply With Quote

Old   March 16, 2017, 08:55
Default
  #4
Senior Member
 
Joachim Herb
Join Date: Sep 2010
Posts: 650
Rep Power: 22
jherb is on a distinguished road
Sorry for the late reply. But if you have constant density, what should be the effect of gravity?
Santiago likes this.
jherb is offline   Reply With Quote

Old   March 17, 2017, 12:08
Default
  #5
Senior Member
 
Santiago Lopez Castano
Join Date: Nov 2012
Posts: 354
Rep Power: 16
Santiago is on a distinguished road
I don't see the point of putting gravity if you are not solving a variable density, or buoyancy-driven, flow

Sent from my GT-I8190L using CFD Online Forum mobile app
Santiago is offline   Reply With Quote

Old   January 4, 2018, 22:42
Default
  #6
Member
 
Federico Zabaleta
Join Date: May 2016
Posts: 47
Rep Power: 10
fedez91 is on a distinguished road
Hi rick,

I've been trying to do the same. I don't really understand what do you mean by "gh". Is it only g? is g*z (if z is your vertical direction)?

I have implemented g in icoFoam adding g to transport properties as a vector and in the U equation as follows,

Code:
 
        fvVectorMatrix UEqn
        (
            fvm::ddt(U)
          + fvm::div(phi, U)
          - fvm::laplacian(nu, U)
          - g
        );

        if (piso.momentumPredictor())
        {
            solve(UEqn == -fvc::grad(p));
        }
but I got the same error as you do (some velocities near the wall in the cavity test).

Where you able to solve this problem? Could you please explain me what did you mean by gh and how did you defined it in the case?

(Sorry for the silly questions, first time trying to programming in OF)

Best,
fedez91 is offline   Reply With Quote

Old   February 9, 2018, 17:57
Default
  #7
Senior Member
 
Santiago Lopez Castano
Join Date: Nov 2012
Posts: 354
Rep Power: 16
Santiago is on a distinguished road
Quote:
Originally Posted by fedez91 View Post
Hi rick,

I've been trying to do the same. I don't really understand what do you mean by "gh". Is it only g? is g*z (if z is your vertical direction)?

I have implemented g in icoFoam adding g to transport properties as a vector and in the U equation as follows,

Code:
 
        fvVectorMatrix UEqn
        (
            fvm::ddt(U)
          + fvm::div(phi, U)
          - fvm::laplacian(nu, U)
          - g
        );

        if (piso.momentumPredictor())
        {
            solve(UEqn == -fvc::grad(p));
        }
but I got the same error as you do (some velocities near the wall in the cavity test).

Where you able to solve this problem? Could you please explain me what did you mean by gh and how did you defined it in the case?

(Sorry for the silly questions, first time trying to programming in OF)

Best,
Youre explicitly adding a source to a trabsport eqn that, in principle, is time-discretized in an implicit form. You should add the term to the diagonal of the resulting linear system, via the fvm::Sp method
Santiago is offline   Reply With Quote

Old   June 18, 2022, 05:57
Default
  #8
Member
 
Mahmoud
Join Date: Nov 2020
Location: United Kingdom
Posts: 43
Rep Power: 6
Mahmoud Abbaszadeh is on a distinguished road
Quote:
Originally Posted by jherb View Post
Sorry for the late reply. But if you have constant density, what should be the effect of gravity?
to see the effects of the hydrostatic pressure
Mahmoud Abbaszadeh is offline   Reply With Quote

Reply


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
mass flow in is not equal to mass flow out saii CFX 12 March 19, 2018 06:21
Turbulence model for two phase incompressible flow SailorLiu OpenFOAM Running, Solving & CFD 2 April 4, 2016 08:53
two-phase flow with a single phase simulation caunima Fluent Multiphase 0 October 28, 2013 03:42
Mass flow rate of phase in post mat_cfd CFX 0 September 3, 2013 08:55
Incompressible single phase mixing of two fluids phinallydone OpenFOAM Running, Solving & CFD 4 August 2, 2010 00:28


All times are GMT -4. The time now is 15:38.