← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-dev/yade/trunk] Rev 3035: - fix periodicity of interactions when large bodies are present. Demo script comming soon.

 

------------------------------------------------------------
revno: 3035
committer: Bruno Chareyre <bruno.chareyre@xxxxxxxxxxx>
branch nick: trunk
timestamp: Wed 2012-02-29 13:23:14 +0100
message:
  - fix periodicity of interactions when large bodies are present. Demo script comming soon.
modified:
  pkg/common/InsertionSortCollider.cpp
  pkg/common/SpatialQuickSortCollider.cpp
  pkg/dem/Ig2_Box_Sphere_ScGeom.cpp


--
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 'pkg/common/InsertionSortCollider.cpp'
--- pkg/common/InsertionSortCollider.cpp	2012-01-30 20:53:49 +0000
+++ pkg/common/InsertionSortCollider.cpp	2012-02-29 12:23:14 +0000
@@ -442,18 +442,25 @@
 				TRVAR4(pmn1,pmx1,pmn2,pmx2);
 			}
 		#endif
-		if (allowBiggerThanPeriod &&  ((pmn1!=pmx1) || (pmn2!=pmx2)) ){
-			// If both bodies are bigger, we place them in the (0,0,0) period
-			if(unlikely((pmn1!=pmx1) && (pmn2!=pmx2))) {periods[axis]=0; return true;}
-			// else we define period with the position of the small body (we assume the big one sits in period (0,0,0), keep that in mind if velGrad(.,axis) is not a null vector)
-			else {periods[axis]=(pmn1==pmx1)? pmn1 : -pmn2; return true;}
-		} else if(unlikely((pmn1!=pmx1) || (pmn2!=pmx2))){
-			Real span=(pmn1!=pmx1?mx1-mn1:mx2-mn2); if(span<0) span=dim-span;
-			LOG_FATAL("Body #"<<(pmn1!=pmx1?id1:id2)<<" spans over half of the cell size "<<dim<<" (axis="<<axis<<", min="<<(pmn1!=pmx1?mn1:mn2)<<", max="<<(pmn1!=pmx1?mx1:mx2)<<", span="<<span<<", see flag allowBiggerThanPeriod)");
-			throw runtime_error(__FILE__ ": Body larger than half of the cell size encountered.");
+		if(unlikely((pmn1!=pmx1) || (pmn2!=pmx2))){
+			if (allowBiggerThanPeriod) {
+				// If both bodies are bigger, we place them in the (0,0,0) period
+				if(unlikely((pmn1!=pmx1) && (pmn2!=pmx2))) {periods[axis]=0;}
+				// else we define period with the position of the small body (we assume the big one sits in period (0,0,0), keep that in mind if velGrad(.,axis) is not a null vector)
+				else {
+					//FIXME: not sure what to do here...
+// 					periods[axis]=(pmn1==pmx1)? pmn1 : -pmn2;
+					periods[axis]=0;
+// 					return true;
+				}
+			} else {
+				Real span=(pmn1!=pmx1?mx1-mn1:mx2-mn2); if(span<0) span=dim-span;
+				LOG_FATAL("Body #"<<(pmn1!=pmx1?id1:id2)<<" spans over half of the cell size "<<dim<<" (axis="<<axis<<", min="<<(pmn1!=pmx1?mn1:mn2)<<", max="<<(pmn1!=pmx1?mx1:mx2)<<", span="<<span<<", see flag allowBiggerThanPeriod)");
+				throw runtime_error(__FILE__ ": Body larger than half of the cell size encountered.");}
 		}		
-		periods[axis]=(int)(pmn1-pmn2);
-		if(!(mn1<=mx2 && mx1 >= mn2)) return false;
+		else {
+			periods[axis]=(int)(pmn1-pmn2);
+			if(!(mn1<=mx2 && mx1 >= mn2)) return false;}
 	}
 	#ifdef PISC_DEBUG
 		if(watchIds(id1,id2)) LOG_DEBUG("Overlap #"<<id1<<"+#"<<id2<<", periods "<<periods);

=== modified file 'pkg/common/SpatialQuickSortCollider.cpp'
--- pkg/common/SpatialQuickSortCollider.cpp	2010-10-13 16:23:08 +0000
+++ pkg/common/SpatialQuickSortCollider.cpp	2012-02-29 12:23:14 +0000
@@ -41,7 +41,7 @@
 	shared_ptr<Body> b;
 	int i=0;
 	FOREACH(const shared_ptr<Body>& b, *bodies){
-		if(!b || !b->bound) continue;
+		if(!b->bound) continue;
 	   
 	   min = b->bound->min;
 	   max = b->bound->max;

=== modified file 'pkg/dem/Ig2_Box_Sphere_ScGeom.cpp'
--- pkg/dem/Ig2_Box_Sphere_ScGeom.cpp	2010-12-31 14:35:21 +0000
+++ pkg/dem/Ig2_Box_Sphere_ScGeom.cpp	2012-02-29 12:23:14 +0000
@@ -36,7 +36,7 @@
 	Matrix3r boxAxisT=se31.orientation.toRotationMatrix();
 	Matrix3r boxAxis = boxAxisT.transpose();
 
-	Vector3r relPos21 = se32.position-se31.position; // relative position of centroids
+	Vector3r relPos21 = se32.position+shift2-se31.position; // relative position of centroids
 
 	// cOnBox_boxLocal is the sphere centroid (in box-local coordinates), but projected onto box if it is outside.
 	// _boxLocal means that ROTATION is local and origin is in box's origin
@@ -125,7 +125,7 @@
 
 		cOnBox_sphere.normalize(); // we want only direction in the following
 
-		pt2=se32.position+cOnBox_sphere*s->radius;
+		pt2=se32.position+shift2+cOnBox_sphere*s->radius;
 
 		bool isNew=!c->geom;
 		if (isNew) scm = shared_ptr<ScGeom>(new ScGeom());