← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-dev/yade/trunk] Rev 2749: Nicer fix for 721107 (should work)

 

Merge authors:
  Sergei D. <sega@think>
------------------------------------------------------------
revno: 2749 [merge]
fixes bug(s): https://launchpad.net/bugs/721107
committer: Václav Šmilauer <eu@xxxxxxxx>
branch nick: yade
timestamp: Sun 2011-02-20 11:28:40 +0100
message:
  Nicer fix for 721107 (should work)
modified:
  pkg/common/InsertionSortCollider.cpp
  pkg/common/VelocityBins.cpp
  pkg/common/VelocityBins.hpp


--
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	2011-01-10 08:08:23 +0000
+++ pkg/common/InsertionSortCollider.cpp	2011-02-20 10:28:40 +0000
@@ -99,7 +99,7 @@
 		// or the time of scheduled run already came, or we were never scheduled yet
 		if(!strideActive) return true;
 		if(!newton || (nBins>=1 && !newton->velocityBins)) return true;
-		if(nBins>=1 && newton->velocityBins->incrementDists_shouldCollide(scene->dt)) return true;
+		if(nBins>=1 && newton->velocityBins->checkSize_incrementDists_shouldCollide(scene)) return true;
 		if(nBins<=0){
 			if(fastestBodyMaxDist<0){fastestBodyMaxDist=0; return true;}
 			fastestBodyMaxDist+=sqrt(newton->maxVelocitySq)*scene->dt;

=== modified file 'pkg/common/VelocityBins.cpp'
--- pkg/common/VelocityBins.cpp	2011-02-07 09:00:07 +0000
+++ pkg/common/VelocityBins.cpp	2011-02-20 10:28:40 +0000
@@ -9,8 +9,12 @@
 #endif
 CREATE_LOGGER(VelocityBins);
 
-bool VelocityBins::incrementDists_shouldCollide(Real dt){
+bool VelocityBins::checkSize_incrementDists_shouldCollide(const Scene* scene){
+	// number of particles increased, recollision necessary
+	// smaller number of particles is handled in setBins
+	if(bodyBins.size()>scene->bodies->size()) { bodyBins.resize(scene->bodies->size(),/* put new particles to the slowest bin*/ bins.size()-1); return true; }
 	int i=0;
+	const Real& dt=scene->dt;
 	FOREACH(Bin& bin, bins){
 		// NOTE: this mimics the integration scheme of NewtonIntegrator
 		// if you use different integration method, it must be changed (or the infrastructure somehow modified to allow for that)

=== modified file 'pkg/common/VelocityBins.hpp'
--- pkg/common/VelocityBins.hpp	2010-10-13 16:23:08 +0000
+++ pkg/common/VelocityBins.hpp	2011-02-20 10:28:40 +0000
@@ -23,7 +23,7 @@
 	struct Bin{
 		Bin(): binMinVelSq(-1), binMaxVelSq(-1), maxDist(0), currDist(0), currMaxVelSq(0), nBodies(0){
 			#ifdef YADE_OPENMP
-				threadMaxVelSq.resize(omp_get_max_threads());
+				threadMaxVelSq.resize(omp_get_max_threads(),0.);
 			#endif
 		};
 		// limits for bin memebrship
@@ -60,7 +60,8 @@
 	void setBins(Scene*, Real currMaxVelSq, Real refSweepLength);
 
 	// Increment maximum per-bin distances and tell whether some bodies may be	already getting out of the swept bbox (in that case, we need to recompute bounding volumes and run the collider)
-	bool incrementDists_shouldCollide(Real dt);
+	// Also returns true if number of particles changed, in which case it adjusts internal storage accordingly
+	bool checkSize_incrementDists_shouldCollide(const Scene*);
 	
 	/* NOTE: following 3 functions are separated because of multi-threaded operation of NewtonIntegrator
 	in that case, every thread must have its own per-bin maximum and binVelSqFinalize will assign the


Follow ups