ENH: Re-inistated weighted-average fieldAverage usage

This commit is contained in:
andy
2012-03-02 17:13:46 +00:00
parent edccfce28e
commit 04033b6968
6 changed files with 35 additions and 12 deletions

View File

@ -50,12 +50,13 @@ namespace Foam
const char* Foam::NamedEnum
<
Foam::fieldValues::cellSource::operationType,
8
9
>::names[] =
{
"none",
"sum",
"average",
"weightedAverage",
"volAverage",
"volIntegrate",
"min",
@ -68,7 +69,7 @@ namespace Foam
const Foam::NamedEnum<Foam::fieldValues::cellSource::sourceType, 2>
Foam::fieldValues::cellSource::sourceTypeNames_;
const Foam::NamedEnum<Foam::fieldValues::cellSource::operationType, 8>
const Foam::NamedEnum<Foam::fieldValues::cellSource::operationType, 9>
Foam::fieldValues::cellSource::operationTypeNames_;

View File

@ -51,9 +51,12 @@ Description
- none
- sum
- average
- weightedAverage
- volAverage
- volIntegrate
- CoV (Coefficient of variation: standard deviation/mean)
- min
- max
SourceFiles
cellSource.C
@ -105,6 +108,7 @@ public:
opNone,
opSum,
opAverage,
opWeightedAverage,
opVolAverage,
opVolIntegrate,
opMin,
@ -113,7 +117,7 @@ public:
};
//- Operation type names
static const NamedEnum<operationType, 8> operationTypeNames_;
static const NamedEnum<operationType, 9> operationTypeNames_;
private:
@ -169,7 +173,8 @@ protected:
Type processValues
(
const Field<Type>& values,
const scalarField& V
const scalarField& V,
const scalarField& weightField
) const;
//- Output file header information

View File

@ -78,7 +78,8 @@ template<class Type>
Type Foam::fieldValues::cellSource::processValues
(
const Field<Type>& values,
const scalarField& V
const scalarField& V,
const scalarField& weightField
) const
{
Type result = pTraits<Type>::zero;
@ -94,6 +95,11 @@ Type Foam::fieldValues::cellSource::processValues
result = sum(values)/values.size();
break;
}
case opWeightedAverage:
{
result = sum(values)/sum(weightField);
break;
}
case opVolAverage:
{
result = sum(values*V)/sum(V);
@ -169,7 +175,7 @@ bool Foam::fieldValues::cellSource::writeValues(const word& fieldName)
if (Pstream::master())
{
Type result = processValues(values, V);
Type result = processValues(values, V, weightField);
if (valueOutput_)
{

View File

@ -53,12 +53,13 @@ namespace Foam
const char* Foam::NamedEnum
<
Foam::fieldValues::faceSource::operationType,
8
9
>::names[] =
{
"none",
"sum",
"average",
"weightedAverage",
"areaAverage",
"areaIntegrate",
"min",
@ -72,7 +73,7 @@ namespace Foam
const Foam::NamedEnum<Foam::fieldValues::faceSource::sourceType, 3>
Foam::fieldValues::faceSource::sourceTypeNames_;
const Foam::NamedEnum<Foam::fieldValues::faceSource::operationType, 8>
const Foam::NamedEnum<Foam::fieldValues::faceSource::operationType, 9>
Foam::fieldValues::faceSource::operationTypeNames_;

View File

@ -59,6 +59,7 @@ Description
- none
- sum
- average
- weightedAverage
- areaAverage
- areaIntegrate
- min
@ -132,6 +133,7 @@ public:
opNone,
opSum,
opAverage,
opWeightedAverage,
opAreaAverage,
opAreaIntegrate,
opMin,
@ -140,7 +142,7 @@ public:
};
//- Operation type names
static const NamedEnum<operationType, 8> operationTypeNames_;
static const NamedEnum<operationType, 9> operationTypeNames_;
private:
@ -215,7 +217,8 @@ protected:
Type processValues
(
const Field<Type>& values,
const scalarField& magSf
const scalarField& magSf,
const scalarField& weightField
) const;
//- Output file header information

View File

@ -97,7 +97,9 @@ template<class Type>
Type Foam::fieldValues::faceSource::processValues
(
const Field<Type>& values,
const scalarField& magSf
const scalarField& magSf,
const scalarField& weightField
) const
{
Type result = pTraits<Type>::zero;
@ -113,6 +115,11 @@ Type Foam::fieldValues::faceSource::processValues
result = sum(values)/values.size();
break;
}
case opWeightedAverage:
{
result = sum(values)/sum(weightField);
break;
}
case opAreaAverage:
{
result = sum(values*magSf)/sum(magSf);
@ -203,7 +210,7 @@ bool Foam::fieldValues::faceSource::writeValues(const word& fieldName)
if (Pstream::master())
{
Type result = processValues(values, magSf);
Type result = processValues(values, magSf, weightField);
if (valueOutput_)
{