CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Siemens (https://www.cfd-online.com/Forums/siemens/)
-   -   accessing current time (https://www.cfd-online.com/Forums/siemens/77565-accessing-current-time.html)

Henry Arrigo June 27, 2010 12:13

accessing current time
 
Dear all.
hi
working with star-CCM+ i want to write a field function which uses current physical time. how can I access current physical time?

thanx alot

svenne August 4, 2010 07:14

It is possible to access time using java or usercode (C, FORTRAN) The documentation how to compile and bind user code is actually pretty good. Read it and follow the instructions mentioned there.

The following files should do what you want, except that they are only updated while iterating. (Havent found a way to force an update yet)

Code:

//filename =  uclib.c
#include "uclib.h"
void physicaltime(Real*, int, Real*);
void
uclib()
{
ucfunc(physicaltime, "VectorFieldFunction", "physicaltime");
ucarg(physicaltime, "Cell", "Temperature", sizeof (int));
}

Code:

//filename = physicaltime.c
#include "uclib.h"
#include <stdlib.h>
void physicaltime(Real (*result)[3], int size, Real *T) {
 
int i;
unsigned int t;
int seconds, minutes, hours;
t = time(NULL);
 
seconds = t % 60;
minutes = (t % 3600 - seconds) / 60;
hours = (t % 86400 - 60 * minutes - seconds) / 3600;
for (i = 0; i != size; ++i) {
result[i][0] = hours;
result[i][1] = minutes;
result[i][2] = seconds;
}
}

this gives you access to a vector field function called user physicaltime [hrs, min, sec].

Henry Arrigo August 4, 2010 13:54

thanks Svenne. it was very helpful


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