ENH: fieldExpression - added verbose flag to foundObject

This commit is contained in:
Andrew Heather
2016-12-18 21:44:25 +00:00
parent 03e1f9c433
commit 519248d3f4
8 changed files with 24 additions and 20 deletions

View File

@ -57,11 +57,11 @@ bool Foam::functionObjects::components::calcComponents()
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType;
if (foundObject<VolFieldType>(fieldName_))
if (foundObject<VolFieldType>(fieldName_, false))
{
return calcFieldComponents<VolFieldType>();
}
else if (foundObject<SurfaceFieldType>(fieldName_))
else if (foundObject<SurfaceFieldType>(fieldName_, false))
{
return calcFieldComponents<SurfaceFieldType>();
}

View File

@ -30,7 +30,7 @@ License
template<class FieldType>
bool Foam::functionObjects::div::calcDiv()
{
if (foundObject<FieldType>(fieldName_))
if (foundObject<FieldType>(fieldName_, false))
{
return store
(

View File

@ -77,7 +77,7 @@ protected:
void setResultName(const word& typeName, const word& defaultArg);
template<class Type>
bool foundObject(const word& name);
bool foundObject(const word& name, const bool verbose = true) const;
private:

View File

@ -30,8 +30,9 @@ License
template<class Type>
bool Foam::functionObjects::fieldExpression::foundObject
(
const word& name
)
const word& name,
const bool verbose
) const
{
if (fvMeshFunctionObject::foundObject<Type>(name))
{
@ -39,10 +40,13 @@ bool Foam::functionObjects::fieldExpression::foundObject
}
else
{
Warning
<< " functionObjects::" << type() << " " << this->name()
<< " cannot find required object " << name << " of type "
<< Type::typeName << endl;
if (verbose)
{
Warning
<< " functionObjects::" << type() << " " << this->name()
<< " cannot find required object " << name << " of type "
<< Type::typeName << endl;
}
return false;
}

View File

@ -33,7 +33,7 @@ bool Foam::functionObjects::grad::calcGrad()
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType;
if (foundObject<VolFieldType>(fieldName_))
if (foundObject<VolFieldType>(fieldName_, false))
{
return store
(
@ -42,7 +42,7 @@ bool Foam::functionObjects::grad::calcGrad()
mesh_.changing() && mesh_.cache(resultName_)
);
}
else if (foundObject<SurfaceFieldType>(fieldName_))
else if (foundObject<SurfaceFieldType>(fieldName_, false))
{
return store
(

View File

@ -36,7 +36,7 @@ bool Foam::functionObjects::mag::calcMag()
typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType;
typedef DimensionedField<Type, surfGeoMesh> SurfFieldType;
if (foundObject<VolFieldType>(fieldName_))
if (foundObject<VolFieldType>(fieldName_, false))
{
return store
(
@ -44,7 +44,7 @@ bool Foam::functionObjects::mag::calcMag()
Foam::mag(lookupObject<VolFieldType>(fieldName_))
);
}
else if (foundObject<SurfaceFieldType>(fieldName_))
else if (foundObject<SurfaceFieldType>(fieldName_, false))
{
return store
(
@ -52,7 +52,7 @@ bool Foam::functionObjects::mag::calcMag()
Foam::mag(lookupObject<SurfaceFieldType>(fieldName_))
);
}
else if (foundObject<SurfFieldType>(fieldName_))
else if (foundObject<SurfFieldType>(fieldName_, false))
{
return store
(

View File

@ -36,7 +36,7 @@ bool Foam::functionObjects::magSqr::calcMagSqr()
typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType;
typedef DimensionedField<Type, surfGeoMesh> SurfFieldType;
if (foundObject<VolFieldType>(fieldName_))
if (foundObject<VolFieldType>(fieldName_, false))
{
return store
(
@ -44,7 +44,7 @@ bool Foam::functionObjects::magSqr::calcMagSqr()
Foam::magSqr(lookupObject<VolFieldType>(fieldName_))
);
}
else if (foundObject<SurfaceFieldType>(fieldName_))
else if (foundObject<SurfaceFieldType>(fieldName_, false))
{
return store
(
@ -52,7 +52,7 @@ bool Foam::functionObjects::magSqr::calcMagSqr()
Foam::magSqr(lookupObject<SurfaceFieldType>(fieldName_))
);
}
else if (foundObject<SurfFieldType>(fieldName_))
else if (foundObject<SurfFieldType>(fieldName_, false))
{
return store
(

View File

@ -33,11 +33,11 @@ bool Foam::functionObjects::randomise::calcRandomised()
{
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
if (foundObject<VolFieldType>(fieldName_))
if (foundObject<VolFieldType>(fieldName_, false))
{
const VolFieldType& field = lookupObject<VolFieldType>(fieldName_);
resultName_ = fieldName_ + "Random";
resultName_ = fieldName_ & "Random";
tmp<VolFieldType> rfieldt(new VolFieldType(field));
VolFieldType& rfield = rfieldt.ref();