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

runtime error after succ. compilation + vector component division

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 22, 2011, 11:12
Default runtime error after succ. compilation + vector component division
  #1
New Member
 
Join Date: Aug 2010
Location: Chennai
Posts: 24
Rep Power: 16
ramhari is on a distinguished road
I have a problem in running after successfully compiling the modified rhoCentralFoam code.

volVectorField rhoU_dummy = rhoU_old;
:
:///////////
:
:
volScalarField q_2 = ( rhoU.component(vector::X) - rhoU_dummy.component(vector::X) ) / rhoU_dummy.component(vector::X) );

compiles well. But when it runs immediately shows "floating point exception" error.
The denominator going zero may be one of the reason. I tried even tried adding 1e-06 to it. It compiles well but throws away the same error during run time.

may be my vector component division goes wrong?

Can anyone help me please : )

Last edited by ramhari; May 22, 2011 at 15:08. Reason: I corrected the typo
ramhari is offline   Reply With Quote

Old   May 25, 2011, 12:08
Default
  #2
Senior Member
 
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 437
Rep Power: 22
marupio is on a distinguished road
You could try using the stabilise function on the denominator. Also, try adding log lines just prior to the equation, so you can see what values are going into it.
marupio is offline   Reply With Quote

Old   May 26, 2011, 02:18
Default
  #3
New Member
 
Join Date: Aug 2010
Location: Chennai
Posts: 24
Rep Power: 16
ramhari is on a distinguished road
The velocity vector is initially set zero. I think by adding some 1e-06 to it before division should not show any problem. The floating point exception error shows at the
second iteration itself.
ramhari is offline   Reply With Quote

Old   May 26, 2011, 09:37
Default
  #4
Senior Member
 
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 437
Rep Power: 22
marupio is on a distinguished road
The stabilize function will add a small amount to the number if it is close to zero.
marupio is offline   Reply With Quote

Old   May 28, 2011, 16:53
Default
  #5
New Member
 
Join Date: Aug 2010
Location: Chennai
Posts: 24
Rep Power: 16
ramhari is on a distinguished road
Dear marupio,

I am sorry that i m not getting clearly of what u mean by stabilise function. Can u pls post something of that sort!
ramhari is offline   Reply With Quote

Old   May 28, 2011, 17:01
Default
  #6
Senior Member
 
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 437
Rep Power: 22
marupio is on a distinguished road
Sorry, the function is stabilise(scalar value, scalar smallAmount).

I was wrong - it doesn't check if it is close to zero, it always adds the smallAmount. But, it will add it in the right direction (positive or negative).

Here's how you'd use it:

Code:
volScalarField q_2 = ( rhoU.component(vector::X) - rhoU_dummy.component(vector::X) ) / stabilise(rhoU_dummy.component(vector::X), SMALL) );
marupio is offline   Reply With Quote

Old   May 30, 2011, 07:40
Default
  #7
New Member
 
Join Date: Aug 2010
Location: Chennai
Posts: 24
Rep Power: 16
ramhari is on a distinguished road
Thanks marupio,
ramhari is offline   Reply With Quote

Reply

Tags
division, exception, floating, point, vector


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



All times are GMT -4. The time now is 00:20.