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

How to get the volume of a cell

Register Blogs Community New Posts Updated Threads Search

Like Tree8Likes
  • 2 Post By eugene
  • 1 Post By l_r_mcglashan
  • 3 Post By kmooney
  • 1 Post By elmo555
  • 1 Post By JackW

Reply
 
LinkBack Thread Tools Search this Thread 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: 17
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: 21
eugene is on a distinguished road
mesh.V()[cellID]
eugene is offline   Reply With Quote

Old   August 1, 2010, 04:09
Default
  #3
Senior Member
 
Nima Samkhaniani
Join Date: Sep 2009
Location: Tehran, Iran
Posts: 1,267
Blog Entries: 1
Rep Power: 25
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 04:28.
nimasam is offline   Reply With Quote

Old   June 9, 2011, 08:15
Default
  #4
Member
 
fisch
Join Date: Feb 2010
Posts: 97
Rep Power: 16
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, 10:40
Default
  #5
Senior Member
 
Laurence R. McGlashan
Join Date: Mar 2009
Posts: 370
Rep Power: 23
l_r_mcglashan will become famous soon enough
mesh.V() is a scalarField, not a volScalarField. Why would you have volumes at patches?
lourencosm likes this.
__________________
Laurence R. McGlashan :: Website
l_r_mcglashan is offline   Reply With Quote

Old   June 9, 2011, 11:11
Default
  #6
Member
 
fisch
Join Date: Feb 2010
Posts: 97
Rep Power: 16
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, 09:02
Default measuring volume
  #7
Member
 
Join Date: Jul 2015
Posts: 33
Rep Power: 11
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, 21:20
Default
  #8
Senior Member
 
kmooney's Avatar
 
Kyle Mooney
Join Date: Jul 2009
Location: San Francisco, CA USA
Posts: 323
Rep Power: 18
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, Aaron_L and wht like this.
kmooney is offline   Reply With Quote

Old   February 12, 2016, 13:22
Default
  #9
Member
 
Join Date: Jul 2014
Posts: 39
Rep Power: 12
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, 06:02
Default
  #10
Member
 
Lennart
Join Date: Feb 2016
Posts: 46
Rep Power: 10
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?
linyanx likes this.
elmo555 is offline   Reply With Quote

Old   August 14, 2017, 01:54
Default
  #11
Member
 
Jack
Join Date: Aug 2012
Posts: 47
Rep Power: 14
JackW is on a distinguished road
I assume that people want to do it for postprocessing. This is how I did it (by copying LESDelta and cubeRootVolDelta implementation):

Code:
# include "calculatedFvPatchFields.H"

volScalarField V (
        IOobject (
            "V",
            runTime.timeName(),
            mesh,
            IOobject::NO_READ
       ),
       mesh,
       dimensionedScalar("small", dimLength*dimLength*dimLength, SMALL),
       calculatedFvPatchScalarField::typeName
);
V.internalField() = mesh.V();
V.write();
The calculatedFvPatchScalarField::typeName just defines calculated patch types, which evaluates to SMALL (what it was initialised as)
wht likes this.
JackW is offline   Reply With Quote

Old   September 25, 2017, 12:39
Default
  #12
Member
 
Linyan X
Join Date: Dec 2015
Posts: 43
Rep Power: 11
linyanx is on a distinguished road
Hi Lennart,
I meet the exactly the same question as you mentioned. I was trying to calculate the weight for every cell and store the value into the volScalarField.
Quote:
K = 0.5*magSqr(U)*rho*mesh.V();
Sadly the system would complain it while compilation. Do you have any idea about this?
All the best,
Linyan
linyanx is offline   Reply With Quote

Old   February 3, 2022, 08:18
Default
  #13
Member
 
hari charan
Join Date: Sep 2021
Location: India,hyderabad
Posts: 97
Rep Power: 5
saicharan662000@gmail.com is on a distinguished road
Hi jack,
I know this post is old but

Can u tell me how to use it in twoPhaseMixtureThermo.C in compressibleInterfoam solver. Because when I am using it as

const volScalarField& cellVolume = mesh.V();
I am getting an error that mesh was not declared in this scope.
saicharan662000@gmail.com is offline   Reply With Quote

Old   July 21, 2022, 16:46
Default
  #14
New Member
 
Join Date: Jun 2022
Posts: 10
Rep Power: 4
AbhishekTAMU is on a distinguished road
I feel that my question is somehow relevant to this thread. Hence, I am posting it here.

I know that magSf() function can calculate individual face area. However, I want to know the surface area of a cell just like we can get cell volume by using mesh.V().

Does anyone know how to get the cell surface area?

Thanks in advance !
AbhishekTAMU is offline   Reply With Quote

Old   July 22, 2022, 00:32
Default
  #15
Member
 
hari charan
Join Date: Sep 2021
Location: India,hyderabad
Posts: 97
Rep Power: 5
saicharan662000@gmail.com is on a distinguished road
Hi abhishek,
Though I didn’t try this. Try using fvc::surfaceSum(mesh.sf())
saicharan662000@gmail.com is offline   Reply With Quote

Old   July 22, 2022, 01:47
Default
  #16
New Member
 
Join Date: Jun 2022
Posts: 10
Rep Power: 4
AbhishekTAMU is on a distinguished road
Hello Hari Charan,

Thanks, I will try it and let you know if it works !
AbhishekTAMU is offline   Reply With Quote

Old   September 28, 2023, 17:13
Default
  #17
New Member
 
Eduardo Paiva
Join Date: Jul 2020
Posts: 5
Rep Power: 6
eduardopaiva is on a distinguished road
Someone knows how to do that? I need to get a volume of a cell patch

Quote:
Originally Posted by PicklER View Post
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.
eduardopaiva 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
How to fix a volume cell? jpsegura FLUENT 0 May 31, 2007 19: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 9, 2003 00:58
Cell volume Takeshi Siemens 2 July 16, 2003 23: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 05:03.