Stability fix: hinv inverse of truly singular tensors

This commit is contained in:
Hrvoje Jasak 2019-03-22 11:49:53 +00:00
parent 7fc1abd4b7
commit 7ea4631c84

View file

@ -658,6 +658,12 @@ tensor hinv(const tensor& t)
zeroInv += tensor(sqr(eigVecs.y()));
}
if (det(t + zeroInv) < VSMALL)
{
// Determinant is still zero. Return zero inverse
return tensor::zero;
}
return inv(t + zeroInv) - zeroInv;
}
}
@ -705,6 +711,12 @@ symmTensor hinv(const symmTensor& t)
zeroInv += sqr(eigVecs.y());
}
if (det(t + zeroInv) < VSMALL)
{
// Determinant is still zero. Return zero inverse
return symmTensor::zero;
}
return inv(t + zeroInv) - zeroInv;
}
}