Commit 422993f9 authored by Mark Olesen's avatar Mark Olesen
Browse files

ENH: add weightedAreaIntegrate operation for surfaceFieldValue

parent 690f58d2
......@@ -64,7 +64,7 @@ template<>
const char* Foam::NamedEnum
<
Foam::functionObjects::fieldValues::surfaceFieldValue::operationType,
15
16
>::names[] =
{
"none",
......@@ -77,6 +77,7 @@ const char* Foam::NamedEnum
"areaAverage",
"weightedAreaAverage",
"areaIntegrate",
"weightedAreaIntegrate",
"min",
"max",
"CoV",
......@@ -93,7 +94,7 @@ const Foam::NamedEnum
const Foam::NamedEnum
<
Foam::functionObjects::fieldValues::surfaceFieldValue::operationType,
15
16
> Foam::functionObjects::fieldValues::surfaceFieldValue::operationTypeNames_;
......
......@@ -109,14 +109,15 @@ Usage
sumDirectionBalance | sum of balance of values in given direction
average | ensemble average
weightedAverage | weighted average
areaAverage | area weighted average
areaAverage | area-weighted average
weightedAreaAverage | weighted area average
areaIntegrate | area integral
weightedAreaIntegrate | weighted area integral
min | minimum
max | maximum
CoV | coefficient of variation: standard deviation/mean
areaNormalAverage| area weighted average in face normal direction
areaNormalIntegrate | area weighted integral in face normal directon
areaNormalAverage| area-weighted average in face normal direction
areaNormalIntegrate | area-weighted integral in face normal directon
\endplaintable
Note
......@@ -210,6 +211,7 @@ public:
opAreaAverage, //!< Area average
opWeightedAreaAverage, //!< Weighted area average
opAreaIntegrate, //!< Area integral
opWeightedAreaIntegrate, //!< Weighted area integral
opMin, //!< Minimum
opMax, //!< Maximum
opCoV, //!< Coefficient of variation
......@@ -218,7 +220,7 @@ public:
};
//- Operation type names
static const NamedEnum<operationType, 15> operationTypeNames_;
static const NamedEnum<operationType, 16> operationTypeNames_;
private:
......
......@@ -176,10 +176,9 @@ processSameTypeValues
}
case opWeightedAverage:
{
label wSize = returnReduce(weightField.size(), sumOp<label>());
if (wSize > 0)
if (returnReduce(weightField.size(), sumOp<label>()))
{
// has weights
result =
gSum(weightField*values)/(gSum(weightField) + ROOTVSMALL);
}
......@@ -192,31 +191,40 @@ processSameTypeValues
}
case opAreaAverage:
{
const scalarField magSf(mag(Sf));
const scalarField factor(mag(Sf));
result = gSum(magSf*values)/gSum(magSf);
result = gSum(factor*values)/gSum(factor);
break;
}
case opWeightedAreaAverage:
{
const scalarField magSf(mag(Sf));
label wSize = returnReduce(weightField.size(), sumOp<label>());
if (wSize > 0)
{
result = gSum(weightField*magSf*values)/gSum(magSf*weightField);
}
else
{
result = gSum(magSf*values)/gSum(magSf);
}
const scalarField factor
(
returnReduce(weightField.size(), sumOp<label>()) // has weights
? weightField*mag(Sf)
: mag(Sf)
);
result = gSum(factor*values)/gSum(factor);
break;
}
case opAreaIntegrate:
{
const scalarField magSf(mag(Sf));
const scalarField factor(mag(Sf));
result = gSum(magSf*values);
result = gSum(factor*values);
break;
}
case opWeightedAreaIntegrate:
{
const scalarField factor
(
returnReduce(weightField.size(), sumOp<label>()) // has weights
? weightField*mag(Sf)
: mag(Sf)
);
result = gSum(factor*values);
break;
}
case opMin:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment