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

@ -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;
}

View File

@ -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