|
[Sponsors] |
October 4, 2022, 05:38 |
Output (scalar) data on secondary logfile
|
#1 |
New Member
Thomas
Join Date: Jul 2018
Posts: 16
Rep Power: 7 |
I'd like to output a scalar value (say for example runTime.value()) to a ASCII text file in real time during a simulation.
My current implementation is: in main solver: Code:
fileName outputFile(runTime.path()/"log.custom"); OFstream customLog(outputFile); dimensionedScalar t("t", dimTime, runTime.value()); Code:
customLog << "Time: " << t.value() << endl; On the other hand, if I redirect the standard output to a logfile (i.e. mySolverFoam > log.mySolverFoam), I am able to monitor in real time the output. Any idea how to get my second log to behave like the standard one? |
|
October 4, 2022, 13:03 |
|
#2 |
Senior Member
|
I wonder whether you need to use something equivalent to flush, see https://cplusplus.com/reference/ostream/flush-free/
|
|
October 5, 2022, 10:08 |
|
#3 | |
New Member
Thomas
Join Date: Jul 2018
Posts: 16
Rep Power: 7 |
Quote:
I am surprised flush is not implemented in "OFStream"... Update: After checking the source of OFstream, there is indeed a flush function that can be called as Code:
Info << "test" << nl << flush; Code:
Info << "test" << endl; Last edited by Roxxor91; October 6, 2022 at 05:32. |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Non uniform temperature gradient | Nabeel Abed | OpenFOAM Programming & Development | 2 | August 20, 2019 08:10 |
UDF value to large for defined data type | Anna73 | Fluent UDF and Scheme Programming | 9 | September 30, 2018 22:18 |
problem during mpi in server: expected Scalar, found on line 0 the word 'nan' | muth | OpenFOAM Running, Solving & CFD | 3 | August 27, 2018 04:18 |
Division by zero exception - loop over scalarField | Pat84 | OpenFOAM Programming & Development | 6 | February 18, 2017 05:57 |
Run OpenFoam in 2 nodes of a cluster | WhiteW | OpenFOAM Running, Solving & CFD | 16 | December 20, 2016 00:51 |