CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Post-Processing (
-   -   How to get the cells coordinate (

whyingwang January 17, 2013 22:33

How to get the cells coordinate
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.

fumiya January 18, 2013 11:32


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


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,

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:

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


$ cellCenters -latestTime
Or in parallel:

$ 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.


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:

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

Best regards,

All times are GMT -4. The time now is 00:51.