|
[Sponsors] |
![]() |
![]() |
#1 |
New Member
mehran
Join Date: Jul 2016
Posts: 5
Rep Power: 10 ![]() |
Dear Foamers,
I want to write output of a scalar in a .txt file during runTime. all the things are ok and the log file shows correct answer. but in the text file the scalar over writes on its old time value. can anyone help me to write output of this scalar (yy in this code) and runTime in two separate columns in each time step in the .txt file? here is the code: GRBFoam.C |
|
![]() |
![]() |
![]() |
![]() |
#2 |
Senior Member
khedar
Join Date: Oct 2016
Posts: 111
Rep Power: 9 ![]() |
You should open the file in append mode to not over write the values. Instead of
Code:
std::ofstream file("results.txt"); file << runTime.timeName() << " " << yy << std::endl << "\n"; file << nl << endl; file.close(); try this Code:
std::ofstream file; file.open ("results.txt", std::ofstream::out | std::ofstream::app); file << runTime.timeName() << " " << yy << std::endl << "\n"; file << nl << endl; file.close(); http://www.cplusplus.com/reference/f...ofstream/open/ |
|
![]() |
![]() |
![]() |
![]() |
#3 | |
New Member
mehran
Join Date: Jul 2016
Posts: 5
Rep Power: 10 ![]() |
Quote:
thank you so much Khedar. the file must be open before runTime. it helped me so much. |
||
![]() |
![]() |
![]() |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
courant number increases to rather large values | 6863523 | OpenFOAM Running, Solving & CFD | 22 | July 5, 2023 23:48 |
decomposePar problem: Cell 0contains face labels out of range | vaina74 | OpenFOAM Pre-Processing | 37 | July 20, 2020 05:38 |
Division by zero exception - loop over scalarField | Pat84 | OpenFOAM Programming & Development | 6 | February 18, 2017 05:57 |
[snappyHexMesh] crash sHM | H25E | OpenFOAM Meshing & Mesh Conversion | 11 | November 10, 2014 11:27 |
mixerVesselAMI2D's mass is not balancing | sharonyue | OpenFOAM Running, Solving & CFD | 6 | June 10, 2013 09:34 |