CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   Division by zero (https://www.cfd-online.com/Forums/openfoam-solving/58589-division-zero.html)

vitke August 28, 2008 02:52

Hi. I have a volVectorField U
 
Hi. I have a volVectorField U and I'd like to make a volTensorField D=(U*U)/mag(U) whenever mag(U)!=0 and zero otherwise. Is there any way to accomplish this simple task?

hjasak August 28, 2008 03:31

volTensorField hrv = U*U/stabi
 
volTensorField hrv = U*U/stabilise(mag(U), SMALL);

Hrv

vitke August 28, 2008 04:29

Thanks Hrvoje. But it does not
 
Thanks Hrvoje. But it does not work, and it gives a complicated error message, which, I guess, says that mag(U) gives a GeometricField, and stabilise expects an UList:

Making dependency list for source file thermohaline.C
SOURCE=thermohaline.C ; g++ -m64 -Dlinux64 -DDP -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast -march=opteron -O3 -DNoRepository -ftemplate-depth-40 -I/home/dvidovic/OpenFOAM/OpenFOAM-1.5/src/finiteVolume/lnInclude -IlnInclude -I. -I/home/dvidovic/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude -I/home/dvidovic/OpenFOAM/OpenFOAM-1.5/src/OSspecific/Unix/lnInclude -fPIC -c $SOURCE -o Make/linux64GccDPOpt/thermohaline.o
In file included from thermohaline.C:45:
createFields.H: In function 'int main(int, char**)':
createFields.H:130: error: call of overloaded 'stabilise(Foam::tmp<foam::geometricfield<double,> >, const Foam::scalar&)' is ambiguous
/home/dvidovic/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/scalarField.H:72: note: candidates are: Foam::tmp<foam::field<double> > Foam::stabilise(const Foam::UList<double>&, Foam::scalar)
/home/dvidovic/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/GeometricScalarField .C:87: note: Foam::tmp<foam::geometricfield<double,> > Foam::stabilise(const Foam::tmp<foam::geometricfield<double,> >&, const Foam::dimensioned<double>&) [with PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]
make: *** [Make/linux64GccDPOpt/thermohaline.o] Error 1

kathrin_kissling September 1, 2008 03:47

Hi Dragan, have you found a
 
Hi Dragan,

have you found a solution for this problem? I'm dealing with the same errors.

Regards

Kathrin

vitke September 1, 2008 04:44

Hi Kathrin Yes, this is wha
 
Hi Kathrin

Yes, this is what I did:

(U*U)/(mag(U)+SMALL*UUnits)

And UUnits is this:

dimensionedScalar UUnits // Velocity units
(
"kUnits",
dimensionSet(0,1,-1,0,0),
1.0
);

I don't know how small is SMALL, I hope it's small enough. I'd prefer to modify mag(U) only when it is smaller than SMALL, but I don't think this is worth any more trouble. Of course, if you want to compute this often, then put SMALL in the dimensionedScalar.

Good luck

Dragan

kathrin_kissling September 1, 2008 05:35

Hi Dragan, thank you! It
 
Hi Dragan,


thank you! It works now!

Best regards
Kathrin


All times are GMT -4. The time now is 02:19.