OFstream for parallel processing
Hi everyone!
I wrote a code in which several useful numbers and calculated values are written to one single file during runtime. The file is constructed like this: fileName heatData(runTime.path()/"postProcessing"); OFstream heatFile("heatData"); In the solver code, the following lines are included in order to write the average temperature at the wall, the average Nusselt number, the heat flux etc. to the "heatData" file. heatFile<< runTime.timeName() << tab << average(Twall.boundaryField()[wallPatch]) << tab << Tbulk.value() << tab << gradTwallAv.value() << tab << heatFlux.value() <<tab << gamma.value() << tab << average(nusseltNumber.boundaryField()[wallPatch]) << ";" << endl; heatFile.flush(); This works perfectly when I work on 1 processor. All values are written to the "heatData"-file in separate columns, just as I want. However, when I run my case in parallel on different processors (using decomposePar), the "heatData"-file looks totally useless. Data is written randomly, line breaks are randomly added and zeros are outputted instead of the real values. Can anyone explain what's going on here? Or give me some help? |
Hi Laurien,
Yes, it is basically, because all of your processors try to write the information to the same file. Since not all of the processors have faces on all patches, this probably explains the zeros. The random input of values will be due to the fact that the processors are not synchronised all of the time. Let me try to sketch something, which should probably (not compiled): IN CONSTRUCTOR: Code:
autoPtr<OFstream> file_; Code:
// Get reference to the boundary fields Kind regards, Niels |
You might also want to use a small function to get the output directory:
Code:
const fileName pollutant::getOutputDir() const Cheers, L |
Hey FOAMers,
At the end of my parallel solver, i filled a vectorField with some values and i'd like to print them into a file : Code:
Ub= ... ; If i don't use 'Pstream::master()' , simulation keeps going without any problem. Tnx in advance for any idea about the reason. |
Quote:
Greetings, Max |
Has anyone managed to figure out what the problem is? Even I'm stuck with the same problem.
Best, Scram_1 |
All times are GMT -4. The time now is 17:24. |