← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-pkg/yade/git-trunk] Rev 3806: better handling of double contacts, get gid of function ScGem goOneWay

 

------------------------------------------------------------
revno: 3806
committer: Klaus Thoeni <klaus.thoeni@xxxxxxxxx>
timestamp: Thu 2016-03-10 21:35:34 +1100
message:
  better handling of double contacts, get gid of function ScGem goOneWay
modified:
  pkg/common/PFacet.cpp
  pkg/common/PFacet.hpp


--
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 'pkg/common/PFacet.cpp'
--- pkg/common/PFacet.cpp	2016-01-02 22:07:33 +0000
+++ pkg/common/PFacet.cpp	2016-03-10 10:35:34 +0000
@@ -138,7 +138,7 @@
 					if(GridNodeList[i]->pfacetList[j]->getId()!=c->id2){
 						boost::tuple <Vector3r,bool, double, double,double> projectionPrev = projection(GridNodeList[i]->pfacetList[j]->shape,state1);
 						bool isintrianglePrev = boost::get<1>(projectionPrev);
-						if(isintrianglePrev){	//if(!isintrianglePrev)
+						if(!isintrianglePrev){	//if(!isintrianglePrev)
 							const shared_ptr<Interaction> intr = scene->interactions->find(c->id1,GridNodeList[i]->pfacetList[j]->getId());
 							if( intr && intr->isReal() ){// if an interaction exist between the sphere and the previous pfacet, import parameters.
 // 								cout<<"Copying contact with pfacet geom and phys from "<<intr->id1<<"-"<<intr->id2<<" to here ("<<c->id1<<"-"<<c->id2<<")"<<endl;
@@ -171,13 +171,17 @@
 						boost::tuple <Vector3r,bool, double, double,double> projectionPrev = projection(GridNodeList[i]->pfacetList[j]->shape,state1);
 						bool isintrianglePrev = boost::get<1>(projectionPrev);
 						if(isintrianglePrev){
-							if (isNew){return false;}
-							else {
-// 								cout<<"The contact "<<c->id1<<"-"<<c->id2<<" may be copied and will be deleted now."<<endl ;
-								scm->isDuplicate=1 ;
-								scm->trueInt=-1 ;
-								return true;
-							}
+							const shared_ptr<Interaction> intr = scene->interactions->find(c->id1,GridNodeList[i]->pfacetList[j]->getId());
+							if( intr && intr->isReal() ){// if an interaction exist between the sphere and the previous pfacet, import parameters.  
+								if (isNew){
+									return false;}
+								else {
+									scm->isDuplicate=1 ;
+									scm->trueInt=-1 ;
+									return true;
+								}	
+							}							
+						
 						}
 					}	
 				}	  
@@ -467,19 +471,18 @@
 	
 	if(gridCo->node1==Pfacet->node1 || gridCo->node1==Pfacet->node2|| gridCo->node1==Pfacet->node3 || gridCo->node2==Pfacet->node1 || gridCo->node2==Pfacet->node2|| gridCo->node2==Pfacet->node3){return false;}
 	
-
-	
 	Body::id_t idNode1=gridCo->node1->getId();
 	Body::id_t idNode2=gridCo->node2->getId();
 	Body::id_t ids2[3]={Pfacet->conn1->getId(),Pfacet->conn2->getId(),Pfacet->conn3->getId()};
-	
-	if (!scene->interactions->found(idNode1,c->id2)){ 
-		shared_ptr<Interaction> scm1 (new Interaction(idNode1,c->id2));
+	Body::id_t id1=c->id1;
+	Body::id_t id2=c->id2;
+	if (!scene->interactions->found(idNode1,id2)){ 
+		shared_ptr<Interaction> scm1 (new Interaction(idNode1,id2));
 		scene->interactions->insert(scm1);
 	}
-		
-	if (!scene->interactions->found(idNode2,c->id2)){ 
-		shared_ptr<Interaction> scm2 (new Interaction(idNode2,c->id2));
+
+	if (!scene->interactions->found(idNode2,id2)){ 
+		shared_ptr<Interaction> scm2 (new Interaction(idNode2,id2));
 		scene->interactions->insert(scm2);
 	}
 	
@@ -489,8 +492,8 @@
 		string chaine = "scm";
 		oss << chaine << entier;
 		string chaine1=oss.str();
-		if (!scene->interactions->found(c->id1,ids2[i])){ 
-			shared_ptr<Interaction> chaine1 (new Interaction(c->id1,ids2[i]));
+		if (!scene->interactions->found(id1,ids2[i])){ 
+			shared_ptr<Interaction> chaine1 (new Interaction(id1,ids2[i]));
 			scene->interactions->insert(chaine1);
 		}
 	}
@@ -505,70 +508,257 @@
 YADE_PLUGIN((Ig2_GridConnection_PFacet_ScGeom));
 
 
-bool Ig2_PFacet_PFacet_ScGeom::goOneWay( const shared_ptr<Shape>& cm1, const shared_ptr<Shape>& cm2, const State& state1, const State& state2, const Vector3r& shift2, const bool& force, const shared_ptr<Interaction>& c)
-{	
-	/*FIXME : /!\ Note that this geometry doesn't take care of any unwished duplicated contact or shear force following. /!\*/
-	PFacet* Pfacet1 = YADE_CAST<PFacet*>(cm1.get());
-
-	Body::id_t idNode1=Pfacet1->node1->getId();
-	Body::id_t idNode2=Pfacet1->node2->getId();
-	Body::id_t idNode3=Pfacet1->node3->getId();
-
-	Body::id_t id2=c->id2;
-
-	if (!scene->interactions->found(idNode1,id2)){ 
-		shared_ptr<Interaction> scm1 (new Interaction(idNode1,id2));
-		scene->interactions->insert(scm1);
-	}
-
-	if (!scene->interactions->found(idNode2,id2)){ 
-		shared_ptr<Interaction> scm2 (new Interaction(idNode2,id2));
-		scene->interactions->insert(scm2);
-	}
-	
-	if (!scene->interactions->found(idNode3,id2)){ 
-		shared_ptr<Interaction> scm3 (new Interaction(idNode3,id2));
-		scene->interactions->insert(scm3);
-	}
-
-	return (false);  
- 	
-}
-
 
 bool Ig2_PFacet_PFacet_ScGeom::go( const shared_ptr<Shape>& cm1, const shared_ptr<Shape>& cm2, const State& state1, const State& state2, const Vector3r& shift2, const bool& force, const shared_ptr<Interaction>& c)
 {
 	PFacet* Pfacet1 = YADE_CAST<PFacet*>(cm1.get());
 	PFacet* Pfacet2 = YADE_CAST<PFacet*>(cm2.get());
+	Body::id_t id1=c->id1;
+	Body::id_t id2=c->id2;
 	
 	if(Pfacet1->node1==Pfacet2->node1 || Pfacet1->node1==Pfacet2->node2|| Pfacet1->node1==Pfacet2->node3
 	  || Pfacet1->node2==Pfacet2->node1 || Pfacet1->node2==Pfacet2->node2|| Pfacet1->node2==Pfacet2->node3
 	  || Pfacet1->node3==Pfacet2->node1 || Pfacet1->node3==Pfacet2->node2|| Pfacet1->node3==Pfacet2->node3 ){ return false;}
 	
-
-	goOneWay( cm1, cm2, state1, state2,shift2,force, c);
-
-	swap(c->id1,c->id2);
-
-	goOneWay( cm2, cm1, state2, state1,-shift2,force, c);
-
-	Body::id_t ids1[3]={Pfacet1->conn1->getId(),Pfacet1->conn2->getId(),Pfacet1->conn3->getId()};
-	Body::id_t ids2[3]={Pfacet2->conn1->getId(),Pfacet2->conn2->getId(),Pfacet2->conn3->getId()};
-	
-	for (int i=0; i<3; i++){ 
-		for (int j=0; j<3; j++){ 
-			int entier = j+i*3;
-			ostringstream oss;
-			string chaine = "scm";
-			oss << chaine << entier;
-			string chaine1=oss.str();
-			if (!scene->interactions->found(ids1[i],ids2[j])){ 
-				shared_ptr<Interaction> chaine1 (new Interaction(ids1[i],ids2[j]));
-				scene->interactions->insert(chaine1);
-			}
-		}
-	}
-
+	
+	boost::tuple <Vector3r,bool, double, double,double> p1 = Ig2_Sphere_PFacet_ScGridCoGeom::projection(cm1,* Pfacet2->node1->state);
+	boost::tuple <Vector3r,bool, double, double,double> p2 = Ig2_Sphere_PFacet_ScGridCoGeom::projection(cm1,* Pfacet2->node2->state);
+	boost::tuple <Vector3r,bool, double, double,double> p3 = Ig2_Sphere_PFacet_ScGridCoGeom::projection(cm1,* Pfacet2->node3->state);
+
+	boost::tuple <Vector3r,bool, double, double,double> p4 = Ig2_Sphere_PFacet_ScGridCoGeom::projection(cm2,* Pfacet1->node1->state);
+	boost::tuple <Vector3r,bool, double, double,double> p5 = Ig2_Sphere_PFacet_ScGridCoGeom::projection(cm2,* Pfacet1->node2->state);
+	boost::tuple <Vector3r,bool, double, double,double> p6 = Ig2_Sphere_PFacet_ScGridCoGeom::projection(cm2,* Pfacet1->node3->state);
+	
+	bool isintriangle1 = boost::get<1>(p1);
+	bool isintriangle2 = boost::get<1>(p2);
+	bool isintriangle3 = boost::get<1>(p3);
+	
+
+	
+	bool isintriangle4 = boost::get<1>(p4);
+	bool isintriangle5 = boost::get<1>(p5);
+	bool isintriangle6 = boost::get<1>(p6);
+	
+	
+	bool istriangleNodes2P1 = (isintriangle1==true) && (isintriangle2==true)  && (isintriangle3==true);
+	bool istriangleNodes1P2 = (isintriangle4==true) && (isintriangle5==true)  && (isintriangle6==true);
+	
+	
+	if(istriangleNodes1P2 ){
+		Body::id_t idNode11=Pfacet1->node1->getId();
+		Body::id_t idNode12=Pfacet1->node2->getId();
+		Body::id_t idNode13=Pfacet1->node3->getId();
+
+
+		if (!scene->interactions->found(idNode11,id2)){ 
+			shared_ptr<Interaction> scm1 (new Interaction(idNode11,id2));
+			scene->interactions->insert(scm1);
+		}
+
+		if (!scene->interactions->found(idNode12,id2)){ 
+			shared_ptr<Interaction> scm2 (new Interaction(idNode12,id2));
+			scene->interactions->insert(scm2);
+		}
+		
+		if (!scene->interactions->found(idNode13,id2)){ 
+			shared_ptr<Interaction> scm3 (new Interaction(idNode13,id2));
+			scene->interactions->insert(scm3);
+		}
+	}
+	else if(istriangleNodes2P1 ){
+		Body::id_t idNode21=Pfacet2->node1->getId();
+		Body::id_t idNode22=Pfacet2->node2->getId();
+		Body::id_t idNode23=Pfacet2->node3->getId();
+
+		
+
+		if (!scene->interactions->found(idNode21,id1)){ 
+			shared_ptr<Interaction> scm1 (new Interaction(idNode21,id1));
+			scene->interactions->insert(scm1);
+		}
+
+		if (!scene->interactions->found(idNode22,id1)){ 
+			shared_ptr<Interaction> scm2 (new Interaction(idNode22,id1));
+			scene->interactions->insert(scm2);
+		}
+		
+		if (!scene->interactions->found(idNode23,id1)){ 
+			shared_ptr<Interaction> scm3 (new Interaction(idNode23,id1));
+			scene->interactions->insert(scm3);
+		}
+	}
+	else{
+
+		vector<Vector3r> vertices1={Pfacet1->node1->state->pos,Pfacet1->node2->state->pos,Pfacet1->node3->state->pos};
+		vector<Vector3r> vertices2={Pfacet2->node1->state->pos,Pfacet2->node2->state->pos,Pfacet2->node3->state->pos};
+
+	
+		
+		GridConnection* gridCo1P1    = (GridConnection*) Pfacet1->conn1->shape.get();
+		GridConnection* gridCo2P1    = (GridConnection*) Pfacet1->conn2->shape.get();
+		GridConnection* gridCo3P1    = (GridConnection*) Pfacet1->conn3->shape.get();
+		
+		GridConnection* gridCo1P2    = (GridConnection*) Pfacet2->conn1->shape.get();
+		GridConnection* gridCo2P2    = (GridConnection*) Pfacet2->conn2->shape.get();
+		GridConnection* gridCo3P2    = (GridConnection*) Pfacet2->conn3->shape.get();
+		
+
+		State*          gridNo1StgridCo1P1 = YADE_CAST<State*>(gridCo1P1->node1->state.get());
+		State*          gridNo2StgridCo1P1 = YADE_CAST<State*>(gridCo1P1->node2->state.get());
+		
+		State*          gridNo1StgridCo2P1 = YADE_CAST<State*>(gridCo2P1->node1->state.get());
+		State*          gridNo2StgridCo2P1 = YADE_CAST<State*>(gridCo2P1->node2->state.get());
+		
+		State*          gridNo1StgridCo3P1 = YADE_CAST<State*>(gridCo3P1->node1->state.get());
+		State*          gridNo2StgridCo3P1 = YADE_CAST<State*>(gridCo3P1->node2->state.get());
+		
+		State*          gridNo1StgridCo1P2 = YADE_CAST<State*>(gridCo1P2->node1->state.get());
+		State*          gridNo2StgridCo1P2 = YADE_CAST<State*>(gridCo1P2->node2->state.get());
+		
+		State*          gridNo1StgridCo2P2 = YADE_CAST<State*>(gridCo2P2->node1->state.get());
+		State*          gridNo2StgridCo2P2 = YADE_CAST<State*>(gridCo2P2->node2->state.get());
+		
+		State*          gridNo1StgridCo3P2 = YADE_CAST<State*>(gridCo3P2->node1->state.get());
+		State*          gridNo2StgridCo3P2 = YADE_CAST<State*>(gridCo3P2->node2->state.get());
+		
+		
+		Vector3r seg11=(gridNo1StgridCo1P1->pos - gridNo2StgridCo1P1->pos)/(gridNo1StgridCo1P1->pos - gridNo2StgridCo1P1->pos).norm();
+		Vector3r seg12=(gridNo1StgridCo2P1->pos - gridNo2StgridCo2P1->pos)/(gridNo1StgridCo2P1->pos - gridNo2StgridCo2P1->pos).norm() ;
+		Vector3r seg13=(gridNo1StgridCo3P1->pos - gridNo2StgridCo3P1->pos)/(gridNo1StgridCo3P1->pos - gridNo2StgridCo3P1->pos).norm();
+		
+		
+		Vector3r seg21=(gridNo1StgridCo1P2->pos - gridNo2StgridCo1P2->pos)/(gridNo1StgridCo1P2->pos - gridNo2StgridCo1P2->pos).norm();
+		Vector3r seg22=(gridNo1StgridCo2P2->pos - gridNo2StgridCo2P2->pos)/(gridNo1StgridCo2P2->pos - gridNo2StgridCo2P2->pos).norm();
+		Vector3r seg23=(gridNo1StgridCo3P2->pos - gridNo2StgridCo3P2->pos)/(gridNo1StgridCo3P2->pos - gridNo2StgridCo3P2->pos).norm();
+		
+		
+		Real normal1seg21seg11= seg21.dot(seg11);
+		Real normal1seg21seg12= seg21.dot(seg12);
+		Real normal1seg21seg13= seg21.dot(seg13);
+		
+		Real normal1seg22seg11= seg22.dot(seg11);
+		Real normal1seg22seg12= seg22.dot(seg12);
+		Real normal1seg22seg13= seg22.dot(seg13);
+		
+		Real normal1seg23seg11= seg23.dot(seg11);
+		Real normal1seg23seg12= seg23.dot(seg12);
+		Real normal1seg23seg13= seg23.dot(seg13);
+
+		Body::id_t ids1[3]={Pfacet1->conn1->getId(),Pfacet1->conn2->getId(),Pfacet1->conn3->getId()};
+		Body::id_t ids2[3]={Pfacet2->conn1->getId(),Pfacet2->conn2->getId(),Pfacet2->conn3->getId()};
+		
+		Body::id_t c1 =-1;
+		Body::id_t c2 =-1;	
+	  
+		
+		if(std::abs(normal1seg21seg11)==1){c1=ids2[0];c2=ids1[0];}
+		if(std::abs(normal1seg21seg12)==1){c1=ids2[0];c2=ids1[1];}
+		if(std::abs(normal1seg21seg13)==1){c1=ids2[0];c2=ids1[2];}
+		
+		if(std::abs(normal1seg22seg11)==1){c1=ids2[1];c2=ids1[0];}
+		if(std::abs(normal1seg22seg12)==1){c1=ids2[1];c2=ids1[1];}
+		if(std::abs(normal1seg22seg13)==1){c1=ids2[1];c2=ids1[2];}
+		
+		if(std::abs(normal1seg23seg11)==1){c1=ids2[2];c2=ids1[0];}
+		if(std::abs(normal1seg23seg12)==1){c1=ids2[2];c2=ids1[1];}
+		if(std::abs(normal1seg23seg13)==1){c1=ids2[2];c2=ids1[2];}
+
+		if(	(isintriangle1==false) && (isintriangle2==false)  && (isintriangle3==false) && (isintriangle4==false) && (isintriangle5==false)  && (isintriangle6==false)){
+			if((c1!=-1)and (c2!=-1) and(Body::byId(c1)->getGroupMask()!=0)and(Body::byId(c2)->getGroupMask()!=0)){
+				ostringstream oss;
+				string chaine = "scm";
+				if (!scene->interactions->found(c1,c2)){ 
+					shared_ptr<Interaction> chaine (new Interaction(c1,c2));
+					scene->interactions->insert(chaine);
+				}
+			}
+			else{			
+				for (int i=0; i<3; i++){ 
+					for (int j=0; j<3; j++){ 
+						int entier = j+i*3;
+						ostringstream oss;
+						string chaine = "scm";
+						oss << chaine << entier;
+						string chaine1=oss.str();
+						if (!scene->interactions->found(ids1[i],ids2[j])){
+							if((Body::byId(ids1[i])->getGroupMask()!=0)and(Body::byId(ids2[j])->getGroupMask()!=0)){
+								shared_ptr<Interaction> chaine1 (new Interaction(ids1[i],ids2[j]));
+								scene->interactions->insert(chaine1);
+							}
+						}
+					}
+				}
+			  
+			}
+		  
+		}
+		else{
+			Body::id_t idNode11=Pfacet1->node1->getId();
+			Body::id_t idNode12=Pfacet1->node2->getId();
+			Body::id_t idNode13=Pfacet1->node3->getId();
+
+
+
+			if (!scene->interactions->found(idNode11,id2)){ 
+				shared_ptr<Interaction> scm1 (new Interaction(idNode11,id2));
+				scene->interactions->insert(scm1);
+			}
+
+			if (!scene->interactions->found(idNode12,id2)){ 
+				shared_ptr<Interaction> scm2 (new Interaction(idNode12,id2));
+				scene->interactions->insert(scm2);
+			}
+			
+			if (!scene->interactions->found(idNode13,id2)){ 
+				shared_ptr<Interaction> scm3 (new Interaction(idNode13,id2));
+				scene->interactions->insert(scm3);
+			}
+			
+			Body::id_t idNode21=Pfacet2->node1->getId();
+			Body::id_t idNode22=Pfacet2->node2->getId();
+			Body::id_t idNode23=Pfacet2->node3->getId();
+
+			
+
+			if (!scene->interactions->found(idNode21,id1)){ 
+				shared_ptr<Interaction> scm1 (new Interaction(idNode21,id1));
+				scene->interactions->insert(scm1);
+			}
+
+			if (!scene->interactions->found(idNode22,id1)){ 
+				shared_ptr<Interaction> scm2 (new Interaction(idNode22,id1));
+				scene->interactions->insert(scm2);
+			}
+			
+			if (!scene->interactions->found(idNode23,id1)){ 
+				shared_ptr<Interaction> scm3 (new Interaction(idNode23,id1));
+				scene->interactions->insert(scm3);
+			}
+
+			Body::id_t ids1[3]={Pfacet1->conn1->getId(),Pfacet1->conn2->getId(),Pfacet1->conn3->getId()};
+			Body::id_t ids2[3]={Pfacet2->conn1->getId(),Pfacet2->conn2->getId(),Pfacet2->conn3->getId()};
+			
+			for (int i=0; i<3; i++){ 
+				for (int j=0; j<3; j++){ 
+					int entier = j+i*3;
+					ostringstream oss;
+					string chaine = "scm";
+					oss << chaine << entier;
+					string chaine1=oss.str();
+					if (!scene->interactions->found(ids1[i],ids2[j])){ 
+						if((Body::byId(ids1[i])->getGroupMask()!=0)and(Body::byId(ids2[j])->getGroupMask()!=0)){
+							shared_ptr<Interaction> chaine1 (new Interaction(ids1[i],ids2[j]));
+							scene->interactions->insert(chaine1);
+						}
+					}
+				}
+			}
+		  
+		  
+		}
+	
+	}
+	
 	return(false);
 }
 

=== modified file 'pkg/common/PFacet.hpp'
--- pkg/common/PFacet.hpp	2015-12-15 12:57:49 +0000
+++ pkg/common/PFacet.hpp	2016-03-10 10:35:34 +0000
@@ -27,7 +27,7 @@
 //!			O/
 class Ig2_Sphere_PFacet_ScGridCoGeom: public Ig2_Sphere_GridConnection_ScGridCoGeom{
 	public :
-	  
+		
 		boost::tuple<Vector3r,bool, double, double,double> projection(
 					const shared_ptr<Shape>& cm2,
 					const State& state1);
@@ -94,13 +94,6 @@
 					const Vector3r& shift2,
 					const bool& force,
 					const shared_ptr<Interaction>& c);
-		virtual bool goOneWay(const shared_ptr<Shape>& cm1,
-					const shared_ptr<Shape>& cm2,
-					const State& state1,
-					const State& state2,
-					const Vector3r& shift2,
-					const bool& force,
-					const shared_ptr<Interaction>& c);
 		virtual bool goReverse(	const shared_ptr<Shape>& cm1,
 					const shared_ptr<Shape>& cm2,
 					const State& state1,


Follow ups