CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Post-Processing (http://www.cfd-online.com/Forums/openfoam-post-processing/)
-   -   How to get the cells coordinate (http://www.cfd-online.com/Forums/openfoam-post-processing/111915-how-get-cells-coordinate.html)

whyingwang January 17, 2013 22:33

How to get the cells coordinate
 
Hi,foamers
Recently I get some troubles.The reslut store in the time file,e.g. 100,200.
The value store the cell's value.But in the polyMesh folder,the points file store the point's coordinate.I don't find the cells file,only the cellZone file.
I want to know, How can I get every cells coordinate?I can only see the point's coordinate, not the cell's.
Thanks

fumiya January 18, 2013 11:32

Hi,

The cells file is not necessary to run the OpenFOAM applications.
I don't understand what exactly you mean by the cell's coordinate,
but you can access the coordinates of cell centers using the
mesh.C():

Code:

forAll(U, cellI)
{
    Info<< mesh.C()[cellI] << endl; //cell center coordinate of cellI
}

You can also use the utility "writeCellCentres" to output to the file.

Hope that helps,
Fumiya

opedrofunk February 4, 2015 00:53

Here's a utility I wrote to write the cell centers to a file at each specified time.
 
Download, instructions, usage, and examples are here:

https://bitbucket.org/peterjvonk/cellcenters

You can use the utility in the standard way, i.e.:

Code:

$ cellCenters -latestTime
Or in parallel:
Code:

$ mpirun -np <num-processors> cellCenters -parallel -latestTime
This is a bit different than the writeCellCentres utility that comes with OpenFOAM, as it writes the vector to a single file (rather than to three separate files, one for x, y, and z). I found it a bit cumbersome to work with three files, so I wrote this. Hope it helps.

Regards,
Peter

wyldckat March 21, 2015 16:05

Greetings to all!

@Peter: I've created a basic wiki page to help getting your cellCenters utility known to the community that uses OpenFOAM technology: http://openfoamwiki.net/index.php/Contrib/cellCenters

May you or anyone else feel free to update that wiki page!

Best regards,
Bruno


All times are GMT -4. The time now is 12:44.