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<>
|
template<>
|
||||||
const char* NamedEnum<fieldValues::cellSource::operationType, 10>::names[] =
|
const char* NamedEnum<fieldValues::cellSource::operationType, 11>::names[] =
|
||||||
{
|
{
|
||||||
"none",
|
"none",
|
||||||
"sum",
|
"sum",
|
||||||
@ -49,6 +49,7 @@ namespace Foam
|
|||||||
"average",
|
"average",
|
||||||
"weightedAverage",
|
"weightedAverage",
|
||||||
"volAverage",
|
"volAverage",
|
||||||
|
"weightedVolAverage",
|
||||||
"volIntegrate",
|
"volIntegrate",
|
||||||
"min",
|
"min",
|
||||||
"max",
|
"max",
|
||||||
@ -66,7 +67,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, 10>
|
const Foam::NamedEnum<Foam::fieldValues::cellSource::operationType, 11>
|
||||||
Foam::fieldValues::cellSource::operationTypeNames_;
|
Foam::fieldValues::cellSource::operationTypeNames_;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -85,6 +85,7 @@ Description
|
|||||||
average | ensemble average
|
average | ensemble average
|
||||||
weightedAverage | weighted average
|
weightedAverage | weighted average
|
||||||
volAverage | volume weighted average
|
volAverage | volume weighted average
|
||||||
|
weightedVolAverage | weighted volume average
|
||||||
volIntegrate | volume integral
|
volIntegrate | volume integral
|
||||||
min | minimum
|
min | minimum
|
||||||
max | maximum
|
max | maximum
|
||||||
@ -149,6 +150,7 @@ public:
|
|||||||
opAverage,
|
opAverage,
|
||||||
opWeightedAverage,
|
opWeightedAverage,
|
||||||
opVolAverage,
|
opVolAverage,
|
||||||
|
opWeightedVolAverage,
|
||||||
opVolIntegrate,
|
opVolIntegrate,
|
||||||
opMin,
|
opMin,
|
||||||
opMax,
|
opMax,
|
||||||
@ -156,7 +158,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
//- Operation type names
|
//- Operation type names
|
||||||
static const NamedEnum<operationType, 10> operationTypeNames_;
|
static const NamedEnum<operationType, 11> operationTypeNames_;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@ -102,17 +102,22 @@ Type Foam::fieldValues::cellSource::processValues
|
|||||||
}
|
}
|
||||||
case opWeightedAverage:
|
case opWeightedAverage:
|
||||||
{
|
{
|
||||||
result = sum(values)/sum(weightField);
|
result = sum(weightField*values)/sum(weightField);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case opVolAverage:
|
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;
|
break;
|
||||||
}
|
}
|
||||||
case opVolIntegrate:
|
case opVolIntegrate:
|
||||||
{
|
{
|
||||||
result = sum(values*V);
|
result = sum(V*values);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case opMin:
|
case opMin:
|
||||||
@ -175,14 +180,11 @@ bool Foam::fieldValues::cellSource::writeValues(const word& fieldName)
|
|||||||
combineFields(V);
|
combineFields(V);
|
||||||
combineFields(weightField);
|
combineFields(weightField);
|
||||||
|
|
||||||
// apply weight field
|
|
||||||
values *= weightField;
|
|
||||||
|
|
||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
{
|
{
|
||||||
Type result = processValues(values, V, weightField);
|
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);
|
resultDict_.add(fieldName, result, true);
|
||||||
|
|
||||||
if (valueOutput_)
|
if (valueOutput_)
|
||||||
@ -198,7 +200,7 @@ bool Foam::fieldValues::cellSource::writeValues(const word& fieldName)
|
|||||||
IOobject::NO_READ,
|
IOobject::NO_READ,
|
||||||
IOobject::NO_WRITE
|
IOobject::NO_WRITE
|
||||||
),
|
),
|
||||||
values
|
weightField*values
|
||||||
).write();
|
).write();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -48,7 +48,7 @@ namespace Foam
|
|||||||
|
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
const char* NamedEnum<fieldValues::faceSource::operationType, 14>::names[] =
|
const char* NamedEnum<fieldValues::faceSource::operationType, 15>::names[] =
|
||||||
{
|
{
|
||||||
"none",
|
"none",
|
||||||
"sum",
|
"sum",
|
||||||
@ -58,6 +58,7 @@ namespace Foam
|
|||||||
"average",
|
"average",
|
||||||
"weightedAverage",
|
"weightedAverage",
|
||||||
"areaAverage",
|
"areaAverage",
|
||||||
|
"weightedAreaAverage",
|
||||||
"areaIntegrate",
|
"areaIntegrate",
|
||||||
"min",
|
"min",
|
||||||
"max",
|
"max",
|
||||||
@ -77,7 +78,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, 14>
|
const Foam::NamedEnum<Foam::fieldValues::faceSource::operationType, 15>
|
||||||
Foam::fieldValues::faceSource::operationTypeNames_;
|
Foam::fieldValues::faceSource::operationTypeNames_;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -97,6 +97,7 @@ Description
|
|||||||
average | ensemble average
|
average | ensemble average
|
||||||
weightedAverage | weighted average
|
weightedAverage | weighted average
|
||||||
areaAverage | area weighted average
|
areaAverage | area weighted average
|
||||||
|
weightedAreaAverage | weighted area average
|
||||||
areaIntegrate | area integral
|
areaIntegrate | area integral
|
||||||
min | minimum
|
min | minimum
|
||||||
max | maximum
|
max | maximum
|
||||||
@ -190,6 +191,7 @@ public:
|
|||||||
opAverage,
|
opAverage,
|
||||||
opWeightedAverage,
|
opWeightedAverage,
|
||||||
opAreaAverage,
|
opAreaAverage,
|
||||||
|
opWeightedAreaAverage,
|
||||||
opAreaIntegrate,
|
opAreaIntegrate,
|
||||||
opMin,
|
opMin,
|
||||||
opMax,
|
opMax,
|
||||||
@ -199,7 +201,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
//- Operation type names
|
//- Operation type names
|
||||||
static const NamedEnum<operationType, 14> operationTypeNames_;
|
static const NamedEnum<operationType, 15> operationTypeNames_;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@ -197,7 +197,7 @@ Type Foam::fieldValues::faceSource::processSameTypeValues
|
|||||||
{
|
{
|
||||||
if (weightField.size())
|
if (weightField.size())
|
||||||
{
|
{
|
||||||
result = sum(values)/sum(weightField);
|
result = sum(weightField*values)/sum(weightField);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -209,14 +209,28 @@ Type Foam::fieldValues::faceSource::processSameTypeValues
|
|||||||
{
|
{
|
||||||
const scalarField magSf(mag(Sf));
|
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;
|
break;
|
||||||
}
|
}
|
||||||
case opAreaIntegrate:
|
case opAreaIntegrate:
|
||||||
{
|
{
|
||||||
const scalarField magSf(mag(Sf));
|
const scalarField magSf(mag(Sf));
|
||||||
|
|
||||||
result = sum(values*magSf);
|
result = sum(magSf*values);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case opMin:
|
case opMin:
|
||||||
@ -337,18 +351,14 @@ bool Foam::fieldValues::faceSource::writeValues
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// apply scale factor and weight field
|
// Apply scale factor
|
||||||
values *= scaleFactor_;
|
values *= scaleFactor_;
|
||||||
if (weightField.size())
|
|
||||||
{
|
|
||||||
values *= weightField;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
{
|
{
|
||||||
Type result = processValues(values, Sf, weightField);
|
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);
|
resultDict_.add(fieldName, result, true);
|
||||||
|
|
||||||
file()<< tab << result;
|
file()<< tab << result;
|
||||||
|
|||||||
Reference in New Issue
Block a user