-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
First of all, there is a typo here:
cells/src/deformableParticles2D.cpp
Line 959 in 258c141
| cout << " ** uxi = " << uxi << ", uyi = " << uyi << "; uxim1 = " << uyim1 << ", uyim1 = " << uyim1 << endl; |
I guess it meant to print "uxim1 = " << uxim1" instead of "uxim1 = " << uyim1".
Then,
cells/src/deformableParticles2D.cpp
Line 931 in 258c141
| thetai = acos(ci); |
It is dangerous to call acos on a value exactly equals +/-1.0, because rounding errors can cause the computed value to be outside this range.
Such as:
ERROR: vertex area calculated is a nan, vi = 14, thetai = nan.
** uxi = 0.979597, uyi = -0.200974; uxim1 = 0.200974, uyim1 = 0.200974
** segmentCosine(vi) = -1
** Ending.
Even thought segmentCosine(vi) is exactly -1.0, acos returns nan.
A possible fix:
double Safe_Acos (double x)
{
if (x < -1.0) x = -1.0 ;
else if (x > 1.0) x = 1.0 ;
return acos (x) ;
}
Metadata
Metadata
Assignees
Labels
No labels