diff --git a/src/OpenFOAM/db/functionObjects/writeFile/writeFile.C b/src/OpenFOAM/db/functionObjects/writeFile/writeFile.C index bbe328fa62..0785b8f9b6 100644 --- a/src/OpenFOAM/db/functionObjects/writeFile/writeFile.C +++ b/src/OpenFOAM/db/functionObjects/writeFile/writeFile.C @@ -291,9 +291,22 @@ bool Foam::functionObjects::writeFile::writeToFile() const } +bool Foam::functionObjects::writeFile::canWriteToFile() const +{ + return (Pstream::master() && writeToFile_ && filePtr_); +} + + +bool Foam::functionObjects::writeFile::canResetFile() const +{ + return (Pstream::master() && writeToFile_ && !filePtr_); +} + + bool Foam::functionObjects::writeFile::canWriteHeader() const { - return writeToFile_ && (updateHeader_ || !writtenHeader_); + return + Pstream::master() && writeToFile_ && (updateHeader_ || !writtenHeader_); } diff --git a/src/OpenFOAM/db/functionObjects/writeFile/writeFile.H b/src/OpenFOAM/db/functionObjects/writeFile/writeFile.H index 3c776876a6..0fee04364f 100644 --- a/src/OpenFOAM/db/functionObjects/writeFile/writeFile.H +++ b/src/OpenFOAM/db/functionObjects/writeFile/writeFile.H @@ -31,23 +31,23 @@ Description Base class for writing single files from the function objects. Usage - \verbatim - + { - // Mandatory and other optional entries + // Inherited entries ... - // Optional (inherited) entries (runtime modifiable) - writePrecision 8; - writeToFile true; - useUserTime true; + // Optional entries + writePrecision ; + writeToFile ; + useUserTime ; + updateHeader ; } \endverbatim where the entries mean: \table - Property | Description | Type | Reqd | Dflt + Property | Description | Type | Reqd | Deflt writePrecision | Number of decimal points | int | no | \ writeToFile | Produce text file output? | bool | no | true useUserTime | Use user time (e.g. degrees)? | bool | no | true @@ -60,12 +60,9 @@ Note unaffected by these changes. Use the \c updateHeader flag to override the default behaviour. -See also - - Foam::functionObject - - Foam::functionObjects::logFiles - SourceFiles writeFile.C + writeFileTemplates.C \*---------------------------------------------------------------------------*/ @@ -91,7 +88,7 @@ class writeFile { protected: - // Protected data + // Protected Data //- Reference to the region objectRegistry const objectRegistry& fileObr_; @@ -244,6 +241,12 @@ public: //- Flag to allow writing to file virtual bool writeToFile() const; + //- Flag to allow writing to the file + virtual bool canWriteToFile() const; + + //- Flag to allow resetting the file + virtual bool canResetFile() const; + //- Flag to allow writing the header virtual bool canWriteHeader() const;