ENH: Added coefficient of variance (CoV) operation to fieldValues function objects

This commit is contained in:
andy
2011-11-21 14:00:18 +00:00
parent 9dd55c02cb
commit 49b0676573
6 changed files with 52 additions and 10 deletions

View File

@ -134,6 +134,25 @@ Type Foam::fieldValues::faceSource::processValues
result = max(values);
break;
}
case opCoV:
{
Type meanValue = sum(values*magSf)/sum(magSf);
const label nComp = pTraits<Type>::nComponents;
for (direction d=0; d<nComp; ++d)
{
scalarField vals(values.component(d));
scalar mean = component(meanValue, d);
scalar& res = setComponent(result, d);
res =
sqrt(sum(magSf*sqr(vals - mean))/(magSf.size()*sum(magSf)))
/mean;
}
break;
}
default:
{
// Do nothing