functionObjects::Q: Result field named "Q" if the field is "U" otherwise "Q(<fieldName>)"

This commit is contained in:
Henry Weller
2016-05-26 15:32:31 +01:00
parent 9d71c18fcf
commit 712fba33e3
3 changed files with 16 additions and 3 deletions

View File

@ -34,6 +34,7 @@ histogram/histogram.C
fieldExpression/fieldExpression.C fieldExpression/fieldExpression.C
components/components.C components/components.C
randomise/randomise.C
div/div.C div/div.C
grad/grad.C grad/grad.C
mag/mag.C mag/mag.C

View File

@ -77,8 +77,20 @@ Foam::functionObjects::Q::Q
const dictionary& dict const dictionary& dict
) )
: :
fieldExpression(name, runTime, dict, "U", "Q") fieldExpression(name, runTime, dict, "U")
{} {
if (resultName_.empty())
{
if (fieldName_ != "U")
{
resultName_ = "Q(" + fieldName_ + ')';
}
else
{
resultName_ = 'Q';
}
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //

View File

@ -77,7 +77,7 @@ bool Foam::functionObjects::fieldExpression::read(const dictionary& dict)
{ {
fvMeshFunctionObject::read(dict); fvMeshFunctionObject::read(dict);
if (fieldName_ == word::null || dict.found("field")) if (fieldName_.empty() || dict.found("field"))
{ {
dict.lookup("field") >> fieldName_; dict.lookup("field") >> fieldName_;
} }