functionObjects::fieldExpression: Rationalised setting the field and result names
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2013-2018 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2013-2019 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -112,9 +112,8 @@ Foam::functionObjects::CourantNo::CourantNo
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fieldExpression(name, runTime, dict, "phi")
|
||||
fieldExpression(name, runTime, dict, "Co", "phi")
|
||||
{
|
||||
setResultName("Co", "phi");
|
||||
read(dict);
|
||||
}
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2013-2018 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2013-2019 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -83,10 +83,8 @@ Foam::functionObjects::Lambda2::Lambda2
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fieldExpression(name, runTime, dict, "U")
|
||||
{
|
||||
setResultName(typeName, "U");
|
||||
}
|
||||
fieldExpression(name, runTime, dict, typeName, "U")
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -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-2019 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -82,10 +82,8 @@ Foam::functionObjects::MachNo::MachNo
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fieldExpression(name, runTime, dict, "U")
|
||||
{
|
||||
setResultName("Ma", "U");
|
||||
}
|
||||
fieldExpression(name, runTime, dict, "Ma", "U")
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2013-2018 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2013-2019 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -90,10 +90,8 @@ Foam::functionObjects::PecletNo::PecletNo
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fieldExpression(name, runTime, dict, "phi")
|
||||
{
|
||||
setResultName("Pe", "phi");
|
||||
}
|
||||
fieldExpression(name, runTime, dict, "Pe", "phi")
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2013-2018 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2013-2019 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -77,10 +77,8 @@ Foam::functionObjects::Q::Q
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fieldExpression(name, runTime, dict, "U")
|
||||
{
|
||||
setResultName(typeName, "U");
|
||||
}
|
||||
fieldExpression(name, runTime, dict, typeName, "U")
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2013-2018 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2013-2019 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -60,7 +60,7 @@ Foam::functionObjects::blendingFactor::blendingFactor
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fieldExpression(name, runTime, dict)
|
||||
fieldExpression(name, runTime, dict, typeName)
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
@ -76,8 +76,6 @@ Foam::functionObjects::blendingFactor::~blendingFactor()
|
||||
|
||||
bool Foam::functionObjects::blendingFactor::read(const dictionary& dict)
|
||||
{
|
||||
fieldExpression::read(dict);
|
||||
|
||||
phiName_ = dict.lookupOrDefault<word>("phi", "phi");
|
||||
|
||||
resultName_ = "blendingFactor:" + fieldName_;
|
||||
|
||||
@ -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-2019 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -62,10 +62,8 @@ Foam::functionObjects::components::components
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fieldExpression(name, runTime, dict)
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
fieldExpression(name, runTime, dict, typeName)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -72,11 +72,8 @@ Foam::functionObjects::ddt::ddt
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fieldExpression(name, runTime, dict)
|
||||
{
|
||||
setResultName(typeName);
|
||||
read(dict);
|
||||
}
|
||||
fieldExpression(name, runTime, dict, typeName)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -62,10 +62,8 @@ Foam::functionObjects::div::div
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fieldExpression(name, runTime, dict)
|
||||
{
|
||||
setResultName(typeName);
|
||||
}
|
||||
fieldExpression(name, runTime, dict, typeName)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -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-2019 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -75,10 +75,8 @@ Foam::functionObjects::enstrophy::enstrophy
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fieldExpression(name, runTime, dict, "U")
|
||||
{
|
||||
setResultName(typeName, "U");
|
||||
}
|
||||
fieldExpression(name, runTime, dict, typeName, "U")
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -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 * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::fieldExpression::fieldExpression
|
||||
@ -66,16 +44,21 @@ Foam::functionObjects::fieldExpression::fieldExpression
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict,
|
||||
const word& fieldName,
|
||||
const word& resultName
|
||||
const word& functionName,
|
||||
const word& defaultFieldName
|
||||
)
|
||||
:
|
||||
fvMeshFunctionObject(name, runTime, dict),
|
||||
fieldName_(fieldName),
|
||||
resultName_(resultName)
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
fieldName_(dict.lookupOrDefault("field", defaultFieldName)),
|
||||
resultName_
|
||||
(
|
||||
dict.found("result")
|
||||
? dict.lookup("result")
|
||||
: (defaultFieldName.empty() || fieldName_ != defaultFieldName)
|
||||
? word(functionName + '(' + fieldName_ + ')')
|
||||
: functionName
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
@ -88,18 +71,6 @@ Foam::functionObjects::fieldExpression::~fieldExpression()
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@ -70,12 +70,6 @@ protected:
|
||||
|
||||
virtual bool calc() = 0;
|
||||
|
||||
void setResultName
|
||||
(
|
||||
const word& functionName,
|
||||
const word& defaultFieldName = word::null
|
||||
);
|
||||
|
||||
template<class Type>
|
||||
bool foundObject(const word& name);
|
||||
|
||||
@ -94,8 +88,8 @@ public:
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict,
|
||||
const word& fieldName = word::null,
|
||||
const word& resultName = word::null
|
||||
const word& functionName,
|
||||
const word& defaultFieldName = word::null
|
||||
);
|
||||
|
||||
//- Disallow default bitwise copy construction
|
||||
|
||||
@ -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-2019 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -87,10 +87,8 @@ Foam::functionObjects::flowType::flowType
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fieldExpression(name, runTime, dict, "U")
|
||||
{
|
||||
setResultName(typeName, "U");
|
||||
}
|
||||
fieldExpression(name, runTime, dict, typeName, "U")
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -60,11 +60,8 @@ Foam::functionObjects::grad::grad
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fieldExpression(name, runTime, dict)
|
||||
{
|
||||
setResultName(typeName);
|
||||
read(dict);
|
||||
}
|
||||
fieldExpression(name, runTime, dict, typeName)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -94,12 +94,11 @@ Foam::functionObjects::log::log
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fieldExpression(name, runTime, dict),
|
||||
fieldExpression(name, runTime, dict, typeName),
|
||||
clip_(false),
|
||||
clipValue_(0),
|
||||
checkDimensions_(true)
|
||||
{
|
||||
setResultName(typeName);
|
||||
read(dict);
|
||||
}
|
||||
|
||||
@ -114,13 +113,6 @@ Foam::functionObjects::log::~log()
|
||||
|
||||
bool Foam::functionObjects::log::read(const dictionary& dict)
|
||||
{
|
||||
fieldExpression::read(dict);
|
||||
|
||||
if (resultName_.empty())
|
||||
{
|
||||
resultName_ = "log(" + fieldName_ + ")";
|
||||
}
|
||||
|
||||
if (dict.found("clip"))
|
||||
{
|
||||
clip_ = true;
|
||||
|
||||
@ -63,11 +63,8 @@ Foam::functionObjects::mag::mag
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fieldExpression(name, runTime, dict)
|
||||
{
|
||||
setResultName(typeName);
|
||||
read(dict);
|
||||
}
|
||||
fieldExpression(name, runTime, dict, typeName)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -63,11 +63,8 @@ Foam::functionObjects::magSqr::magSqr
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fieldExpression(name, runTime, dict)
|
||||
{
|
||||
setResultName(typeName);
|
||||
read(dict);
|
||||
}
|
||||
fieldExpression(name, runTime, dict, typeName)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -189,7 +189,7 @@ Foam::functionObjects::pressure::pressure
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fieldExpression(name, runTime, dict, "p"),
|
||||
fieldExpression(name, runTime, dict, typeName, "p"),
|
||||
UName_("U"),
|
||||
rhoName_("rho"),
|
||||
calcTotal_(false),
|
||||
|
||||
@ -63,9 +63,8 @@ Foam::functionObjects::randomise::randomise
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fieldExpression(name, runTime, dict)
|
||||
fieldExpression(name, runTime, dict, typeName)
|
||||
{
|
||||
setResultName(typeName);
|
||||
read(dict);
|
||||
}
|
||||
|
||||
@ -80,8 +79,6 @@ Foam::functionObjects::randomise::~randomise()
|
||||
|
||||
bool Foam::functionObjects::randomise::read(const dictionary& dict)
|
||||
{
|
||||
fieldExpression::read(dict);
|
||||
|
||||
dict.lookup("magPerturbation") >> magPerturbation_;
|
||||
|
||||
return true;
|
||||
|
||||
@ -63,10 +63,9 @@ Foam::functionObjects::scale::scale
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fieldExpression(name, runTime, dict),
|
||||
fieldExpression(name, runTime, dict, typeName),
|
||||
scale_(0)
|
||||
{
|
||||
setResultName(typeName);
|
||||
read(dict);
|
||||
}
|
||||
|
||||
@ -81,7 +80,6 @@ Foam::functionObjects::scale::~scale()
|
||||
|
||||
bool Foam::functionObjects::scale::read(const dictionary& dict)
|
||||
{
|
||||
fieldExpression::read(dict);
|
||||
dict.lookup("scale") >> scale_;
|
||||
|
||||
return true;
|
||||
|
||||
@ -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-2019 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -434,10 +434,8 @@ Foam::functionObjects::streamFunction::streamFunction
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fieldExpression(name, runTime, dict, "phi")
|
||||
fieldExpression(name, runTime, dict, typeName, "phi")
|
||||
{
|
||||
setResultName("streamFunction", "phi");
|
||||
|
||||
label nD = mesh_.nGeometricD();
|
||||
|
||||
if (nD != 2)
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2014-2018 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2014-2019 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -75,10 +75,8 @@ Foam::functionObjects::vorticity::vorticity
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fieldExpression(name, runTime, dict, "U")
|
||||
{
|
||||
setResultName(typeName, "U");
|
||||
}
|
||||
fieldExpression(name, runTime, dict, typeName, "U")
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Reference in New Issue
Block a user