functionObjects::fieldExpression: Rationalised setting the field and result names

This commit is contained in:
Henry Weller
2019-11-29 11:22:01 +00:00
parent ffb65bcee5
commit 8a6800abfe
22 changed files with 58 additions and 141 deletions

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2013-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2013-2019 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -112,9 +112,8 @@ Foam::functionObjects::CourantNo::CourantNo
const dictionary& dict const dictionary& dict
) )
: :
fieldExpression(name, runTime, dict, "phi") fieldExpression(name, runTime, dict, "Co", "phi")
{ {
setResultName("Co", "phi");
read(dict); read(dict);
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2013-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2013-2019 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -83,10 +83,8 @@ Foam::functionObjects::Lambda2::Lambda2
const dictionary& dict const dictionary& dict
) )
: :
fieldExpression(name, runTime, dict, "U") fieldExpression(name, runTime, dict, typeName, "U")
{ {}
setResultName(typeName, "U");
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2016-2019 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -82,10 +82,8 @@ Foam::functionObjects::MachNo::MachNo
const dictionary& dict const dictionary& dict
) )
: :
fieldExpression(name, runTime, dict, "U") fieldExpression(name, runTime, dict, "Ma", "U")
{ {}
setResultName("Ma", "U");
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2013-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2013-2019 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -90,10 +90,8 @@ Foam::functionObjects::PecletNo::PecletNo
const dictionary& dict const dictionary& dict
) )
: :
fieldExpression(name, runTime, dict, "phi") fieldExpression(name, runTime, dict, "Pe", "phi")
{ {}
setResultName("Pe", "phi");
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2013-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2013-2019 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -77,10 +77,8 @@ Foam::functionObjects::Q::Q
const dictionary& dict const dictionary& dict
) )
: :
fieldExpression(name, runTime, dict, "U") fieldExpression(name, runTime, dict, typeName, "U")
{ {}
setResultName(typeName, "U");
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2013-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2013-2019 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -60,7 +60,7 @@ Foam::functionObjects::blendingFactor::blendingFactor
const dictionary& dict const dictionary& dict
) )
: :
fieldExpression(name, runTime, dict) fieldExpression(name, runTime, dict, typeName)
{ {
read(dict); read(dict);
} }
@ -76,8 +76,6 @@ Foam::functionObjects::blendingFactor::~blendingFactor()
bool Foam::functionObjects::blendingFactor::read(const dictionary& dict) bool Foam::functionObjects::blendingFactor::read(const dictionary& dict)
{ {
fieldExpression::read(dict);
phiName_ = dict.lookupOrDefault<word>("phi", "phi"); phiName_ = dict.lookupOrDefault<word>("phi", "phi");
resultName_ = "blendingFactor:" + fieldName_; resultName_ = "blendingFactor:" + fieldName_;

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2016-2019 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -62,10 +62,8 @@ Foam::functionObjects::components::components
const dictionary& dict const dictionary& dict
) )
: :
fieldExpression(name, runTime, dict) fieldExpression(name, runTime, dict, typeName)
{ {}
read(dict);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //

View File

@ -72,11 +72,8 @@ Foam::functionObjects::ddt::ddt
const dictionary& dict const dictionary& dict
) )
: :
fieldExpression(name, runTime, dict) fieldExpression(name, runTime, dict, typeName)
{ {}
setResultName(typeName);
read(dict);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //

View File

@ -62,10 +62,8 @@ Foam::functionObjects::div::div
const dictionary& dict const dictionary& dict
) )
: :
fieldExpression(name, runTime, dict) fieldExpression(name, runTime, dict, typeName)
{ {}
setResultName(typeName);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2016-2019 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -75,10 +75,8 @@ Foam::functionObjects::enstrophy::enstrophy
const dictionary& dict const dictionary& dict
) )
: :
fieldExpression(name, runTime, dict, "U") fieldExpression(name, runTime, dict, typeName, "U")
{ {}
setResultName(typeName, "U");
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //

View File

@ -37,28 +37,6 @@ namespace functionObjects
} }
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
void Foam::functionObjects::fieldExpression::setResultName
(
const word& functionName,
const word& defaultFieldName
)
{
if (resultName_.empty())
{
if (defaultFieldName.empty() || fieldName_ != defaultFieldName)
{
resultName_ = functionName + '(' + fieldName_ + ')';
}
else
{
resultName_ = functionName;
}
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::functionObjects::fieldExpression::fieldExpression Foam::functionObjects::fieldExpression::fieldExpression
@ -66,16 +44,21 @@ Foam::functionObjects::fieldExpression::fieldExpression
const word& name, const word& name,
const Time& runTime, const Time& runTime,
const dictionary& dict, const dictionary& dict,
const word& fieldName, const word& functionName,
const word& resultName const word& defaultFieldName
) )
: :
fvMeshFunctionObject(name, runTime, dict), fvMeshFunctionObject(name, runTime, dict),
fieldName_(fieldName), fieldName_(dict.lookupOrDefault("field", defaultFieldName)),
resultName_(resultName) resultName_
{ (
read(dict); dict.found("result")
} ? dict.lookup("result")
: (defaultFieldName.empty() || fieldName_ != defaultFieldName)
? word(functionName + '(' + fieldName_ + ')')
: functionName
)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
@ -88,18 +71,6 @@ Foam::functionObjects::fieldExpression::~fieldExpression()
bool Foam::functionObjects::fieldExpression::read(const dictionary& dict) bool Foam::functionObjects::fieldExpression::read(const dictionary& dict)
{ {
fvMeshFunctionObject::read(dict);
if (fieldName_.empty() || dict.found("field"))
{
dict.lookup("field") >> fieldName_;
}
if (dict.found("result"))
{
dict.lookup("result") >> resultName_;
}
return true; return true;
} }

