Author: eudoxos Date: 2009-07-19 22:24:24 +0200 (Sun, 19 Jul 2009) New Revision: 1879
Added: trunk/scripts/test/collider-sweep-simple.py Modified: trunk/pkg/common/DataClass/VelocityBins.cpp trunk/pkg/common/DataClass/VelocityBins.hpp trunk/scripts/linkdeps.py trunk/scripts/test/gts-horse.py Log: 1. Fix mathematical error with VelocityBins, verified by new script scripts/test/collider-sweep-simple.py to be correct 2. Add py/ directory to skipped dirs for linkdeps.py so that it works on current trunk Modified: trunk/pkg/common/DataClass/VelocityBins.cpp =================================================================== --- trunk/pkg/common/DataClass/VelocityBins.cpp 2009-07-18 21:07:49 UTC (rev 1878) +++ trunk/pkg/common/DataClass/VelocityBins.cpp 2009-07-19 20:24:24 UTC (rev 1879) @@ -11,11 +11,14 @@ CREATE_LOGGER(VelocityBins); bool VelocityBins::incrementDists_shouldCollide(Real dt){ + // const shared_ptr<Body>& b=Body::byId(0); LOG_INFO("Body #0: z off "<<b->physicalParameters->se3.position[2]-b->physicalParameters->refSe3.position[2]<<", velocity "<<static_pointer_cast<RigidBodyParameters>(b->physicalParameters)->velocity[2]); int i=0; FOREACH(Bin& bin, bins){ - bin.currDistSq+=dt*dt*bin.currMaxVelSq; i++; - if(bin.currDistSq>pow(bin.maxDist,2)){ - LOG_TRACE("Collide: bin"<<i<<": max dist "<<bin.maxDist<<", current "<<sqrt(bin.currDistSq)); + // NOTE: this mimics the integration scheme of NewtonsDampedLaw + // if you use different integration method, it must be changed (or the infrastructure somehow modified to allow for that) + bin.currDist+=dt*sqrt(bin.currMaxVelSq); i++; + if(bin.currDist>bin.maxDist){ + LOG_TRACE("Collide: bin"<<i<<": max dist "<<bin.maxDist<<", current "<<bin.currDist); return true; } } @@ -38,7 +41,8 @@ if(refMaxVelSq<0){ refMaxVelSq=currMaxVelSq; /* first time */} else { // there should be some maximum speed change parameter, so that bins do not change their limits (and therefore bodies, also!) too often, depending on 1 particle going crazy - refMaxVelSq=min(max(refMaxVelSq/pow(1+maxRefRelStep,2),currMaxVelSq),refMaxVelSq*pow(1+maxRefRelStep,2)); + if(maxRefRelStep>0) refMaxVelSq=min(max(refMaxVelSq/pow(1+maxRefRelStep,2),currMaxVelSq),refMaxVelSq*pow(1+maxRefRelStep,2)); + else refMaxVelSq=currMaxVelSq; if(refMaxVelSq==0) refMaxVelSq=currMaxVelSq; } LOG_TRACE("new refMaxVel: "<<sqrt(refMaxVelSq)); @@ -52,7 +56,7 @@ (refMaxVelSq==0 ? 0: refSweepLength) : refSweepLength/pow(binCoeff,(int)i) ); - bin.currDistSq=0; bin.currMaxVelSq=0; bin.nBodies=0; + bin.currDist=0; bin.currMaxVelSq=0; bin.nBodies=0; } long moveFaster=0, moveSlower=0; FOREACH(const shared_ptr<Body>& b, *rootBody->bodies){ Modified: trunk/pkg/common/DataClass/VelocityBins.hpp =================================================================== --- trunk/pkg/common/DataClass/VelocityBins.hpp 2009-07-18 21:07:49 UTC (rev 1878) +++ trunk/pkg/common/DataClass/VelocityBins.hpp 2009-07-19 20:24:24 UTC (rev 1879) @@ -17,10 +17,10 @@ */ class VelocityBins{ public: - VelocityBins(int _nBins, Real _refMaxVelSq, Real _binCoeff=10, Real _binOverlap=0.8): refMaxVelSq(_refMaxVelSq), binCoeff(_binCoeff), binOverlap(_binOverlap), maxRefRelStep(100), nBins(_nBins), histInterval(200), histLast(-1){} + VelocityBins(int _nBins, Real _refMaxVelSq, Real _binCoeff=10, Real _binOverlap=0.8): refMaxVelSq(_refMaxVelSq), binCoeff(_binCoeff), binOverlap(_binOverlap), maxRefRelStep(-1), nBins(_nBins), histInterval(200), histLast(-1){} typedef signed char binNo_t; struct Bin{ - Bin(): binMinVelSq(-1), binMaxVelSq(-1), maxDist(0), currDistSq(0), currMaxVelSq(0), nBodies(0){ + Bin(): binMinVelSq(-1), binMaxVelSq(-1), maxDist(0), currDist(0), currMaxVelSq(0), nBodies(0){ #ifdef YADE_OPENMP threadMaxVelSq.resize(omp_get_max_threads()); #endif @@ -30,7 +30,7 @@ // maximum distance that body in this bin can travel before it goes out of its swept bbox Real maxDist; // distance so far traveled by the fastest body in this bin (since last setBins) - Real currDistSq; + Real currDist; // maximum velSq over all bodies in this bin Real currMaxVelSq; // number of bodies in this bin (for informational purposes only) @@ -49,7 +49,7 @@ Real binCoeff; // relative overlap beween bins; body will not be moved from faster bin until its velocity is min*binOverlap; must be <=1 Real binOverlap; - // maximum relative change of reference max velocity per invocation + // maximum relative change of reference max velocity per invocation (if <0, disabled; this is the default) Real maxRefRelStep; // number of bins; must be >=1 and <=100 (artificial upper limit) size_t nBins; Modified: trunk/scripts/linkdeps.py =================================================================== --- trunk/scripts/linkdeps.py 2009-07-18 21:07:49 UTC (rev 1878) +++ trunk/scripts/linkdeps.py 2009-07-19 20:24:24 UTC (rev 1879) @@ -17,7 +17,7 @@ def walkSourceFiles(): ret=[] for root, dirs, files in os.walk(srcRoot,topdown=True): - for d in ('.svn','mgpost','SpherePadder','QGLViewer','triangulation','sqlite3x','miniWm3'): + for d in ('.svn','mgpost','SpherePadder','QGLViewer','triangulation','sqlite3x','miniWm3','py'): try: dirs.remove(d) except ValueError: pass for f in files: Added: trunk/scripts/test/collider-sweep-simple.py =================================================================== --- trunk/scripts/test/collider-sweep-simple.py 2009-07-18 21:07:49 UTC (rev 1878) +++ trunk/scripts/test/collider-sweep-simple.py 2009-07-19 20:24:24 UTC (rev 1879) @@ -0,0 +1,26 @@ +O.bodies.append(utils.sphere([0,0,10],.5)) +#O.bodies.append(utils.sphere([0,0,0],.5,dynamic=False)) + +O.engines=[ + BexResetter(), + BoundingVolumeMetaEngine([InteractingSphere2AABB(),InteractingFacet2AABB(),MetaInteractingGeometry2AABB()]), + InsertionSortCollider(label='collider'), + InteractionDispatchers( + [ef2_Sphere_Sphere_Dem3DofGeom(),ef2_Facet_Sphere_Dem3DofGeom()], + [SimpleElasticRelationships()], + [Law2_Dem3Dof_Elastic_Elastic()], + ), + GravityEngine(gravity=[0,0,-1e4]), + NewtonsDampedLaw(damping=.1) +] +collider['sweepLength'],collider['nBins'],collider['binCoeff']=.5,2,2 +O.dt=8e-2*utils.PWaveTimeStep() +O.saveTmp() +from yade import timing +O.timingEnabled=True +from yade import qt +r=qt.Renderer() +r['Body_bounding_volume']=True +v=qt.View(); qt.Controller() +v.ortho=True; #v.viewDir=O.bodies[0].phys.pos; v.lookAt=O.bodies[0].phys.pos; v.upVector=(0,0,1); +O.run(2,True) Modified: trunk/scripts/test/gts-horse.py =================================================================== --- trunk/scripts/test/gts-horse.py 2009-07-18 21:07:49 UTC (rev 1878) +++ trunk/scripts/test/gts-horse.py 2009-07-19 20:24:24 UTC (rev 1879) @@ -42,9 +42,7 @@ GravityEngine(gravity=[0,0,-1e4]), NewtonsDampedLaw(damping=.1) ] -#collider['sweepLength']=.2*dim0/30. -#collider['nBins']=10 -#collider['binCoeff']=2 +collider['sweepLength'],collider['nBins'],collider['binCoeff']=.1*dim0/30.5,10,2 O.dt=1.5*utils.PWaveTimeStep() O.saveTmp() O.timingEnabled=True _______________________________________________ Mailing list: https://launchpad.net/~yade-dev Post to : yade-...@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-dev More help : https://help.launchpad.net/ListHelp _______________________________________________ yade-dev mailing list yade-dev@lists.berlios.de https://lists.berlios.de/mailman/listinfo/yade-dev