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:
Henry Weller
2015-06-30 11:20:02 +01:00
parent 72300041df
commit ce844e6f5b
6 changed files with 41 additions and 23 deletions

View File

@ -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_;

View File

@ -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:

View File

@ -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;