CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Read Field Value at known (x,y,z) coordinate (https://www.cfd-online.com/Forums/openfoam-programming-development/220541-read-field-value-known-x-y-z-coordinate.html)

ctaylor97 September 11, 2019 00:47

Read Field Value at known (x,y,z) coordinate
 
Hey all,


As the title suggests I want to access pressure at a specific point of my internal field, (x,y,z). I know you can use a probe to read these values and it works well, however, I am creating a coded boundary condition and I need to use the values of pressure in the internal field to calculate velocity for my boundary condition.


In simple I want to do:
P1 = pressure(x1,y1,z1);
P2 = pressure(x2,y2,z2);
Velocity = f(P1,P2);


Is there a simple way I can do this?
Thanks in advance.

clapointe September 19, 2019 13:42

You should be able to use findCell. Something like :

Code:

point p1 = vector(x1,y1,z1);
label c1 = mesh.findCell(p1);
scalar pressure1 = p[c1];

You'll need to make sure p is accessible.

Caelan


All times are GMT -4. The time now is 06:35.