mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
cellSource: Added weightedVolAverage option
faceSource: Added weightedAreaAverage option Resolves bug-report http://www.openfoam.org/mantisbt/view.php?id=1769
This commit is contained in:
@ -41,7 +41,7 @@ namespace Foam
|
||||
|
||||
|
||||
template<>
|
||||
const char* NamedEnum<fieldValues::cellSource::operationType, 10>::names[] =
|
||||
const char* NamedEnum<fieldValues::cellSource::operationType, 11>::names[] =
|
||||
{
|
||||
"none",
|
||||
"sum",
|
||||
@ -49,6 +49,7 @@ namespace Foam
|
||||
"average",
|
||||
"weightedAverage",
|
||||
"volAverage",
|
||||
"weightedVolAverage",
|
||||
"volIntegrate",
|
||||
"min",
|
||||
"max",
|
||||
@ -66,7 +67,7 @@ namespace Foam
|
||||
const Foam::NamedEnum<Foam::fieldValues::cellSource::sourceType, 2>
|
||||
Foam::fieldValues::cellSource::sourceTypeNames_;
|
||||
|
||||
const Foam::NamedEnum<Foam::fieldValues::cellSource::operationType, 10>
|
||||
const Foam::NamedEnum<Foam::fieldValues::cellSource::operationType, 11>
|
||||
Foam::fieldValues::cellSource::operationTypeNames_;
|
||||
|
||||
|
||||
|
||||
@ -85,6 +85,7 @@ Description
|
||||
average | ensemble average
|
||||
weightedAverage | weighted average
|
||||
volAverage | volume weighted average
|
||||
weightedVolAverage | weighted volume average
|
||||
volIntegrate | volume integral
|
||||
min | minimum
|
||||
max | maximum
|
||||
@ -149,6 +150,7 @@ public:
|
||||
opAverage,
|
||||
opWeightedAverage,
|
||||
opVolAverage,
|
||||
opWeightedVolAverage,
|
||||
opVolIntegrate,
|
||||
opMin,
|
||||
opMax,
|
||||
@ -156,7 +158,7 @@ public:
|
||||
};
|
||||
|
||||
//- Operation type names
|
||||
static const NamedEnum<operationType, 10> operationTypeNames_;
|
||||
static const NamedEnum<operationType, 11> operationTypeNames_;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
@ -102,17 +102,22 @@ Type Foam::fieldValues::cellSource::processValues
|
||||
}
|
||||
case opWeightedAverage:
|
||||
{
|
||||
result = sum(values)/sum(weightField);
|
||||
result = sum(weightField*values)/sum(weightField);
|
||||
break;
|
||||
}
|
||||
case opVolAverage:
|
||||
{
|
||||
result = sum(values*V)/sum(V);
|
||||
result = sum(V*values)/sum(V);
|
||||
break;
|
||||
}
|
||||
case opWeightedVolAverage:
|
||||
{
|
||||
result = sum(weightField*V*values)/sum(weightField*V);
|
||||
break;
|
||||
}
|
||||
case opVolIntegrate:
|
||||
{
|
||||
result = sum(values*V);
|
||||
result = sum(V*values);
|
||||
break;
|
||||
}
|
||||
case opMin:
|
||||
@ -175,14 +180,11 @@ bool Foam::fieldValues::cellSource::writeValues(const word& fieldName)
|
||||
combineFields(V);
|
||||
combineFields(weightField);
|
||||
|
||||
// apply weight field
|
||||
values *= weightField;
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
Type result = processValues(values, V, weightField);
|
||||
|
||||
// add to result dictionary, over-writing any previous entry
|
||||
// Add to result dictionary, over-writing any previous entry
|
||||
resultDict_.add(fieldName, result, true);
|
||||
|
||||
if (valueOutput_)
|
||||
@ -198,7 +200,7 @@ bool Foam::fieldValues::cellSource::writeValues(const word& fieldName)
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
values
|
||||
weightField*values
|
||||
).write();
|
||||
}
|
||||
|
||||
|
||||
@ -48,7 +48,7 @@ namespace Foam
|
||||
|
||||
|
||||
template<>
|
||||
const char* NamedEnum<fieldValues::faceSource::operationType, 14>::names[] =
|
||||
const char* NamedEnum<fieldValues::faceSource::operationType, 15>::names[] =
|
||||
{
|
||||
"none",
|
||||
"sum",
|
||||
@ -58,6 +58,7 @@ namespace Foam
|
||||
"average",
|
||||
"weightedAverage",
|
||||
"areaAverage",
|
||||
"weightedAreaAverage",
|
||||
"areaIntegrate",
|
||||
"min",
|
||||
"max",
|
||||
@ -77,7 +78,7 @@ namespace Foam
|
||||
const Foam::NamedEnum<Foam::fieldValues::faceSource::sourceType, 3>
|
||||
Foam::fieldValues::faceSource::sourceTypeNames_;
|
||||
|
||||
const Foam::NamedEnum<Foam::fieldValues::faceSource::operationType, 14>
|
||||
const Foam::NamedEnum<Foam::fieldValues::faceSource::operationType, 15>
|
||||
Foam::fieldValues::faceSource::operationTypeNames_;
|
||||
|
||||
|
||||
|
||||
@ -97,6 +97,7 @@ Description
|
||||
average | ensemble average
|
||||
weightedAverage | weighted average
|
||||
areaAverage | area weighted average
|
||||
weightedAreaAverage | weighted area average
|
||||
areaIntegrate | area integral
|
||||
min | minimum
|
||||
max | maximum
|
||||
@ -190,6 +191,7 @@ public:
|
||||
opAverage,
|
||||
opWeightedAverage,
|
||||
opAreaAverage,
|
||||
opWeightedAreaAverage,
|
||||
opAreaIntegrate,
|
||||
opMin,
|
||||
opMax,
|
||||
@ -199,7 +201,7 @@ public:
|
||||
};
|
||||
|
||||
//- Operation type names
|
||||
static const NamedEnum<operationType, 14> operationTypeNames_;
|
||||
static const NamedEnum<operationType, 15> operationTypeNames_;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
@ -197,7 +197,7 @@ Type Foam::fieldValues::faceSource::processSameTypeValues
|
||||
{
|
||||
if (weightField.size())
|
||||
{
|
||||
result = sum(values)/sum(weightField);
|
||||
result = sum(weightField*values)/sum(weightField);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -209,14 +209,28 @@ Type Foam::fieldValues::faceSource::processSameTypeValues
|
||||
{
|
||||
const scalarField magSf(mag(Sf));
|
||||
|
||||
result = sum(values*magSf)/sum(magSf);
|
||||
result = sum(magSf*values)/sum(magSf);
|
||||
break;
|
||||
}
|
||||
case opWeightedAreaAverage:
|
||||
{
|
||||
const scalarField magSf(mag(Sf));
|
||||
|
||||
if (weightField.size())
|
||||
{
|
||||
result = sum(weightField*magSf*values)/sum(magSf*weightField);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = sum(magSf*values)/sum(magSf);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case opAreaIntegrate:
|
||||
{
|
||||
const scalarField magSf(mag(Sf));
|
||||
|
||||
result = sum(values*magSf);
|
||||
result = sum(magSf*values);
|
||||
break;
|
||||
}
|
||||
case opMin:
|
||||
@ -337,18 +351,14 @@ bool Foam::fieldValues::faceSource::writeValues
|
||||
}
|
||||
|
||||
|
||||
// apply scale factor and weight field
|
||||
// Apply scale factor
|
||||
values *= scaleFactor_;
|
||||
if (weightField.size())
|
||||
{
|
||||
values *= weightField;
|
||||
}
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
Type result = processValues(values, Sf, weightField);
|
||||
|
||||
// add to result dictionary, over-writing any previous entry
|
||||
// Add to result dictionary, over-writing any previous entry
|
||||
resultDict_.add(fieldName, result, true);
|
||||
|
||||
file()<< tab << result;
|
||||
|
||||
Reference in New Issue
Block a user