Commit ee462f82 authored by Henry Weller's avatar Henry Weller
Browse files

messageStream: Added 'Log' macro which outputs to 'Info' if 'log' is true

regionFunctionObject: moved 'log_' to public 'log' to support the 'Log' macro
parent 82ca430a
......@@ -313,6 +313,11 @@ extern messageStream Info;
<< #var " " << var << ::Foam::endl
//- Report write to Foam::Info if the local log switch is true
#define Log \
if (log) Info
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
......
......@@ -49,7 +49,7 @@ bool Foam::functionObjects::regionFunctionObject::writeObject
{
const regIOobject& field = obr_.lookupObject<regIOobject>(fieldName);
if (log_)
if (log)
{
Info<< "functionObjects::" << type() << " " << name()
<< " writing field: " << field.name() << endl;
......@@ -109,7 +109,7 @@ Foam::functionObjects::regionFunctionObject::regionFunctionObject
dict.lookupOrDefault("region", polyMesh::defaultRegion)
)
),
log_(true)
log(true)
{}
......@@ -123,7 +123,7 @@ Foam::functionObjects::regionFunctionObject::regionFunctionObject
functionObject(name),
time_(obr.time()),
obr_(obr),
log_(true)
log(true)
{}
......@@ -137,7 +137,7 @@ Foam::functionObjects::regionFunctionObject::~regionFunctionObject()
bool Foam::functionObjects::regionFunctionObject::read(const dictionary& dict)
{
log_ = dict.lookupOrDefault<Switch>("log", true);
log = dict.lookupOrDefault<Switch>("log", true);
return true;
}
......
......@@ -72,9 +72,6 @@ protected:
//- Reference to the region objectRegistry
const objectRegistry& obr_;
//- Switch to send output to Info as well as to file
Switch log_;
// Protected member functions
......@@ -118,6 +115,9 @@ public:
//- Runtime type information
TypeName("regionFunctionObject");
//- Switch write log to Info
Switch log;
// Constructors
......
......@@ -95,7 +95,7 @@ void Foam::functionObjects::fieldAverage::initialize()
void Foam::functionObjects::fieldAverage::restart()
{
if (log_) Info
Log
<< " Restarting averaging at time " << obr_.time().timeName()
<< nl << endl;
......@@ -134,7 +134,7 @@ void Foam::functionObjects::fieldAverage::calcAverages()
periodIndex_++;
}
if (log_) Info
Log
<< type() << " " << name() << " output:" << nl
<< " Calculating averages" << nl;
......@@ -156,13 +156,13 @@ void Foam::functionObjects::fieldAverage::calcAverages()
totalTime_[fieldi] += obr_.time().deltaTValue();
}
if (log_) Info<< endl;
Log << endl;
}
void Foam::functionObjects::fieldAverage::writeAverages() const
{
if (log_) Info<< " Writing average fields" << endl;
Log << " Writing average fields" << endl;
writeFields<scalar>();
writeFields<vector>();
......@@ -170,7 +170,7 @@ void Foam::functionObjects::fieldAverage::writeAverages() const
writeFields<symmTensor>();
writeFields<tensor>();
if (log_) Info<< endl;
Log << endl;
}
......@@ -200,7 +200,7 @@ void Foam::functionObjects::fieldAverage::writeAveragingProperties() const
propsDict.regIOobject::write();
if (log_) Info<< endl;
Log << endl;
}
......@@ -212,7 +212,7 @@ void Foam::functionObjects::fieldAverage::readAveragingProperties()
totalTime_.clear();
totalTime_.setSize(faItems_.size(), obr_.time().deltaTValue());
if ((restartOnRestart_ || restartOnOutput_) && log_)
if ((restartOnRestart_ || restartOnOutput_) && log)
{
Info<< " Starting averaging at time " << obr_.time().timeName()
<< nl;
......@@ -232,7 +232,7 @@ void Foam::functionObjects::fieldAverage::readAveragingProperties()
if (!propsDictHeader.headerOk())
{
if (log_) Info
Log
<< " Starting averaging at time "
<< obr_.time().timeName() << nl;
......@@ -241,7 +241,7 @@ void Foam::functionObjects::fieldAverage::readAveragingProperties()
IOdictionary propsDict(propsDictHeader);
if (log_) Info<< " Restarting averaging for fields:" << nl;
Log << " Restarting averaging for fields:" << nl;
forAll(faItems_, fieldi)
{
......@@ -253,7 +253,7 @@ void Foam::functionObjects::fieldAverage::readAveragingProperties()
totalIter_[fieldi] = readLabel(fieldDict.lookup("totalIter"));
totalTime_[fieldi] = readScalar(fieldDict.lookup("totalTime"));
if (log_) Info
Log
<< " " << fieldName
<< " iters = " << totalIter_[fieldi]
<< " time = " << totalTime_[fieldi] << nl;
......@@ -302,7 +302,7 @@ bool Foam::functionObjects::fieldAverage::read(const dictionary& dict)
initialised_ = false;
if (log_) Info<< type() << " " << name() << ":" << nl;
Log << type() << " " << name() << ":" << nl;
dict.readIfPresent("restartOnRestart", restartOnRestart_);
dict.readIfPresent("restartOnOutput", restartOnOutput_);
......@@ -316,7 +316,7 @@ bool Foam::functionObjects::fieldAverage::read(const dictionary& dict)
readAveragingProperties();
if (log_) Info<< endl;
Log << endl;
return true;
}
......
......@@ -36,7 +36,7 @@ void Foam::functionObjects::fieldAverage::addMeanFieldType(const label fieldi)
const word& fieldName = faItems_[fieldi].fieldName();
const word& meanFieldName = faItems_[fieldi].meanFieldName();
if (log_) Info<< " Reading/initialising field " << meanFieldName << endl;
Log << " Reading/initialising field " << meanFieldName << endl;
if (obr_.foundObject<Type>(meanFieldName))
{
......@@ -44,8 +44,7 @@ void Foam::functionObjects::fieldAverage::addMeanFieldType(const label fieldi)
}
else if (obr_.found(meanFieldName))
{
if (log_) Info
<< " Cannot allocate average field " << meanFieldName
Log << " Cannot allocate average field " << meanFieldName
<< " since an object with that name already exists."
<< " Disabling averaging for field." << endl;
......@@ -112,8 +111,7 @@ void Foam::functionObjects::fieldAverage::addPrime2MeanFieldType
const word& meanFieldName = faItems_[fieldi].meanFieldName();
const word& prime2MeanFieldName = faItems_[fieldi].prime2MeanFieldName();
if (log_) Info
<< " Reading/initialising field " << prime2MeanFieldName << nl;
Log << " Reading/initialising field " << prime2MeanFieldName << nl;
if (obr_.foundObject<Type2>(prime2MeanFieldName))
{
......@@ -121,8 +119,7 @@ void Foam::functionObjects::fieldAverage::addPrime2MeanFieldType
}
else if (obr_.found(prime2MeanFieldName))
{
if (log_) Info
<< " Cannot allocate average field " << prime2MeanFieldName
Log << " Cannot allocate average field " << prime2MeanFieldName
<< " since an object with that name already exists."
<< " Disabling averaging for field." << nl;
......
......@@ -60,8 +60,7 @@ fieldCoordinateSystemTransform
{
read(dict);
if (log_) Info
<< type() << " " << name << ":" << nl
Log << type() << " " << name << ":" << nl
<< " Applying transformation from global Cartesian to local "
<< coordSys_ << nl << endl;
}
......
......@@ -151,7 +151,7 @@ bool Foam::functionObjects::fieldMinMax::write(const bool postProcess)
writeFiles::write();
if (!location_) writeTime(file());
if (log_) Info<< type() << " " << name() << " output:" << nl;
Log << type() << " " << name() << " output:" << nl;
forAll(fieldSet_, fieldi)
{
......@@ -163,7 +163,7 @@ bool Foam::functionObjects::fieldMinMax::write(const bool postProcess)
}
if (!location_) file()<< endl;
if (log_) Info<< endl;
Log << endl;
return true;
}
......
......@@ -67,34 +67,31 @@ void Foam::functionObjects::fieldMinMax::output
file<< endl;
if (log_) Info
<< " min(" << outputName << ") = " << minValue
Log << " min(" << outputName << ") = " << minValue
<< " at location " << minC;
if (Pstream::parRun())
{
if (log_) Info<< " on processor " << minProci;
Log << " on processor " << minProci;
}
if (log_) Info
<< nl << " max(" << outputName << ") = " << maxValue
Log << nl << " max(" << outputName << ") = " << maxValue
<< " at location " << maxC;
if (Pstream::parRun())
{
if (log_) Info<< " on processor " << maxProci;
Log << " on processor " << maxProci;
}
}
else
{
file<< token::TAB << minValue << token::TAB << maxValue;
if (log_) Info
<< " min/max(" << outputName << ") = "
Log << " min/max(" << outputName << ") = "
<< minValue << ' ' << maxValue;
}
if (log_) Info<< endl;
Log << endl;
}
......
......@@ -294,7 +294,7 @@ bool Foam::functionObjects::fieldValues::cellSource::write
{
file() << tab << volume_;
}
if (log_) Info<< " total volume = " << volume_ << endl;
Log << " total volume = " << volume_ << endl;
}
forAll(fields_, i)
......@@ -322,7 +322,7 @@ bool Foam::functionObjects::fieldValues::cellSource::write
file()<< endl;
}
if (log_) Info<< endl;
Log << endl;
return true;
}
......
......@@ -205,7 +205,7 @@ bool Foam::functionObjects::fieldValues::cellSource::writeValues
file()<< tab << result;
if (log_) Info<< " " << operationTypeNames_[operation_]
Log << " " << operationTypeNames_[operation_]
<< "(" << sourceName_ << ") of " << fieldName
<< " = " << result << endl;
}
......
......@@ -744,7 +744,7 @@ bool Foam::functionObjects::fieldValues::faceSource::write
{
file() << tab << totalArea_;
}
if (log_) Info<< " total area = " << totalArea_ << endl;
Log << " total area = " << totalArea_ << endl;
}
// construct weight field. Note: zero size means weight = 1
......@@ -791,7 +791,7 @@ bool Foam::functionObjects::fieldValues::faceSource::write
file()<< endl;
}
if (log_) Info<< endl;
Log << endl;
return true;
}
......
......@@ -344,7 +344,7 @@ bool Foam::functionObjects::fieldValues::faceSource::writeValues
file()<< tab << result;
if (log_) Info<< " " << operationTypeNames_[operation_]
Log << " " << operationTypeNames_[operation_]
<< "(" << sourceName_ << ") of " << fieldName
<< " = " << result << endl;
}
......
......@@ -110,7 +110,7 @@ bool Foam::functionObjects::fieldValue::write(const bool postProcess)
{
writeFiles::write();
if (log_) Info<< type() << " " << name() << " output:" << nl;
Log << type() << " " << name() << " output:" << nl;
return true;
}
......
......@@ -179,7 +179,7 @@ bool Foam::functionObjects::fieldValues::fieldValueDelta::write
writeTime(file());
}
if (log_) Info<< type() << " " << name() << " output:" << endl;
Log << type() << " " << name() << " output:" << endl;
bool found = false;
processFields<scalar>(found);
......@@ -193,16 +193,13 @@ bool Foam::functionObjects::fieldValues::fieldValueDelta::write
file()<< endl;
}
if (log_)
if (!found)
{
if (!found)
{
Info<< " none" << endl;
}
else
{
Info<< endl;
}
Log << " none" << endl;
}
else
{
Log << endl;
}
return true;
......
......@@ -110,7 +110,7 @@ void Foam::functionObjects::fieldValues::fieldValueDelta::processFields
Type result = applyOperation(r1, r2);
if (log_) Info<< " " << operationTypeNames_[operation_]
Log << " " << operationTypeNames_[operation_]
<< "(" << fieldName << ") = " << result
<< endl;
......
......@@ -57,8 +57,7 @@ void Foam::functionObjects::histogram::writeGraph
outputPath/formatterPtr_().getFileName(coords, fieldNames)
);
if (log_) Info
<< " Writing histogram of " << fieldName
Log << " Writing histogram of " << fieldName
<< " to " << graphFile.name() << endl;
List<const scalarField*> yPtrs(1);
......@@ -118,18 +117,18 @@ bool Foam::functionObjects::histogram::execute(const bool postProcess)
bool Foam::functionObjects::histogram::write(const bool postProcess)
{
if (log_) Info<< type() << " " << name() << " output:" << nl;
Log << type() << " " << name() << " output:" << nl;
const fvMesh& mesh = refCast<const fvMesh>(obr_);
autoPtr<volScalarField> fieldPtr;
if (obr_.foundObject<volScalarField>(fieldName_))
{
if (log_) Info<< " Looking up field " << fieldName_ << endl;
Log << " Looking up field " << fieldName_ << endl;
}
else
{
if (log_) Info<< " Reading field " << fieldName_ << endl;
Log << " Reading field " << fieldName_ << endl;
fieldPtr.reset
(
new volScalarField
......
......@@ -276,7 +276,7 @@ bool Foam::functionObjects::nearWallFields::read(const dictionary& dict)
reverseFieldMap_.insert(sampleFldName, fldName);
}
if (log_) Info << type() << " " << name()
Log << type() << " " << name()
<< ": Sampling " << fieldMap_.size() << " fields" << endl;
// Do analysis
......@@ -300,7 +300,7 @@ bool Foam::functionObjects::nearWallFields::execute(const bool postProcess)
&& vtf_.empty()
)
{
if (log_) Info<< type() << " " << name()
Log << type() << " " << name()
<< ": Creating " << fieldMap_.size() << " fields" << endl;
createFields(vsf_);
......@@ -309,10 +309,10 @@ bool Foam::functionObjects::nearWallFields::execute(const bool postProcess)
createFields(vSymmtf_);
createFields(vtf_);
if (log_) Info<< endl;
Log << endl;
}
if (log_) Info<< type() << " " << name()
Log << type() << " " << name()
<< " output:" << nl
<< " Sampling fields to " << time_.timeName()
<< endl;
......@@ -331,7 +331,7 @@ bool Foam::functionObjects::nearWallFields::write(const bool postProcess)
{
DebugInFunction << endl;
if (log_) Info<< " Writing sampled fields to " << time_.timeName()
Log << " Writing sampled fields to " << time_.timeName()
<< endl;
forAll(vsf_, i)
......@@ -355,7 +355,7 @@ bool Foam::functionObjects::nearWallFields::write(const bool postProcess)
vtf_[i].write();
}
if (log_) Info<< endl;
Log << endl;
return true;
}
......
......@@ -47,7 +47,7 @@ void Foam::functionObjects::nearWallFields::createFields
if (obr_.found(sampleFldName))
{
if (log_) Info<< " a field " << sampleFldName
Log << " a field " << sampleFldName
<< " already exists on the mesh."
<< endl;
}
......@@ -63,7 +63,7 @@ void Foam::functionObjects::nearWallFields::createFields
sflds.set(sz, new VolFieldType(io, fld));
if (log_) Info<< " created " << sflds[sz].name()
Log << " created " << sflds[sz].name()
<< " to sample " << fld.name() << endl;
}
}
......
......@@ -71,7 +71,7 @@ void Foam::functionObjects::readFields::loadField
)
{
// Store field locally
if (log_) Info<< " Reading " << fieldName << endl;
Log << " Reading " << fieldName << endl;
label sz = vflds.size();
vflds.setSize(sz+1);
......@@ -84,7 +84,7 @@ void Foam::functionObjects::readFields::loadField
)
{
// Store field locally
if (log_) Info<< " Reading " << fieldName << endl;
Log << " Reading " << fieldName << endl;
label sz = sflds.size();
sflds.setSize(sz+1);
......
......@@ -208,7 +208,7 @@ bool Foam::functionObjects::forceCoeffs::write(const bool postProcess)
<< tab << Cm << tab << Cd
<< tab << Cl << tab << Clf << tab << Clr << endl;
if (log_) Info<< type() << " " << name() << " output:" << nl
Log << type() << " " << name() << " output:" << nl
<< " Cm = " << Cm << nl
<< " Cd = " << Cd << nl
<< " Cl = " << Cl << nl
......@@ -240,7 +240,7 @@ bool Foam::functionObjects::forceCoeffs::write(const bool postProcess)
file(1) << endl;
}
if (log_) Info<< endl;
Log << endl;
}
return true;
......
Markdown is supported
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