CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   read wall-time, cpu-time etc from udf (https://www.cfd-online.com/Forums/fluent-udf/205751-read-wall-time-cpu-time-etc-udf.html)

denis.sanga@hotmail.it August 24, 2018 11:20

read wall-time, cpu-time etc from udf
 
Goodmorning,

I would use the output parameters as "time/iter" and variables obtained with /parallel/timer/usage command as "Average wall-clock time per iteration", "Total-clock time" etc in my UDF.

Do someone know how to import that parameters in UDF?

Thank you very much
Best Regards
DS

gernzn September 28, 2018 06:31

Hi Denis!

What I did is defining a UNIX-timestamp as an User Defined Report Definition. Put following code in a ".c" file and compile it in your fluent (make sure, you have VisualStudio installed). You can then make a User Defined Report Definition with the function "getSystemTime" and write a UNIX time stamp for every saved data-set in an output file. When you copy the output file in a Excel-Sheet and format the column with the timestamp like "DD.MM.YYYY hh:mm:ss" you get time and can calculate the time-difference between your iterations. If you don't get your time, you might be in another timezone. In that case, change the code like follows: timestamp = (now + <hoursOfTimezoneDifference> * 3600) / 86400.0 + 25569.0;

Hope that did help.

#include <udf.h>
#include<time.h>

DEFINE_REPORT_DEFINITION_FN(getSystemTime)
{
time_t now;
double timestamp;

time(&now);

timestamp = now / 86400.0 + 25569.0;

return timestamp;
}


All times are GMT -4. The time now is 03:30.