CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Cell volume and face area calculation

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 18, 2015, 14:28
Default Cell volume and face area calculation
  #1
New Member
 
Richard Vega
Join Date: Jun 2014
Location: Texas
Posts: 12
Rep Power: 12
richard_vega is on a distinguished road
Is there a simple way to obtain a list that has the volume of each cell in a mesh along with a list that has the area of each face in a mesh?
richard_vega is offline   Reply With Quote

Old   August 18, 2015, 14:37
Default
  #2
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,938
Rep Power: 39
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
Hi,

1. V method in fvMesh (http://foam.sourceforge.net/docs/cpp...9d5006af5644e5)

2. Sf method in fvMesh (http://foam.sourceforge.net/docs/cpp...121219b4ce84f9)
alexeym is offline   Reply With Quote

Old   August 18, 2015, 14:54
Default
  #3
New Member
 
Richard Vega
Join Date: Jun 2014
Location: Texas
Posts: 12
Rep Power: 12
richard_vega is on a distinguished road
Thank you for the quick reply. I probably should have stated somewhere in that question that I have no experience programming in OpenFOAM. The extent of my experience is using standard solvers and utilities, so the links did not mean a while lot to me. Could you add a bit more explanation on how I could use these functions?
richard_vega is offline   Reply With Quote

Old   August 18, 2015, 15:04
Default
  #4
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,938
Rep Power: 39
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
Quote:
Originally Posted by richard_vega View Post
Could you add a bit more explanation on how I could use these functions?
Obviously, it depends on where you would like to use them.

But basically if you have mesh object or type fvMesh (usually you have it in solvers and in most of utilities), then if you would like to iterate over cell volumes, you can use something like:

Code:
forAll(mesh.V(), idx)
{
    Info<< "Volume of cell with index " << idx << " is " << mesh.V()[idx] << end;
}
Maybe it would be better, if you post why do you need volumes of cells and areas of faces.
alexeym is offline   Reply With Quote

Old   August 18, 2015, 15:10
Default why I need them...
  #5
New Member
 
Richard Vega
Join Date: Jun 2014
Location: Texas
Posts: 12
Rep Power: 12
richard_vega is on a distinguished road
I am using OpenFOAM only as a pre and post processor to my code, which is written in C/OpenCL. Somewhere in my code, I am calculating the volumes and areas and I am getting some strange results that I believe are a result of the 5 digit precision in the points file. I wanted to use OpenFOAM to calculate the volumes and areas to see if this a bug in my code, or indeed the precision issue I am suspecting. Thus, I was hoping for sort of a one-liner that would generate a file called "volumes," but I guess no dice. I will try your suggestion tonight.
richard_vega is offline   Reply With Quote

Old   August 18, 2015, 15:46
Default
  #6
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,938
Rep Power: 39
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
If you just need to look at the list of volumes you can use

Code:
Info << mesh.V() << endl;
Or you can use utility from attached archive, it will write cell volumes in volumes.dat file and face areas into areas.dat file.
Attached Files
File Type: gz write_cell_volumes_and_face_areas.tar.gz (759 Bytes, 190 views)
alexeym is offline   Reply With Quote

Old   April 7, 2021, 07:08
Default
  #7
New Member
 
Jingna Pan
Join Date: Nov 2019
Posts: 3
Rep Power: 7
J. Pan is on a distinguished road
Quote:
Originally Posted by alexeym View Post
If you just need to look at the list of volumes you can use

Code:
Info << mesh.V() << endl;
Or you can use utility from attached archive, it will write cell volumes in volumes.dat file and face areas into areas.dat file.
Hi Alexey,

I tried to compile the utility but encountered the following error. I appreciate if you could give any hints. FYI: I am using openfoam 5 and Ubuntu 20.04.

write_cell_volumes_and_face_areas.cpp:6:10: fatal error: OFstream.H: No such file or directory
6 | #include "OFstream.H"
| ^~~~~~~~~~~~
compilation terminated.
J. Pan is offline   Reply With Quote

Reply

Tags
face area cell volume


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 Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Other] mesh airfoil NACA0012 anand_30 OpenFOAM Meshing & Mesh Conversion 13 March 7, 2022 18:22
how to set periodic boundary conditions Ganesh FLUENT 15 November 18, 2020 07:09
[blockMesh] error message with modeling a cube with a hold at the center hsingtzu OpenFOAM Meshing & Mesh Conversion 2 March 14, 2012 10:56
fluent add additional zones for the mesh file SSL FLUENT 2 January 26, 2008 12:55
[blockMesh] Axisymmetrical mesh Rasmus Gjesing (Gjesing) OpenFOAM Meshing & Mesh Conversion 10 April 2, 2007 15:00


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