BUG: distributionModels::general: avoid zero-division errors

This commit is contained in:
Kutalmis Bercin
2021-09-07 09:04:28 +01:00
committed by Andrew Heather
parent 0aa44f2b9b
commit aeda015a78

View File

@ -78,7 +78,7 @@ void Foam::distributionModels::general::initialise()
}
// normalize the distribution
scalar sumArea = integral_.last();
const scalar sumArea = integral_.last();
for (label i = 0; i < nEntries_; ++i)
{
@ -86,8 +86,8 @@ void Foam::distributionModels::general::initialise()
integral_[i] /= sumArea + eps;
}
meanValue_ /= sumArea;
meanValue_ = cumulative_ ? (maxValue_ - meanValue_ + eps) : meanValue_;
meanValue_ /= sumArea + eps;
meanValue_ = cumulative_ ? (maxValue_ - meanValue_) : meanValue_;
}