Commit ddf1268e authored by Henry Weller's avatar Henry Weller
Browse files

functionObjects:surfaceFieldValue, volFieldValue: Added weightedSum and weighted[Area|Vol]Integrate

Patch contributed by Timo Niemi, VTT.
Resolves patch request https://bugs.openfoam.org/view.php?id=2452
parent 23809f7a
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -65,11 +65,12 @@ template<>
const char* Foam::NamedEnum
<
Foam::functionObjects::fieldValues::surfaceFieldValue::operationType,
15
17
>::names[] =
{
"none",
"sum",
"weightedSum",
"sumMag",
"sumDirection",
"sumDirectionBalance",
......@@ -78,6 +79,7 @@ const char* Foam::NamedEnum
"areaAverage",
"weightedAreaAverage",
"areaIntegrate",
"weightedAreaIntegrate",
"min",
"max",
"CoV",
......@@ -94,7 +96,7 @@ const Foam::NamedEnum
const Foam::NamedEnum
<
Foam::functionObjects::fieldValues::surfaceFieldValue::operationType,
15
17
> Foam::functionObjects::fieldValues::surfaceFieldValue::operationTypeNames_;
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -116,6 +116,7 @@ Usage
\plaintable
none | no operation
sum | sum
weightedSum | weighted sum
sumMag | sum of component magnitudes
sumDirection | sum values which are positive in given direction
sumDirectionBalance | sum of balance of values in given direction
......@@ -124,6 +125,7 @@ Usage
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
......@@ -209,6 +211,7 @@ public:
{
opNone,
opSum,
opWeightedSum,
opSumMag,
opSumDirection,
opSumDirectionBalance,
......@@ -217,6 +220,7 @@ public:
opAreaAverage,
opWeightedAreaAverage,
opAreaIntegrate,
opWeightedAreaIntegrate,
opMin,
opMax,
opCoV,
......@@ -225,7 +229,7 @@ public:
};
//- Operation type names
static const NamedEnum<operationType, 15> operationTypeNames_;
static const NamedEnum<operationType, 17> operationTypeNames_;
private:
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -141,6 +141,18 @@ processSameTypeValues
result = sum(values);
break;
}
case opWeightedSum:
{
if (weightField.size())
{
result = sum(weightField*values);
}
else
{
result = sum(values);
}
break;
}
case opSumMag:
{
result = sum(cmptMag(values));
......@@ -213,6 +225,20 @@ processSameTypeValues
result = sum(magSf*values);
break;
}
case opWeightedAreaIntegrate:
{
const scalarField magSf(mag(Sf));
if (weightField.size())
{
result = sum(weightField*magSf*values);
}
else
{
result = sum(magSf*values);
}
break;
}
case opMin:
{
result = min(values);
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -48,17 +48,19 @@ const char*
Foam::NamedEnum
<
Foam::functionObjects::fieldValues::volFieldValue::operationType,
11
13
>::names[] =
{
"none",
"sum",
"weightedSum",
"sumMag",
"average",
"weightedAverage",
"volAverage",
"weightedVolAverage",
"volIntegrate",
"weightedVolIntegrate",
"min",
"max",
"CoV"
......@@ -67,7 +69,7 @@ Foam::NamedEnum
const Foam::NamedEnum
<
Foam::functionObjects::fieldValues::volFieldValue::operationType,
11
13
> Foam::functionObjects::fieldValues::volFieldValue::operationTypeNames_;
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -79,17 +79,19 @@ Usage
The \c operation is one of:
\plaintable
none | No operation
sum | Sum
sumMag | Sum of component magnitudes
average | Ensemble average
weightedAverage | Weighted average
volAverage | Volume weighted average
weightedVolAverage | Weighted volume average
volIntegrate | Volume integral
min | Minimum
max | Maximum
CoV | Coefficient of variation: standard deviation/mean
none | No operation
sum | Sum
weightedSum | Weighted sum
sumMag | Sum of component magnitudes
average | Ensemble average
weightedAverage | Weighted average
volAverage | Volume weighted average
weightedVolAverage | Weighted volume average
volIntegrate | Volume integral
weightedVolIntegrate | Weighted volume integral
min | Minimum
max | Maximum
CoV | Coefficient of variation: standard deviation/mean
\endplaintable
See also
......@@ -136,19 +138,21 @@ public:
{
opNone,
opSum,
opWeightedSum,
opSumMag,
opAverage,
opWeightedAverage,
opVolAverage,
opWeightedVolAverage,
opVolIntegrate,
opWeightedVolIntegrate,
opMin,
opMax,
opCoV
};
//- Operation type names
static const NamedEnum<operationType, 11> operationTypeNames_;
static const NamedEnum<operationType, 13> operationTypeNames_;
protected:
......@@ -158,7 +162,7 @@ protected:
//- Operation to apply to values
operationType operation_;
//- Weight field name - only used for opWeightedAverage mode
//- Weight field name - only used for weighted modes
word weightFieldName_;
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -87,6 +87,11 @@ Type Foam::functionObjects::fieldValues::volFieldValue::processValues
result = gSum(values);
break;
}
case opWeightedSum:
{
result = gSum(weightField*values);
break;
}
case opSumMag:
{
result = gSum(cmptMag(values));
......@@ -117,6 +122,11 @@ Type Foam::functionObjects::fieldValues::volFieldValue::processValues
result = gSum(V*values);
break;
}
case opWeightedVolIntegrate:
{
result = gSum(weightField*V*values);
break;
}
case opMin:
{
result = gMin(values);
......
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