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

Division by zero

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 2 Post By hjasak

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 28, 2008, 03:52
Default Hi. I have a volVectorField U
  #1
New Member
 
Dragan Vidovic
Join Date: Mar 2009
Posts: 17
Rep Power: 17
vitke is on a distinguished road
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?
vitke is offline   Reply With Quote

Old   August 28, 2008, 04:31
Default volTensorField hrv = U*U/stabi
  #2
Senior Member
 
Hrvoje Jasak
Join Date: Mar 2009
Location: London, England
Posts: 1,907
Rep Power: 33
hjasak will become famous soon enough
volTensorField hrv = U*U/stabilise(mag(U), SMALL);

Hrv
chegdan and lbossle like this.
__________________
Hrvoje Jasak
Providing commercial FOAM/OpenFOAM and CFD Consulting: http://wikki.co.uk
hjasak is offline   Reply With Quote

Old   August 28, 2008, 05:29
Default Thanks Hrvoje. But it does not
  #3
New Member
 
Dragan Vidovic
Join Date: Mar 2009
Posts: 17
Rep Power: 17
vitke is on a distinguished road
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
vitke is offline   Reply With Quote

Old   September 1, 2008, 04:47
Default Hi Dragan, have you found a
  #4
Senior Member
 
Kathrin Kissling
Join Date: Mar 2009
Location: Besigheim, Germany
Posts: 134
Rep Power: 17
kathrin_kissling is on a distinguished road
Hi Dragan,

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

Regards

Kathrin
kathrin_kissling is offline   Reply With Quote

Old   September 1, 2008, 05:44
Default Hi Kathrin Yes, this is wha
  #5
New Member
 
Dragan Vidovic
Join Date: Mar 2009
Posts: 17
Rep Power: 17
vitke is on a distinguished road
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
vitke is offline   Reply With Quote

Old   September 1, 2008, 06:35
Default Hi Dragan, thank you! It
  #6
Senior Member
 
Kathrin Kissling
Join Date: Mar 2009
Location: Besigheim, Germany
Posts: 134
Rep Power: 17
kathrin_kissling is on a distinguished road
Hi Dragan,


thank you! It works now!

Best regards
Kathrin
kathrin_kissling 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
About flow division sunnysun OpenFOAM Running, Solving & CFD 5 March 2, 2009 13:34
Rather obscure division by zero in triangleFuncsintersectAxesBundle gschaider OpenFOAM Bugs 2 August 13, 2008 08:08
Division by zero in Xoodles hannes OpenFOAM Bugs 3 August 4, 2008 12:04
ScalarField division maka OpenFOAM Pre-Processing 2 August 27, 2007 06:10


All times are GMT -4. The time now is 01:58.