From dd04dd9c2cb85c953f04fe1c4f498da09de37742 Mon Sep 17 00:00:00 2001 From: Henry Date: Mon, 18 May 2015 11:54:56 +0100 Subject: [PATCH] messageStream: Remove confusing argument-based conditional output This had been used in functionObjects: Info(log)<< "messages" << data << .... in which it is not at all clear what the "log" argument does whereas if (log) Info<< "messages" << data << .... is totally clear and more efficient. --- src/OpenFOAM/db/error/messageStream.C | 19 +++---------------- src/OpenFOAM/db/error/messageStream.H | 6 +----- .../field/fieldMinMax/fieldMinMax.C | 16 ++++------------ .../field/fieldMinMax/fieldMinMaxTemplates.C | 12 ++++++------ .../field/fieldValues/cellSource/cellSource.C | 4 ++-- .../cellSource/cellSourceTemplates.C | 2 +- .../field/fieldValues/faceSource/faceSource.C | 4 ++-- .../faceSource/faceSourceTemplates.C | 2 +- .../field/fieldValues/fieldValue/fieldValue.C | 2 +- .../fieldValueDelta/fieldValueDelta.C | 2 +- .../fieldValueDeltaTemplates.C | 2 +- .../forces/forceCoeffs/forceCoeffs.C | 4 ++-- .../functionObjects/forces/forces/forces.C | 10 +++++----- .../wallShearStress/wallShearStress.C | 8 ++++---- .../functionObjects/utilities/yPlus/yPlus.C | 4 ++-- .../utilities/yPlus/yPlusTemplates.C | 4 ++-- 16 files changed, 38 insertions(+), 63 deletions(-) diff --git a/src/OpenFOAM/db/error/messageStream.C b/src/OpenFOAM/db/error/messageStream.C index 75ae1b4770..3f738e4280 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-2014 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -66,13 +66,13 @@ Foam::OSstream& Foam::messageStream::masterStream(const label communicator) error::printStack(Pout); } - if (communicator == UPstream::worldComm) + if (communicator == UPstream::worldComm || UPstream::master(communicator)) { return operator()(); } else { - return operator()(UPstream::master(communicator)); + return Snull; } } @@ -186,19 +186,6 @@ Foam::OSstream& Foam::messageStream::operator() } -Foam::OSstream& Foam::messageStream::operator()(const bool output) -{ - if (output) - { - return operator()(); - } - else - { - return Snull; - } -} - - Foam::messageStream::operator Foam::OSstream&() { if (level) diff --git a/src/OpenFOAM/db/error/messageStream.H b/src/OpenFOAM/db/error/messageStream.H index 01575f2266..f572e64265 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-2014 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -189,10 +189,6 @@ public: const dictionary& ); - //- Convert to OSstream - // Use Info for default communicator, control output using bool flag - OSstream& operator()(const bool output); - //- Convert to OSstream for << operations operator OSstream&(); diff --git a/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMax.C b/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMax.C index cc01c6696d..dac7d8a71e 100644 --- a/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMax.C +++ b/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMax.C @@ -174,12 +174,8 @@ void Foam::fieldMinMax::write() { functionObjectFile::write(); - if (!location_) - { - file()<< obr_.time().value(); - } - - Info(log_)<< type() << " " << name_ << " output:" << nl; + if (!location_) file()<< obr_.time().value(); + if (log_) Info<< type() << " " << name_ << " output:" << nl; forAll(fieldSet_, fieldI) { @@ -190,12 +186,8 @@ void Foam::fieldMinMax::write() calcMinMaxFields(fieldSet_[fieldI], mode_); } - if (!location_) - { - file()<< endl; - } - - Info(log_)<< endl; + if (!location_) file()<< endl; + if (log_) Info<< endl; } } diff --git a/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMaxTemplates.C b/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMaxTemplates.C index 42da3d3c1b..729500caef 100644 --- a/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMaxTemplates.C +++ b/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMaxTemplates.C @@ -67,34 +67,34 @@ void Foam::fieldMinMax::output file<< endl; - Info(log_) + if (log_) Info << " min(" << outputName << ") = " << minValue << " at location " << minC; if (Pstream::parRun()) { - Info(log_)<< " on processor " << minProcI; + if (log_) Info<< " on processor " << minProcI; } - Info(log_) + if (log_) Info << nl << " max(" << outputName << ") = " << maxValue << " at location " << maxC; if (Pstream::parRun()) { - Info(log_)<< " on processor " << maxProcI; + if (log_) Info<< " on processor " << maxProcI; } } else { file<< token::TAB << minValue << token::TAB << maxValue; - Info(log_) + if (log_) Info << " min/max(" << outputName << ") = " << minValue << ' ' << maxValue; } - Info(log_)<< endl; + if (log_) Info<< endl; } diff --git a/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSource.C b/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSource.C index f672579b83..afe4ea5f2c 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSource.C +++ b/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSource.C @@ -245,7 +245,7 @@ void Foam::fieldValues::cellSource::write() { file() << tab << volume_; } - Info(log_)<< " total volume = " << volume_ << endl; + if (log_) Info<< " total volume = " << volume_ << endl; } forAll(fields_, i) @@ -273,7 +273,7 @@ void Foam::fieldValues::cellSource::write() file()<< endl; } - Info(log_)<< endl; + if (log_) Info<< endl; } } diff --git a/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSourceTemplates.C b/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSourceTemplates.C index 1371083b4d..f53755e3ff 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSourceTemplates.C +++ b/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSourceTemplates.C @@ -205,7 +205,7 @@ bool Foam::fieldValues::cellSource::writeValues(const word& fieldName) file()<< tab << result; - Info(log_)<< " " << operationTypeNames_[operation_] + if (log_) Info<< " " << operationTypeNames_[operation_] << "(" << sourceName_ << ") of " << fieldName << " = " << result << endl; } diff --git a/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.C b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.C index 924b3cdc22..50804908c2 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.C +++ b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.C @@ -701,7 +701,7 @@ void Foam::fieldValues::faceSource::write() { file() << tab << totalArea_; } - Info(log_)<< " total area = " << totalArea_ << endl; + if (log_) Info<< " total area = " << totalArea_ << endl; } // construct weight field. Note: zero size means weight = 1 @@ -748,7 +748,7 @@ void Foam::fieldValues::faceSource::write() file()<< endl; } - Info(log_)<< endl; + if (log_) Info<< endl; } } diff --git a/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSourceTemplates.C b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSourceTemplates.C index e61fb5c765..27c392f562 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSourceTemplates.C +++ b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSourceTemplates.C @@ -353,7 +353,7 @@ bool Foam::fieldValues::faceSource::writeValues file()<< tab << result; - Info(log_)<< " " << operationTypeNames_[operation_] + if (log_) Info<< " " << operationTypeNames_[operation_] << "(" << sourceName_ << ") of " << fieldName << " = " << result << endl; } diff --git a/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.C b/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.C index c2ee5e3485..e54187c5f4 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.C +++ b/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.C @@ -58,7 +58,7 @@ void Foam::fieldValue::write() { functionObjectFile::write(); - Info(log_)<< type() << " " << name_ << " output:" << nl; + if (log_) Info<< type() << " " << name_ << " output:" << nl; } } diff --git a/src/postProcessing/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.C b/src/postProcessing/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.C index d467b8146c..8f2542f775 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.C +++ b/src/postProcessing/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.C @@ -158,7 +158,7 @@ void Foam::fieldValues::fieldValueDelta::write() file()<< obr_.time().value(); } - Info(log_)<< type() << " " << name_ << " output:" << endl; + if (log_) Info<< type() << " " << name_ << " output:" << endl; bool found = false; processFields(found); diff --git a/src/postProcessing/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDeltaTemplates.C b/src/postProcessing/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDeltaTemplates.C index 48581422a9..4b94c56890 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDeltaTemplates.C +++ b/src/postProcessing/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDeltaTemplates.C @@ -114,7 +114,7 @@ void Foam::fieldValues::fieldValueDelta::processFields(bool& found) Type result = applyOperation(r1, r2); - Info(log_)<< " " << operationTypeNames_[operation_] + if (log_) Info<< " " << operationTypeNames_[operation_] << "(" << fieldName << ") = " << result << endl; diff --git a/src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffs.C b/src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffs.C index 6c20c0a19b..5576a6f8a2 100644 --- a/src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffs.C +++ b/src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffs.C @@ -227,7 +227,7 @@ void Foam::forceCoeffs::write() << obr_.time().value() << tab << Cm << tab << Cd << tab << Cl << tab << Clf << tab << Clr << endl; - Info(log_)<< type() << " " << name_ << " output:" << nl + if (log_) Info<< type() << " " << name_ << " output:" << nl << " Cm = " << Cm << nl << " Cd = " << Cd << nl << " Cl = " << Cl << nl @@ -259,7 +259,7 @@ void Foam::forceCoeffs::write() file(1) << endl; } - Info(log_)<< endl; + if (log_) Info<< endl; } } diff --git a/src/postProcessing/functionObjects/forces/forces/forces.C b/src/postProcessing/functionObjects/forces/forces/forces.C index 42e2781cc1..749731567d 100644 --- a/src/postProcessing/functionObjects/forces/forces/forces.C +++ b/src/postProcessing/functionObjects/forces/forces/forces.C @@ -390,7 +390,7 @@ void Foam::forces::applyBins void Foam::forces::writeForces() { - Info(log_) + if (log_) Info << type() << " " << name_ << " output:" << nl << " sum of forces:" << nl << " pressure : " << sum(force_[0]) << nl @@ -639,7 +639,7 @@ void Foam::forces::read(const dictionary& dict) log_ = dict.lookupOrDefault("log", false); - Info(log_)<< type() << " " << name_ << ":" << nl; + if (log_) Info<< type() << " " << name_ << ":" << nl; directForceDensity_ = dict.lookupOrDefault("directForceDensity", false); @@ -680,11 +680,11 @@ void Foam::forces::read(const dictionary& dict) dict.readIfPresent("porosity", porosity_); if (porosity_) { - Info(log_)<< " Including porosity effects" << endl; + if (log_) Info<< " Including porosity effects" << endl; } else { - Info(log_)<< " Not including porosity effects" << endl; + if (log_) Info<< " Not including porosity effects" << endl; } if (dict.found("binData")) @@ -801,7 +801,7 @@ void Foam::forces::write() writeBins(); - Info(log_)<< endl; + if (log_) Info<< endl; } } diff --git a/src/postProcessing/functionObjects/utilities/wallShearStress/wallShearStress.C b/src/postProcessing/functionObjects/utilities/wallShearStress/wallShearStress.C index c6bd8a9e19..4271fa5394 100644 --- a/src/postProcessing/functionObjects/utilities/wallShearStress/wallShearStress.C +++ b/src/postProcessing/functionObjects/utilities/wallShearStress/wallShearStress.C @@ -83,7 +83,7 @@ void Foam::wallShearStress::calcShearStress << endl; } - Info(log_)<< " min/max(" << pp.name() << ") = " + if (log_) Info<< " min/max(" << pp.name() << ") = " << minSsp << ", " << maxSsp << endl; } } @@ -238,7 +238,7 @@ void Foam::wallShearStress::execute() mesh.lookupObject(type()) ); - Info(log_)<< type() << " " << name_ << " output:" << nl; + if (log_) Info<< type() << " " << name_ << " output:" << nl; tmp Reff; @@ -258,7 +258,7 @@ void Foam::wallShearStress::execute() } else { - FatalErrorIn("void Foam::wallShearStress::write()") + FatalErrorIn("void Foam::wallShearStress::execute()") << "Unable to find turbulence model in the " << "database" << exit(FatalError); } @@ -292,7 +292,7 @@ void Foam::wallShearStress::write() const volVectorField& wallShearStress = obr_.lookupObject(type()); - Info(log_)<< type() << " " << name_ << " output:" << nl + if (log_) Info<< type() << " " << name_ << " output:" << nl << " writing field " << wallShearStress.name() << nl << endl; diff --git a/src/postProcessing/functionObjects/utilities/yPlus/yPlus.C b/src/postProcessing/functionObjects/utilities/yPlus/yPlus.C index c85882fc9e..119a0f895d 100644 --- a/src/postProcessing/functionObjects/utilities/yPlus/yPlus.C +++ b/src/postProcessing/functionObjects/utilities/yPlus/yPlus.C @@ -146,7 +146,7 @@ void Foam::yPlus::execute() mesh.lookupObject(type()) ); - Info(log_)<< type() << " " << name_ << " output:" << nl; + if (log_) Info<< type() << " " << name_ << " output:" << nl; tmp Reff; if (mesh.foundObject(turbulenceModel::propertiesName)) @@ -197,7 +197,7 @@ void Foam::yPlus::write() const volScalarField& yPlus = obr_.lookupObject(type()); - Info(log_)<< " writing field " << yPlus.name() << nl << endl; + if (log_) Info<< " writing field " << yPlus.name() << nl << endl; yPlus.write(); } diff --git a/src/postProcessing/functionObjects/utilities/yPlus/yPlusTemplates.C b/src/postProcessing/functionObjects/utilities/yPlus/yPlusTemplates.C index 9061a6f013..818610cfe5 100644 --- a/src/postProcessing/functionObjects/utilities/yPlus/yPlusTemplates.C +++ b/src/postProcessing/functionObjects/utilities/yPlus/yPlusTemplates.C @@ -72,7 +72,7 @@ void Foam::yPlus::calcYPlus if (Pstream::master()) { - Info(log_) + if (log_) Info << " patch " << patch.name() << " y+ : min = " << minYplus << ", max = " << maxYplus << ", average = " << avgYplus << nl; @@ -102,7 +102,7 @@ void Foam::yPlus::calcYPlus if (Pstream::master()) { - Info(log_) + if (log_) Info << " patch " << patch.name() << " y+ : min = " << minYplus << ", max = " << maxYplus << ", average = " << avgYplus << nl;