diff --git a/src/sampling/probes/probes.C b/src/sampling/probes/probes.C index 071e6cd303..b4b8e5e95c 100644 --- a/src/sampling/probes/probes.C +++ b/src/sampling/probes/probes.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2015-2022 OpenCFD Ltd. + Copyright (C) 2015-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -105,6 +105,7 @@ void Foam::probes::createProbeFiles(const wordList& fieldNames) DebugInfo<< "open probe stream: " << os.name() << endl; const unsigned int width(IOstream::defaultPrecision() + 7); + os << setf(ios_base::left); forAll(*this, probei) { @@ -139,8 +140,7 @@ void Foam::probes::createProbeFiles(const wordList& fieldNames) os << nl; } - os << '#' << setw(IOstream::defaultPrecision() + 6) - << "Probe"; + os << setw(width) << "# Time"; forAll(*this, probei) { @@ -149,10 +149,7 @@ void Foam::probes::createProbeFiles(const wordList& fieldNames) os << ' ' << setw(width) << probei; } } - os << nl; - - os << '#' << setw(IOstream::defaultPrecision() + 6) - << "Time" << endl; + os << endl; } } } diff --git a/src/sampling/probes/probesTemplates.C b/src/sampling/probes/probesTemplates.C index f13f10b0a1..06cd892287 100644 --- a/src/sampling/probes/probesTemplates.C +++ b/src/sampling/probes/probesTemplates.C @@ -31,6 +31,7 @@ License #include "surfaceFields.H" #include "IOmanip.H" #include "interpolation.H" +#include "SpanStream.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -137,11 +138,15 @@ void Foam::probes::writeValues os << setw(width) << timeValue; + OCharStream buf; + forAll(values, probei) { if (includeOutOfBounds_ || processor_[probei] != -1) { - os << ' ' << setw(width) << values[probei]; + buf.rewind(); + buf << values[probei]; + os << ' ' << setw(width) << buf.str().data(); } } os << endl;