← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-dev/yade/trunk] Rev 1881: Update ResetRandomPosition

 

------------------------------------------------------------
revno: 1881
committer: Sergei D. <sega@think>
branch nick: trunk
timestamp: Wed 2009-12-09 21:53:59 +0300
message:
  Update ResetRandomPosition
modified:
  pkg/common/Engine/GlobalEngine/ResetRandomPosition.cpp
  scripts/test/ResetRandomPosition.py


--
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/Engine/GlobalEngine/ResetRandomPosition.cpp'
--- pkg/common/Engine/GlobalEngine/ResetRandomPosition.cpp	2009-12-06 22:02:12 +0000
+++ pkg/common/Engine/GlobalEngine/ResetRandomPosition.cpp	2009-12-09 18:53:59 +0000
@@ -12,7 +12,7 @@
 #include<yade/pkg-common/InteractingSphere.hpp>
 #include<yade/pkg-common/InteractingFacet.hpp>
 #include<yade/pkg-common/InteractionDispatchers.hpp>
-#include<yade/pkg-dem/BodyMacroParameters.hpp>
+//#include<yade/pkg-dem/BodyMacroParameters.hpp>
 #include"ResetRandomPosition.hpp"
 #include<sstream>
 
@@ -82,7 +82,7 @@
 	FOREACH(int id, subscribedBodies)
 	{
 		shared_ptr<Body> b = Body::byId(id);
-		RigidBodyParameters* rb = YADE_CAST<RigidBodyParameters*>(b->physicalParameters.get());
+		State* rb = b->state.get();
 		Vector3r& position = rb->se3.position;
 
 		if ( (position-point).Dot(normal) < 0 )
@@ -105,7 +105,7 @@
 				// Test overlap with already shifted bodies
 				FOREACH(shared_ptr<Body> sb, shiftedBodies)
 				{
-					if (iGME->explicitAction(b,sb)->interactionGeometry,/*force*/false)
+					if (iGME->explicitAction(b,sb,/*force*/false)->interactionGeometry)
 					{
 						is_overlap=true;
 						break;
@@ -116,7 +116,7 @@
 				// Test overlap with other bodies
 				vector<body_id_t> probedBodies=bI->probeBoundingVolume(bv);
 				FOREACH(body_id_t id, probedBodies){
-					if (iGME->explicitAction(b,Body::byId(bI->probedBodies[i]))->interactionGeometry,/*force*/false){
+					if (iGME->explicitAction(b,Body::byId(id),/*force*/false)->interactionGeometry){
 						is_overlap=true;
 						break;
 					}
@@ -131,11 +131,11 @@
 				return;
 			}
 
-			rb->velocity		= Vector3r(//
+			rb->vel		= Vector3r(//
 					velocity[0]+velocityRange[0]*randomSymmetricUnit(),
 					velocity[1]+velocityRange[1]*randomSymmetricUnit(),
 					velocity[2]+velocityRange[2]*randomSymmetricUnit());
-			rb->angularVelocity= Vector3r(//
+			rb->angVel = Vector3r(//
 					angularVelocity[0]+angularVelocityRange[0]*randomSymmetricUnit(),
 					angularVelocity[1]+angularVelocityRange[1]*randomSymmetricUnit(),
 					angularVelocity[2]+angularVelocityRange[2]*randomSymmetricUnit());
@@ -154,7 +154,7 @@
     shared_ptr<Body> facet = Body::byId(facetId);
 	InteractingFacet* ifacet = static_cast<InteractingFacet*>(facet->shape.get());
 
-	return t1*(ifacet->vertices[1]-ifacet->vertices[0])+t2*(ifacet->vertices[2]-ifacet->vertices[0])+ifacet->vertices[0]+facet->physicalParameters->se3.position;
+	return t1*(ifacet->vertices[1]-ifacet->vertices[0])+t2*(ifacet->vertices[2]-ifacet->vertices[0])+ifacet->vertices[0]+facet->state->se3.position;
     
 }
 
@@ -168,5 +168,5 @@
 }
 
 
-YADE_REQUIRE_FEATURE(PHYSPAR);
+//YADE_REQUIRE_FEATURE(PHYSPAR);
 

=== modified file 'scripts/test/ResetRandomPosition.py'
--- scripts/test/ResetRandomPosition.py	2009-12-09 17:11:51 +0000
+++ scripts/test/ResetRandomPosition.py	2009-12-09 18:53:59 +0000
@@ -14,6 +14,11 @@
 frictionAngle=radians(35)# 
 density=2700
 kw=utils.getViscoelasticFromSpheresInteraction(10e3,tc,en,es)
+params=utils.getViscoelasticFromSpheresInteraction(10e3,tc,en,es)
+# facets material
+facetMat=O.materials.append(SimpleViscoelasticMat(frictionAngle=frictionAngle,**params)) 
+# default spheres material
+dfltSpheresMat=O.materials.append(SimpleViscoelasticMat(density=density,frictionAngle=frictionAngle))
 
 O.dt=.2*tc # time step
 
@@ -23,40 +28,39 @@
 
 # Create geometry
 pln=Plane( (-.5, -.5, 0), (.5, -.5, -.05), (.5, .5, 0), (-.5, .5, -.05) ); 
-plnIds=O.bodies.append(pack.gtsSurface2Facets(pln.faces(),frictionAngle=frictionAngle,physParamsClass='SimpleViscoelasticBodyParameters',color=(0,1,0),**kw))
+plnIds=O.bodies.append(pack.gtsSurface2Facets(pln.faces(),material=facetMat,color=(0,1,0)))
 
 fct=Plane( (-.25, -.25, .5), (.25, -.25, .5), (.25, .25, .5), (-.25, .25, .5) ); 
-fctIds=O.bodies.append(pack.gtsSurface2Facets(fct.faces(),frictionAngle=frictionAngle,physParamsClass='SimpleViscoelasticBodyParameters',color=(1,0,0),noBoundingVolume=True))
+fctIds=O.bodies.append(pack.gtsSurface2Facets(fct.faces(),material=facetMat,color=(1,0,0),noBound=True))
 
 # Create spheres
 sp=pack.SpherePack(); 
 sp.makeCloud(Vector3(-.5, -.5, 0),Vector3(.5, .5, .2), Rs, Rf, int(nSpheres), False)
-spheres=O.bodies.append([utils.sphere(s[0],s[1],color=(0.929,0.412,0.412),density=density,frictionAngle=frictionAngle,physParamsClass="SimpleViscoelasticBodyParameters") for s in sp])
+spheres=O.bodies.append([utils.sphere(s[0],s[1],color=(0.929,0.412,0.412),material=dfltSpheresMat) for s in sp])
 for id in spheres:
 	s=O.bodies[id]
-	p=utils.getViscoelasticFromSpheresInteraction(s.phys['mass'],tc,en,es)
-	s.phys['kn'],s.phys['cn'],s.phys['ks'],s.phys['cs']=p['kn'],p['cn'],p['ks'],p['cs']
+	p=utils.getViscoelasticFromSpheresInteraction(s.state['mass'],tc,en,es)
+	s.mat['kn'],s.mat['cn'],s.mat['ks'],s.mat['cs']=p['kn'],p['cn'],p['ks'],p['cs']
 
 # Create engines
 O.initializers=[ BoundDispatcher([InteractingSphere2AABB(),InteractingFacet2AABB(),MetaInteractingGeometry2AABB()]) ]
 O.engines=[
 	BexResetter(),
-	BoundDispatcher([InteractingSphere2AABB(),InteractingFacet2AABB(), MetaInteractingGeometry2AABB()
-	]),
-	InsertionSortCollider(nBins=5,sweepLength=.1*Rs),
+	BoundDispatcher([InteractingSphere2AABB(),InteractingFacet2AABB()]),
+	InsertionSortCollider(),
 	InteractionDispatchers(
 		[InteractingSphere2InteractingSphere4SpheresContactGeometry(), InteractingFacet2InteractingSphere4SpheresContactGeometry()],
-		[SimpleViscoelasticRelationships()],
-		[ef2_Spheres_Viscoelastic_SimpleViscoelasticContactLaw()],
+		[Ip2_SimleViscoelasticMat_SimpleViscoelasticMat_SimpleViscoelasticPhys()],
+		[Law2_Spheres_Viscoelastic_SimpleViscoelastic()],
 	),
 	GravityEngine(gravity=[0,0,-9.81]),
 	NewtonIntegrator(damping=0),
 	ResetRandomPosition(factoryFacets=fctIds,velocity=(0,0,-2),virtPeriod=0.01,subscribedBodies=spheres,point=(0,0,-.5),normal=(0,0,1),maxAttempts=100),
 ]
 
-renderer = qt.Renderer()
-qt.View()
-O.saveTmp()
-O.run()
+#renderer = qt.Renderer()
+#qt.View()
+#O.saveTmp()
+#O.run()