Commit 89c21888 authored by Mark Olesen's avatar Mark Olesen
Browse files

ENH: 'mag' postOperation returns scalar (#1622)

parent c589d1c9
......@@ -403,20 +403,6 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::writeValues
switch (postOperation_)
{
case postOpNone:
{
break;
}
case postOpMag:
{
// mag: component-wise - does not change the type
for (direction d=0; d < pTraits<Type>::nComponents; ++d)
{
setComponent(result, d)
= mag(component(result, d));
}
break;
}
case postOpSqrt:
{
// sqrt: component-wise - does not change the type
......@@ -427,6 +413,10 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::writeValues
}
break;
}
default:
{
break;
}
}
// Write state/results information
......@@ -453,13 +443,30 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::writeValues
<< " of " << fieldName << " = ";
// Operation tagged that it always returns scalar?
const bool alwaysScalar(operation_ & typeScalar);
// Operation or post-operation returns scalar?
scalar sresult{0};
bool alwaysScalar(operation_ & typeScalar);
if (alwaysScalar)
{
const scalar sresult = component(result, 0);
sresult = component(result, 0);
if (postOperation_ == postOpMag)
{
sresult = mag(sresult);
}
}
else if (postOperation_ == postOpMag)
{
sresult = mag(result);
alwaysScalar = true;
}
if (alwaysScalar)
{
file()<< tab << sresult;
Log << sresult << endl;
......
......@@ -239,20 +239,6 @@ bool Foam::functionObjects::fieldValues::volFieldValue::writeValues
switch (postOperation_)
{
case postOpNone:
{
break;
}
case postOpMag:
{
// mag: component-wise - does not change the type
for (direction d=0; d < pTraits<Type>::nComponents; ++d)
{
setComponent(result, d)
= mag(component(result, d));
}
break;
}
case postOpSqrt:
{
// sqrt: component-wise - does not change the type
......@@ -263,6 +249,10 @@ bool Foam::functionObjects::fieldValues::volFieldValue::writeValues
}
break;
}
default:
{
break;
}
}
// Write state/results information
......@@ -293,13 +283,30 @@ bool Foam::functionObjects::fieldValues::volFieldValue::writeValues
<< " of " << fieldName << " = ";
// Operation tagged that it always returns scalar?
const bool alwaysScalar(operation_ & typeScalar);
// Operation or post-operation returns scalar?
scalar sresult{0};
bool alwaysScalar(operation_ & typeScalar);
if (alwaysScalar)
{
const scalar sresult = component(result, 0);
sresult = component(result, 0);
if (postOperation_ == postOpMag)
{
sresult = mag(sresult);
}
}
else if (postOperation_ == postOpMag)
{
sresult = mag(result);
alwaysScalar = true;
}
if (alwaysScalar)
{
file()<< tab << sresult;
Log << sresult << endl;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment