← Back to team overview

yade-dev team mailing list archive

NaN problem solved

 

It turns out that I had a mistake in my python script that was
generating a sample. In some rare cases I was using the same sphere
twice, putting two spheres in exactly the same location. NaN came
from normal=(0,0,0) which, when normalized was becoming (nan,nan,nan).

It would have been (a lot) easier to find if there was such a code:

=== modified file 'pkg/dem/Ig2_Sphere_Sphere_ScGeom.cpp'
--- pkg/dem/Ig2_Sphere_Sphere_ScGeom.cpp        2010-10-16 18:31:17 +0000
+++ pkg/dem/Ig2_Sphere_Sphere_ScGeom.cpp        2010-10-19 18:33:36 +0000
@@ -34,6 +34,7 @@
                else { scm=shared_ptr<ScGeom>(new ScGeom()); c->geom=scm; }
 
                Real norm=normal.norm(); normal/=norm; // normal is unit vector now
+               if(isnan(normal[0]+normal[1]+normal[2])) throw runtime_error("Contact has normal==NaN!");
                Real penetrationDepth=s1->radius+s2->radius-norm;
                scm->contactPoint=se31.position+(s1->radius-0.5*penetrationDepth)*normal;//0.5*(pt1+pt2);
                scm->penetrationDepth=penetrationDepth;


Or, something like that. What do you think about committing this?

-- 
Janek Kozicki                               http://janek.kozicki.pl/  |



Follow ups