← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-dev/yade/trunk] Rev 2162: - Remove SCG_SCHEAR, clean code and documentation a little bit more.

 

------------------------------------------------------------
revno: 2162
committer: Bruno Chareyre <bchareyre@r1arduina>
branch nick: trunk
timestamp: Mon 2010-04-19 15:33:45 +0200
message:
  - Remove SCG_SCHEAR, clean code and documentation a little bit more.
modified:
  pkg/dem/Engine/GlobalEngine/ElasticContactLaw.cpp
  pkg/dem/Engine/GlobalEngine/ElasticContactLaw.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/dem/Engine/GlobalEngine/ElasticContactLaw.cpp'
--- pkg/dem/Engine/GlobalEngine/ElasticContactLaw.cpp	2010-03-25 13:24:10 +0000
+++ pkg/dem/Engine/GlobalEngine/ElasticContactLaw.cpp	2010-04-19 13:33:45 +0000
@@ -21,9 +21,7 @@
 {
 	if(!functor) functor=shared_ptr<Law2_ScGeom_FrictPhys_Basic>(new Law2_ScGeom_FrictPhys_Basic);
 	functor->sdecGroupMask=sdecGroupMask;
-	#ifdef SCG_SHEAR
-		functor->useShear=useShear;
-	#endif
+	functor->useShear=useShear;
 	functor->neverErase=neverErase;
 	FOREACH(const shared_ptr<Interaction>& I, *scene->interactions){
 		if(!I->isReal()) continue;
@@ -39,60 +37,37 @@
 CREATE_LOGGER(Law2_ScGeom_FrictPhys_Basic);
 void Law2_ScGeom_FrictPhys_Basic::go(shared_ptr<InteractionGeometry>& ig, shared_ptr<InteractionPhysics>& ip, Interaction* contact, Scene* ncb){
 	Real dt = Omega::instance().getTimeStep();
-
-			int id1 = contact->getId1(), id2 = contact->getId2();
-			// FIXME: mask handling should move to LawFunctor itself, outside the functors
-			if( !(Body::byId(id1,ncb)->getGroupMask() & Body::byId(id2,ncb)->getGroupMask() & sdecGroupMask) ) return;
-			ScGeom*    currentContactGeometry= static_cast<ScGeom*>(ig.get());
-			FrictPhys* currentContactPhysics = static_cast<FrictPhys*>(ip.get());			
-						
-			if(currentContactGeometry->penetrationDepth <0)
-			{
-				if (neverErase) {
-					currentContactPhysics->shearForce = Vector3r::ZERO;
-					currentContactPhysics->normalForce = Vector3r::ZERO;}
-				else 	ncb->interactions->requestErase(id1,id2);
-				return;
-			}	
-	
-			State* de1 = Body::byId(id1,ncb)->state.get();
-			State* de2 = Body::byId(id2,ncb)->state.get();
-
-			Vector3r& shearForce 			= currentContactPhysics->shearForce;
-	
-			// no need for this, initialized to Vector3r::ZERO in NormShearPhys ctor
-			// if (contact->isFresh(ncb)) shearForce=Vector3r(0,0,0);
-					
-			Real un=currentContactGeometry->penetrationDepth;
-			TRVAR3(currentContactGeometry->penetrationDepth,de1->se3.position,de2->se3.position);
-			currentContactPhysics->normalForce=currentContactPhysics->kn*std::max(un,(Real) 0)*currentContactGeometry->normal;
-	
-			#ifdef SCG_SHEAR
-				if(useShear){
-					currentContactGeometry->updateShear(de1,de2,dt);
-					shearForce=currentContactPhysics->ks*currentContactGeometry->shear;
-				} else {
-			#endif
-					currentContactGeometry->updateShearForce(shearForce,currentContactPhysics->ks,currentContactPhysics->prevNormal,de1,de2,dt);
-			#ifdef SCG_SHEAR
-				}
-			#endif
-
-			
-			// PFC3d SlipModel, is using friction angle. CoulombCriterion
-			Real maxFs = currentContactPhysics->normalForce.SquaredLength() * std::pow(currentContactPhysics->tangensOfFrictionAngle,2);
-			if( shearForce.SquaredLength() > maxFs )
-			{
-				Real ratio = Mathr::Sqrt(maxFs) / shearForce.Length();
-				shearForce *= ratio;
-				#ifdef SCG_SHEAR
-					// in this case, total shear displacement must be updated as well
-					if(useShear) currentContactGeometry->shear*=ratio;
-				#endif
-			}
-	
-			applyForceAtContactPoint(-currentContactPhysics->normalForce-shearForce , currentContactGeometry->contactPoint , id1 , de1->se3.position , id2 , de2->se3.position , ncb);
-			currentContactPhysics->prevNormal = currentContactGeometry->normal;
+	int id1 = contact->getId1(), id2 = contact->getId2();
+// 			// FIXME: mask handling should move to LawFunctor itself, outside the functors
+// 			if( !(Body::byId(id1,ncb)->getGroupMask() & Body::byId(id2,ncb)->getGroupMask() & sdecGroupMask) ) return;
+	ScGeom*    currentContactGeometry= static_cast<ScGeom*>(ig.get());
+	FrictPhys* currentContactPhysics = static_cast<FrictPhys*>(ip.get());
+	if(currentContactGeometry->penetrationDepth <0){
+		if (neverErase) {
+			currentContactPhysics->shearForce = Vector3r::ZERO;
+			currentContactPhysics->normalForce = Vector3r::ZERO;}
+		else 	ncb->interactions->requestErase(id1,id2);
+		return;}
+	State* de1 = Body::byId(id1,ncb)->state.get();
+	State* de2 = Body::byId(id2,ncb)->state.get();
+	Vector3r& shearForce = currentContactPhysics->shearForce;
+	Real un=currentContactGeometry->penetrationDepth;
+	TRVAR3(currentContactGeometry->penetrationDepth,de1->se3.position,de2->se3.position);
+	currentContactPhysics->normalForce=currentContactPhysics->kn*std::max(un,(Real) 0)*currentContactGeometry->normal;
+	if(useShear){
+		currentContactGeometry->updateShear(de1,de2,dt);
+		shearForce=currentContactPhysics->ks*currentContactGeometry->shear;
+	} else {
+		currentContactGeometry->updateShearForce(shearForce,currentContactPhysics->ks,currentContactPhysics->prevNormal,de1,de2,dt);}
+	// PFC3d SlipModel, is using friction angle. CoulombCriterion
+	Real maxFs = currentContactPhysics->normalForce.SquaredLength()*
+			std::pow(currentContactPhysics->tangensOfFrictionAngle,2);
+	if( shearForce.SquaredLength() > maxFs ){
+		Real ratio = Mathr::Sqrt(maxFs) / shearForce.Length();
+		shearForce *= ratio;
+		if(useShear) currentContactGeometry->shear*=ratio;}
+	applyForceAtContactPoint(-currentContactPhysics->normalForce-shearForce, currentContactGeometry->contactPoint, id1, de1->se3.position, id2, de2->se3.position, ncb);
+	currentContactPhysics->prevNormal = currentContactGeometry->normal;
 }
 
 // same as elasticContactLaw, but using Dem3DofGeom

=== modified file 'pkg/dem/Engine/GlobalEngine/ElasticContactLaw.hpp'
--- pkg/dem/Engine/GlobalEngine/ElasticContactLaw.hpp	2010-03-20 12:40:44 +0000
+++ pkg/dem/Engine/GlobalEngine/ElasticContactLaw.hpp	2010-04-19 13:33:45 +0000
@@ -23,10 +23,8 @@
 		virtual void go(shared_ptr<InteractionGeometry>& _geom, shared_ptr<InteractionPhysics>& _phys, Interaction* I, Scene*);
 	YADE_CLASS_BASE_DOC_ATTRS(Law2_ScGeom_FrictPhys_Basic,LawFunctor,"Law for linear compression, without cohesion and Mohr-Coulomb plasticity surface.\n\n.. note::\n This law uses :yref:`ScGeom`; there is also functionally equivalent :yref:`Law2_Dem3DofGeom_FrictPhys_Basic`, which uses :yref:`Dem3DofGeom`.",
 		((int,sdecGroupMask,1,"Bitmask for allowing collision between particles :yref:`Body::groupMask`"))
-		((bool,neverErase,false,"Keep interactions even if particles go away from each other [for debugging?]"))
-		#ifdef SCG_SHEAR
-			((bool,useShear,false,"Use ScGeom::updateShear rather than ScGeom::updateShearForce for shear force computation."))
-		#endif
+		((bool,neverErase,false,"Keep interactions even if particles go away from each other (only in case another constitutive law is in the scene, e.g. :yref:`Law2_ScGeom_CapillaryPhys_Capillarity`)"))
+		((bool,useShear,false,"Use ScGeom::updateShear rather than ScGeom::updateShearForce for shear force computation."))
 	);
 	FUNCTOR2D(ScGeom,FrictPhys);
 	DECLARE_LOGGER;
@@ -62,10 +60,8 @@
 		void action();
 	YADE_CLASS_BASE_DOC_ATTRS(ElasticContactLaw,GlobalEngine,"[DEPRECATED] Loop over interactions applying :yref:`Law2_ScGeom_FrictPhys_Basic` on all interactions.\n\n.. note::\n  Use :yref:`InteractionDispatchers` and :yref:`Law2_ScGeom_FrictPhys_Basic` instead of this class for performance reasons.",
 		((int,sdecGroupMask,1,"Bitmask for allowing collision between particles :yref:`Body::groupMask`"))
-		((bool,neverErase,false,"Keep interactions even if particles go away from each other [for debugging?]"))
-		#ifdef SCG_SHEAR
-			((bool,useShear,false,"Use :yref:`ScGeom`::updateShear rather than :yref:`ScGeom`::updateShearForce for shear force computation."))
-		#endif
+		((bool,neverErase,false,"Keep interactions even if particles go away from each other (only in case another constitutive law is in the scene, e.g. :yref:`Law2_ScGeom_CapillaryPhys_Capillarity`)"))
+		((bool,useShear,false,"Use :yref:`ScGeom`::updateShear rather than :yref:`ScGeom`::updateShearForce for shear force computation."))
 	);
 };