mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: functionObjects - updated writing to file
This commit is contained in:
@ -31,9 +31,18 @@ License
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
const Foam::word Foam::functionObjectFile::outputPrefix = "postProcessing";
|
||||
Foam::label Foam::functionObjectFile::addChars = 7;
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::functionObjectFile::initStream(Ostream& os) const
|
||||
{
|
||||
os.setf(ios_base::scientific, ios_base::floatfield);
|
||||
// os.precision(IOstream::defaultPrecision());
|
||||
os.width(charWidth());
|
||||
}
|
||||
|
||||
|
||||
Foam::fileName Foam::functionObjectFile::baseFileDir() const
|
||||
{
|
||||
fileName baseDir = obr_.time().path();
|
||||
@ -96,6 +105,8 @@ void Foam::functionObjectFile::createFiles()
|
||||
|
||||
filePtrs_.set(i, new OFstream(outputDir/(fName + ".dat")));
|
||||
|
||||
initStream(filePtrs_[i]);
|
||||
|
||||
writeFileHeader(i);
|
||||
|
||||
i++;
|
||||
@ -149,7 +160,7 @@ void Foam::functionObjectFile::resetName(const word& name)
|
||||
|
||||
Foam::Omanip<int> Foam::functionObjectFile::valueWidth(const label offset) const
|
||||
{
|
||||
return setw(IOstream::defaultPrecision() + 7 + offset);
|
||||
return setw(IOstream::defaultPrecision() + addChars + offset);
|
||||
}
|
||||
|
||||
|
||||
@ -295,4 +306,42 @@ Foam::OFstream& Foam::functionObjectFile::file(const label i)
|
||||
}
|
||||
|
||||
|
||||
Foam::label Foam::functionObjectFile::charWidth() const
|
||||
{
|
||||
return IOstream::defaultPrecision() + addChars;
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjectFile::writeCommented
|
||||
(
|
||||
Ostream& os,
|
||||
const string& str
|
||||
) const
|
||||
{
|
||||
os << setw(1) << "#" << setw(1) << ' '
|
||||
<< setw(charWidth() - 2) << str.c_str();
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjectFile::writeTabbed
|
||||
(
|
||||
Ostream& os,
|
||||
const string& str
|
||||
) const
|
||||
{
|
||||
os << tab << setw(charWidth()) << str.c_str();
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjectFile::writeHeader
|
||||
(
|
||||
Ostream& os,
|
||||
const string& str
|
||||
) const
|
||||
{
|
||||
os << setw(1) << "#" << setw(1) << ' '
|
||||
<< setf(ios_base::left) << setw(charWidth() - 2) << str.c_str() << nl;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
Reference in New Issue
Block a user