mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: return scalar for surface uniformity (#1363)
This commit is contained in:
committed by
Andrew Heather
parent
b8ccbbdf67
commit
d6d95c33bc
@ -229,8 +229,9 @@ public:
|
||||
enum operationVariant
|
||||
{
|
||||
typeBase = 0, //!< Base operation
|
||||
typeWeighted = 0x100, //!< Operation using weighting
|
||||
typeAbsolute = 0x200, //!< Operation using mag (eg, for weighting)
|
||||
typeScalar = 0x100, //!< Operation returns a scalar
|
||||
typeWeighted = 0x200, //!< Operation using weighting
|
||||
typeAbsolute = 0x400, //!< Operation using mag (eg, for weighting)
|
||||
};
|
||||
|
||||
//- Operation type enumeration
|
||||
@ -252,9 +253,17 @@ public:
|
||||
opAreaAverage, //!< Area average
|
||||
opAreaIntegrate, //!< Area integral
|
||||
opCoV, //!< Coefficient of variation
|
||||
opAreaNormalAverage, //!< Area average in normal direction
|
||||
opAreaNormalIntegrate, //!< Area integral in normal direction
|
||||
opUniformity, //!< Uniformity index
|
||||
|
||||
// Scalar return values
|
||||
|
||||
//! Area average in normal direction (output is always scalar)
|
||||
opAreaNormalAverage = typeScalar,
|
||||
|
||||
//! Area integral in normal direction (output is always scalar)
|
||||
opAreaNormalIntegrate,
|
||||
|
||||
//! Uniformity index (output is always scalar)
|
||||
opUniformity,
|
||||
|
||||
// Weighted variants
|
||||
|
||||
|
||||
@ -411,15 +411,13 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::writeValues
|
||||
// sqrt: component-wise - doesn't change the type
|
||||
for (direction d=0; d < pTraits<Type>::nComponents; ++d)
|
||||
{
|
||||
setComponent(result, d)
|
||||
= sqrt(mag(component(result, d)));
|
||||
setComponent(result, d)
|
||||
= sqrt(mag(component(result, d)));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
file()<< tab << result;
|
||||
|
||||
// Write state/results information
|
||||
word prefix, suffix;
|
||||
{
|
||||
@ -436,13 +434,34 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::writeValues
|
||||
suffix += ')';
|
||||
}
|
||||
|
||||
Log << " " << prefix << regionName_ << suffix
|
||||
<< " of " << fieldName
|
||||
<< " = " << result << endl;
|
||||
word resultName = prefix + regionName_ + ',' + fieldName + suffix;
|
||||
|
||||
// Write state/results information
|
||||
word resultName = prefix + regionName_ + ',' + fieldName + suffix;
|
||||
this->setResult(resultName, result);
|
||||
|
||||
Log << " " << prefix << regionName_ << suffix
|
||||
<< " of " << fieldName << " = ";
|
||||
|
||||
// Operation tagged that it always returns scalar?
|
||||
const bool alwaysScalar(operation_ & typeScalar);
|
||||
|
||||
if (alwaysScalar)
|
||||
{
|
||||
const scalar sresult = component(result, 0);
|
||||
|
||||
file()<< tab << sresult;
|
||||
|
||||
Log << sresult << endl;
|
||||
|
||||
this->setResult(resultName, sresult);
|
||||
}
|
||||
else
|
||||
{
|
||||
file()<< tab << result;
|
||||
|
||||
Log << result << endl;
|
||||
|
||||
this->setResult(resultName, result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -140,7 +140,7 @@ public:
|
||||
enum operationVariant
|
||||
{
|
||||
typeBase = 0, //!< Base operation
|
||||
typeWeighted = 0x100, //!< Operation using weighting
|
||||
typeWeighted = 0x200, //!< Operation using weighting
|
||||
};
|
||||
|
||||
//- Operation type enumeration
|
||||
|
||||
@ -229,26 +229,30 @@ bool Foam::functionObjects::fieldValues::volFieldValue::writeValues
|
||||
}
|
||||
}
|
||||
|
||||
// Apply scale factor
|
||||
values *= scaleFactor_;
|
||||
|
||||
Type result = processValues(values, V, weightField);
|
||||
|
||||
file()<< tab << result;
|
||||
|
||||
Log << " " << operationTypeNames_[operation_]
|
||||
<< "(" << this->volRegion::regionName_ << ") of " << fieldName
|
||||
<< " = " << result << endl;
|
||||
|
||||
// Write state/results information
|
||||
const word& opName = operationTypeNames_[operation_];
|
||||
word outName = fieldName;
|
||||
if (this->volRegion::regionName_ != polyMesh::defaultRegion)
|
||||
if (operation_ != opNone)
|
||||
{
|
||||
outName = this->volRegion::regionName_ + ',' + outName;
|
||||
// Apply scale factor
|
||||
values *= scaleFactor_;
|
||||
|
||||
Type result = processValues(values, V, weightField);
|
||||
|
||||
// Write state/results information
|
||||
const word& opName = operationTypeNames_[operation_];
|
||||
word outName = fieldName;
|
||||
if (this->volRegion::regionName_ != polyMesh::defaultRegion)
|
||||
{
|
||||
outName = this->volRegion::regionName_ + ',' + outName;
|
||||
}
|
||||
word resultName = opName + '(' + outName + ')';
|
||||
|
||||
file()<< tab << result;
|
||||
|
||||
Log << " " << opName
|
||||
<< '(' << this->volRegion::regionName_ << ") of " << fieldName
|
||||
<< " = " << result << endl;
|
||||
|
||||
this->setResult(resultName, result);
|
||||
}
|
||||
word resultName = opName + '(' + outName + ')';
|
||||
this->setResult(resultName, result);
|
||||
}
|
||||
|
||||
return ok;
|
||||
|
||||
Reference in New Issue
Block a user