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

[Other] How to get mesh total volume quickly?

Register Blogs Community New Posts Updated Threads Search

Like Tree3Likes
  • 3 Post By alexeym

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 1, 2012, 15:24
Default How to get mesh total volume quickly?
  #1
Member
 
Join Date: Sep 2011
Posts: 45
Rep Power: 14
ic3wall is on a distinguished road
Hi,

What's the fastest way to get the total volume of a mesh precisely (sum of volume of each cell)?

I know checkMesh is giving Mesh total volume but i'm not sure if it's really mesh total volume or volume of bounding box ..

Thank you!
ic3wall is offline   Reply With Quote

Old   August 1, 2012, 17:24
Default
  #2
Senior Member
 
Travis Carrigan
Join Date: Jul 2010
Location: Arlington, TX
Posts: 161
Rep Power: 15
tcarrigan is on a distinguished road
What software are you using to generate the mesh? It may provide the appropriate utilities for doing a volume calculation.
tcarrigan is offline   Reply With Quote

Old   August 1, 2012, 19:20
Default
  #3
Member
 
Join Date: Feb 2012
Posts: 57
Rep Power: 14
matt.mech.eng is on a distinguished road
checkMesh gives the volume of the mesh not the bounding box
you can easily calculate the volume of the bounding box yourself.. compare with checkMesh volume given
matt.mech.eng is offline   Reply With Quote

Old   January 21, 2016, 12:34
Default
  #4
Member
 
Peter
Join Date: Nov 2015
Location: Hamburg, Germany
Posts: 57
Rep Power: 10
potentialFoam is on a distinguished road
Dear Foamers,

I would like to get the total volume of a solution domain.
I tried
Code:
scalar totalVolume(0.0);
forAll(mesh_.cells(),i) //cellI)
{
totalVolume += mesh_.V()[i]; //cellI];
}
without success. (Wrong result, but I don't know why.)

Then I found this last answer and hence I tried to get it with 'checkMesh'.
Unfortunately, I can't find the code snippet in the folder
/OpenFOAM-3.0.1/applications/utilities/mesh/manipulation/checkMesh/
using e.g.:
grep -nr "volume"

Can you please show me, where they hid it?

Regards,
Peter
potentialFoam is offline   Reply With Quote

Old   January 21, 2016, 15:14
Default
  #5
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,930
Rep Power: 38
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
Hi,

Why have you decided to iterate over strange cells() list? This does the job:

Code:
scalar vol = 0.0;
forAll(mesh.V(), idx)
{
    vol += mesh.V()[idx];
}
reduce(vol, sumOp<scalar>());
Info<< vol << endl;
The same thing:

Code:
scalar vol = gSum(mesh.V());
Info<< vol << endl;
(in fact gSum is just short way to say
Code:
scalar vol = sum(mesh.V());
reduce(vol, sumOp<scalar>());
)

Also it is up to you to check if you run 2D axisymmetric case and multiply result to get real mesh volume.

Answering you last question: it is in primitiveMeshCheck.C (http://foam.sourceforge.net/docs/cpp...ce.html#l00318).
reza2031, potentialFoam and RGS like this.

Last edited by alexeym; January 22, 2016 at 17:27.
alexeym is offline   Reply With Quote

Old   January 22, 2016, 03:57
Default
  #6
Member
 
Peter
Join Date: Nov 2015
Location: Hamburg, Germany
Posts: 57
Rep Power: 10
potentialFoam is on a distinguished road
Thanks Alexey,

it works
(I use
Code:
scalar vol = gSum( mesh_.V() );
)
potentialFoam is offline   Reply With Quote

Reply


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
[ICEM] Negative volume error in hybrid mesh siw ANSYS Meshing & Geometry 4 September 3, 2014 05:25
Moving mesh Niklas Wikstrom (Wikstrom) OpenFOAM Running, Solving & CFD 122 June 15, 2014 06:20
[ICEM] Generating Mesh for STL Car in Windtunnel Simulation tommymoose ANSYS Meshing & Geometry 48 April 15, 2013 04:24
channelFoam for a 3D pipe AlmostSurelyRob OpenFOAM 3 June 24, 2011 13:06
Icemcfd 11: Loss of mesh from surface mesh option? Joe CFX 2 March 26, 2007 18:10


All times are GMT -4. The time now is 07:36.