
[Sponsors] 
September 15, 2011, 09:54 
cell volume calculation

#1 
New Member
Mike
Join Date: May 2011
Posts: 19
Rep Power: 7 
Hello,
I'm facing this problem: I want to calculate the volume of a certain cell that is contained in my grid. Is there any straightforward method for doing that? Thank you. 

September 15, 2011, 10:20 

#2 
Senior Member
Roman Thiele
Join Date: Aug 2009
Location: Stockholm, Sweden
Posts: 366
Rep Power: 13 
you could create a field for all the cell volumes and then access your specific cell the field is created with
Code:
volScalarField cellVolu ( IOobject ( "cellVolu", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ), mesh, dimensionedScalar("zero", dimVolume, 0.0) ); cellVolu.internalField() = mesh.V(); Code:
cellVolu()[cellIndex]; Code:
mesh.V()[cellIndex] How to compute cellZone volume
__________________
~roman Last edited by romant; September 15, 2011 at 10:20. Reason: forgot a link 

September 15, 2011, 10:31 

#3 
New Member
Mike
Join Date: May 2011
Posts: 19
Rep Power: 7 
Hi romant,
You mean that if I type in the terminal window "mesh.V()[34332]" I ll get the volume of cell number 34332 ? 

September 15, 2011, 10:43 

#4 
Senior Member
Roman Thiele
Join Date: Aug 2009
Location: Stockholm, Sweden
Posts: 366
Rep Power: 13 
no this should have been in C++ in the source code.
__________________
~roman 

September 16, 2011, 04:06 

#5  
Senior Member
Tomislav Maric
Join Date: Mar 2009
Location: Darmstadt, Germany
Posts: 281
Blog Entries: 5
Rep Power: 12 
Quote:
cell.C: Code:
00238 Foam::scalar Foam::cell::mag 00239 ( 00240 const pointField& p, 00241 const faceUList& f 00242 ) const 00243 { 00244 // When one wants to access the cell centre and magnitude, the 00245 // functionality on the mesh level should be used in preference to the 00246 // functions provided here. They do not rely to the functionality 00247 // implemented here, provide additional checking and are more efficient. 00248 // The cell::centre and cell::mag functions may be removed in the future. 00249 00250 // WARNING! See cell::centre than this one, and you should check out the literature if you absolutely need local computations. Do you need the volume of a single cell (set of cells), or do you need mesh level operations? If you just want a volume of a single cell, or a zone of cells defined by some criterion, you can go about it like this: Code:
const cellList& cells = mesh.cells(); const faceList& faces = mesh.faces(); const pointField& points = mesh.points(); // Let's say that you want a volume of the 100th cell.. scalar cellV = cells[100].mag(points,faces); actually want to do. T. 

September 16, 2011, 06:58 

#6 
New Member
Mike
Join Date: May 2011
Posts: 19
Rep Power: 7 
Thank you tomislav_maric,
Well I need to find the volume of one cell, and I know its label. So I ll try the second idea you mentioned. 

October 11, 2011, 09:43 

#8  
New Member
alex
Join Date: Jun 2009
Posts: 17
Rep Power: 9 
Hi!
If i put Code:
cellVolu.write(); How can I sum all the cell volumes? I want calculate the global volume of my geometry. Thanks. Quote:


October 11, 2011, 10:03 
global volume

#9 
Senior Member
Roman Thiele
Join Date: Aug 2009
Location: Stockholm, Sweden
Posts: 366
Rep Power: 13 
Hej,
it is easiest calculated Code:
scalar volumeSum = sum(cellVolu).value(); Code:
checkMesh
__________________
~roman 

October 11, 2011, 10:48 

#10 
New Member
alex
Join Date: Jun 2009
Posts: 17
Rep Power: 9 
Thanks romant.
The total cell's volume given by your method have deviation from "geometric" calculations of 0.002% in my mesh. 

May 23, 2012, 17:15 

#11 
New Member
Join Date: Feb 2012
Posts: 4
Rep Power: 6 
in which source code file do we have to make these changes


Thread Tools  
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
how to set periodic boundary conditions  Ganesh  FLUENT  13  January 22, 2014 05:11 
FvMatrix coefficients  shrina  OpenFOAM Running, Solving & CFD  10  October 3, 2013 14:38 
gradient calculation of cell centered finite volume method  zhengjg  Main CFD Forum  10  November 12, 2012 00:13 
On the damBreak4phaseFine cases  paean  OpenFOAM Running, Solving & CFD  0  November 14, 2008 22:14 
Calculation of cell volume and face handedness  Mark  FLUENT  0  August 30, 2001 07:45 