functionObjects/.../*FieldValue: Protect against division by zero
Patch contributed by Timo Niemi, VTT. Resolves bug report https://bugs.openfoam.org/view.php?id=3370
This commit is contained in:
@ -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
|
||||
{
|
||||
|
||||
@ -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:
|
||||
|
||||
Reference in New Issue
Block a user