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

Add extra body force (e.g. gravity) in simpleFoam: cavity example

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

Like Tree6Likes
  • 5 Post By jherb
  • 1 Post By jherb

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 2, 2014, 09:49
Default Add extra body force (e.g. gravity) in simpleFoam: cavity example
  #1
New Member
 
Julien
Join Date: Dec 2014
Location: Switzerland
Posts: 1
Rep Power: 0
juchess is on a distinguished road
Hi everyone,

I heard lots of praises about OpenFOAM so I'm trying to get into it, but I have to admit it isn't as straightforward as I thought to set up a new model

I need a steady-state solver for incompressible turbulent flows that are subject to an additional non-uniform body force. As a first step, I just want to use the cavity example (from icoFoam) with laminar flow, no initial pressure gradient, no initial velocity field and no lid movement, but taking the constant uniform field of gravity (0, -9.81, 0) into account. With this very simple example I expect to observe a nice pressure gradient from top to bottom of the cavity (constant in the x-direction).

Here is what I did so far. Following this thread, I created a new solver "myFoam" based on simpleFoam. In order to read a constant force field I added this code
Code:
    Info<< "Reading field F\n" << endl;
    volVectorField F
    (
        IOobject
        (
            "F",
            runTime.constant(),
            mesh,
            IOobject::MUST_READ,
            IOobject::NO_WRITE
        ),
        mesh
    );
in the file myFoam/createFields.H. Then I modified the file myFoam/UEqn.H like this
Code:
    solve(UEqn() == -fvc::grad(p) + F );
and added the momentum corrector
Code:
    U -= rAU*(fvc::grad(p) - F );
in the file myFoam/pEqn.H. I assume that the field F is already divided by rho so that the dimensions match. Compilation of the new "myFoam" application worked perfectly.

Next, I took the cavity example and added the file "F" describing the gravity (internalField uniform (0 -9.81 0) in the constant directory. In the file 0/U I also set the initial velocity of the lid to zero. Since the parameters of the cavity example are intended for icoFoam and not simpleFoam, I then moved the files

- constant/RASProperties
- constant/transportProperties
- system/controlDict
- system/fvSchemes
- system/fvSolution

from the simpleFoam/pitzDaily example to my new cavity example. I set the RASmodel to laminar and call myFoam instead of simpleFoam in the controlDict file. Now when I run myFoam I get a "Floating point exception (core dumped)" after 50 steps, which isn't very nice... but what bothers me even more is the pressure field I obtain after 10 steps (see attached figure), which is far from resembling the one I was expecting

Am I using the wrong approach or doing something wrong? Or has anyone another idea as to how I could achieve my objective?

Thanks a lot in advance for your help! Best regards,

Julien
Attached Images
File Type: jpg pressure.jpg (21.4 KB, 184 views)
juchess is offline   Reply With Quote

Old   December 3, 2014, 09:47
Default
  #2
Senior Member
 
Joachim Herb
Join Date: Sep 2010
Posts: 650
Rep Power: 22
jherb is on a distinguished road
Have a look at the buoyantBoussinesqSimpleFoam and buoyantSimpleFoam solvers.

They include buoyancy forces. If you just want to see the effect of gravity on the pressure field (set the thermal expansion coefficient to 0 in the transportProperties file of the buoyantBoussinesqSimpleFoam solver).

Tutorials are in $FOAM_TUTORIALS/heatTransfer/ directory
amuzeshi, tooran, LoveCFDD and 2 others like this.
jherb is offline   Reply With Quote

Old   December 7, 2016, 05:50
Default
  #3
New Member
 
rakesh927's Avatar
 
rakesh
Join Date: Jul 2015
Location: Nagpur, India
Posts: 16
Rep Power: 11
rakesh927 is on a distinguished road
Hi J Herb,

I have ran two similar cases of buoyantBoussinesqSimpleFoam solver, the only difference is that in one case gravity is enabled and in another without gravity. In both the cases I found the velocity profiles to be same. By the way as you suggested, I have set beta to be zero and there are no temperature gradients in the cases [to simulate simpleFoam kind of case with gravity included].
I am wondering that, the effect of gravity works in buoyantBoussinesqSimpleFoam when there is a difference in density of the fluid due to temperature?

Kindly clarify my doubt.

thanks
rakesh927 is offline   Reply With Quote

Old   December 13, 2016, 05:46
Default
  #4
Senior Member
 
Joachim Herb
Join Date: Sep 2010
Posts: 650
Rep Power: 22
jherb is on a distinguished road
Quote:
Originally Posted by rakesh927 View Post
I am wondering that, the effect of gravity works in buoyantBoussinesqSimpleFoam when there is a difference in density of the fluid due to temperature?
thanks
If you look at the source code of it (https://github.com/OpenFOAM/OpenFOAM...nesqSimpleFoam) you see, that the density difference is used here:
https://github.com/OpenFOAM/OpenFOAM...oam/UEqn.H#L28
https://github.com/OpenFOAM/OpenFOAM...Foam/pEqn.H#L8

The density is calculated from the the temperature field:
https://github.com/OpenFOAM/OpenFOAM...oam/TEqn.H#L26

So if you set beta to zero, there is no density gradient and therefore no difference between simpleFoam and buoyantBoussinesqSimpleFoam. Does this answer your question?
Mahmoud Abbaszadeh likes this.
jherb is offline   Reply With Quote

Old   December 14, 2016, 05:07
Default
  #5
New Member
 
rakesh927's Avatar
 
rakesh
Join Date: Jul 2015
Location: Nagpur, India
Posts: 16
Rep Power: 11
rakesh927 is on a distinguished road
Quote:
Originally Posted by jherb View Post
So if you set beta to zero, there is no density gradient and therefore no difference between simpleFoam and buoyantBoussinesqSimpleFoam. Does this answer your question?
Thanks Jherb for your clarification.
rakesh927 is offline   Reply With Quote

Old   December 15, 2016, 03:18
Default
  #6
Senior Member
 
Santiago Lopez Castano
Join Date: Nov 2012
Posts: 354
Rep Power: 16
Santiago is on a distinguished road
Why you add the force in the momentum corrector?

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

Old   December 17, 2016, 08:19
Default
  #7
Senior Member
 
Joachim Herb
Join Date: Sep 2010
Posts: 650
Rep Power: 22
jherb is on a distinguished road
Do you know this: https://openfoamwiki.net/index.php/B...sinesqPisoFoam

Of course it's the PISO and not the SIMPLE algorithm but it might be a start: Check for the differences due to the gravitational force with the normal algorithm and then apply similar changes to the SIMPLE algorithm.
jherb is offline   Reply With Quote

Reply

Tags
cavity, force, gravity, simplefoam, source

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
SimpleFoam For cavity Problem himanshu28 OpenFOAM 1 January 16, 2013 02:49
Problems with SUPG body force term FEM question Main CFD Forum 0 January 21, 2006 18:51
how to include body force in cfx selvam R.P CFX 4 November 25, 2005 05:01
Body force Jacob FLUENT 0 August 4, 2003 17:38
How to add body force in CFX5.5 Miko CFX 3 June 17, 2003 23:11


All times are GMT -4. The time now is 00:33.