CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   UDF and random functions (https://www.cfd-online.com/Forums/fluent/37080-udf-random-functions.html)

gino briganti June 28, 2005 03:11

UDF and random functions
 
Can anybody tell us why Fluent does not interpret UDF with random functions calls (srand, rand)? The error message says that srand and rand are "undeclared variables"... thanks gino

----------------------------------- #include "udf.h" #define RAND_MAX 32767

DEFINE_PROFILE(temp_face,t,i) { real x[ND_ND]; face_t f;

float ran ;

srand( (unsigned) time (NULL) );

begin_f_loop(f,t)

{

ran = rand()/float(RAND_MAX) ;

F_CENTROID(x,f,t);

F_PROFILE(f,t,i) = 310.+2.*(ran-0.5);

} end_f_loop(f,t) void srand( unsigned int seed ); } -------------------------------------

Luca June 28, 2005 03:14

Re: UDF and random functions
 
Ciao Gino, try to compile your UDF. The problem should disappear.Luca

gino briganti June 28, 2005 04:55

Re: UDF and random functions
 
thanks so much Luca, you are right, now it works! ciao gino


All times are GMT -4. The time now is 15:57.