← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-dev/yade/trunk] Rev 2322: 1. Fix stale potential interactions -- we've been dragging this bug since april, I will backport ...

 

------------------------------------------------------------
revno: 2322
committer: Václav Šmilauer <eudoxos@xxxxxxxx>
branch nick: trunk
timestamp: Mon 2010-07-05 18:34:20 +0200
message:
  1. Fix stale potential interactions -- we've been dragging this bug since april, I will backport it to 0.50. You are strongly recommended to update!!! The bug was, in the end, not in the collider, but in the container; it had <= instead of >= in one condition. Sorry.
modified:
  core/InteractionContainer.cpp
  pkg/common/Engine/GlobalEngine/InsertionSortCollider.cpp
  pkg/common/Engine/GlobalEngine/InsertionSortCollider.hpp
  scripts/test/periodic-shear.py


--
lp:yade
https://code.launchpad.net/~yade-dev/yade/trunk

Your team Yade developers is subscribed to branch lp:yade.
To unsubscribe from this branch go to https://code.launchpad.net/~yade-dev/yade/trunk/+edit-subscription
=== modified file 'core/InteractionContainer.cpp'
--- core/InteractionContainer.cpp	2010-04-25 22:08:06 +0000
+++ core/InteractionContainer.cpp	2010-07-05 16:34:20 +0000
@@ -52,7 +52,7 @@
 bool InteractionContainer::erase(body_id_t id1,body_id_t id2){
 	boost::mutex::scoped_lock lock(drawloopmutex);
 	if (id1>id2) swap(id1,id2);
-	if((size_t)id1<=vecmap.size()) return false; // id1 out of bounds
+	if((size_t)id1>=vecmap.size()) return false; // id1 out of bounds
 	map<body_id_t,size_t>::iterator mii;
 	mii=vecmap[id1].find(id2);
 	if(mii==vecmap[id1].end()) return false; // id2 not in interaction with id1

=== modified file 'pkg/common/Engine/GlobalEngine/InsertionSortCollider.cpp'
--- pkg/common/Engine/GlobalEngine/InsertionSortCollider.cpp	2010-07-05 13:41:14 +0000
+++ pkg/common/Engine/GlobalEngine/InsertionSortCollider.cpp	2010-07-05 16:34:20 +0000
@@ -390,7 +390,15 @@
 		interactions->insert(newI);
 		return;
 	}
-	if(!overlap && hasInter){ if(!I->isReal()) interactions->erase(id1,id2); return; }
+	if(!overlap && hasInter){
+		if(!I->isReal()) {
+			interactions->erase(id1,id2);
+			#ifdef PISC_DEBUG
+				if(watchIds(id1,id2)) LOG_DEBUG("Erased intr #"<<id1<<"+#"<<id2);
+			#endif
+		}
+		return;
+	}
 	assert(false); // unreachable
 }
 
@@ -450,12 +458,6 @@
 	return true;
 }
 
-#ifdef PISC_DEBUG
-	bool InsertionSortCollider::watchIds(body_id_t id1, body_id_t id2) const{
-		return id1==3 || id2==3; //true; //id1==1 || id2==1;
-	}
-#endif
-
 python::tuple InsertionSortCollider::dumpBounds(){
 	python::list bl[3]; // 3 bound lists, inserted into the tuple at the end
 	for(int axis=0; axis<3; axis++){
@@ -463,11 +465,11 @@
 		if(periodic){
 			for(long i=0; i<V.size; i++){
 				long ii=V.norm(i); // start from the period boundary
-				bl[i].append(python::make_tuple(V[ii].coord,(V[ii].flags.isMin?-1:1)*V[ii].id,V[ii].period));
+				bl[axis].append(python::make_tuple(V[ii].coord,(V[ii].flags.isMin?-1:1)*V[ii].id,V[ii].period));
 			}
 		} else {
 			for(long i=0; i<V.size; i++){
-				bl[i].append(python::make_tuple(V[i].coord,(V[i].flags.isMin?-1:1)*V[i].id));
+				bl[axis].append(python::make_tuple(V[i].coord,(V[i].flags.isMin?-1:1)*V[i].id));
 			}
 		}
 	}

=== modified file 'pkg/common/Engine/GlobalEngine/InsertionSortCollider.hpp'
--- pkg/common/Engine/GlobalEngine/InsertionSortCollider.hpp	2010-07-05 13:41:14 +0000
+++ pkg/common/Engine/GlobalEngine/InsertionSortCollider.hpp	2010-07-05 16:34:20 +0000
@@ -72,7 +72,7 @@
 
 // #define to turn on some tracing information for the periodic part
 // all code under this can be probably removed at some point, when the collider will have been tested thoroughly
-// #define PISC_DEBUG
+//#define PISC_DEBUG
 
 
 #ifdef ISC_TIMING
@@ -107,7 +107,8 @@
 		}
 	};
 	#ifdef PISC_DEBUG
