sampling::probes: Improved the output table format to be more consistent with logFiles

Columns are now fixed width, left justified and the column headings are on one
line.

Resolves bug-report https://bugs.openfoam.org/view.php?id=3378#c10866
This commit is contained in:
Henry Weller
2019-11-05 15:19:03 +00:00
parent c1820f19d3
commit 19c03e4dd0
2 changed files with 19 additions and 19 deletions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -239,35 +239,31 @@ Foam::label Foam::probes::prepare()
mkDir(probeDir);
OFstream* fPtr = new OFstream(probeDir/fieldName);
OFstream& fout = *fPtr;
OFstream& os = *fPtr;
if (debug)
{
Info<< "open probe stream: " << fout.name() << endl;
Info<< "open probe stream: " << os.name() << endl;
}
probeFilePtrs_.insert(fieldName, fPtr);
unsigned int w = IOstream::defaultPrecision() + 7;
const unsigned int w = IOstream::defaultPrecision() + 7;
os << setf(ios_base::left);
forAll(*this, probei)
{
fout<< "# Probe " << probei << ' ' << operator[](probei)
os<< "# Probe " << probei << ' ' << operator[](probei)
<< endl;
}
fout<< '#' << setw(IOstream::defaultPrecision() + 6)
<< "Probe";
os << setw(w) << "# Time";
forAll(*this, probei)
{
fout<< ' ' << setw(w) << probei;
os<< ' ' << setw(w) << probei;
}
fout<< endl;
fout<< '#' << setw(IOstream::defaultPrecision() + 6)
<< "Time" << endl;
os<< endl;
}
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -73,14 +73,16 @@ void Foam::probes::sampleAndWrite
if (Pstream::master())
{
unsigned int w = IOstream::defaultPrecision() + 7;
const unsigned int w = IOstream::defaultPrecision() + 7;
OFstream& os = *probeFilePtrs_[vField.name()];
os << setw(w) << vField.time().timeToUserTime(vField.time().value());
forAll(values, probei)
{
os << ' ' << setw(w) << values[probei];
OStringStream buf;
buf << values[probei];
os << ' ' << setw(w) << buf.str().c_str();
}
os << endl;
}
@ -97,14 +99,16 @@ void Foam::probes::sampleAndWrite
if (Pstream::master())
{
unsigned int w = IOstream::defaultPrecision() + 7;
const unsigned int w = IOstream::defaultPrecision() + 7;
OFstream& os = *probeFilePtrs_[sField.name()];
os << setw(w) << sField.time().timeToUserTime(sField.time().value());
os << sField.time().timeToUserTime(sField.time().value());
forAll(values, probei)
{
os << ' ' << setw(w) << values[probei];
OStringStream buf;
buf << values[probei];
os << ' ' << setw(w) << buf.str().c_str();
}
os << endl;
}