fieldValues.diff (2,660 bytes)
diff --git a/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValueTemplates.C b/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValueTemplates.C
index 1300e6e8b..38ddd5ba9 100644
--- a/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValueTemplates.C
+++ b/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValueTemplates.C
@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
- \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
+ \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@@ -197,7 +197,7 @@ processSameTypeValues
{
if (weightField.size())
{
- result = sum(weightField*values)/sum(weightField);
+ result = sum(weightField*values)/max(sum(weightField), vSmall);
}
else
{
@@ -218,7 +218,9 @@ processSameTypeValues
if (weightField.size())
{
- result = sum(weightField*magSf*values)/sum(magSf*weightField);
+ result =
+ sum(weightField*magSf*values)
+ /max(sum(magSf*weightField), vSmall);
}
else
{
diff --git a/src/functionObjects/field/fieldValues/volFieldValue/volFieldValueTemplates.C b/src/functionObjects/field/fieldValues/volFieldValue/volFieldValueTemplates.C
index 2bc002309..5e3658243 100644
--- a/src/functionObjects/field/fieldValues/volFieldValue/volFieldValueTemplates.C
+++ b/src/functionObjects/field/fieldValues/volFieldValue/volFieldValueTemplates.C
@@ -104,7 +104,7 @@ Type Foam::functionObjects::fieldValues::volFieldValue::processValues
}
case operationType::weightedAverage:
{
- result = gSum(weightField*values)/gSum(weightField);
+ result = gSum(weightField*values)/max(gSum(weightField), vSmall);
break;
}
case operationType::volAverage:
@@ -114,7 +114,8 @@ Type Foam::functionObjects::fieldValues::volFieldValue::processValues
}
case operationType::weightedVolAverage:
{
- result = gSum(weightField*V*values)/gSum(weightField*V);
+ result =
+ gSum(weightField*V*values)/max(gSum(weightField*V), vSmall);
break;
}
case operationType::volIntegrate: