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

Info(messageStream) - Specifying the Precision

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

Like Tree1Likes
  • 1 Post By HakikiCanakkaleli

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 4, 2013, 09:47
Default Info(messageStream) - Specifying the Precision
  #1
Senior Member
 
Canakkale Dardanelspor
Join Date: Aug 2012
Posts: 135
Rep Power: 13
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, 15:25
Default
  #2
Senior Member
 
Canakkale Dardanelspor
Join Date: Aug 2012
Posts: 135
Rep Power: 13
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.
Pinqing Wang likes this.
HakikiCanakkaleli is offline   Reply With Quote

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

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
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 10: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 11:15
what's wrong about my code for 2d burgers equation morxio Main CFD Forum 3 April 27, 2007 11:38


All times are GMT -4. The time now is 04:22.