ENH: writeFile - return bool on successful read

This commit is contained in:
Andrew Heather
2016-11-29 14:45:45 +00:00
parent 89b1b64414
commit 86982f5eb7
2 changed files with 11 additions and 9 deletions

View File

@ -182,7 +182,7 @@ Foam::functionObjects::writeFile::~writeFile()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::functionObjects::writeFile::read(const dictionary& dict) bool Foam::functionObjects::writeFile::read(const dictionary& dict)
{ {
writePrecision_ = writePrecision_ =
dict.lookupOrDefault("writePrecision", IOstream::defaultPrecision()); dict.lookupOrDefault("writePrecision", IOstream::defaultPrecision());
@ -190,6 +190,8 @@ void Foam::functionObjects::writeFile::read(const dictionary& dict)
// Only write on master process // Only write on master process
writeToFile_ = dict.lookupOrDefault("writeToFile", true); writeToFile_ = dict.lookupOrDefault("writeToFile", true);
writeToFile_ = writeToFile_ && Pstream::master(); writeToFile_ = writeToFile_ && Pstream::master();
return true;
} }

View File

@ -148,28 +148,28 @@ public:
// Member Functions // Member Functions
//- Read //- Read
void read(const dictionary& dict); virtual bool read(const dictionary& dict);
//- Return access to the file (if only 1) //- Return access to the file (if only 1)
OFstream& file(); virtual OFstream& file();
//- Flag to allow writing to file //- Flag to allow writing to file
bool writeToFile() const; virtual bool writeToFile() const;
//- Return width of character stream output //- Return width of character stream output
label charWidth() const; virtual label charWidth() const;
//- Write a commented string to stream //- Write a commented string to stream
void writeCommented(Ostream& os, const string& str) const; virtual void writeCommented(Ostream& os, const string& str) const;
//- Write a tabbed string to stream //- Write a tabbed string to stream
void writeTabbed(Ostream& os, const string& str) const; virtual void writeTabbed(Ostream& os, const string& str) const;
//- Write a commented header to stream //- Write a commented header to stream
void writeHeader(Ostream& os, const string& str) const; virtual void writeHeader(Ostream& os, const string& str) const;
//- Write the current time to stream //- Write the current time to stream
void writeTime(Ostream& os) const; virtual void writeTime(Ostream& os) const;
//- Write a (commented) header property and value pair //- Write a (commented) header property and value pair
template<class Type> template<class Type>