functionObjects: Rationalize logging

This commit is contained in:
Henry Weller
2016-05-24 10:40:28 +01:00
parent 70ccff6840
commit 9ef803920c
10 changed files with 49 additions and 88 deletions

View File

@ -60,7 +60,8 @@ fieldCoordinateSystemTransform
{
read(dict);
Info<< type() << " " << name << ":" << nl
if (log_) Info
<< type() << " " << name << ":" << nl
<< " Applying transformation from global Cartesian to local "
<< coordSys_ << nl << endl;
}

View File

@ -82,10 +82,6 @@ SourceFiles
namespace Foam
{
// Forward declaration of classes
class objectRegistry;
namespace functionObjects
{

View File

@ -57,11 +57,9 @@ void Foam::functionObjects::fieldCoordinateSystemTransform::transform
if (mesh_.foundObject<VolFieldType>(fieldName))
{
if (debug)
{
Info<< type() << ": Field " << fieldName << " already in database"
<< endl;
}
DebugInfo
<< type() << ": Field " << fieldName << " already in database"
<< endl;
transformField<VolFieldType>
(
@ -70,11 +68,9 @@ void Foam::functionObjects::fieldCoordinateSystemTransform::transform
}
else if (mesh_.foundObject<SurfaceFieldType>(fieldName))
{
if (debug)
{
Info<< type() << ": Field " << fieldName << " already in database"
<< endl;
}
DebugInfo
<< type() << ": Field " << fieldName << " already in database"
<< endl;
transformField<SurfaceFieldType>
(
@ -98,11 +94,9 @@ void Foam::functionObjects::fieldCoordinateSystemTransform::transform
&& fieldHeader.headerClassName() == VolFieldType::typeName
)
{
if (debug)
{
Info<< type() << ": Field " << fieldName << " read from file"
<< endl;
}
DebugInfo
<< type() << ": Field " << fieldName << " read from file"
<< endl;
transformField<VolFieldType>
(
@ -115,11 +109,9 @@ void Foam::functionObjects::fieldCoordinateSystemTransform::transform
&& fieldHeader.headerClassName() == SurfaceFieldType::typeName
)
{
if (debug)
{
Info<< type() << ": Field " << fieldName << " read from file"
<< endl;
}
DebugInfo
<< type() << ": Field " << fieldName << " read from file"
<< endl;
transformField<SurfaceFieldType>
(

View File

@ -57,7 +57,8 @@ void Foam::functionObjects::histogram::writeGraph
outputPath/formatterPtr_().getFileName(coords, fieldNames)
);
Info<< " Writing histogram of " << fieldName
if (log_) Info
<< " Writing histogram of " << fieldName
<< " to " << graphFile.name() << endl;
List<const scalarField*> yPtrs(1);
@ -117,18 +118,18 @@ bool Foam::functionObjects::histogram::execute(const bool postProcess)
bool Foam::functionObjects::histogram::write(const bool postProcess)
{
Info<< type() << " " << name() << " output:" << nl;
if (log_) Info<< type() << " " << name() << " output:" << nl;
const fvMesh& mesh = refCast<const fvMesh>(obr_);
autoPtr<volScalarField> fieldPtr;
if (obr_.foundObject<volScalarField>(fieldName_))
{
Info<< " Looking up field " << fieldName_ << endl;
if (log_) Info<< " Looking up field " << fieldName_ << endl;
}
else
{
Info<< " Reading field " << fieldName_ << endl;
if (log_) Info<< " Reading field " << fieldName_ << endl;
fieldPtr.reset
(
new volScalarField

View File

@ -57,10 +57,7 @@ void Foam::functionObjects::nearWallFields::calcAddressing()
// Global indexing
globalIndex globalWalls(nPatchFaces);
if (debug)
{
InfoInFunction << "nPatchFaces: " << globalWalls.size() << endl;
}
DebugInFunction << "nPatchFaces: " << globalWalls.size() << endl;
// Construct cloud
Cloud<findCellParticle> cloud(mesh_, IDLList<findCellParticle>());
@ -239,10 +236,7 @@ Foam::functionObjects::nearWallFields::nearWallFields
Foam::functionObjects::nearWallFields::~nearWallFields()
{
if (debug)
{
InfoInFunction << endl;
}
DebugInFunction << endl;
}
@ -282,8 +276,8 @@ bool Foam::functionObjects::nearWallFields::read(const dictionary& dict)
reverseFieldMap_.insert(sampleFldName, fldName);
}
Info<< type() << " " << name() << ": Sampling " << fieldMap_.size()
<< " fields" << endl;
if (log_) Info << type() << " " << name()
<< ": Sampling " << fieldMap_.size() << " fields" << endl;
// Do analysis
calcAddressing();
@ -294,10 +288,7 @@ bool Foam::functionObjects::nearWallFields::read(const dictionary& dict)
bool Foam::functionObjects::nearWallFields::execute(const bool postProcess)
{
if (debug)
{
InfoInFunction << endl;
}
DebugInFunction << endl;
if
(
@ -309,8 +300,8 @@ bool Foam::functionObjects::nearWallFields::execute(const bool postProcess)
&& vtf_.empty()
)
{
Info<< type() << " " << name() << ": Creating " << fieldMap_.size()
<< " fields" << endl;
if (log_) Info<< type() << " " << name()
<< ": Creating " << fieldMap_.size() << " fields" << endl;
createFields(vsf_);
createFields(vvf_);
@ -318,12 +309,12 @@ bool Foam::functionObjects::nearWallFields::execute(const bool postProcess)
createFields(vSymmtf_);
createFields(vtf_);
Info<< endl;
if (log_) Info<< endl;
}
Info<< type() << " " << name() << " output:" << nl;
Info<< " Sampling fields to " << time_.timeName()
if (log_) Info<< type() << " " << name()
<< " output:" << nl
<< " Sampling fields to " << time_.timeName()
<< endl;
sampleFields(vsf_);
@ -338,12 +329,9 @@ bool Foam::functionObjects::nearWallFields::execute(const bool postProcess)
bool Foam::functionObjects::nearWallFields::write(const bool postProcess)
{
if (debug)
{
InfoInFunction << endl;
}
DebugInFunction << endl;
Info<< " Writing sampled fields to " << time_.timeName()
if (log_) Info<< " Writing sampled fields to " << time_.timeName()
<< endl;
forAll(vsf_, i)
@ -367,7 +355,7 @@ bool Foam::functionObjects::nearWallFields::write(const bool postProcess)
vtf_[i].write();
}
Info<< endl;
if (log_) Info<< endl;
return true;
}

View File

@ -47,7 +47,7 @@ void Foam::functionObjects::nearWallFields::createFields
if (obr_.found(sampleFldName))
{
Info<< " a field " << sampleFldName
if (log_) Info<< " a field " << sampleFldName
<< " already exists on the mesh."
<< endl;
}
@ -63,8 +63,8 @@ void Foam::functionObjects::nearWallFields::createFields
sflds.set(sz, new VolFieldType(io, fld));
Info<< " created " << sflds[sz].name() << " to sample "
<< fld.name() << endl;
if (log_) Info<< " created " << sflds[sz].name()
<< " to sample " << fld.name() << endl;
}
}
}

View File

@ -43,19 +43,15 @@ void Foam::functionObjects::readFields::loadField
if (obr_.foundObject<VolFieldType>(fieldName))
{
if (debug)
{
Info<< "readFields : Field " << fieldName << " already in database"
<< endl;
}
DebugInfo
<< "readFields : Field " << fieldName << " already in database"
<< endl;
}
else if (obr_.foundObject<SurfaceFieldType>(fieldName))
{
if (debug)
{
Info<< "readFields : Field " << fieldName << " already in database"
<< endl;
}
DebugInfo
<< "readFields : Field " << fieldName
<< " already in database" << endl;
}
else
{
@ -74,8 +70,9 @@ void Foam::functionObjects::readFields::loadField
&& fieldHeader.headerClassName() == VolFieldType::typeName
)
{
// store field locally
Info<< " Reading " << fieldName << endl;
// Store field locally
if (log_) Info<< " Reading " << fieldName << endl;
label sz = vflds.size();
vflds.setSize(sz+1);
vflds.set(sz, new VolFieldType(fieldHeader, mesh_));
@ -86,8 +83,9 @@ void Foam::functionObjects::readFields::loadField
&& fieldHeader.headerClassName() == SurfaceFieldType::typeName
)
{
// store field locally
Info<< " Reading " << fieldName << endl;
// Store field locally
if (log_) Info<< " Reading " << fieldName << endl;
label sz = sflds.size();
sflds.setSize(sz+1);
sflds.set(sz, new SurfaceFieldType(fieldHeader, mesh_));

View File

@ -119,7 +119,6 @@ namespace Foam
{
// Forward declaration of classes
class objectRegistry;
class regionSplit;
namespace functionObjects

View File

@ -127,22 +127,9 @@ Foam::functionObjects::turbulenceFields::turbulenceFields
const dictionary& dict
)
:
functionObject(name),
obr_
(
runTime.lookupObject<objectRegistry>
(
dict.lookupOrDefault("region", polyMesh::defaultRegion)
)
),
fvMeshFunctionObject(name, runTime, dict),
fieldSet_()
{
if (!isA<fvMesh>(obr_))
{
FatalErrorInFunction
<< "objectRegistry is not an fvMesh" << exit(FatalError);
}
if
(
!obr_.foundObject<compressible::turbulenceModel>(modelName)

View File

@ -53,7 +53,6 @@ namespace Foam
{
// Forward declaration of classes
class objectRegistry;
class fvMesh;
class turbulenceModel;