← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-pkg/yade/git-trunk] Rev 4033: Critical bugfix for collision detection in periodic boundary conditions. Bounds lists were left p...

 

------------------------------------------------------------
revno: 4033
committer: bchareyre <bruno.chareyre@xxxxxxxxxxxxxxx>
timestamp: Fri 2017-04-14 12:04:32 +0200
message:
  Critical bugfix for collision detection in periodic boundary conditions. Bounds lists were left partially unordered,  then some interactions were never detected (my toughest yade debugging until now).
modified:
  pkg/common/InsertionSortCollider.cpp


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

Your team Yade developers is subscribed to branch lp:yade.
To unsubscribe from this branch go to https://code.launchpad.net/~yade-pkg/yade/git-trunk/+edit-subscription
=== modified file 'pkg/common/InsertionSortCollider.cpp'
--- pkg/common/InsertionSortCollider.cpp	2017-04-13 11:56:42 +0000
+++ pkg/common/InsertionSortCollider.cpp	2017-04-14 10:04:32 +0000
@@ -410,8 +410,10 @@
 void InsertionSortCollider::insertionSortPeri(VecBounds& v, InteractionContainer* interactions, Scene*, bool doCollide){
 	assert(periodic);
 	long &loIdx=v.loIdx; const long &size=v.size;
-	for(long _i=0; _i<size; _i++){
-		const long i=v.norm(_i);
+	/* We have to visit each bound at least once (first condition), but this is not enough. The correct ordering in the begining of the list needs a second pass to connect begin and end consistently (the second condition). Strictly the second condition should include "+ (v.norm(j+1)==loIdx ? v.cellDim : 0)" but it is ok as is since the shift is added inside the loop. */
+	long _i=0;
+	for(; (_i<size) || (v[v.norm(_i)].coord <  v[v.norm(_i-1)].coord); _i++){
+		const long i=v.norm(_i);//FIXME: useless, and many others can probably be removed
 		const long i_1=v.norm(i-1);
 		//switch period of (i) if the coord is below the lower edge cooridnate-wise and just above the split
 		if(i==loIdx && v[i].coord<0){ v[i].period-=1; v[i].coord+=v.cellDim; loIdx=v.norm(loIdx+1); }