Skip to content
Snippets Groups Projects
Commit 7f272430 authored by andy's avatar andy
Browse files

ENH: messageStream - updated writing to Info with optional output flag

parent 79312b05
Branches
Tags
No related merge requests found
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
...@@ -57,6 +57,26 @@ Foam::messageStream::messageStream(const dictionary& dict) ...@@ -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() Foam::OSstream& Foam::messageStream::operator()
( (
const char* functionName, const char* functionName,
...@@ -166,53 +186,37 @@ Foam::OSstream& Foam::messageStream::operator() ...@@ -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) if (output && level)
{
Pout<< "** messageStream with comm:" << communicator
<< endl;
error::printStack(Pout);
}
if (communicator == UPstream::worldComm)
{ {
return operator()(); bool collect = (severity_ == INFO || severity_ == WARNING);
}
else
{
bool master = UPstream::master(communicator);
if (level) // Report the error
if (collect)
{ {
bool collect = (severity_ == INFO || severity_ == WARNING); return Snull;
}
// Report the error else
if (!master && collect) {
if (title().size())
{ {
return Snull; Pout<< title().c_str();
} }
else
if (maxErrors_)
{ {
if (title().size()) errorCount_++;
{
Pout<< title().c_str();
}
if (maxErrors_) if (errorCount_ >= maxErrors_)
{ {
errorCount_++; FatalErrorIn("messageStream::operator OSstream&()")
<< "Too many errors"
if (errorCount_ >= maxErrors_) << abort(FatalError);
{
FatalErrorIn("messageStream::operator OSstream&()")
<< "Too many errors"
<< abort(FatalError);
}
} }
return Pout;
} }
return Pout;
} }
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
...@@ -134,6 +134,11 @@ public: ...@@ -134,6 +134,11 @@ public:
return maxErrors_; return maxErrors_;
} }
//- Convert to OSstream
// Prints to Pout for the master stream
OSstream& masterStream(const label communicator);
//- Convert to OSstream //- Convert to OSstream
// Prints basic message and returns OSstream for further info. // Prints basic message and returns OSstream for further info.
OSstream& operator() OSstream& operator()
...@@ -185,9 +190,8 @@ public: ...@@ -185,9 +190,8 @@ public:
); );
//- Convert to OSstream //- Convert to OSstream
// Use Info for default communicator, use Pout // Use Info for default communicator, control output using bool flag
// on master for non-default one. OSstream& operator()(const bool output);
OSstream& operator()(const label communicator);
//- Convert to OSstream for << operations //- Convert to OSstream for << operations
operator OSstream&(); operator OSstream&();
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment