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: 7
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: 217
Blog Entries: 1
Rep Power: 11
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: 60
Rep Power: 4
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: 10,123
Blog Entries: 39
Rep Power: 110
wyldckat is a glorious beacon of lightwyldckat is a glorious beacon of lightwyldckat is a glorious beacon of lightwyldckat is a glorious beacon of lightwyldckat is a glorious beacon of lightwyldckat is a glorious beacon of light
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

Old   October 25, 2017, 03:51
New Member
Ayush Agrawal
Join Date: Jun 2014
Posts: 16
Rep Power: 5
ayushmorx is on a distinguished road

I am trying to get cellCenters working for the past couple of days, but unfortunately I am having problems using it. I have attached the output here. Would be glad for any help!
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 4.1 |
| \\ / A nd | Web: |
| \\/ M anipulation | |
Build : 4.1
Exec : cellCenters
Date : Oct 25 2017
Time : 03:44:04
Host : "Ayush-Work"
PID : 19641
Case : /media/ayushmorx/HD2/lownu_mine
nProcs : 1
sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).
fileModificationChecking : Monitoring run-time modified files using timeStampMaster
allowSystemOperations : Allowing user-supplied system call operations

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time

Create mesh for time = 5

Time = 5

error in IOstream "/media/ayushmorx/HD2/lownu_mine/5/cellCenters" for operation Ostream& operator<<(Ostream&, const char)

file: /media/ayushmorx/HD2/lownu_mine/5/cellCenters at line 18.

From function virtual bool Foam::IOstream::check(const char*) const
in file db/IOstreams/IOstreams/IOstream.C at line 96.

FOAM exiting
ayushmorx 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 Siemens 2 August 3, 2005 00:32

All times are GMT -4. The time now is 22:39.