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:
Will Bainbridge
2019-10-14 09:02:47 +01:00
parent 19fd11d418
commit 8ea55e8f06
2 changed files with 8 additions and 5 deletions

View File

@ -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
{