|
[Sponsors] |
How to keep syntax (decimal places) when writing from array to .txt-file? |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
May 29, 2017, 02:53 |
How to keep syntax (decimal places) when writing from array to .txt-file?
|
#1 |
New Member
Sarah
Join Date: May 2017
Posts: 8
Rep Power: 9 |
Hello everybody,
I wrote a UDF where I want to write the temperature values from an Array into a .txt-file: DEFINE_ON_DEMAND(export__temp) { cell_t c; Domain *d = Get_Domain(1); FILE *temp__piece; real temp1; Thread *c_thread= Lookup_Thread(d,3); temp__piece=fopen("temp__piece.txt","w"); begin_c_loop(c, c_thread) { temp1 = C_T(c,c_thread); fprintf(temp__piece,"%g \n",temp1); } end_c_loop(c, c_thread) fclose(temp__piece); } The UDF works - but the temperatures do have between 0-3 decimal places. The textfile will be exported and used for Ansys Classic further. The problem is now: If a temperature has 0 decimal places, Ansys Classic calculates wrong (Temperature that is used then is just 1/100 as high as in the .txt-file). Therefore, I would like Fluent always to use the same number of decimal places (3). Is that possible and can someone explain me, how this might work? Kind regards, Sarah |
|
May 29, 2017, 05:01 |
|
#2 |
New Member
Alexander
Join Date: Dec 2016
Posts: 24
Rep Power: 9 |
use printf format identiffiers
%.3f |
|
May 29, 2017, 08:48 |
|
#3 |
New Member
Sarah
Join Date: May 2017
Posts: 8
Rep Power: 9 |
It worked out!
Thank you so much |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[swak4Foam] funkyDoCalc with OF2.3 massflow | NiFl | OpenFOAM Community Contributions | 14 | November 25, 2020 04:30 |
[foam-extend.org] problem when installing foam-extend-1.6 | Thomas pan | OpenFOAM Installation | 7 | September 9, 2015 22:53 |
friction forces icoFoam | ofslcm | OpenFOAM | 3 | April 7, 2012 11:57 |
DecomposePar links against liblamso0 with OpenMPI | jens_klostermann | OpenFOAM Bugs | 11 | June 28, 2007 18:51 |
error while compiling the USER Sub routine | CFD user | CFX | 3 | November 25, 2002 16:16 |