← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-pkg/yade/git-trunk] Rev 3832: fix bugs in Clump::updateProperties, fixes https://bugs.launchpad.net/yade/+bug/1273172

 

------------------------------------------------------------
revno: 3832
committer: Christian Jakob <jakob@xxxxxxxxxxxxxxxxxxx>
timestamp: Tue 2014-03-04 08:19:07 +0100
message:
  fix bugs in Clump::updateProperties, fixes https://bugs.launchpad.net/yade/+bug/1273172
modified:
  core/Clump.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 'core/Clump.cpp'
--- core/Clump.cpp	2014-02-27 08:27:24 +0000
+++ core/Clump.cpp	2014-03-04 07:19:07 +0000
@@ -120,9 +120,10 @@
 					const Sphere* sphere1 = YADE_CAST<Sphere*> (subBody1->shape.get());
 					const Sphere* sphere2 = YADE_CAST<Sphere*> (subBody2->shape.get());
 					Real un = (sphere1->radius+sphere2->radius) - dist.norm();
-					if (un > -0.001*min(sphere1->radius,sphere2->radius)) {intersecting = true; break;}
+					if (un > 0.001*min(sphere1->radius,sphere2->radius)) {intersecting = true; break;}
 				}
 			}
+			if (intersecting) break;
 		}
 	}
 	/* quantities suffixed by
@@ -153,9 +154,11 @@
 		}
 		//get volume and inertia tensor using regular cubic cell array inside bounding box of the clump:
 		Real dx = rMin/discretization; 	//edge length of cell
-		Real aabbMax = max(max(aabb.max().x()-aabb.min().x(),aabb.max().y()-aabb.min().y()),aabb.max().z()-aabb.min().z());
-		if (aabbMax/dx > 150) dx = aabbMax/150;//limit dx
+		//Real aabbMax = max(max(aabb.max().x()-aabb.min().x(),aabb.max().y()-aabb.min().y()),aabb.max().z()-aabb.min().z());
+		//if (aabbMax/dx > 150) dx = aabbMax/150;//limit dx: leads to bug, when long chain of clump members is created (https://bugs.launchpad.net/yade/+bug/1273172)
 		Real dv = pow(dx,3);		//volume of cell
+		long nCells=(aabb.sizes()/dx).prod();
+		if(nCells>1e7) LOG_WARN("Clump::updateProperties: Cell array has "<<nCells<<" cells. Integrate inertia may take a while ...");
 		Vector3r x;			//position vector (center) of cell
 		for(x.x()=aabb.min().x()+dx/2.; x.x()<aabb.max().x(); x.x()+=dx){
 			for(x.y()=aabb.min().y()+dx/2.; x.y()<aabb.max().y(); x.y()+=dx){