CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

Problem in UDF

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 21, 2016, 17:06
Default Problem in UDF
  #1
Member
 
cfd^2
Join Date: Mar 2013
Posts: 31
Rep Power: 13
cfd^2 is on a distinguished road
Hi,

I have had a problem with a UDF. When writing

C_UDMI(c,t,0) = C_UDSI_G(c,t,0)[0];

it works perfectly, but when I write the inverse of the gradient component (or even the magnitue of the gradient) like that

C_UDMI(c,t,0) = 1/C_UDSI_G(c,t,0)[0];

I get the error:

Error: cx-set-real-entry: wta[2](float)
Error Object: 1.#inf

Could someone help me to clarify this issue?
cfd^2 is offline   Reply With Quote

Old   January 21, 2016, 17:46
Default
  #2
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
The C_UDMI macro is expecting a real value (float or double depending on single or double precision). Try using a trailing dot for the numerator (makes that value a real number instead of an integer):

Code:
C_UDMI(c,t,0) = 1./C_UDSI_G(c,t,0)[0];
`e` is offline   Reply With Quote

Old   January 21, 2016, 18:26
Default
  #3
Member
 
cfd^2
Join Date: Mar 2013
Posts: 31
Rep Power: 13
cfd^2 is on a distinguished road
Quote:
Originally Posted by `e` View Post
The C_UDMI macro is expecting a real value (float or double depending on single or double precision). Try using a trailing dot for the numerator (makes that value a real number instead of an integer):

Code:
C_UDMI(c,t,0) = 1./C_UDSI_G(c,t,0)[0];

Thank you. But didn't work... Any other tip?
cfd^2 is offline   Reply With Quote

Old   January 21, 2016, 19:50
Default
  #4
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
Then it's probably another line at fault (unless C_UDSI_G(c,t,0)[0] is returning zero in at least one of the cells; which might explain your error of "1.#inf"). Try only using that line within the UDF and add in a Message(); function to output the value of C_UDSI_G(c,t,0)[0] and 1./C_UDSI_G(c,t,0)[0]; to the command line. You may want to perform this debugging on a mesh with fewer cells to avoid excess messages being printed to the screen.

If you find that there are cells with zero gradient values (generally the case for the first iteration, regardless) then you could add a conditional statement to avoid the error:

Code:
if (C_UDSI_G(c,t,0)[0] == 0.)
{
    // gradient is zero, don't try to divide by zero!
}
else
{
    // gradient is nonzero, now you can divide
}
`e` is offline   Reply With Quote

Old   January 21, 2016, 19:53
Default
  #5
Member
 
cfd^2
Join Date: Mar 2013
Posts: 31
Rep Power: 13
cfd^2 is on a distinguished road
Quote:
Originally Posted by `e` View Post
Then it's probably another line at fault (unless C_UDSI_G(c,t,0)[0] is returning zero in at least one of the cells; which might explain your error of "1.#inf"). Try only using that line within the UDF and add in a Message(); function to output the value of C_UDSI_G(c,t,0)[0] and 1./C_UDSI_G(c,t,0)[0]; to the command line. You may want to perform this debugging on a mesh with fewer cells to avoid excess messages being printed to the screen.
I got it! I was interpreting the UDF. I compiled it and it worked using you tip (./)! Thank you very much!
cfd^2 is offline   Reply With Quote

Reply

Tags
fluent, udf


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
ATTN ALL: SOLUTON TO UDF COMPILE PROBLEM Rizwan Fluent UDF and Scheme Programming 40 March 18, 2018 06:05
Problem with DPM simulation with particles injection and EXECUTE_AT_THE_END UDF. Ari Fluent UDF and Scheme Programming 4 May 31, 2016 08:51
udf loading problem santu Fluent UDF and Scheme Programming 1 May 22, 2015 15:47
Vaporization pressure UDF property problem? lehoanganh07 Fluent UDF and Scheme Programming 1 September 13, 2014 10:59
Problem with my udf july Fluent UDF and Scheme Programming 3 June 20, 2010 06:56


All times are GMT -4. The time now is 23:31.