mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: Added coefficient of variance (CoV) operation to fieldValues function objects
This commit is contained in:
@ -50,7 +50,7 @@ namespace Foam
|
|||||||
const char* Foam::NamedEnum
|
const char* Foam::NamedEnum
|
||||||
<
|
<
|
||||||
Foam::fieldValues::cellSource::operationType,
|
Foam::fieldValues::cellSource::operationType,
|
||||||
7
|
8
|
||||||
>::names[] =
|
>::names[] =
|
||||||
{
|
{
|
||||||
"none",
|
"none",
|
||||||
@ -59,7 +59,8 @@ namespace Foam
|
|||||||
"volIntegrate",
|
"volIntegrate",
|
||||||
"weightedAverage",
|
"weightedAverage",
|
||||||
"min",
|
"min",
|
||||||
"max"
|
"max",
|
||||||
|
"CoV"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,7 +68,7 @@ namespace Foam
|
|||||||
const Foam::NamedEnum<Foam::fieldValues::cellSource::sourceType, 2>
|
const Foam::NamedEnum<Foam::fieldValues::cellSource::sourceType, 2>
|
||||||
Foam::fieldValues::cellSource::sourceTypeNames_;
|
Foam::fieldValues::cellSource::sourceTypeNames_;
|
||||||
|
|
||||||
const Foam::NamedEnum<Foam::fieldValues::cellSource::operationType, 7>
|
const Foam::NamedEnum<Foam::fieldValues::cellSource::operationType, 8>
|
||||||
Foam::fieldValues::cellSource::operationTypeNames_;
|
Foam::fieldValues::cellSource::operationTypeNames_;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -52,6 +52,7 @@ Description
|
|||||||
- volAverage
|
- volAverage
|
||||||
- volIntegrate
|
- volIntegrate
|
||||||
- weightedAverage
|
- weightedAverage
|
||||||
|
- CoV (Coefficient of variation: standard deviation/mean)
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
cellSource.C
|
cellSource.C
|
||||||
@ -106,11 +107,12 @@ public:
|
|||||||
opVolIntegrate,
|
opVolIntegrate,
|
||||||
opWeightedAverage,
|
opWeightedAverage,
|
||||||
opMin,
|
opMin,
|
||||||
opMax
|
opMax,
|
||||||
|
opCoV
|
||||||
};
|
};
|
||||||
|
|
||||||
//- Operation type names
|
//- Operation type names
|
||||||
static const NamedEnum<operationType, 7> operationTypeNames_;
|
static const NamedEnum<operationType, 8> operationTypeNames_;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@ -115,6 +115,23 @@ Type Foam::fieldValues::cellSource::processValues
|
|||||||
result = max(values);
|
result = max(values);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case opCoV:
|
||||||
|
{
|
||||||
|
Type meanValue = sum(values*V)/sum(V);
|
||||||
|
|
||||||
|
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(V*sqr(vals - mean))/(V.size()*sum(V)))/mean;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
// Do nothing
|
// Do nothing
|
||||||
|
|||||||
@ -53,7 +53,7 @@ namespace Foam
|
|||||||
const char* Foam::NamedEnum
|
const char* Foam::NamedEnum
|
||||||
<
|
<
|
||||||
Foam::fieldValues::faceSource::operationType,
|
Foam::fieldValues::faceSource::operationType,
|
||||||
7
|
8
|
||||||
>::names[] =
|
>::names[] =
|
||||||
{
|
{
|
||||||
"none",
|
"none",
|
||||||
@ -62,7 +62,8 @@ namespace Foam
|
|||||||
"areaIntegrate",
|
"areaIntegrate",
|
||||||
"weightedAverage",
|
"weightedAverage",
|
||||||
"min",
|
"min",
|
||||||
"max"
|
"max",
|
||||||
|
"CoV"
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -71,7 +72,7 @@ namespace Foam
|
|||||||
const Foam::NamedEnum<Foam::fieldValues::faceSource::sourceType, 3>
|
const Foam::NamedEnum<Foam::fieldValues::faceSource::sourceType, 3>
|
||||||
Foam::fieldValues::faceSource::sourceTypeNames_;
|
Foam::fieldValues::faceSource::sourceTypeNames_;
|
||||||
|
|
||||||
const Foam::NamedEnum<Foam::fieldValues::faceSource::operationType, 7>
|
const Foam::NamedEnum<Foam::fieldValues::faceSource::operationType, 8>
|
||||||
Foam::fieldValues::faceSource::operationTypeNames_;
|
Foam::fieldValues::faceSource::operationTypeNames_;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -62,6 +62,7 @@ Description
|
|||||||
- weightedAverage
|
- weightedAverage
|
||||||
- min
|
- min
|
||||||
- max
|
- max
|
||||||
|
- CoV (Coefficient of variation: standard deviation/mean)
|
||||||
|
|
||||||
Notes:
|
Notes:
|
||||||
- faces on empty patches get ignored
|
- faces on empty patches get ignored
|
||||||
@ -132,11 +133,12 @@ public:
|
|||||||
opAreaIntegrate,
|
opAreaIntegrate,
|
||||||
opWeightedAverage,
|
opWeightedAverage,
|
||||||
opMin,
|
opMin,
|
||||||
opMax
|
opMax,
|
||||||
|
opCoV
|
||||||
};
|
};
|
||||||
|
|
||||||
//- Operation type names
|
//- Operation type names
|
||||||
static const NamedEnum<operationType, 7> operationTypeNames_;
|
static const NamedEnum<operationType, 8> operationTypeNames_;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@ -134,6 +134,25 @@ Type Foam::fieldValues::faceSource::processValues
|
|||||||
result = max(values);
|
result = max(values);
|
||||||
break;
|
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:
|
default:
|
||||||
{
|
{
|
||||||
// Do nothing
|
// Do nothing
|
||||||
|
|||||||
Reference in New Issue
Block a user