functionObjects: Emit warning messages only for field names which do not exist for any type

Resolves bug-report https://bugs.openfoam.org/view.php?id=3583
This commit is contained in:
Henry Weller
2020-10-27 20:03:19 +00:00
parent efbf198022
commit f7848e62a1
27 changed files with 140 additions and 123 deletions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -40,6 +40,17 @@ namespace functionObjects
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
void Foam::functionObjects::regionFunctionObject::cannotFindObject
(
const word& fieldName
)
{
Warning
<< " functionObjects::" << type() << " " << name()
<< " cannot find required object " << fieldName << endl;
}
bool Foam::functionObjects::regionFunctionObject::writeObject
(
const word& fieldName

View File

@ -78,6 +78,13 @@ protected:
template<class ObjectType>
bool foundObject(const word& fieldName) const;
//- Prints a warning message that fieldName cannot be found
template<class ObjectType>
void cannotFindObject(const word& fieldName);
//- Prints a warning message that fieldName cannot be found
void cannotFindObject(const word& fieldName);
//- Lookup object from the objectRegistry
template<class ObjectType>
const ObjectType& lookupObject(const word& fieldName) const;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2016-2019 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -38,6 +38,19 @@ bool Foam::functionObjects::regionFunctionObject::foundObject
}
template<class Type>
void Foam::functionObjects::regionFunctionObject::cannotFindObject
(
const word& fieldName
)
{
Warning
<< " functionObjects::" << type() << " " << name()
<< " cannot find required object " << fieldName << " of type "
<< Type::typeName << endl;
}
template<class ObjectType>
const ObjectType& Foam::functionObjects::regionFunctionObject::lookupObject
(

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2013-2019 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2013-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -98,6 +98,8 @@ bool Foam::functionObjects::CourantNo::calc()
}
else
{
cannotFindObject<surfaceScalarField>(fieldName_);
return false;
}
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2013-2019 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2013-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -69,6 +69,8 @@ bool Foam::functionObjects::Lambda2::calc()
}
else
{
cannotFindObject<volVectorField>(fieldName_);
return false;
}
}

View File

@ -76,6 +76,8 @@ bool Foam::functionObjects::PecletNo::calc()
}
else
{
cannotFindObject<surfaceScalarField>(fieldName_);
return false;
}
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2013-2019 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2013-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -63,6 +63,8 @@ bool Foam::functionObjects::Q::calc()
}
else
{
cannotFindObject<volVectorField>(fieldName_);
return false;
}
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2013-2019 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2013-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -47,6 +47,11 @@ bool Foam::functionObjects::blendingFactor::calc()
processed = processed || calcBF<scalar>();
processed = processed || calcBF<vector>();
if (!processed)
{
cannotFindObject(fieldName_);
}
return processed;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2016-2019 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -49,6 +49,11 @@ bool Foam::functionObjects::components::calc()
processed = processed || calcComponents<symmTensor>();
processed = processed || calcComponents<tensor>();
if (!processed)
{
cannotFindObject(fieldName_);
}
return processed;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2017-2019 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2017-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -53,11 +53,14 @@ bool Foam::functionObjects::ddt::calc()
bool processed = false;
processed = processed || calcDdt<scalar>();
processed = processed || calcDdt<vector>();
processed = processed || calcDdt<sphericalTensor>();
processed = processed || calcDdt<symmTensor>();
processed = processed || calcDdt<tensor>();
#define processType(fieldType, none) \
processed = processed || calcDdt<fieldType>();
FOR_ALL_FIELD_TYPES(processType)
if (!processed)
{
cannotFindObject(fieldName_);
}
return processed;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2013-2019 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2013-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -49,6 +49,11 @@ bool Foam::functionObjects::div::calc()
processed = processed || calcDiv<surfaceScalarField>();
processed = processed || calcDiv<volVectorField>();
if (!processed)
{
cannotFindObject(fieldName_);
}
return processed;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2016-2019 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -59,6 +59,8 @@ bool Foam::functionObjects::enstrophy::calc()
}
else
{
cannotFindObject<volVectorField>(fieldName_);
return false;
}

View File

@ -38,7 +38,6 @@ SourceFiles
#define functionObjects_fieldExpression_H
#include "fvMeshFunctionObject.H"
#include "volFieldsFwd.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -70,9 +69,6 @@ protected:
virtual bool calc() = 0;
template<class Type>
bool foundObject(const word& name);
public:
@ -129,12 +125,6 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "fieldExpressionTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,52 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "fieldExpression.H"
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
template<class Type>
bool Foam::functionObjects::fieldExpression::foundObject
(
const word& name
)
{
if (fvMeshFunctionObject::foundObject<Type>(name))
{
return true;
}
else
{
Warning
<< " functionObjects::" << type() << " " << this->name()
<< " cannot find required object " << name << " of type "
<< Type::typeName << endl;
return false;
}
}
// ************************************************************************* //

View File

