← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-dev/yade/trunk] Rev 2263: 1. Remove pause time from omega, avoids negative realtime

 

------------------------------------------------------------
revno: 2263
fixes bug(s): https://launchpad.net/bugs/412393
committer: Václav Šmilauer <eudoxos@xxxxxxxx>
branch nick: trunk
timestamp: Sun 2010-05-30 15:41:00 +0200
message:
  1. Remove pause time from omega, avoids negative realtime
  2. Fix some scripts in scripts/test
renamed:
  scripts/test/bex-move.py => scripts/test/force-move.py
modified:
  core/Omega.cpp
  core/Omega.hpp
  gui/qt3/SimulationController.cpp
  py/pack/pack.py
  scripts/test/clump-hopper-viscoelastic.py
  scripts/test/clump-inbox-viscoelastic.py
  scripts/test/clump-viscoelastic.py
  scripts/test/collider-stride-triax.py
  scripts/test/wall.py
  scripts/test/force-move.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 'core/Omega.cpp'
--- core/Omega.cpp	2010-05-13 20:19:38 +0000
+++ core/Omega.cpp	2010-05-30 13:41:00 +0000
@@ -48,8 +48,6 @@
 CREATE_LOGGER(Omega);
 SINGLETON_SELF(Omega);
 
-// Omega::~Omega(){LOG_INFO("Shuting down; duration "<<(microsec_clock::local_time()-msStartingSimulationTime)/1000<<" s");}
-
 const map<string,DynlibDescriptor>& Omega::getDynlibsDescriptor(){return dynlibs;}
 
 long int Omega::getCurrentIteration(){ return (scene?scene->currentIteration:-1); }
@@ -64,10 +62,8 @@
 void Omega::setScene(shared_ptr<Scene>& rb){ RenderMutexLock lock; scene=rb;}
 void Omega::resetScene(){ RenderMutexLock lock; scene = shared_ptr<Scene>(new Scene);}
 
