CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   how to create a volScalarField of mesh.V() ??? (http://www.cfd-online.com/Forums/openfoam-programming-development/77966-how-create-volscalarfield-mesh-v.html)

sebware July 8, 2010 11:36

how to create a volScalarField of mesh.V() ???
 
Hey
I use a volScalarField with the volume of cells.
It works with the cell center but not with cell volume.

- Why the following line works
volVectorField centres = Sj.mesh().C();

- Why the following line dosn't work
volScalarField volume= Sj.mesh().V();

Sj is a volVectorField defined as follow:

volVectorField Sj
(
IOobject
(
"Sj",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),mesh, dimensionSet(1,-1,-3,0,0,-1,0)
);

thanks
Sebastian

lfbarcelo June 13, 2011 12:59

Did you ever get to fix this? I have the exact same problem.

pablodecastillo June 13, 2011 17:20

I think that mesh.V() is a scalarField, not a volscalarField ..........

Fransje July 2, 2011 07:48

Looking at the doxygen documentation on the openfoam.com website, you can see that:

Quote:

const DimensionedField< scalar, volMesh > & V () const - Return cell volumes.
Meaning that V() will return a DimensionedField.

Did you try using:
Quote:

volScalarField volume= Sj.mesh().V().field();
Kind regards,

Francois.

kathrin_kissling July 6, 2011 10:17

This is due that a volScalarField does store values on the boundary, what does not make a lot of sense for cell volumes.
So just the internalField of a volScalarField does have cell volumes

So I personally would not try to cast this into a volScalarField! What will you do on the boundaries? If you initialize the volScalarField with zero than there will be zero at the boundaries too. What happens if you divide at a point by these values?
I would just work on the internalField

volScalarField myWhatEverField =mag(U);
scalarField volumes = mesh.V();

volScalarField result(IOobject(...),mesh, 0);
result.internalField() = myWahateverField.internalField/volumes;

Do whatever you need to do on the boundaries

Best

Kathrin


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