]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fixed an issue reported by @gassmoeller. 1669/head
authorDavid Wells <wellsd2@rpi.edu>
Thu, 24 Sep 2015 21:04:13 +0000 (17:04 -0400)
committerDavid Wells <wellsd2@rpi.edu>
Fri, 2 Oct 2015 20:32:04 +0000 (16:32 -0400)
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.

source/fe/mapping_q_generic.cc

index 42fea442f7f638f88032d8f9d33ea9ea56216057..7f200432259a61ddc10001534d29ecfca644ac81 100644 (file)
@@ -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);

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.