|
[Sponsors] |
January 21, 2016, 18:06 |
Problem in UDF
|
#1 |
Member
cfd^2
Join Date: Mar 2013
Posts: 31
Rep Power: 13 |
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? |
|
January 21, 2016, 18:46 |
|
#2 |
Senior Member
Join Date: Mar 2015
Posts: 892
Rep Power: 18 |
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]; |
|
January 21, 2016, 19:26 |
|
#3 | |
Member
cfd^2
Join Date: Mar 2013
Posts: 31
Rep Power: 13 |
Quote:
Thank you. But didn't work... Any other tip? |
||
January 21, 2016, 20:50 |
|
#4 |
Senior Member
Join Date: Mar 2015
Posts: 892
Rep Power: 18 |
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 } |
|
January 21, 2016, 20:53 |
|
#5 | |
Member
cfd^2
Join Date: Mar 2013
Posts: 31
Rep Power: 13 |
Quote:
|
||
Tags |
fluent, udf |
|
|
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 07:05 |
Problem with DPM simulation with particles injection and EXECUTE_AT_THE_END UDF. | Ari | Fluent UDF and Scheme Programming | 4 | May 31, 2016 09:51 |
udf loading problem | santu | Fluent UDF and Scheme Programming | 1 | May 22, 2015 16:47 |
Vaporization pressure UDF property problem? | lehoanganh07 | Fluent UDF and Scheme Programming | 1 | September 13, 2014 11:59 |
Problem with my udf | july | Fluent UDF and Scheme Programming | 3 | June 20, 2010 07:56 |