CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Post-Processing (https://www.cfd-online.com/Forums/openfoam-post-processing/)
-   -   Calculate custom pressure - best way? (https://www.cfd-online.com/Forums/openfoam-post-processing/94655-calculate-custom-pressure-best-way.html)

 grjmell November 22, 2011 06:07

Calculate custom pressure - best way?

I want to add rho*g*h to my pressure field as output by pimpleFoam. The options in my mind are:

1. inclusion of write.H to output p+rho*g*h (requires compiling new pimpleFoam solver)
2. post-process results with a utility to calculate p+rho*g*h

Have i missed an option? it seems option 2 is more appropriate since it only involves making a utility and no recompilation of the entire solver.

What is the best way to get the value for h?

Thanks

 nimasam November 22, 2011 06:16

im not sure but as i know in new OpenFoam version we have two pressures
1) p
2) p - rho*g*h
so i guess the first p contains the effect of gravity! i insist im not sure :D

 Bernhard November 22, 2011 06:18

Either of the two methods will do. If you need it for every timestep or want to sample during runtime I would chose option 1. If you need it only every once in a while, then option 2 will do.

If you go for option 2, have a look at the existing ptot utility. It has almost everything you need.

For the calculation of h, you can have a look in for example the interFoam e.g. createFields.H line 109 reads
Code:

`volScalarField gh("gh", g & mesh.C());`
Which is probably what you are looking for. mesh.C() refers to the central coordinate of a cell.

Good luck!

 grjmell December 15, 2011 05:38

Thanks All. Ok, I've tried with
Code:

`volScalarField gh("gh", g & mesh.C());`
but that gives me the height of the cell from z=0, rather than the depth from top of my domain which is what i need in order to calculate the hydrostatic component g*depth rather than gh. How can I get the depth, i.e. domain height - h?

 FabienF February 1, 2012 11:05

Hi Greg,
I have the same problem. I would like to calculate the vertical offset from my boundary surface (the ground) of my mesh cell centers. Have you found a way to get the cell height relative to a surface/boundary?
Thank you

 grjmell February 1, 2012 12:07

Hi Fabien,
No I haven't done much more on this. There must be a relatively easy way to find the max z value of the mesh to use as the relative datum. But not sure how... if you find anything please post!
G

 All times are GMT -4. The time now is 18:45.