|
[Sponsors] |
February 21, 2011, 04:59 |
convert fileName to double
|
#1 |
Senior Member
Fabian Braennstroem
Join Date: Mar 2009
Posts: 407
Rep Power: 19 |
Hi,
does anyone know, how I can convert a fileName (which is basically just the time step for this case) to double!? Thanks in advance! Fabian |
|
February 21, 2011, 05:40 |
|
#3 |
Senior Member
Fabian Braennstroem
Join Date: Mar 2009
Posts: 407
Rep Power: 19 |
Hello Laurence,
thanks for the hint, though I get for this command: 68 char *url="1"; 69 strcpy(url, timeDir.c_str()); 70 double timeDump = atof(url); this warning: sampledSurface/writers/foamFileVars/foamFileVars.C:68: warning: deprecated conversion from string constant to ‘char*’ sampledSurface/writers/foamFileVars/foamFileVarsWriters.C:41: instantiated from here sampledSurface/writers/foamFileVars/foamFileVars.C:70: warning: unused variable ‘timeDump’ sampledSurface/writers/foamFileVars/foamFileVars.C: In member function ‘void Foam::foamFileVars<Type>::write(const Foam::fileName&, const Foam::fileName&, const Foam::fileName&, const Foam:ointField&, const Foam::faceList&, const Foam::fileName&, const Foam::Field<Type>&, bool) const [with Type = Foam::SymmTensor<double>]’: sampledSurface/writers/foamFileVars/foamFileVarsWriters.C:41: instantiated from here sampledSurface/writers/foamFileVars/foamFileVars.C:68: warning: deprecated conversion from string constant to ‘char*’ sampledSurface/writers/foamFileVars/foamFileVarsWriters.C:41: instantiated from here sampledSurface/writers/foamFileVars/foamFileVars.C:70: warning: unused variable ‘timeDump’ sampledSurface/writers/foamFileVars/foamFileVars.C: In member function ‘void Foam::foamFileVars<Type>::write(const Foam::fileName&, const Foam::fileName&, const Foam::fileName&, const Foam:ointField&, const Foam::faceList&, const Foam::fileName&, const Foam::Field<Type>&, bool) const [with Type = Foam::SphericalTensor<double>]’: sampledSurface/writers/foamFileVars/foamFileVarsWriters.C:41: instantiated from here sampledSurface/writers/foamFileVars/foamFileVars.C:68: warning: deprecated conversion from string constant to ‘char*’ sampledSurface/writers/foamFileVars/foamFileVarsWriters.C:41: instantiated from here sampledSurface/writers/foamFileVars/foamFileVars.C:70: warning: unused variable ‘timeDump’ sampledSurface/writers/foamFileVars/foamFileVars.C: In member function ‘void Foam::foamFileVars<Type>::write(const Foam::fileName&, const Foam::fileName&, const Foam::fileName&, const Foam:ointField&, const Foam::faceList&, const Foam::fileName&, const Foam::Field<Type>&, bool) const [with Type = Foam::Vector<double>]’: sampledSurface/writers/foamFileVars/foamFileVarsWriters.C:41: instantiated from here sampledSurface/writers/foamFileVars/foamFileVars.C:68: warning: deprecated conversion from string constant to ‘char*’ sampledSurface/writers/foamFileVars/foamFileVarsWriters.C:41: instantiated from here sampledSurface/writers/foamFileVars/foamFileVars.C:70: warning: unused variable ‘timeDump’ sampledSurface/writers/foamFileVars/foamFileVars.C: In member function ‘void Foam::foamFileVars<Type>::write(const Foam::fileName&, const Foam::fileName&, const Foam::fileName&, const Foam:ointField&, const Foam::faceList&, const Foam::fileName&, const Foam::Field<Type>&, bool) const [with Type = double]’: sampledSurface/writers/foamFileVars/foamFileVarsWriters.C:41: instantiated from here sampledSurface/writers/foamFileVars/foamFileVars.C:68: warning: deprecated conversion from string constant to ‘char*’ Probably there is a better way...!? Thanks! Fabian |
|
February 21, 2011, 05:50 |
|
#4 |
Senior Member
Laurence R. McGlashan
Join Date: Mar 2009
Posts: 370
Rep Power: 23 |
I'll let someone else find a more 'foam' solution, but you can just do this, then you'll have no warnings:
double timeDump = atof(timeDir.c_str());
__________________
Laurence R. McGlashan :: Website |
|
February 21, 2011, 07:58 |
|
#5 |
Senior Member
Fabian Braennstroem
Join Date: Mar 2009
Posts: 407
Rep Power: 19 |
....Thanks!
|
|
February 21, 2011, 08:29 |
|
#6 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,974
Blog Entries: 45
Rep Power: 128 |
Greetings to all!
A similar question was asked not long ago, including the solution: http://www.cfd-online.com/Forums/ope...-tinename.html Basically, you can use runTime.value() to get the value of the latest time step This is valid only for objects of type Foam::Time, which should be the situation you're in. Otherwise, probably atof is the quickest solution. Best regards, Bruno
__________________
|
|
February 21, 2011, 08:59 |
|
#7 |
Senior Member
Fabian Braennstroem
Join Date: Mar 2009
Posts: 407
Rep Power: 19 |
Hi Bruno,
thanks for the info... I tried to get the current time step in a foamFile-functionObject, where I did have the fileName timedir available, so I thought, it would be easier to use this. Regards! Fabian |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Continuing User Defined Real Gas Model issues | aeroman | FLUENT | 6 | April 8, 2016 04:34 |
New densitybased solver AeroFoam | giulio_romanelli | OpenFOAM Running, Solving & CFD | 48 | January 15, 2016 09:20 |
Parallel User Defined Real Gas Model | aeroman | FLUENT | 4 | July 1, 2015 07:09 |
Missing math.h header | Travis | FLUENT | 4 | January 15, 2009 12:48 |
REAL GAS UDF | brian | FLUENT | 6 | September 11, 2006 09:23 |