CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM (
-   -   Where to define which fields to write? (

bgoeppner April 13, 2010 14:16

Where to define which fields to write?
Hi there,

that's maybe a very simple question, but where can I define which fields OpenFOAM will write? I solved a case with sonicFoam and wanted to have a look at the density, but there is no rho in the time-directories... :confused:

Can I make OpenFOAM to calculate and write rho without re-running the hole job?

BTW: Am I right that the pressure is the dynamicPressure? Because then I could calculate my desity from velocity...

Thanks a lot,

CedricVH April 14, 2010 08:36

The field p is the static pressure (in OpenFOAM 1.6). However, you can calculate the total pressue (static + dynamic pressure) by running the command ptot on the solved case. From there on, you can use foamCalc to calculate other parameters.

bgoeppner April 14, 2010 09:22

Thanks a lot. I tried that but as my p-Field is in Pa (kg/msē) not in mē/sē ptot wants to have a rho-file... And that is exactly what I'm not having ;-)

aruv December 3, 2010 13:22

Hi Benedikt,
I am facing with the same problem with sonicFoam.. how to calculate ptot ... have u found any solution to the problem ???

nakul December 4, 2010 04:09


You may change definition of rho in createFields.H file of sonicFoam locaed in "$applications/solvers".

You may define rho the way U is defined and the recompile your solver. In this way sonicFoam will output rho during runtime.

aruv December 4, 2010 08:06

I made the changes in the createFields.H and recompiled the solver, finally it works. thanks for the suggestion

Using Sampledict one can calculate p, T, U etc . do u have any idea how to calculate variables other than the standard ones for Example (isentropic Mach Number) around a compressor profile

thank u

nakul December 5, 2010 07:36


To get local Mach No. in the domain you may run the command "Mach".

Also refer to the utilities section of the User Guide to find out what all you can get as data from OF.

bgoeppner December 9, 2010 08:25

Hi aruv,

sorry for my late answer...

You can also add the following to the controlDict file:


      type                writeRegisteredObject;
      functionObjectLibs  ("");
      outputControl        outputTime;
      outputInterval      1;

This will work with every solver and gives you all files you want to have... (In my case this is rho and psi)

Have fun!

farhhad July 15, 2011 11:00

I was just reading your posts and leant lots. There is one thing that seems to be forgotten and It is the dimensions of p and p_rgh in OF 1.7 and OF 1.6. The dimension of p is m^2/s^2 which is the square of velocity dimension. Basically, for p OF skips the density in its calculations. On the other hand, the dimension of p_rgh is kg/ms^2 meaning that density is included. Therefore, if p is the addition of dynamic and static pressure, the actual pressure has yet to be obtained multiplying the density to p.

All times are GMT -4. The time now is 07:27.