CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Running, Solving & CFD (
-   -   how to get current time as scalar? (

louisgag May 9, 2009 22:08

how to get current time as scalar?

I am trying to get something like sin(time().timeName()) but timeName is of type word and I couldn't find a scalar equivalent..

Anmyone has a simple solution to this?



su_junwei May 10, 2009 07:50

Hi Louis

just test

//read from runTime
scalar t=runTime.value();

//read from a field ,for example U
scalar t=U.mesh().time().value() ;

//read from mesh
scalar t=mesh.time().value();


louisgag May 10, 2009 10:01

Hi Junwei,

thanks for the help. I got it working with time().value()


All times are GMT -4. The time now is 11:49.