From 18ae63051bcd3aa2047a9cf628d2d56074c67eaa Mon Sep 17 00:00:00 2001 From: andy Date: Mon, 25 Nov 2013 10:51:44 +0000 Subject: [PATCH] ENH: functionObjectFile - added standardised function for writing values --- .../functionObjectFile/functionObjectFile.C | 6 ++++++ .../functionObjectFile/functionObjectFile.H | 20 ++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/OpenFOAM/db/functionObjects/functionObjectFile/functionObjectFile.C b/src/OpenFOAM/db/functionObjects/functionObjectFile/functionObjectFile.C index b711b2d17f..f441f125a6 100644 --- a/src/OpenFOAM/db/functionObjects/functionObjectFile/functionObjectFile.C +++ b/src/OpenFOAM/db/functionObjects/functionObjectFile/functionObjectFile.C @@ -147,6 +147,12 @@ void Foam::functionObjectFile::resetName(const word& name) } +Foam::Omanip Foam::functionObjectFile::valueWidth(const label offset) const +{ + return setw(IOstream::defaultPrecision() + 7 + offset); +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::functionObjectFile::functionObjectFile diff --git a/src/OpenFOAM/db/functionObjects/functionObjectFile/functionObjectFile.H b/src/OpenFOAM/db/functionObjects/functionObjectFile/functionObjectFile.H index f4c0ab1178..54658bdba9 100644 --- a/src/OpenFOAM/db/functionObjects/functionObjectFile/functionObjectFile.H +++ b/src/OpenFOAM/db/functionObjects/functionObjectFile/functionObjectFile.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -43,6 +43,7 @@ SourceFiles #include "OFstream.H" #include "PtrList.H" #include "HashSet.H" +#include "IOmanip.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -98,6 +99,9 @@ protected: //- Reset the list of names to a single name entry virtual void resetName(const word& name); + //- Return the value width when writing to stream with optional offset + virtual Omanip valueWidth(const label offset = 0) const; + //- Disallow default bitwise copy construct functionObjectFile(const functionObjectFile&); @@ -149,6 +153,14 @@ public: //- Return file 'i' OFstream& file(const label i); + + //- Write a formatted value to stream + template + const char* writeValue + ( + const Type& value, + const label offset = 0 + ) const; }; @@ -158,6 +170,12 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +#ifdef NoRepository + #include "functionObjectFileTemplates.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + #endif // ************************************************************************* //