|
[Sponsors] |
February 25, 2010, 05:14 |
access to volume of the cells
|
#1 |
Senior Member
Roman Thiele
Join Date: Aug 2009
Location: Eindhoven, NL
Posts: 374
Rep Power: 21 |
Hej,
I know that I can access the volume of the cells with mesh.V(). But for some reason, the following two lines of code give an error message upon compiling Code:
const fvMesh& mesh = alpha1_.mesh(); const volScalarField& volumeCell = mesh.V(); Code:
invalid initialization of reference of type ‘const Foam::volScalarField&’ from expression of type ‘const Foam::DimensionedField<double, Foam::volMesh>’
__________________
~roman |
|
February 26, 2010, 02:09 |
|
#2 |
Member
Vojtech Betak
Join Date: Mar 2009
Location: Czech republic
Posts: 34
Rep Power: 18 |
Hi,
try this const scalarField& Volumes = mesh.V(); Vojta |
|
February 26, 2010, 03:54 |
half done
|
#3 |
Senior Member
Roman Thiele
Join Date: Aug 2009
Location: Eindhoven, NL
Posts: 374
Rep Power: 21 |
this worked for the part that it did not complain while compiling, the problem now is that it is not a volumeField anymore. therefore I can not use it in further calculations for volumefields like in this one
Code:
const volScalarField& p = alpha1_.db().lookupObject<volScalarField>("p"); volScalarField limitedAlpha1 = min(max(alpha1_, scalar(0)), scalar(1)); const fvMesh& mesh = alpha1_.mesh(); // get the underlying mesh const scalarField& volumeCell = mesh.V(); limitedAlpha1 * rho1() * volumeCell * (Tsat_-Tinf_) * combFrequency_/(ifg_ * (1-limitedAlpha1)), rho2()*0.0*combFrequency_*(pSat()/p)
__________________
~roman |
|
March 3, 2010, 04:51 |
anyone
|
#4 |
Senior Member
Roman Thiele
Join Date: Aug 2009
Location: Eindhoven, NL
Posts: 374
Rep Power: 21 |
Does anyone have an idea? The goal is to have a volScalarField with dimensions m^3, containing the cell volumes in order to calculate further with it.
The programmer's guide gives volScalarField foo = mesh.V(), but this assignment does not work.
__________________
~roman |
|
March 3, 2010, 05:42 |
|
#5 |
Senior Member
Laurence R. McGlashan
Join Date: Mar 2009
Posts: 370
Rep Power: 23 |
A quick fix might be to set the internalField of a volScalarField:
Code:
volumeCell.internalField() = mesh.V();
__________________
Laurence R. McGlashan :: Website Last edited by l_r_mcglashan; March 3, 2010 at 06:10. |
|
March 3, 2010, 05:51 |
|
#6 |
Senior Member
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,903
Rep Power: 37 |
Hi
According to Doxygen, this is the following is the way to access the volume: const Foam:imensionedField<double, Foam::volMesh> & foo = mesh.V(); See http://foam.sourceforge.net/doc/Doxy...4cd0efe7fb3baa Best regards, Niels |
|
March 3, 2010, 06:14 |
|
#7 |
Senior Member
Roman Thiele
Join Date: Aug 2009
Location: Eindhoven, NL
Posts: 374
Rep Power: 21 |
Code:
const Foam::DimensionedField<double, Foam::volMesh> & volumeCell = mesh.V(); This is the reason I want a volScalarField, which contains the volume of each cell of the mesh. It doesn't even have to be dimensioned, because that can be fixed with work arounds. But it must be possible to somehow get the volume of each cell into a volScalarField. Code:
const volScalarField& volumeCell.internalField() = mesh.V();
__________________
~roman |
|
March 3, 2010, 06:39 |
|
#8 |
Senior Member
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,903
Rep Power: 37 |
Hi
A work around, as you have spent a lot of time on this is to do for instance as follows: // gamma being a volScalarField scalarField V = mesh.V(); forAll(V,i) { gamma[i] *= V[i]; } Good luck, Niels |
|
March 3, 2010, 09:14 |
|
#9 |
Senior Member
Jens Klostermann
Join Date: Mar 2009
Posts: 117
Rep Power: 17 |
I would go with Laurence idea:
volScalarField cellVolu ( IOobject ( "cellVolu", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ), mesh, dimensionedScalar("zero", dimVolume, 0.0) ); cellVolu.internalField() = mesh.V(); At least for me it does the job! Jens |
|
March 3, 2010, 09:23 |
|
#10 |
Senior Member
Roman Thiele
Join Date: Aug 2009
Location: Eindhoven, NL
Posts: 374
Rep Power: 21 |
Hej Jens, thanks for the reply, one more question about the following code snippet
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:
const volScalarField& volumes = alpha1_.db().lookupObject<volScalarField>("cellVolu");
__________________
~roman |
|
March 3, 2010, 10:37 |
|
#11 |
Senior Member
Jens Klostermann
Join Date: Mar 2009
Posts: 117
Rep Power: 17 |
I don't know, what you want to do. But cellVolu gives you a field of the cell volumes (this is already of type volScalarField).
If alpha1 is your volume fraction denity*cellVolu gives you the mass per cell. (but this is not the answer?) Hope it helps. Jens |
|
March 3, 2010, 10:50 |
|
#12 |
Senior Member
Roman Thiele
Join Date: Aug 2009
Location: Eindhoven, NL
Posts: 374
Rep Power: 21 |
Thank you for this snippet. I will try the method tomorrow and see what I get.
__________________
~roman |
|
March 4, 2010, 07:36 |
thanks
|
#13 |
Senior Member
Roman Thiele
Join Date: Aug 2009
Location: Eindhoven, NL
Posts: 374
Rep Power: 21 |
Thanks, this worked wonderfully.
__________________
~roman |
|
Tags |
compiling issues, development, volume mesh |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
negative element volume (CFX-10.0) | CFDworker | CFX | 8 | September 27, 2011 19:16 |
[blockMesh] BlockMesh FOAM warning | gaottino | OpenFOAM Meshing & Mesh Conversion | 7 | July 19, 2010 15:11 |
FloWorks (Flow Express) Volume Goal Setting | rbigelow | Main CFD Forum | 0 | November 13, 2009 15:28 |
Calculating volume of Phase | Pavan | FLUENT | 2 | March 5, 2008 11:04 |
split volume | Kabo | FLUENT | 1 | January 28, 2008 08:08 |