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/)
-   -   How to access to field point data (https://www.cfd-online.com/Forums/openfoam-programming-development/105812-how-access-field-point-data.html)

zxj160 August 9, 2012 10:40

How to access to field point data
 
Dear foamers,

I can have access to coordinate of point by:
mesh.points(), and field cell data by U.mesh().C()[].

But now my problem is that how to access and change the corresponding field point data if I choose some interested coordinate?

Many thanks,
Jian

Arnoldinho August 10, 2012 14:25

The values are always stored "in the cells" or at the boundaries, i.e. there is no value assignment for points. These only give the coordinates of the cells.

If you are interested in manipulating the (cell) values at a location x,y,z of interest, you could e.g. have a look at mesh.findCell(), http://www.cfd-online.com/Forums/ope...ordinates.html, which gives you the position in the field (cell index) you want to manipulate.

Greetings,
Arne

zxj160 August 11, 2012 06:35

Quote:

Originally Posted by Arnoldinho (Post 376484)
The values are always stored "in the cells" or at the boundaries, i.e. there is no value assignment for points. These only give the coordinates of the cells.

If you are interested in manipulating the (cell) values at a location x,y,z of interest, you could e.g. have a look at mesh.findCell(), http://www.cfd-online.com/Forums/ope...ordinates.html, which gives you the position in the field (cell index) you want to manipulate.

Greetings,
Arne

Dear Arne,

Many thanks. After I have changed the field data of some cells (first layer of inlet as zero), the case can not run in parallel. Do you know how to solve the problem?

My best regards,
Jian

Arnoldinho August 11, 2012 07:11

You did not give the entire error you get from your run, so I'm not sure what's the problem.
But you have to keep in mind that if running in parallel, every single processor builds up its own mesh, i.e. face and point labels refer to the single processor meshes and are different from the global mesh labels!

Arne

zxj160 August 11, 2012 16:47

Quote:

Originally Posted by Arnoldinho (Post 376571)
You did not give the entire error you get from your run, so I'm not sure what's the problem.
But you have to keep in mind that if running in parallel, every single processor builds up its own mesh, i.e. face and point labels refer to the single processor meshes and are different from the global mesh labels!

Arne

Dear Arne,

Actually, I first select the first layer cell IDs near the inlet and outlet after searching the whole cells. Then I modified the corresponding cell values. It can run directly in one cpu, but can not run in parallel. Do you have any code or documents about parallel running?

My best regards,
Jian

Arnoldinho August 14, 2012 03:32

Hi Jian,

I am still not sure what the problem is. Did you check whether you modified the right cells, e.g. by having a look at the specific processorX folders in ParaView and giving the cells e.g. large numbers?
I am afraid I have no further documents about parallel coding, but my field/cell modifications so far work in parallel with no problem.
One hint: if you are just modifying the boundary-next cells, you could use
Code:

const label patchi = mesh.boundaryMesh().findPatchID("inlet");
U.boundaryField()[patchi] == whatever you want

which saves you the time-consuming searching for single cells.

Greetings,
Arne

Fanfei May 21, 2015 05:35

Quote:

Originally Posted by Arnoldinho (Post 376966)
Hi Jian,

I am still not sure what the problem is. Did you check whether you modified the right cells, e.g. by having a look at the specific processorX folders in ParaView and giving the cells e.g. large numbers?
I am afraid I have no further documents about parallel coding, but my field/cell modifications so far work in parallel with no problem.
One hint: if you are just modifying the boundary-next cells, you could use
Code:

const label patchi = mesh.boundaryMesh().findPatchID("inlet");
U.boundaryField()[patchi] == whatever you want

which saves you the time-consuming searching for single cells.

Greetings,
Arne

Hi Arnoldinho:
I'm so sorry to trobule you and dig that old topic. I have a problem to access the points coorinadte of the assign face. for example i want to get the nodes coordinate of mesh.BoundaryField()[patchID][I], how i can do that? Thank you.
Greeting
Fan Fei


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