CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   float or scalar for runTime.tinename() ?? (https://www.cfd-online.com/Forums/openfoam/84563-float-scalar-runtime-tinename.html)

Canesin February 2, 2011 13:26

float or scalar for runTime.tinename() ??
 
I had look around but I'm not finding a method to call to provide the time the simulation is on.. I wan't to make a change when time = changetime..


I have tried to do casting like:

float(runTime.timeName()) but it do not work.... I'm starting to believe I will have to implement the casting..

wyldckat February 2, 2011 14:12

Hi Fábio,

Type casting only works when the variables are similar, for example between pointers and between double/int/float and so on. To convert a string to float, you can use atof.

But I think that runTime.value() will get you the value already in scalar (float or double) format, without the need to convert the value.

Best regards,
Bruno

Canesin February 2, 2011 15:36

LOL ...

Thanks Bruno, I had looked at the doxygen but the method "value()" was not there, I believe it's because it is from inheritance..

wyldckat February 2, 2011 17:13

Quote:

Originally Posted by Canesin (Post 293335)
I had looked at the doxygen but the method "value()" was not there, I believe it's because it is from inheritance..

You should always check the fine print ;)
Quote:

Originally Posted by http://foam.sourceforge.net/docs/cpp/classFoam_1_1Time.php



All times are GMT -4. The time now is 00:46.