CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   FLUENT (http://www.cfd-online.com/Forums/fluent/)
-   -   Random Function in UDF per DPM (http://www.cfd-online.com/Forums/fluent/41011-random-function-udf-per-dpm.html)

adriano May 17, 2006 04:08

Random Function in UDF per DPM
 
Hi users, I need to generate an array of random part_id #. I tried to use c function 'rand()%scalefactor' and 'srand(time(NULL))' but I need number between 1:10,000,000 and rand() returns numbers bw 0:37,***. How doing? THANKS a lot! Adriano

HS May 18, 2006 06:19

Re: Random Function in UDF per DPM
 
If rand() returns real numbers then you would just have to boost them to the size you want, i.e.

your_random_number = rand() * (10000000.0 / 37.0);

/Henrik


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