@ -191,18 +191,13 @@ bool Foam::functionObjects::fieldValues::volFieldValue::write()
const word& fieldName = fields_[i];
bool processed = false;
processed = processed || writeValues<scalar>(fieldName);
processed = processed || writeValues<vector>(fieldName);
processed = processed || writeValues<sphericalTensor>(fieldName);
processed = processed || writeValues<symmTensor>(fieldName);
processed = processed || writeValues<tensor>(fieldName);
#define processType(fieldType, none) \
processed = processed || writeValues<fieldType>(fieldName);
FOR_ALL_FIELD_TYPES(processType)
if (!processed)
{
WarningInFunction
<< "Requested field " << fieldName
<< " not found in database and not processed"
<< endl;
cannotFindObject(fieldName);
}
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -69,11 +69,9 @@ bool Foam::functionObjects::fieldsExpression::calcAllTypes(FOType& fo)
{
bool processed = false;
processed = processed || fo.template calcType<scalar>(fo);
processed = processed || fo.template calcType<vector>(fo);
processed = processed || fo.template calcType<sphericalTensor>(fo);
processed = processed || fo.template calcType<symmTensor>(fo);
processed = processed || fo.template calcType<tensor>(fo);
#define processType(fieldType, none) \
processed = processed || fo.template calcType<fieldType>(fo);
FOR_ALL_FIELD_TYPES(processType)
return processed;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2016-2019 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -73,6 +73,8 @@ bool Foam::functionObjects::flowType::calc()
}
else
{
cannotFindObject<volVectorField>(fieldName_);
return false;
}
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2013-2019 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2013-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -47,6 +47,11 @@ bool Foam::functionObjects::grad::calc()
processed = processed || calcGrad<scalar>();
processed = processed || calcGrad<vector>();
if (!processed)
{
cannotFindObject(fieldName_);
}
return processed;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2018-2019 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2018-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -78,6 +78,8 @@ bool Foam::functionObjects::log::calc()
}
else
{
cannotFindObject<volScalarField>(fieldName_);
return false;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2013-2019 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2013-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -44,11 +44,14 @@ bool Foam::functionObjects::mag::calc()
{
bool processed = false;
processed = processed || calcMag<scalar>();
processed = processed || calcMag<vector>();
processed = processed || calcMag<sphericalTensor>();
processed = processed || calcMag<symmTensor>();
processed = processed || calcMag<tensor>();
#define processType(fieldType, none) \
processed = processed || calcMag<fieldType>();
FOR_ALL_FIELD_TYPES(processType)
if (!processed)
{
cannotFindObject(fieldName_);
}
return processed;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2016-2019 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -44,11 +44,14 @@ bool Foam::functionObjects::magSqr::calc()
{
bool processed = false;
processed = processed || calcMagSqr<scalar>();
processed = processed || calcMagSqr<vector>();
processed = processed || calcMagSqr<sphericalTensor>();
processed = processed || calcMagSqr<symmTensor>();
processed = processed || calcMagSqr<tensor>();
#define processType(fieldType, none) \
processed = processed || calcMagSqr<fieldType>();
FOR_ALL_FIELD_TYPES(processType)
if (!processed)
{
cannotFindObject(fieldName_);
}
return processed;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2012-2019 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -175,6 +175,8 @@ bool Foam::functionObjects::pressure::calc()
}
else
{
cannotFindObject<volScalarField>(fieldName_);
return false;
}
}

View File

@ -44,11 +44,14 @@ bool Foam::functionObjects::randomise::calc()
{
bool processed = false;
processed = processed || calcRandomised<scalar>();
processed = processed || calcRandomised<vector>();
processed = processed || calcRandomised<sphericalTensor>();
processed = processed || calcRandomised<symmTensor>();
processed = processed || calcRandomised<tensor>();
#define processType(fieldType, none) \
processed = processed || calcRandomised<fieldType>();
FOR_ALL_FIELD_TYPES(processType)
if (!processed)
{
cannotFindObject(fieldName_);
}
return processed;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2018-2019 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2018-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -44,11 +44,14 @@ bool Foam::functionObjects::scale::calc()
{
bool processed = false;
processed = processed || calcScale<scalar>();
processed = processed || calcScale<vector>();
processed = processed || calcScale<sphericalTensor>();
processed = processed || calcScale<symmTensor>();
processed = processed || calcScale<tensor>();
#define processType(fieldType, none) \
processed = processed || calcScale<fieldType>();
FOR_ALL_FIELD_TYPES(processType)
if (!processed)
{
cannotFindObject(fieldName_);
}
return processed;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2016-2019 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -420,6 +420,8 @@ bool Foam::functionObjects::streamFunction::calc()
}
else
{
cannotFindObject<surfaceScalarField>(fieldName_);
return false;
}
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2014-2019 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2014-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -59,6 +59,8 @@ bool Foam::functionObjects::vorticity::calc()
}
else
{
cannotFindObject<volVectorField>(fieldName_);
return false;
}

View File

@ -17,7 +17,7 @@ FoamFile
application rhoCentralFoam;
startFrom latestTime;
startFrom startTime;
startTime 0;
@ -53,7 +53,7 @@ maxDeltaT 2e-8;
functions
{
#includeFunc wallHeatFlux
#includeFunc wallHeatFlux(log = true)
#includeFunc sample
}