From 9c11730d7c0af71ee29be98c803071d791dc6a6d Mon Sep 17 00:00:00 2001 From: Vanja Skuric Date: Wed, 7 Feb 2018 13:31:47 +0100 Subject: [PATCH] Limitting cosTheta to be inside [-1,1] interval --- src/foam/primitives/Tensor/tensor/tensor.C | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/foam/primitives/Tensor/tensor/tensor.C b/src/foam/primitives/Tensor/tensor/tensor.C index 42fc1c23b..31b5e4cfe 100644 --- a/src/foam/primitives/Tensor/tensor/tensor.C +++ b/src/foam/primitives/Tensor/tensor/tensor.C @@ -151,7 +151,9 @@ vector eigenValues(const tensor& t) if (R2 < Q3) { scalar sqrtQ = sqrt(Q); - scalar theta = acos(R/(Q*sqrtQ)); + scalar cosTheta = R/(Q*sqrtQ); + cosTheta += (neg(cosTheta) - pos(cosTheta))*SMALL; + scalar theta = acos(cosTheta); scalar m2SqrtQ = -2*sqrtQ; scalar aBy3 = a/3; @@ -406,7 +408,9 @@ vector eigenValues(const symmTensor& t) if (R2 < Q3) { scalar sqrtQ = sqrt(Q); - scalar theta = acos(R/(Q*sqrtQ)); + scalar cosTheta = R/(Q*sqrtQ); + cosTheta += (neg(cosTheta) - pos(cosTheta))*SMALL; + scalar theta = acos(cosTheta); scalar m2SqrtQ = -2*sqrtQ; scalar aBy3 = a/3;