CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM (http://www.cfd-online.com/Forums/openfoam/)
-   -   Switching from simpleFoam to rhoSimpleFoam (http://www.cfd-online.com/Forums/openfoam/80988-switching-simplefoam-rhosimplefoam.html)

sebastian October 13, 2010 03:38

Switching from simpleFoam to rhoSimpleFoam
 
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

mturcios777 October 14, 2010 12:30

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.

sebastian October 15, 2010 04:59

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

mturcios777 October 15, 2010 15:53

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.

olesen October 16, 2010 08:59

Quote:

Originally Posted by sebastian (Post 278940)
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.

fcollonv October 16, 2010 13:47

Compute static pressure during the run time
 
Quote:

Originally Posted by sebastian (Post 278940)
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 October 19, 2010 05:49

I just found that you can execute just the "functions" by running:
execFlowFunctionObjects

Frederic

gerdahotlich October 27, 2010 04:54

Quote:

Originally Posted by fcollonv (Post 279749)
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

fcollonv October 27, 2010 06:58

execFlowFunctionObjects not so great - changeDictionary to change BC
 
Hi Gerda,

Quote:

Originally Posted by gerdahotlich (Post 280945)
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 (Post 280945)
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

BenJ July 30, 2014 07:34

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 July 31, 2014 03:08

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

arnaud6 January 7, 2015 05:32

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


All times are GMT -4. The time now is 23:24.