CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM Programming & Development

Info(messageStream) - Specifying the Precision

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   August 4, 2013, 08:47
Default Info(messageStream) - Specifying the Precision
  #1
Member
 
Join Date: Aug 2012
Posts: 74
Rep Power: 5
HakikiCanakkaleli is on a distinguished road
Hi,

== 1 ==

Is it possible to specify the precision of an output number which is, say, a variable type of doubleScalar with Info in OpenFOAM?

== 2 ==
For example:

Code:
doubleScalar variable = 2.0000000001;
Info << "variable: " << variable << endl;
== 3 ==
In another thread, the following was given once:

Quote:
Originally Posted by akidess View Post
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;
Try it.
However, it does not work as confirmed by another reader as well.

== 4 ==

Many thanks for any help.
HakikiCanakkaleli is offline   Reply With Quote

Old   August 14, 2013, 14:25
Default
  #2
Member
 
Join Date: Aug 2012
Posts: 74
Rep Power: 5
HakikiCanakkaleli is on a distinguished road
The answer that I found is that:

Code:
#include "IOmanip.H"

...

Info << setprecision(10);
Info << " i " << xx << endl;

...
Simply, identical to that of C++ standard, had forgotten the header file.
HakikiCanakkaleli is offline   Reply With Quote

Old   August 14, 2013, 14:36
Default
  #3
Senior Member
 
mkraposhin's Avatar
 
Matvej Kraposhin
Join Date: Mar 2009
Location: Moscow, Russian Federation
Posts: 197
Rep Power: 9
mkraposhin is on a distinguished road
google: format with cout
mkraposhin is offline   Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[ANSYS Meshing] ICEM output precision papis ANSYS Meshing & Geometry 4 July 9, 2013 09:54
Double precision case open in single precision solver. cinwendy FLUENT 6 March 27, 2013 04:19
Switch from single precision to double precision kk81 OpenFOAM Bugs 0 March 11, 2010 07:14
Number of elements x double precision matheusguzella ANSYS Meshing & Geometry 2 October 7, 2009 10:15
what's wrong about my code for 2d burgers equation morxio Main CFD Forum 3 April 27, 2007 10:38


All times are GMT -4. The time now is 19:18.