CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Pre-Processing (
-   -   To get the magnitude of volVectorField (

susana November 15, 2006 06:29

Hi All, Can anyone please
Hi All,
Can anyone please inform me as to how I can get the magnitude of a vector defined as volVectorField, which I belive is of type GeometricField. I have tried mag() an a lot of other manipulations. In essence I need to get the magnitude of the velocity U (defined as volVectorField) and multiply it with other values defined as dimensionedScalar. I am getting a compile error.

Please please help.

Thanks in advance,

cosimobianchini November 15, 2006 08:13

Hi Susan, something like
Hi Susan,
something like

dimensionedScalar C ("C",p.dimensions(),1000.0) ;
volScalarField magU = C*mag(U);

should work.
U is again the velocity defined as volVectorField

hope it helps


susana November 15, 2006 08:21

Thanks for the response, my pr
Thanks for the response, my problem is like this

scalar x, y, z

z = x*y*mag(U) where U is volVectorField

gives me an error
no match for 'operator=' in 'Re = Foam::operator/(const Foam::tmp<foam::geometricfield<type,> >&, const Foam::dimensioned<double>&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh](((const Foam::dimensioned<double>&)((const Foam::dimensioned<double>*)(& nu))))'
/home/abrahasm/OpenFOAM/OpenFOAM-1.3/src/OpenFOAM/lnInclude/dimensionedScalarFwd .H:45: note: candidates are: Foam::dimensioned<double>& Foam::dimensioned<double>::operator=(const Foam::dimensioned<double>&)

Please help.

cosimobianchini November 15, 2006 08:32

If with scalar you mean just d
If with scalar you mean just dimensionedScalar the problem is:

z must be a volScalarField


lucchini November 15, 2006 08:34

Hi Susan, you get the error b
Hi Susan,
you get the error because you try to assign to a scalar variable the product between a scalarField and a volScalarField.
You can get it working if you write:

volScalarField z = x*y*mag(U)

I hope it has been useful,


susana November 16, 2006 07:53

Thanks so much! It takes a whi
Thanks so much! It takes a while to understand how the different classes are structured.

All times are GMT -4. The time now is 11:38.