|
[Sponsors] |
Data awfully saved with IOStream when using scalar |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
December 22, 2019, 08:32 |
Data awfully saved with IOStream when using scalar [SOLVED]
|
#1 |
New Member
Join Date: Sep 2019
Posts: 18
Rep Power: 7 |
Hi all,
I am trying to save some data from some variables that I am working out every time step with: Code:
energyFile << runTime.timeName() << "\t\t" << Em.weightedAverage(mesh.V()).value() << "\t\t" //Em is volScalarField << Ek.weightedAverage(mesh.V()).value() << "\t\t"//Ek is volScalarField << Et.weightedAverage(mesh.V()).value() << "\t\t"//Et is volScalarField << max(mag(J)).value() << "\t\t"//J is volVectorField << a.weightedAverage(mesh.V()).value()+b.weightedAverage(mesh.V()).value() << "\t\t" //a & b are volScalarField << pR << "\t\t" ////pR is scalar << endl; Code:
0.01 0.271417 0.000693869 0.272111 3.13241 0.0263245 5.1935 00.02 0.271321 0.000464667 0.271786 3.44374 0.0238673 4.8994 00.03 0.271221 0.00033977 0.271561 3.48565 0.0224566 5.15044 000.04 0.271117 0.000268453 0.271386 3.47999 0.021592 4.63075 000.05 0.271011 0.000229149 0.27124 3.41899 0.0210318 4.6224100.06 0.270903 0.000210638 0.271114 3.29874 0.0206501 4.8617 000.07 0.270795 0.000206592 0.271001 3.14365 0.0203772 4.84191 00.08 0.270686 0.000213266 0.270899 2.99081 0.0201733 4.81369 However, if i remove the scalar "pR" Code:
energyFile << runTime.timeName() << "\t\t" << Em.weightedAverage(mesh.V()).value() << "\t\t" //Em is volScalarField << Ek.weightedAverage(mesh.V()).value() << "\t\t"//Ek is volScalarField << Et.weightedAverage(mesh.V()).value() << "\t\t"//Et is volScalarField << max(mag(J)).value() << "\t\t"//J is volVectorField << a.weightedAverage(mesh.V()).value()+b.weightedAverage(mesh.V()).value() << "\t\t" //a & b are volScalarField //<< pR << "\t\t" ////pR is scalar << endl; Code:
0.01 0.271417 0.000693869 0.272111 3.13241 0.0263245 0.02 0.271321 0.000464667 0.271786 3.44374 0.0238673 0.03 0.271221 0.00033977 0.271561 3.48565 0.0224566 0.04 0.271117 0.000268453 0.271386 3.47999 0.021592 0.05 0.271011 0.000229149 0.27124 3.41899 0.0210318 0.06 0.270903 0.000210638 0.271114 3.29874 0.0206501 0.07 0.270795 0.000206592 0.271001 3.14365 0.0203772 0.08 0.270686 0.000213266 0.270899 2.99081 0.0201733 Does anyone known what is happening and how can I save a scalar? Regards. Last edited by rucky96; January 14, 2020 at 21:29. |
|
December 27, 2019, 14:52 |
|
#2 |
New Member
Dan
Join Date: Nov 2013
Posts: 27
Rep Power: 13 |
Are you having the same problem running the case in parallel and in serial?
In case you run in parallel you should use: Code:
if(Pstream::master()) and the printing commands within { }. Hope this helps |
|
December 30, 2019, 19:28 |
|
#3 |
New Member
Join Date: Sep 2019
Posts: 18
Rep Power: 7 |
Hi Danubi, thanks for answering.
I tried the following: Code:
if(Pstream::master()) { energyFile << runTime.timeName() << "\t\t" << Em.weightedAverage(mesh.V()).value() << "\t\t" << Ek.weightedAverage(mesh.V()).value() << "\t\t" << Et.weightedAverage(mesh.V()).value() << "\t\t" << max(mag(J)).value() << "\t\t" << a.weightedAverage(mesh.V()).value()+b.weightedAverage(mesh.V()).value() << "\t\t" << pR << "\t\t" << endl; } PS: The problem also disappears when I run it in serial |
|
January 14, 2020, 21:28 |
|
#4 |
New Member
Join Date: Sep 2019
Posts: 18
Rep Power: 7 |
In the end I have solved it, I took the idea of Danubi and continued testing combinations until it has come out:
Code:
energyFile << runTime.timeName() << "\t\t" << Em.weightedAverage(mesh.V()).value() << "\t\t" << Ek.weightedAverage(mesh.V()).value() << "\t\t" << Et.weightedAverage(mesh.V()).value() << "\t\t" << max(mag(J)).value() << "\t\t" << a.weightedAverage(mesh.V()).value()+b.weightedAverage(mesh.V()).value() << "\t\t"; if(Pstream::master()){energyFile << pR << "\t\t" << endl;} |
|
Tags |
iostream |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
ERROR: request for volScalarField thermo:psi from objectRegistry region0 | AAbouali | OpenFOAM Running, Solving & CFD | 1 | September 19, 2020 05:53 |
Non uniform temperature gradient | Nabeel Abed | OpenFOAM Programming & Development | 2 | August 20, 2019 09:10 |
UDF value to large for defined data type | Anna73 | Fluent UDF and Scheme Programming | 9 | September 30, 2018 23:18 |
Run OpenFoam in 2 nodes of a cluster | WhiteW | OpenFOAM Running, Solving & CFD | 16 | December 20, 2016 01:51 |
studying a valve case | mina.basta | OpenFOAM | 33 | August 30, 2013 05:46 |