View File

@ -70,12 +70,6 @@ protected:
virtual bool calc() = 0; virtual bool calc() = 0;
void setResultName
(
const word& functionName,
const word& defaultFieldName = word::null
);
template<class Type> template<class Type>
bool foundObject(const word& name); bool foundObject(const word& name);
@ -94,8 +88,8 @@ public:
const word& name, const word& name,
const Time& runTime, const Time& runTime,
const dictionary& dict, const dictionary& dict,
const word& fieldName = word::null, const word& functionName,
const word& resultName = word::null const word& defaultFieldName = word::null
); );
//- Disallow default bitwise copy construction //- Disallow default bitwise copy construction

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2016-2019 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -87,10 +87,8 @@ Foam::functionObjects::flowType::flowType
const dictionary& dict const dictionary& dict
) )
: :
fieldExpression(name, runTime, dict, "U") fieldExpression(name, runTime, dict, typeName, "U")
{ {}
setResultName(typeName, "U");
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //

View File

@ -60,11 +60,8 @@ Foam::functionObjects::grad::grad
const dictionary& dict const dictionary& dict
) )
: :
fieldExpression(name, runTime, dict) fieldExpression(name, runTime, dict, typeName)
{ {}
setResultName(typeName);
read(dict);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //

View File

@ -94,12 +94,11 @@ Foam::functionObjects::log::log
const dictionary& dict const dictionary& dict
) )
: :
fieldExpression(name, runTime, dict), fieldExpression(name, runTime, dict, typeName),
clip_(false), clip_(false),
clipValue_(0), clipValue_(0),
checkDimensions_(true) checkDimensions_(true)
{ {
setResultName(typeName);
read(dict); read(dict);
} }
@ -114,13 +113,6 @@ Foam::functionObjects::log::~log()
bool Foam::functionObjects::log::read(const dictionary& dict) bool Foam::functionObjects::log::read(const dictionary& dict)
{ {
fieldExpression::read(dict);
if (resultName_.empty())
{
resultName_ = "log(" + fieldName_ + ")";
}
if (dict.found("clip")) if (dict.found("clip"))
{ {
clip_ = true; clip_ = true;

View File

@ -63,11 +63,8 @@ Foam::functionObjects::mag::mag
const dictionary& dict const dictionary& dict
) )
: :
fieldExpression(name, runTime, dict) fieldExpression(name, runTime, dict, typeName)
{ {}
setResultName(typeName);
read(dict);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //

View File

@ -63,11 +63,8 @@ Foam::functionObjects::magSqr::magSqr
const dictionary& dict const dictionary& dict
) )
: :
fieldExpression(name, runTime, dict) fieldExpression(name, runTime, dict, typeName)
{ {}
setResultName(typeName);
read(dict);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //

View File

@ -189,7 +189,7 @@ Foam::functionObjects::pressure::pressure
const dictionary& dict const dictionary& dict
) )
: :
fieldExpression(name, runTime, dict, "p"), fieldExpression(name, runTime, dict, typeName, "p"),
UName_("U"), UName_("U"),
rhoName_("rho"), rhoName_("rho"),
calcTotal_(false), calcTotal_(false),

View File

@ -63,9 +63,8 @@ Foam::functionObjects::randomise::randomise
const dictionary& dict const dictionary& dict
) )
: :
fieldExpression(name, runTime, dict) fieldExpression(name, runTime, dict, typeName)
{ {
setResultName(typeName);
read(dict); read(dict);
} }
@ -80,8 +79,6 @@ Foam::functionObjects::randomise::~randomise()
bool Foam::functionObjects::randomise::read(const dictionary& dict) bool Foam::functionObjects::randomise::read(const dictionary& dict)
{ {
fieldExpression::read(dict);
dict.lookup("magPerturbation") >> magPerturbation_; dict.lookup("magPerturbation") >> magPerturbation_;
return true; return true;

View File

@ -63,10 +63,9 @@ Foam::functionObjects::scale::scale
const dictionary& dict const dictionary& dict
) )
: :
fieldExpression(name, runTime, dict), fieldExpression(name, runTime, dict, typeName),
scale_(0) scale_(0)
{ {
setResultName(typeName);
read(dict); read(dict);
} }
@ -81,7 +80,6 @@ Foam::functionObjects::scale::~scale()
bool Foam::functionObjects::scale::read(const dictionary& dict) bool Foam::functionObjects::scale::read(const dictionary& dict)
{ {
fieldExpression::read(dict);
dict.lookup("scale") >> scale_; dict.lookup("scale") >> scale_;
return true; return true;

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2016-2019 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -434,10 +434,8 @@ Foam::functionObjects::streamFunction::streamFunction
const dictionary& dict const dictionary& dict
) )
: :
fieldExpression(name, runTime, dict, "phi") fieldExpression(name, runTime, dict, typeName, "phi")
{ {
setResultName("streamFunction", "phi");
label nD = mesh_.nGeometricD(); label nD = mesh_.nGeometricD();
if (nD != 2) if (nD != 2)

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2014-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2014-2019 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -75,10 +75,8 @@ Foam::functionObjects::vorticity::vorticity
const dictionary& dict const dictionary& dict
) )
: :
fieldExpression(name, runTime, dict, "U") fieldExpression(name, runTime, dict, typeName, "U")
{ {}
setResultName(typeName, "U");
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //