CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM Running, Solving & CFD

How to get the volume of a cell

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

Like Tree2Likes
  • 2 Post By kmooney

Reply
 
LinkBack Thread Tools Display Modes
Old   March 19, 2007, 01:35
Default Hi, all: I searched the for
  #1
Member
 
roy fokker
Join Date: Mar 2009
Posts: 44
Rep Power: 9
dbxmcf is on a distinguished road
Hi, all:

I searched the forum and doxygen, found a function mag and the following comments:
// INSTRUCTION FOR USE!
// When one wants to access the cell centre and magnitude, the
// functionality on the mesh level should be used in preference to the
// functions provided here. They do not rely to the functionality
// implemented here, provide additional checking and are more efficient.
// The cell::centre and cell::mag functions may be removed in the future.

// WARNING! See cell::centre

// first calculate the aproximate cell centre as the average of all
// face centres

I am just confused how to use it and what is the best way to find the cell volume? What I am trying to do is something like:
mesh.cells()[cellLabel].V()...

Thanks a lot!
dbxmcf is offline   Reply With Quote

Old   March 19, 2007, 06:57
Default mesh.V()
  #2
Senior Member
 
Eugene de Villiers
Join Date: Mar 2009
Posts: 725
Rep Power: 13
eugene is on a distinguished road
mesh.V()[cellID]
eugene is offline   Reply With Quote

Old   August 1, 2010, 03:09
Default
  #3
Senior Member
 
Nima Samkhaniani
Join Date: Sep 2009
Location: Tehran, Iran
Posts: 1,187
Blog Entries: 1
Rep Power: 15
nimasam is on a distinguished road
hi friend
i want to access volume of cells in volScalarField but in openFoam there is two ways to access to the mesh volume and none of them are volScalarField:
const DimensionedField<scalar, volMesh>& V() const;
or
const scalarField& cellVolumes() const;

Last edited by nimasam; August 1, 2010 at 03:28.
nimasam is offline   Reply With Quote

Old   June 9, 2011, 07:15
Default
  #4
Member
 
fisch
Join Date: Feb 2010
Posts: 97
Rep Power: 8
fisch is on a distinguished road
nimasam, did you found a solution?
I have the same problem now...

thanks, rupert
fisch is offline   Reply With Quote

Old   June 9, 2011, 09:40
Default
  #5
Senior Member
 
Laurence R. McGlashan
Join Date: Mar 2009
Posts: 370
Rep Power: 15
l_r_mcglashan will become famous soon enough
mesh.V() is a scalarField, not a volScalarField. Why would you have volumes at patches?
__________________
Laurence R. McGlashan :: Website
l_r_mcglashan is offline   Reply With Quote

Old   June 9, 2011, 10:11
Default
  #6
Member
 
fisch
Join Date: Feb 2010
Posts: 97
Rep Power: 8
fisch is on a distinguished road
thanks for the quick reply, l_r_mcglashan

i used it without thinking because it's written like this in the programmersGuide P33.
fisch is offline   Reply With Quote

Old   August 8, 2015, 08:02
Default measuring volume
  #7
Member
 
Join Date: Jul 2015
Posts: 33
Rep Power: 3
kaveh19 is on a distinguished road
hi guys,
how can I measure the volume of geometry in openFoan?
kaveh19 is offline   Reply With Quote

Old   August 9, 2015, 20:20
Default
  #8
Senior Member
 
kmooney's Avatar
 
Kyle Mooney
Join Date: Jul 2009
Location: Amherst, MA USA - San Diego, CA USA
Posts: 319
Rep Power: 10
kmooney is on a distinguished road
Quote:
Originally Posted by kaveh19 View Post
hi guys,
how can I measure the volume of geometry in openFoan?
Something like this should work if executed in a top level of a solver:

Code:
scalar totalVolume(0.0);
forAll(mesh.cells(),cellI)
{
totalVolume += mesh.V()[cellI];
}
Traction and Aaron_L like this.
kmooney is offline   Reply With Quote

Old   February 12, 2016, 13:22
Default
  #9
Member
 
Join Date: Jul 2014
Posts: 37
Rep Power: 3
PicklER is on a distinguished road
Is it possible to get the volumes only of the cells at patchID?

If I have:

Code:
label patchID = mesh.boundaryMesh().findPatchID(patchName);
Then something like mesh.V()[patchID] ?

Otherwise to get the
Code:
cellI
for only the patch corresponding to patchID?

Then I can use that which Kyle recommended. I would like to multiply the value on a patch face with the volume of the cell corresponding to the patch face. The will give me something like a indication of adding mass to cell.

Last edited by PicklER; February 12, 2016 at 13:25. Reason: Clarity
PicklER is offline   Reply With Quote

Old   April 19, 2016, 05:02
Default
  #10
New Member
 
Lennart
Join Date: Feb 2016
Posts: 19
Rep Power: 2
elmo555 is on a distinguished road
I also have a question regarding the use of mesh.V():

  • Why is a volScalarField not available? Volume is a scalar quantity, and I'd like to have it for each cell in my mesh. How is this related to patches? (@l_r_mcglashan). Patches shouldn't have volumes
  • How comes I can use mesh.V() to multiply with a volScalarField, but not divide one by it? Example below...
Code:
//works
Info<< "Total liquid volume liquidV = " << sum(mesh.V()*alpha1).value() << endl;
// doesn't work
volScalarField interfDens(aInterfaceCells/mesh.V());
Both alpha1 and aInterfaceCells are volScalarField. What am I doing wrong?
elmo555 is offline   Reply With Quote

Reply

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
How to fix a volume cell? jpsegura FLUENT 0 May 31, 2007 18:42
negative cell volume alfin FLUENT 2 January 19, 2006 21:17
Cell-vertex and cell-centered finite volume method Praveen Main CFD Forum 4 September 8, 2003 23:58
Cell volume Takeshi CD-adapco 2 July 16, 2003 22:02
How to caculate cell volume Tareq Al-shaalan Main CFD Forum 2 November 4, 2002 09:48


All times are GMT -4. The time now is 20:12.