mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: 'mag' postOperation returns scalar (#1622)
This commit is contained in:
@ -403,20 +403,6 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::writeValues
|
|||||||
|
|
||||||
switch (postOperation_)
|
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:
|
case postOpSqrt:
|
||||||
{
|
{
|
||||||
// sqrt: component-wise - does not change the type
|
// sqrt: component-wise - does not change the type
|
||||||
@ -427,6 +413,10 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::writeValues
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write state/results information
|
// Write state/results information
|
||||||
@ -453,13 +443,30 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::writeValues
|
|||||||
<< " of " << fieldName << " = ";
|
<< " of " << fieldName << " = ";
|
||||||
|
|
||||||
|
|
||||||
// Operation tagged that it always returns scalar?
|
// Operation or post-operation returns scalar?
|
||||||
const bool alwaysScalar(operation_ & typeScalar);
|
|
||||||
|
scalar sresult{0};
|
||||||
|
|
||||||
|
bool alwaysScalar(operation_ & typeScalar);
|
||||||
|
|
||||||
if (alwaysScalar)
|
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;
|
file()<< tab << sresult;
|
||||||
|
|
||||||
Log << sresult << endl;
|
Log << sresult << endl;
|
||||||
|
|||||||
@ -239,20 +239,6 @@ bool Foam::functionObjects::fieldValues::volFieldValue::writeValues
|
|||||||
|
|
||||||
switch (postOperation_)
|
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:
|
case postOpSqrt:
|
||||||
{
|
{
|
||||||
// sqrt: component-wise - does not change the type
|
// sqrt: component-wise - does not change the type
|
||||||
@ -263,6 +249,10 @@ bool Foam::functionObjects::fieldValues::volFieldValue::writeValues
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write state/results information
|
// Write state/results information
|
||||||
@ -293,13 +283,30 @@ bool Foam::functionObjects::fieldValues::volFieldValue::writeValues
|
|||||||
<< " of " << fieldName << " = ";
|
<< " of " << fieldName << " = ";
|
||||||
|
|
||||||
|
|
||||||
// Operation tagged that it always returns scalar?
|
// Operation or post-operation returns scalar?
|
||||||
const bool alwaysScalar(operation_ & typeScalar);
|
|
||||||
|
scalar sresult{0};
|
||||||
|
|
||||||
|
bool alwaysScalar(operation_ & typeScalar);
|
||||||
|
|
||||||
if (alwaysScalar)
|
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;
|
file()<< tab << sresult;
|
||||||
|
|
||||||
Log << sresult << endl;
|
Log << sresult << endl;
|
||||||
|
|||||||
Reference in New Issue
Block a user