CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM

Switching from simpleFoam to rhoSimpleFoam

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

Reply
 
LinkBack Thread Tools Display Modes
Old   October 13, 2010, 03:38
Default Switching from simpleFoam to rhoSimpleFoam
  #1
Member
 
Sebastian Saegeler
Join Date: Nov 2009
Location: Munich
Posts: 70
Rep Power: 7
sebastian is on a distinguished road
Hi!


I generated a solution with simpleFoam. Now I want to have a look at the compressible case by switching to rhoSimpleFoam.

As in simpleFoam, pressure is normalized by density, I cannot use the solution of my incompressible case as a starting solution for rhoSimpleFoam straight forward. Therefore I should multiply pressure by density...

Has anybody got an idea how to use a simpleFoam generated solution as starting solution for rhoSimpleFoam?


Thanks in advance!


Sebastian
sebastian is offline   Reply With Quote

Old   October 14, 2010, 12:30
Default
  #2
Senior Member
 
mturcios777's Avatar
 
Marco A. Turcios
Join Date: Mar 2009
Location: Vancouver, BC, Canada
Posts: 727
Rep Power: 18
mturcios777 will become famous soon enough
At first I thought foamCalc could do a multiplication, but it seems it can't.

You can modify the simpleFoam code to create a new field pComp:

In createFields.H, add the following at the end:
Code:
    volScalarField pComp
    (
        IOobject
        (
            "pComp",
            runTime.timeName(),
            mesh,
            IOobject::NO_READ,
            IOobject::AUTO_WRITE
        ),
        p*rho
    );
NOTE: You will need to create a dimensionedScalar rho, where the value of rho is read in from the transportProperties file.

This should write out the new field at all timesteps. You'd then need to rename it "p" for when preparing the case for rhoSimpleFoam.
mturcios777 is offline   Reply With Quote

Old   October 15, 2010, 04:59
Default
  #3
Member
 
Sebastian Saegeler
Join Date: Nov 2009
Location: Munich
Posts: 70
Rep Power: 7
sebastian is on a distinguished road
Hi Thanks a lot!

Yes, meanwhile I did that by myself. Just a bit more simple:

Code:
    volScalarField pRho
    (
        IOobject
        (
            "pRho",
            runTime.timeName(),
            mesh,
            IOobject::NO_READ,
            IOobject::AUTO_WRITE
        ),
        p*1.225 //p * density [kg/m^3]
    );

    pRho.write();
Hope this may help anybody else!

Unfortunatelly it messes up a bit my boundary conditions. It even writes out the pressure field on the walls and at my pressure inlets (total pressure inlets). So I have to manually correct it at my boundaries and reset the inital settings there. Has anybody an idea to avoid that?


Best regards,

Sebastian
sebastian is offline   Reply With Quote

Old   October 15, 2010, 15:53
Arrow
  #4
Senior Member
 
mturcios777's Avatar
 
Marco A. Turcios
Join Date: Mar 2009
Location: Vancouver, BC, Canada
Posts: 727
Rep Power: 18
mturcios777 will become famous soon enough
Try creating pRho as a copy of p, then just performing the rho*p calculation over all the interior cells:
Code:
forAll(pRho.mesh().cells(),celli)
{
   pRho[celli]*=rho
}
Other than that, you'd probably have to do some switching of internal flags or something. For what you are doing, it seems like its easier just to change the BC manually or write a script that does it for you.
mturcios777 is offline   Reply With Quote

Old   October 16, 2010, 08:59
Default
  #5
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: http://olesenm.github.io/
Posts: 777
Rep Power: 18
olesen will become famous soon enough
Quote:
Originally Posted by sebastian View Post
Hi!


I generated a solution with simpleFoam. Now I want to have a look at the compressible case by switching to rhoSimpleFoam.

As in simpleFoam, pressure is normalized by density, I cannot use the solution of my incompressible case as a starting solution for rhoSimpleFoam straight forward. Therefore I should multiply pressure by density...

Has anybody got an idea how to use a simpleFoam generated solution as starting solution for rhoSimpleFoam?
I tried this sort of thing when I first started with OpenFOAM. I had a very basic rhoPotentialFoam solver that used the P/T values to establish a rho field and used its average value to scale the pressure etc. Note that you'll also have to scale phi too.
In the end I found that this was all a waste of time and it was much easier just to use rhoSimpleFoam directly.
olesen is offline   Reply With Quote

Old   October 16, 2010, 13:47
Default Compute static pressure during the run time
  #6
Member
 
Frederic Collonval
Join Date: Apr 2009
Location: Technische Universitaet Munich - Lehrstuhl fuer Thermodynamik
Posts: 53
Rep Power: 8
fcollonv is on a distinguished road
Quote:
Originally Posted by sebastian View Post
Hi!


I generated a solution with simpleFoam. Now I want to have a look at the compressible case by switching to rhoSimpleFoam.

As in simpleFoam, pressure is normalized by density, I cannot use the solution of my incompressible case as a starting solution for rhoSimpleFoam straight forward. Therefore I should multiply pressure by density...

Has anybody got an idea how to use a simpleFoam generated solution as starting solution for rhoSimpleFoam?


Thanks in advance!


Sebastian
If you know before running the case that you want the static pressure, you can computed during the run time using the function object capability of OpenFOAM.

Add the following lines at the end of the controlDict. Then a new field called pStatic = rho*p will be computed during the resolution and output in the time folders.

Code:
functions
{
computepStatic
{
type staticPressure;
functionObjectLibs ( "libutilityFunctionObjects.so" );
enabled true;
outputControl outputTime;
p    p; // Name of the kinematic pressure
rho 1.225; // Value of the density
}
}
Frederic
fcollonv is offline   Reply With Quote

Old   October 19, 2010, 05:49
Default
  #7
Member
 
Frederic Collonval
Join Date: Apr 2009
Location: Technische Universitaet Munich - Lehrstuhl fuer Thermodynamik
Posts: 53
Rep Power: 8
fcollonv is on a distinguished road
I just found that you can execute just the "functions" by running:
execFlowFunctionObjects

Frederic
fcollonv is offline   Reply With Quote

Old   October 27, 2010, 04:54
Default
  #8
New Member
 
s k
Join Date: Oct 2010
Posts: 1
Rep Power: 0
gerdahotlich is on a distinguished road
Quote:
Originally Posted by fcollonv View Post
I just found that you can execute just the "functions" by running:
execFlowFunctionObjects

Frederic
Hi Frederic

first of all thanks for your code which works perfekt for this kind of problem.

but I encountered two problems:
1. "execFlowFunctionObjects" didnt't work for me, it actually did something (read Fields etc.), but eventually there was no pStatic. It seems that nothing happened. I just received pStatic by calculating one more step of calculation (by starting simpleFoam)

2. the BCs were messed up in pStatic, so for walls e.g. zerogradient BC in p was changed to calculated with nonuniform list. Is there a fix to that?

regards,
gerda
gerdahotlich is offline   Reply With Quote

Old   October 27, 2010, 06:58
Default execFlowFunctionObjects not so great - changeDictionary to change BC
  #9
Member
 
Frederic Collonval
Join Date: Apr 2009
Location: Technische Universitaet Munich - Lehrstuhl fuer Thermodynamik
Posts: 53
Rep Power: 8
fcollonv is on a distinguished road
Hi Gerda,

Quote:
Originally Posted by gerdahotlich View Post
1. "execFlowFunctionObjects" didnt't work for me, it actually did something (read Fields etc.), but eventually there was no pStatic. It seems that nothing happened. I just received pStatic by calculating one more step of calculation (by starting simpleFoam)
I was not using that tool. But you are right nothing is written even though the function objects are executed. This is because the function "write" is not called by the tool.

Quote:
Originally Posted by gerdahotlich View Post
2. the BCs were messed up in pStatic, so for walls e.g. zerogradient BC in p was changed to calculated with nonuniform list. Is there a fix to that?
It is not messed up. pStatic is computed from the field p and the density you provided. It is logical that the boundary conditions have the type "computed". The value is just the field p in the first cell multiplies by rho to obtain the static pressure.
If your plan is to switch from a incompressible solution to a compressible solution. You can correct the boundary conditions easily using changeDictionary "$FOAM_UTILITIES/preProcessing/changeDictionary". An example is explained at the begin of the code "changeDictionary.C" and an example of dictionary is provided there. But that make the trick only for the first time as define in controlDict (so startTime or latestTime).

Kindly,

Frederic

Last edited by fcollonv; October 27, 2010 at 07:00. Reason: Grammar error+add a detail
fcollonv is offline   Reply With Quote

Old   July 30, 2014, 07:34
Default
  #10
New Member
 
Join Date: Mar 2014
Posts: 17
Rep Power: 3
BenJ is on a distinguished road
Hi!

I've found this solution using the function staticpressure very confortable for the previous version of OpenFOAM.

But it seems this function is not available anymore in OF 2.3.0 that I wish to use now. Does anybody knows how to implement the function pressureTools (or another one ?) in order tu compute static pressure ?

Thanks in advance !

BenJ
BenJ is offline   Reply With Quote

Old   July 31, 2014, 03:08
Default
  #11
New Member
 
Join Date: Mar 2014
Posts: 17
Rep Power: 3
BenJ is on a distinguished road
Hi!

After reading the descritption here: http://foam.sourceforge.net/docs/cpp/a01944.html, it seems the utility has to be used as follow:

functions
(
computepStatic
{
type pressureTools;
functionObjectLibs ("libutilityFunctionObjects.so");
enabled yes;
outputControl outputTime;
p_k p;
rho 1.225;
calcTotal no;
calcCoeff no;
}
);

If I want to compute the static pressure, I have to set the two parameters calcTotal and calcCoeff to "no".

And indeed, when I run a case, this outputs a volScalarField "static(p)". But this one has a range between 0 and 1e-16, which does not look like a pressure in Pa.

I tried to tell OpenFOAM the static pressure p_k is p and the density value, but it does not help.

Has anybody an idea?

Best regards
BenJ
BenJ is offline   Reply With Quote

Old   January 7, 2015, 05:32
Default
  #12
New Member
 
Join Date: May 2013
Posts: 22
Rep Power: 4
arnaud6 is on a distinguished road
Hello BenJ,

Did you make some progress with your question ?

I am facing exactly the same problem !
I can not make the computepStatic works correctly either
arnaud6 is offline   Reply With Quote

Reply

Thread Tools
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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
transsonic nozzle with rhoSimpleFoam Unseen OpenFOAM Running, Solving & CFD 7 April 16, 2014 03:38
Laminar simpleFoam and inviscid simpleFoam herenger OpenFOAM Running, Solving & CFD 7 July 11, 2013 06:27
Dimesion error after switching from simpleFoam to rhoSimpleFoam sebastian OpenFOAM Bugs 2 June 17, 2010 08:03
Naca0012 k-e mpirun gives fpe whereas simpleFoam not Pierpaolo OpenFOAM 1 May 8, 2010 03:08
TRANSONIC FLOW in RHOSIMPLEFOAM dinonettis OpenFOAM Running, Solving & CFD 9 October 21, 2009 12:02


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