Problem in UDF
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? |
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]; |
Quote:
Thank you. But didn't work... Any other tip? |
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.) |
Quote:
|
All times are GMT -4. The time now is 01:33. |