|
[Sponsors] |
what is the Best way for formating the output numbers |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
September 20, 2011, 16:24 |
what is the Best way for formating the output numbers
|
#1 |
Senior Member
Daniel WEI (老魏)
Join Date: Mar 2009
Location: Beijing, China
Posts: 689
Blog Entries: 9
Rep Power: 21 |
Good afternoon,
Is it possible to use "Info" to output the numbers in a certain format, like printf does, for example, 7.3f, something like that? Thanks
__________________
~ Daniel WEI ------------- Boeing Research & Technology - China Beijing, China |
|
September 21, 2011, 05:13 |
|
#2 |
Senior Member
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 22 |
Is the writePrecision option in controlDict an option?
I think the alternative is either digging really deep in the code (maybe the precision member of IOstream can help you?) or just cheat by using printf anyhow |
|
September 21, 2011, 11:26 |
|
#3 | ||
Senior Member
Daniel WEI (老魏)
Join Date: Mar 2009
Location: Beijing, China
Posts: 689
Blog Entries: 9
Rep Power: 21 |
No, it's not relevant.
Quote:
Quote:
__________________
~ Daniel WEI ------------- Boeing Research & Technology - China Beijing, China |
|||
September 22, 2011, 04:16 |
|
#4 |
Senior Member
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 30 |
printf is pure C, it's C++ descendant is cout. Assuming Info is built upon cout, you can do:
Code:
Info << setw(7); Info.precision(3); Info << fixed << a << '\t' << b << '\t' << c << endl; |
|
September 26, 2011, 09:17 |
|
#5 | |
Senior Member
Arjun
Join Date: Mar 2009
Location: Nurenberg, Germany
Posts: 1,285
Rep Power: 34 |
Quote:
i use %2.10le for my DNS code. Creates big file but never had problems with precision. PS: Sorry if this is not what you asked. |
||
November 29, 2011, 14:19 |
|
#6 |
Senior Member
Daniel WEI (老魏)
Join Date: Mar 2009
Location: Beijing, China
Posts: 689
Blog Entries: 9
Rep Power: 21 |
It doesn't work, I don't think the Info(messageStream) is built on cout, I found the printf is still the best option we have.
__________________
~ Daniel WEI ------------- Boeing Research & Technology - China Beijing, China |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
lift and drag on ship superstructures | vaina74 | OpenFOAM Running, Solving & CFD | 3 | June 8, 2010 13:30 |
Probe output produce merged numbers | olesen | OpenFOAM Bugs | 3 | October 15, 2008 16:51 |
[Other] Output Format of MetaMesh | t42 | OpenFOAM Meshing & Mesh Conversion | 0 | August 3, 2007 05:28 |
IcoFoam parallel woes | msrinath80 | OpenFOAM Running, Solving & CFD | 9 | July 22, 2007 03:58 |
Could anybody help me see this error and give help | liugx212 | OpenFOAM Running, Solving & CFD | 3 | January 4, 2006 19:07 |