-ptime Omega::getMsStartingSimulationTime(){return msStartingSimulationTime;}
-time_duration Omega::getSimulationPauseDuration(){return simulationPauseDuration;}
-Real Omega::getComputationTime(){ return (microsec_clock::local_time()-msStartingSimulationTime-simulationPauseDuration).total_milliseconds()/1e3; }
-time_duration Omega::getComputationDuration(){return microsec_clock::local_time()-msStartingSimulationTime-simulationPauseDuration;}
+Real Omega::getComputationTime(){ return (microsec_clock::local_time()-msStartingSimulationTime).total_milliseconds()/1e3; }
+time_duration Omega::getComputationDuration(){return microsec_clock::local_time()-msStartingSimulationTime;}
 
 
 void Omega::initTemps(){
@@ -103,8 +99,6 @@
 
 void Omega::timeInit(){
 	msStartingSimulationTime=microsec_clock::local_time();
-	simulationPauseDuration=msStartingSimulationTime-msStartingSimulationTime;
-	msStartingPauseTime=msStartingSimulationTime;
 }
 
 void Omega::createSimulationLoop(){	simulationLoop=shared_ptr<ThreadRunner>(new ThreadRunner(&simulationFlow_));}
@@ -125,7 +119,6 @@
 void Omega::startSimulationLoop(){
 	if(!simulationLoop){ LOG_ERROR("No Omega::simulationLoop? Creating one (please report bug)."); createSimulationLoop(); }
 	if (simulationLoop && !simulationLoop->looping()){
-		simulationPauseDuration += microsec_clock::local_time()-msStartingPauseTime;
 		simulationLoop->start();
 	}
 }
@@ -133,7 +126,6 @@
 
 void Omega::stopSimulationLoop(){
 	if (simulationLoop && simulationLoop->looping()){
-		msStartingPauseTime = microsec_clock::local_time();
 		simulationLoop->stop();
 	}
 }

=== modified file 'core/Omega.hpp'
--- core/Omega.hpp	2010-05-13 20:19:38 +0000
+++ core/Omega.hpp	2010-05-30 13:41:00 +0000
@@ -133,9 +133,6 @@
 		void		setScene(shared_ptr<Scene>&);
 		void		resetScene();
 		
-		ptime		getMsStartingSimulationTime();
-		time_duration	getSimulationPauseDuration();
-		
 		void		setSimulationFileName(const string);
 		string	getSimulationFileName();
 		void		loadSimulation();

=== modified file 'gui/qt3/SimulationController.cpp'
--- gui/qt3/SimulationController.cpp	2010-05-26 17:49:15 +0000
+++ gui/qt3/SimulationController.cpp	2010-05-30 13:41:00 +0000
@@ -388,9 +388,8 @@
 	string sim=Omega::instance().getSimulationFileName();
 	tlCurrentSimulation->setText(sim.empty() ? "[no file]" : sim); 
 
-	if(Omega::instance().isRunning()){
-		duration = microsec_clock::local_time()-Omega::instance().getMsStartingSimulationTime();
-		duration -= Omega::instance().getSimulationPauseDuration();
+	{
+		duration = Omega::instance().getComputationDuration();
 
 		unsigned int hours	= duration.hours();
 		unsigned int minutes 	= duration.minutes();
@@ -400,8 +399,8 @@
 		hours			= hours-24*days;
 
 		char strReal[64];
-		if(days>0) snprintf(strReal,64,"real %dd %02d:%02d:%03d.%03d",days,hours,minutes,seconds,mseconds);
-		else snprintf(strReal,64,"real %02d:%02d:%03d.%03d",hours,minutes,seconds,mseconds);
+		if(days>0) snprintf(strReal,64,"real %dd %02d:%02d:%02d",days,hours,minutes,seconds);
+		else snprintf(strReal,64,"real %02d:%02d:%02d",hours,minutes,seconds);
 		string s(strReal);
 	   // update estimation time
 		if (scene->stopAtIteration>0 && iterPerSec>0){

=== modified file 'py/pack/pack.py'
--- py/pack/pack.py	2010-05-28 20:57:41 +0000
+++ py/pack/pack.py	2010-05-30 13:41:00 +0000
@@ -376,7 +376,7 @@
 			# upperCorner is just size ratio, if radiusMean is specified
 			upperCorner=fullDim,
 			## no need to touch any the following
-			noFiles=True,lowerCorner=[0,0,0],sigmaIsoCompaction=1e7,sigmaLateralConfinement=1e3,StabilityCriterion=.05,strainRate=.2,fast=True,thickness=-1,maxWallVelocity=.1,wallOversizeFactor=1.5,autoUnload=True,autoCompressionActivation=False).load()
+			noFiles=True,lowerCorner=[0,0,0],sigmaIsoCompaction=1e7,sigmaLateralConfinement=1e3,StabilityCriterion=.05,strainRate=.2,thickness=-1,maxWallVelocity=.1,wallOversizeFactor=1.5,autoUnload=True,autoCompressionActivation=False).load()
 		log.setLevel('TriaxialCompressionEngine',log.WARN)
 		O.run(); O.wait()
 		sp=SpherePack(); sp.fromSimulation()

=== modified file 'scripts/test/clump-hopper-viscoelastic.py'
--- scripts/test/clump-hopper-viscoelastic.py	2010-04-10 15:11:48 +0000
+++ scripts/test/clump-hopper-viscoelastic.py	2010-05-30 13:41:00 +0000
@@ -52,8 +52,8 @@
 	clpId,sphId=O.bodies.appendClumped([utils.sphere(Vector3(x0t+Rs*(k*4+2),y0t+Rs*(l*4+2),i*Rs*2+zt),Rs,color=clumpColor,material=dfltSpheresMat) for i in xrange(4)])
 	for id in sphId:
 		s=O.bodies[id]
-		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']
+		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']
 	#O.bodies[clpId].state.blockedDOFs=['rx','ry','rz']
 	#O.bodies[clpId].state.blockedDOFs=['x','y']
 
@@ -63,8 +63,8 @@
 	sphAloneId=O.bodies.append( [utils.sphere( Vector3(x0t+Rs*(k*4+4),y0t+Rs*(l*4+4),i*Rs*2.3+zt),Rs,color=spheresColor,material=dfltSpheresMat) for i in xrange(4) ] )
 	for id in sphAloneId:
 		s=O.bodies[id]
-		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']
+		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']
 		#s.state.blockedDOFs=['rx','ry','rz']
 		#s.state.blockedDOFs=['x','y']
 
@@ -76,7 +76,7 @@
 	InteractionDispatchers(
 		[Ig2_Sphere_Sphere_ScGeom(), Ig2_Facet_Sphere_ScGeom()],
 		[Ip2_ViscElMat_ViscElMat_ViscElPhys()],
-		[Law2_Spheres_Viscoelastic_SimpleViscoelastic()],
+		[Law2_ScGeom_ViscElPhys_Basic()],
 	),
 	GravityEngine(gravity=[0,0,-9.81]),
 	NewtonIntegrator(damping=0,exactAsphericalRot=True),

=== modified file 'scripts/test/clump-inbox-viscoelastic.py'
--- scripts/test/clump-inbox-viscoelastic.py	2010-04-10 15:11:48 +0000
+++ scripts/test/clump-inbox-viscoelastic.py	2010-05-30 13:41:00 +0000
@@ -47,15 +47,15 @@
 	clpId,sphId=O.bodies.appendClumped([utils.sphere(Vector3(0,Rs*2*i,(j+1)*Rs*2),Rs,material=dfltSpheresMat) for i in xrange(4)])
 	for id in sphId:
 		s=O.bodies[id]
-		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']
+		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']
 
 # ... and spheres
 sphAloneId=O.bodies.append( [utils.sphere( Vector3(0.5,Rs*2*i,(j+1)*Rs*2), Rs, material=dfltSpheresMat) for i in xrange(4) ] )
 for id in sphAloneId:
 	s=O.bodies[id]
-	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']
+	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.engines=[
@@ -65,10 +65,10 @@
 	InteractionDispatchers(
 		[Ig2_Sphere_Sphere_ScGeom(), Ig2_Facet_Sphere_ScGeom()],
 		[Ip2_ViscElMat_ViscElMat_ViscElPhys()],
-		[Law2_Spheres_Viscoelastic_SimpleViscoelastic()],
+		[Law2_ScGeom_ViscElPhys_Basic()],
 	),
 	GravityEngine(gravity=[0,0,-9.81]),
-	NewtonIntegrator(damping=0,accRigidBodyRot=True),
+	NewtonIntegrator(damping=0,exactAsphericalRot=True),
 ]
 
 renderer = qt.Renderer()

=== modified file 'scripts/test/clump-viscoelastic.py'
--- scripts/test/clump-viscoelastic.py	2010-04-10 15:11:48 +0000
+++ scripts/test/clump-viscoelastic.py	2010-05-30 13:41:00 +0000
@@ -45,10 +45,10 @@
 	InteractionDispatchers(
 		[Ig2_Sphere_Sphere_ScGeom(), Ig2_Facet_Sphere_ScGeom()],
 		[Ip2_ViscElMat_ViscElMat_ViscElPhys()],
-		[Law2_Spheres_Viscoelastic_SimpleViscoelastic()],
+		[Law2_ScGeom_ViscElPhys_Basic()],
 	),
 	GravityEngine(gravity=[0,0,-9.81]),
-	NewtonIntegrator(damping=0,accRigidBodyRot=True),
+	NewtonIntegrator(damping=0,exactAsphericalRot=True),
 ]
 
 
@@ -62,34 +62,31 @@
 print '\nClump:\n======'
 #print '\nMaterial:'
 if clump.mat:
-	for k in clump.mat.keys():
-		print k,'=',clump.mat[k]
+	print clump.mat.dict()
 else:
 	print 'no material'
 
-print '\nMold:'
-if clump.mold:
-	for k in clump.mold.keys():
-		print k,'=',clump.mold[k]
+print '\nshape:'
+if clump.shape:
+	print k.shape.dict()
 else:
-	print 'no mold'
+	print 'no shape'
 
 print '\nState:'
 if clump.state:
-	for k in clump.state.keys():
-		print k,'=',clump.state[k]
+	print clump.state.dict()
 else:
 	print 'no state'
 
 print '\nControl:'
-mass = sum( [ s.state['mass'] for s in spheres ] )
-xm_ = [ s.state['pos'][0]*s.state['mass'] for s in spheres ]
-ym_ = [ s.state['pos'][1]*s.state['mass'] for s in spheres ]
-zm_ = [ s.state['pos'][2]*s.state['mass'] for s in spheres ]
+mass = sum( [ s.state.mass for s in spheres ] )
+xm_ = [ s.state.pos[0]*s.state.mass for s in spheres ]
+ym_ = [ s.state.pos[1]*s.state.mass for s in spheres ]
+zm_ = [ s.state.pos[2]*s.state.mass for s in spheres ]
 centroid  = Vector3( sum(xm_)/mass, sum(ym_)/mass, sum(zm_)/mass )
 
-def sphereInertiaTenzor(p, m, r, c):
-	''' Inertia tenzor sphere with position p, mass m and radus r relative point c '''
+def sphereInertiaTensor(p, m, r, c):
+	''' Inertia tensor sphere with position p, mass m and radus r relative point c '''
 	I = zeros((3,3))
 	rp = array(p)-array(c)
 	I[0,0] = 2./5.*m*r*r + m*(rp[1]**2+rp[2]**2)
@@ -101,7 +98,7 @@
 
 I = zeros((3,3))
 for s in spheres:
-	I += sphereInertiaTenzor(s.state['pos'],s.state['mass'],s.mold['radius'],centroid)
+	I += sphereInertiaTensor(s.state.pos,s.state.mass,s.shape.radius,centroid)
 I_eigenvalues, I_eigenvectors = linalg.eig(I)
 
 print 'mass = ', mass

=== modified file 'scripts/test/collider-stride-triax.py'
--- scripts/test/collider-stride-triax.py	2009-12-09 17:11:51 +0000
+++ scripts/test/collider-stride-triax.py	2010-05-30 13:41:00 +0000
@@ -4,7 +4,7 @@
 import os.path
 loadFrom='/tmp/triax.xml'
 #if not os.path.exists(loadFrom):
-TriaxialTest(numberOfGrains=2000,fast=True,noFiles=True).generate(loadFrom)
+TriaxialTest(numberOfGrains=2000,noFiles=True).generate(loadFrom)
 O.load(loadFrom)
 log.setLevel('TriaxialCompressionEngine',log.WARN) # shut up
 log.setLevel('InsertionSortCollider',log.DEBUG)
@@ -15,11 +15,11 @@
 # use striding; say "if 0:" to disable striding and compare to regular runs
 if 1:
 	# length by which bboxes will be made larger
-	collider['sweepLength']=.2*O.bodies[100].shape['radius']
+	collider.sweepLength=.2*O.bodies[100].shape.radius
 	# if this is enabled, bboxes will be enlarged based on velocity bin for each body
 	if 1:
-		collider['nBins']=3
-		collider['binCoeff']=10
+		collider.nBins=3
+		collider.binCoeff=10
 		log.setLevel('VelocityBins',log.DEBUG)
 
 O.step() # filter out initialization

=== renamed file 'scripts/test/bex-move.py' => 'scripts/test/force-move.py'
--- scripts/test/bex-move.py	2009-12-25 14:46:48 +0000
+++ scripts/test/force-move.py	2010-05-30 13:41:00 +0000
@@ -1,11 +1,11 @@
 O.bodies.append(utils.sphere([0,0,0],1,dynamic=True))
 O.engines=[
 	ForceResetter(),
-	PeriodicPythonRunner(command='O.bex.addMove(0,(1e-2,0,0))',iterPeriod=1),
+	PeriodicPythonRunner(command='O.forces.addMove(0,(1e-2,0,0))',iterPeriod=1),
 	NewtonIntegrator()
 ]
 
 for i in xrange(0,20):
 	O.step()
-	print O.bex.f(0),O.bodies[0].state.pos
+	print O.forces.f(0),O.bodies[0].state.pos
 quit()

=== modified file 'scripts/test/wall.py'
--- scripts/test/wall.py	2010-03-22 17:39:33 +0000
+++ scripts/test/wall.py	2010-05-30 13:41:00 +0000
@@ -2,20 +2,18 @@
 Show basic wall functionality (infinite axis-aligned planes).
 """
 from yade import utils
-kw=dict(young=30e9,density=1000)
+O.materials.append(FrictMat(young=30e9,density=1000,poisson=.2,frictionAngle=.5)
 O.bodies.append([
-	utils.wall(1,axis=2,sense=-1,**kw),
-	utils.wall(-5,axis=0,sense=1,**kw),
-	utils.wall(1,axis=1,**kw),
-	utils.wall((1,0,0),0,**kw),
+	utils.wall(1,axis=2,sense=-1),
+	utils.wall(-5,axis=0,sense=1),
+	utils.wall(1,axis=1),
+	utils.wall((1,0,0),0),
 	utils.sphere([0,0,0],.5),
-	utils.sphere([-5,-4,-3],.5,**kw)
+	utils.sphere([-5,-4,-3],.5)
 ])
 Gl1_Wall(div=10)
 
 from yade import qt
-renderer=qt.Renderer()
-renderer['Body_interacting_geom']=True
 qt.Controller()
 qt.View()