From 3ae0021235aedb3f9079a22db93f3719bd97c056 Mon Sep 17 00:00:00 2001 From: Hrvoje Jasak Date: Sun, 27 Feb 2011 02:19:31 +0000 Subject: [PATCH] Robustness improvement --- .../primitives/Tensor/tensor/tensor.C | 20 +++++-------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/src/OpenFOAM/primitives/Tensor/tensor/tensor.C b/src/OpenFOAM/primitives/Tensor/tensor/tensor.C index 5f466159c..248e52bf7 100644 --- a/src/OpenFOAM/primitives/Tensor/tensor/tensor.C +++ b/src/OpenFOAM/primitives/Tensor/tensor/tensor.C @@ -317,24 +317,14 @@ vector eigenValues(const symmTensor& t) // If there is a zero root if (mag(c) < SMALL) -// if (mag(c) < 1.0e-100) { - scalar disc = sqr(a) - 4*b; + const scalar disc = Foam::max(sqr(a) - 4*b, 0.0); - if (disc >= -SMALL) - { - scalar q = -0.5*sqrt(max(scalar(0), disc)); + scalar q = -0.5*sqrt(max(scalar(0), disc)); - i = 0; - ii = -0.5*a + q; - iii = -0.5*a - q; - } - else - { - FatalErrorIn("eigenValues(const tensor&)") - << "zero and complex eigenvalues in tensor: " << t - << abort(FatalError); - } + i = 0; + ii = -0.5*a + q; + iii = -0.5*a - q; } else {