CFD Online Logo CFD Online URL
Home > Forums > OpenFOAM Post-Processing

How to get the cells coordinate

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree2Likes
  • 2 Post By fumiya

LinkBack Thread Tools Display Modes
Old   January 17, 2013, 22:33
Question How to get the cells coordinate
New Member
Wang Han
Join Date: May 2012
Location: Shanghai China
Posts: 21
Rep Power: 5
whyingwang is on a distinguished road
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.
whyingwang is offline   Reply With Quote

Old   January 18, 2013, 11:32
Senior Member
Fumiya Nozaki
Join Date: Jun 2010
Location: Yokohama, Japan
Posts: 170
Rep Power: 7
fumiya is on a distinguished road

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,
solefire and Alexee like this.
fumiya is offline   Reply With Quote

Old   February 4, 2015, 00:53
Default Here's a utility I wrote to write the cell centers to a file at each specified time.
Join Date: Feb 2015
Location: California
Posts: 33
Rep Power: 2
opedrofunk is on a distinguished road
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.


Last edited by opedrofunk; February 4, 2015 at 03:38.
opedrofunk is offline   Reply With Quote

Old   March 21, 2015, 16:05
Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 8,507
Blog Entries: 34
Rep Power: 86
wyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nice
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,
wyldckat is offline   Reply With Quote


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
No layers in a small gap bobburnquist OpenFOAM Native Meshers: snappyHexMesh and Others 6 August 26, 2015 09:38
Import netgen mesh to OpenFOAM hsieh Open Source Meshers: Gmsh, Netgen, CGNS, ... 32 September 13, 2011 05:50
snappyHexMesh won't work - zeros everywhere! sc298 OpenFOAM Native Meshers: snappyHexMesh and Others 2 March 27, 2011 21:11
snappyHexMesh aborting Tobi OpenFOAM Native Meshers: snappyHexMesh and Others 0 November 10, 2010 04:23
physical boundary error!! kris CD-adapco 2 August 3, 2005 00:32

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