From: David Wells Date: Thu, 24 Sep 2015 21:04:13 +0000 (-0400) Subject: Fixed an issue reported by @gassmoeller. X-Git-Tag: v8.4.0-rc2~348^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F1669%2Fhead;p=dealii.git Fixed an issue reported by @gassmoeller. This fixes an issue in the real_to_unit mapping code where, in the quadratic formula, it was possible to reach a division by zero issue for certain inputs. --- diff --git a/source/fe/mapping_q_generic.cc b/source/fe/mapping_q_generic.cc index 42fea442f7..7f20043225 100644 --- a/source/fe/mapping_q_generic.cc +++ b/source/fe/mapping_q_generic.cc @@ -259,8 +259,10 @@ namespace internal eta1 = -c/b; eta2 = -c/b; } - // special case #2: if c is very small: - else if (std::abs(c/b) < 1e-12) + // special case #2: if c is very small or the square root of the + // discriminant is nearly b. + else if (std::abs(c) < 1e-12*std::abs(b) + || std::abs(std::sqrt(discriminant) - b) <= 1e-14*std::abs(b)) { eta1 = (-b - std::sqrt(discriminant)) / (2*a); eta2 = (-b + std::sqrt(discriminant)) / (2*a);