← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-dev/yade/trunk] Rev 2827: 1. Fix a crash, which appears, when force is read from non-existing body.

 

------------------------------------------------------------
revno: 2827
committer: Anton Gladky <gladky.anton@xxxxxxxxx>
branch nick: yade
timestamp: Thu 2011-04-21 15:59:13 +0200
message:
  1. Fix a crash, which appears, when force is read from non-existing body.
  2. Fix warning in CohesiveFrictionalContactLaw
modified:
  pkg/common/PressTestEngine.cpp
  pkg/dem/CohesiveFrictionalContactLaw.cpp
  pkg/dem/ForceTorqueRecorder.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/PressTestEngine.cpp'
--- pkg/common/PressTestEngine.cpp	2010-10-13 16:23:08 +0000
+++ pkg/common/PressTestEngine.cpp	2011-04-21 13:59:13 +0000
@@ -7,7 +7,7 @@
 	if (curentDirection != stop) {
 		if (curentDirection==forward) { 										 ///<Forward direction of the press
 			FOREACH(Body::id_t id, ids){
-				assert(scene->bodies->exists(id));
+				if (!(scene->bodies->exists(id))) continue;
 				currentVerticalForce = scene->forces.getForce(id)[2]; 	///<Define current vertical force
 				minimalForce = maxVerticalForce*0.1;									///<Define minimal edge of the force (10% from Maximal)
 				minimalPredictedForce = predictedForce*0.1;						///<Define minimal edge of the Predicted force (10% from Predicted)

=== modified file 'pkg/dem/CohesiveFrictionalContactLaw.cpp'
--- pkg/dem/CohesiveFrictionalContactLaw.cpp	2011-04-16 11:35:08 +0000
+++ pkg/dem/CohesiveFrictionalContactLaw.cpp	2011-04-21 13:59:13 +0000
@@ -23,7 +23,7 @@
 	Real normEnergy=0;
 	FOREACH(const shared_ptr<Interaction>& I, *scene->interactions){
 		if(!I->isReal()) continue;
-		ScGeom6D* scg = YADE_CAST<ScGeom6D*>(I->geom.get());
+		//ScGeom6D* scg = YADE_CAST<ScGeom6D*>(I->geom.get());  //Commented due to warning
 		CohFrictPhys* phys = YADE_CAST<CohFrictPhys*>(I->phys.get());
 		if (phys) {
 			normEnergy += 0.5*(phys->normalForce.squaredNorm()/phys->kn);
@@ -36,7 +36,7 @@
 	Real shearEnergy=0;
 	FOREACH(const shared_ptr<Interaction>& I, *scene->interactions){
 		if(!I->isReal()) continue;
-		ScGeom6D* scg = YADE_CAST<ScGeom6D*>(I->geom.get());
+		//ScGeom6D* scg = YADE_CAST<ScGeom6D*>(I->geom.get());  //Commented due to warning
 		CohFrictPhys* phys = YADE_CAST<CohFrictPhys*>(I->phys.get());
 		if (phys) {
 			shearEnergy += 0.5*(phys->shearForce.squaredNorm()/phys->ks);

=== modified file 'pkg/dem/ForceTorqueRecorder.cpp'
--- pkg/dem/ForceTorqueRecorder.cpp	2011-03-02 09:00:04 +0000
+++ pkg/dem/ForceTorqueRecorder.cpp	2011-04-21 13:59:13 +0000
@@ -6,7 +6,7 @@
 void ForceRecorder::action(){
 	totalForce=Vector3r::Zero();
 	FOREACH(Body::id_t id, ids){
-		assert(scene->bodies->exists(id)); 
+		if (!(scene->bodies->exists(id))) continue; 
 		totalForce+=scene->forces.getForce(id);
 	};
 	
@@ -21,7 +21,7 @@
 	Vector3r tmpAxis = rotationAxis.normalized();
 	
 	FOREACH(Body::id_t id, ids){
-		assert(scene->bodies->exists(id)); 
+		if (!(scene->bodies->exists(id))) continue;
 		Body* b=Body::byId(id,scene).get();
 		
 		Vector3r tmpPos = b->state->pos;