-		bool watchIds(body_id_t id1,body_id_t id2) const;
+		int watch1, watch2;
+		bool watchIds(body_id_t id1,body_id_t id2) const { return (watch1<0 &&(watch2==id1||watch2==id2))||(watch2<0 && (watch1==id1||watch1==id2))||(watch1==id1 && watch2==id2)||(watch1==id2 && watch2==id1); }
 	#endif
 		// keep this dispatcher and call it ourselves as needed
 		shared_ptr<BoundDispatcher> boundDispatcher;
@@ -213,6 +214,9 @@
 			#ifdef ISC_TIMING
 				timingDeltas=shared_ptr<TimingDeltas>(new TimingDeltas);
 			#endif 
+			#ifdef PISC_DEBUG
+				watch1=watch2=-1; // disable watching
+			#endif
 			for(int i=0; i<3; i++) BB[i].axis=i;
 			periodic=false;
 			strideActive=false;
@@ -220,7 +224,11 @@
 		/* py */
 		.def_readonly("strideActive",&InsertionSortCollider::strideActive,"Whether striding is active (read-only; for debugging). |yupdate|")
 		.def_readonly("periodic",&InsertionSortCollider::periodic,"Whether the collider is in periodic mode (read-only; for debugging) |yupdate|")
-		.def("dumpBounds",&InsertionSortCollider::dumpBounds,"Return representation of the internal sort data. The format is ``([...],[...],[...])`` for 3 axes, where each ``...`` is a list of entries (bounds). The entry is a tuple with the fllowing items:\n\n* coordinate (float)\n* body id (int), but negated for negative bounds\n* period numer (int), if the collider is in the periodic regime.");
+		.def("dumpBounds",&InsertionSortCollider::dumpBounds,"Return representation of the internal sort data. The format is ``([...],[...],[...])`` for 3 axes, where each ``...`` is a list of entries (bounds). The entry is a tuple with the fllowing items:\n\n* coordinate (float)\n* body id (int), but negated for negative bounds\n* period numer (int), if the collider is in the periodic regime.")
+		#ifdef PISC_DEBUG
+			.def_readwrite("watch1",&InsertionSortCollider::watch1,"debugging only: watched body Id.")
+			.def_readwrite("watch2",&InsertionSortCollider::watch2,"debugging only: watched body Id.")
+		#endif
 	);
 	DECLARE_LOGGER;
 };

=== modified file 'scripts/test/periodic-shear.py'
--- scripts/test/periodic-shear.py	2010-06-16 16:39:17 +0000
+++ scripts/test/periodic-shear.py	2010-07-05 16:34:20 +0000
@@ -1,13 +1,13 @@
 O.periodic=True
 O.cell.refSize=Vector3(.55,.55,.55)
-O.bodies.append(utils.facet([[.4,.0001,.3],[.2,.0001,.3],[.3,.2,.2]]))
+#O.bodies.append(utils.facet([[.4,.0001,.3],[.2,.0001,.3],[.3,.2,.2]]))
 O.bodies.append(utils.sphere([.3,.1,.4],.05,dynamic=True))
-O.bodies.append(utils.sphere([.200001,.2000001,.4],.05,dynamic=False))
+#O.bodies.append(utils.sphere([.200001,.2000001,.4],.05,dynamic=False))
 O.bodies.append(utils.sphere([.3,0,0],.1,dynamic=False))
 O.engines=[
 	ForceResetter(),
 	BoundDispatcher([Bo1_Sphere_Aabb(),Bo1_Facet_Aabb()]),
-	InsertionSortCollider(),
+	InsertionSortCollider(label='isc'),
 	InteractionDispatchers(
 		[Ig2_Sphere_Sphere_Dem3DofGeom(),Ig2_Facet_Sphere_Dem3DofGeom()],
 		[Ip2_FrictMat_FrictMat_FrictPhys()],
@@ -15,7 +15,7 @@
 	),
 	GravityEngine(gravity=(0,0,-10)),
 	NewtonIntegrator(),
-	PeriodicPythonRunner(command='doCellFlip()',realPeriod=5)
+	#PeriodicPythonRunner(command='doCellFlip()',realPeriod=5)
 ]
 
 def doCellFlip():
@@ -31,8 +31,10 @@
 O.dt=2e-2*utils.PWaveTimeStep()
 O.step()
 O.saveTmp()
-rdr=yade.qt.Renderer()
-rdr.intrAllWire=True
+rrr=yade.qt.Renderer()
+rrr.intrAllWire,rrr.bound=True,True
+isc.watch1,isc.watch2=0,-1
+
 #from yade import log
 #import yade.qt,time
 #v=yade.qt.View()
@@ -41,4 +43,4 @@
 
 from yade import log
 #log.setLevel('Shop',log.TRACE)
-#log.setLevel('InsertionSortCollider',log.TRACE)
+log.setLevel('InsertionSortCollider',log.TRACE)


Follow ups