← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-pkg/yade/git-trunk] Rev 3811: Add zero-forces to the youngest body after simulation load. Closes LP:1560171

 

------------------------------------------------------------
revno: 3811
committer: Anton Gladky <gladky.anton@xxxxxxxxx>
timestamp: Wed 2016-03-23 21:28:24 +0100
message:
  Add zero-forces to the youngest body after simulation load. Closes LP:1560171
  
  Zero-forces are added to be sure that ForceContainer is large enough
  for all bodies.
modified:
  core/ForceContainerParallel.cpp
  core/Omega.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/ForceContainerParallel.cpp'
--- core/ForceContainerParallel.cpp	2016-03-22 21:43:26 +0000
+++ core/ForceContainerParallel.cpp	2016-03-23 20:28:24 +0000
@@ -221,6 +221,7 @@
 }
 
 void ForceContainer::resize(size_t newSize, int threadN) {
+  LOG_DEBUG("Resize ForceContainer from the size "<<size<<" to the size "<<newSize);
   _forceData [threadN].resize(newSize,Vector3r::Zero());
   _torqueData[threadN].resize(newSize,Vector3r::Zero());
   _moveData[threadN].resize(newSize,Vector3r::Zero());

=== modified file 'core/Omega.cpp'
--- core/Omega.cpp	2015-11-19 06:41:51 +0000
+++ core/Omega.cpp	2016-03-23 20:28:24 +0000
@@ -247,6 +247,16 @@
 	if(scene->getClassName()!="Scene") throw logic_error("Wrong file format (scene is not a Scene!?) in "+f);
 	sceneFile=f;
 	timeInit();
+	
+	//Add zero-force to the youngest body to be sure ForceContainer is large enough.
+	const int _sz = scene->bodies->size();
+	for(Body::id_t _id=0; _id<_sz; _id++) {
+		if((&scene->bodies)[_id]) {
+			scene->forces.addForce(_id, Vector3r::Zero());
+			break;
+		}
+	}
+	
 	if(!quiet) LOG_DEBUG("Simulation loaded");
 }