← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-dev/yade/trunk] Rev 2609: 1.Add silent switcher to NozzleFactory; 2.Fix examples

 

------------------------------------------------------------
revno: 2609
committer: Sergei D. <sega@think>
branch nick: trunk
timestamp: Sun 2010-12-19 12:55:19 +0300
message:
  1.Add silent switcher to NozzleFactory; 2.Fix examples
modified:
  examples/ring2d/ringSimpleViscoelastic.py
  pkg/dem/NozzleFactory.cpp
  pkg/dem/NozzleFactory.hpp
  scripts/test/shots.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 'examples/ring2d/ringSimpleViscoelastic.py'
--- examples/ring2d/ringSimpleViscoelastic.py	2010-11-09 10:57:08 +0000
+++ examples/ring2d/ringSimpleViscoelastic.py	2010-12-19 09:55:19 +0000
@@ -67,7 +67,7 @@
 	NewtonIntegrator(damping=0),
 	## Apply kinematics to walls
     ## angularVelocity = 0.73 rad/sec = 7 rpm
-	RotationEngine(subscribedBodies=walls,rotationAxis=[0,0,1],rotateAroundZero=True,angularVelocity=0.73)
+	RotationEngine(ids=walls,rotationAxis=[0,0,1],rotateAroundZero=True,angularVelocity=0.73)
 
 ]
 
@@ -78,7 +78,7 @@
 
 for b in o.bodies:
 	if b.shape.name=='Sphere':
-		b.state.blockedDOFs=['z']
+		b.state.blockedDOFs=['z','rx','ry']
 
 
 O.dt=0.02*tc

=== modified file 'pkg/dem/NozzleFactory.cpp'
--- pkg/dem/NozzleFactory.cpp	2010-11-12 08:03:16 +0000
+++ pkg/dem/NozzleFactory.cpp	2010-12-19 09:55:19 +0000
@@ -31,6 +31,8 @@
 	goalMass+=massFlowRate*scene->dt; // totalMass that we want to attain in the current step
 
 	normal.normalize();
+	const Quaternionr q(Quaternionr().setFromTwoVectors(Vector3r::UnitZ(),normal));
+
 	LOG_TRACE("totalMass="<<totalMass<<", goalMass="<<goalMass);
 
 	while(totalMass<goalMass && (maxParticles<0 || numParticles<maxParticles)){
@@ -41,11 +43,10 @@
 		// until there is no overlap, pick a random position for the new particle
 		int attempt;
 		for(attempt=0; attempt<maxAttempt; attempt++){
-			//TODO: update c (position on the circle in space)
-			//Real angle=randomUnit()*2*Mathr::PI, rr=randomUnit()*(radius-r); // random polar coordinate inside the nozzle
+			Real angle=randomUnit()*2*Mathr::PI, rr=randomUnit()*(radius-r); // random polar coordinate inside the nozzle
+			c = center+q*Vector3r(cos(angle)*rr,sin(angle)*rr,0)
 			// this version places center in a box around the nozzle center (its size 1.15=2/sqrt(3) diagonal, which is not very exact
-			c=center+Vector3r((randomUnit()-.5)*1.15*radius,(randomUnit()-.5)*1.15*radius,(randomUnit()-.5)*1.15*radius);
-			
+			//c=center+Vector3r((randomUnit()-.5)*1.15*radius,(randomUnit()-.5)*1.15*radius,(randomUnit()-.5)*1.15*radius);
 			LOG_TRACE("Center "<<c);
 			Bound b; b.min=c-Vector3r(r,r,r); b.max=c+Vector3r(r,r,r);
 			vector<Body::id_t> collidingParticles=collider->probeBoundingVolume(b);
@@ -55,7 +56,8 @@
 			#endif
 		}
 		if(attempt==maxAttempt) {
-			LOG_WARN("Unable to place new sphere after "<<maxAttempt<<" attempts, giving up.");
+			if (silent) {massFlowRate=0;} 
+			else {LOG_WARN("Unable to place new sphere after "<<maxAttempt<<" attempts, giving up.");}
 			return;
 		}
 		// pick random initial velocity (normal with some variation)

=== modified file 'pkg/dem/NozzleFactory.hpp'
--- pkg/dem/NozzleFactory.hpp	2010-11-07 11:46:20 +0000
+++ pkg/dem/NozzleFactory.hpp	2010-12-19 09:55:19 +0000
@@ -25,6 +25,7 @@
 		((int,maxParticles,100,,"The number of particles at which to stop generating new ones (regardless of massFlowRate"))
 		((int,numParticles,0,,"Cummulative number of particles produces so far |yupdate|"))
 		((int,maxAttempt,5000 ,,"Maximum number of attempts to position a new sphere randomly."))
+		((bool,silent,false ,,"If true no complain about excessing maxAttempt but disable factory (by set massFlowRate=0)."))
 	);
 };
 REGISTER_SERIALIZABLE(NozzleFactory);

=== modified file 'scripts/test/shots.py'
--- scripts/test/shots.py	2010-09-27 17:47:59 +0000
+++ scripts/test/shots.py	2010-12-19 09:55:19 +0000
@@ -19,7 +19,8 @@
 		[Ig2_Sphere_Sphere_ScGeom(),Ig2_Facet_Sphere_ScGeom()],
 		[Ip2_FrictMat_FrictMat_MindlinPhys(
 			# define restitution coefficients between different pairs of material ids, see the functor's documentation for details
-			en=MatchMaker(fallback='zero',matches=((steelId,shotsId,.4),(shotsId,shotsId,1)))
+			#en=MatchMaker(fallback='zero',matches=((steelId,shotsId,.4),(shotsId,shotsId,1)))
+			en=MatchMaker(matches=((steelId,shotsId,.4),(shotsId,shotsId,1)))
 		)],
 		[Law2_ScGeom_MindlinPhys_Mindlin(label='contactLaw')]
 	),