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

output stream file in scientific notation

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By Voulet

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 12, 2022, 01:15
Default output stream file in scientific notation
  #1
Member
 
Join Date: Jun 2019
Posts: 41
Rep Power: 6
Voulet is on a distinguished road
Hello. I didn't find any relevant post while googling this thus for future generation here is how to output some values in scientific notation. The key here is the following line :

mySuperStream.setf(ios_base::scientific, ios_base::floatfield);


Code:
// near your CreateField outside main loops
OFstream mySuperStream((string("Coucou")));
mySuperStream.precision(5);
mySuperStream.setf(ios_base::scientific, ios_base::floatfield);

mySuperStream   << "Time" << tab
                << "sumMatter" << tab
                << "Pthermique" << tab
                << "diff_pression"<< tab
                << "Joth"<< tab
                << endl;

// inside your loop
if (Pstream::master()) {
    mySuperStream <<    U.db().time().value() << tab
                            << sumMatter << tab
                            << Pthermique << tab
                            << diff_pression << tab
                            << Joth << tab
                            << endl;
 }

Happy foaming.
Kummi likes this.
__________________
« Debugging is what CFD is about. 5 minutes to modify your code, 5 months to find why it does not work anymore. »
Voulet is offline   Reply With Quote

Reply


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
OpenFoam "Permission denied" and "command not found" problems. iyidaniel@yahoo.co.uk OpenFOAM Running, Solving & CFD 11 January 2, 2018 06:47
[foam-extend.org] problem when installing foam-extend-1.6 Thomas pan OpenFOAM Installation 7 September 9, 2015 21:53
[swak4Foam] Problem installing swak_2.x for OpenFoam-2.4.0 towanda OpenFOAM Community Contributions 6 September 5, 2015 21:03
SparceImage v1.7.x Issue on MAC OS X rcarmi OpenFOAM Installation 4 August 14, 2014 06:42
DecomposePar links against liblamso0 with OpenMPI jens_klostermann OpenFOAM Bugs 11 June 28, 2007 17:51


All times are GMT -4. The time now is 01:47.