diff --git a/src/OpenFOAM/db/error/messageStream.C b/src/OpenFOAM/db/error/messageStream.C index 402bede54059bc49a163c6abf7bd8c4e984e4cd0..afc83c3d33bd64a0d0b9b7222b5383c54abf5920 100644 --- a/src/OpenFOAM/db/error/messageStream.C +++ b/src/OpenFOAM/db/error/messageStream.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -57,6 +57,26 @@ Foam::messageStream::messageStream(const dictionary& dict) {} +Foam::OSstream& Foam::messageStream::masterStream(const label communicator) +{ + if (UPstream::warnComm != -1 && communicator != UPstream::warnComm) + { + Pout<< "** messageStream with comm:" << communicator + << endl; + error::printStack(Pout); + } + + if (communicator == UPstream::worldComm) + { + return operator()(Pstream::master()); + } + else + { + return operator()(UPstream::master(communicator)); + } +} + + Foam::OSstream& Foam::messageStream::operator() ( const char* functionName, @@ -166,53 +186,37 @@ Foam::OSstream& Foam::messageStream::operator() } -Foam::OSstream& Foam::messageStream::operator()(const label communicator) +Foam::OSstream& Foam::messageStream::operator()(const bool output) { - if (UPstream::warnComm != -1 && communicator != UPstream::warnComm) - { - Pout<< "** messageStream with comm:" << communicator - << endl; - error::printStack(Pout); - } - - if (communicator == UPstream::worldComm) + if (output && level) { - return operator()(); - } - else - { - bool master = UPstream::master(communicator); + bool collect = (severity_ == INFO || severity_ == WARNING); - if (level) + // Report the error + if (collect) { - bool collect = (severity_ == INFO || severity_ == WARNING); - - // Report the error - if (!master && collect) + return Snull; + } + else + { + if (title().size()) { - return Snull; + Pout<< title().c_str(); } - else + + if (maxErrors_) { - if (title().size()) - { - Pout<< title().c_str(); - } + errorCount_++; - if (maxErrors_) + if (errorCount_ >= maxErrors_) { - errorCount_++; - - if (errorCount_ >= maxErrors_) - { - FatalErrorIn("messageStream::operator OSstream&()") - << "Too many errors" - << abort(FatalError); - } + FatalErrorIn("messageStream::operator OSstream&()") + << "Too many errors" + << abort(FatalError); } - - return Pout; } + + return Pout; } } diff --git a/src/OpenFOAM/db/error/messageStream.H b/src/OpenFOAM/db/error/messageStream.H index 54c41ab5641ebaed7be921542e482b0d734259e6..68032d406fe69d39f1821e3f08dcff7c8b1514b3 100644 --- a/src/OpenFOAM/db/error/messageStream.H +++ b/src/OpenFOAM/db/error/messageStream.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -134,6 +134,11 @@ public: return maxErrors_; } + //- Convert to OSstream + // Prints to Pout for the master stream + OSstream& masterStream(const label communicator); + + //- Convert to OSstream // Prints basic message and returns OSstream for further info. OSstream& operator() @@ -185,9 +190,8 @@ public: ); //- Convert to OSstream - // Use Info for default communicator, use Pout - // on master for non-default one. - OSstream& operator()(const label communicator); + // Use Info for default communicator, control output using bool flag + OSstream& operator()(const bool output); //- Convert to OSstream for << operations operator OSstream&();