← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-dev/yade/trunk] Rev 2135: 1. Import yade.plot when showing graph

 

------------------------------------------------------------
revno: 2135
committer: Václav Šmilauer <eudoxos@xxxxxxxx>
branch nick: trunk
timestamp: Fri 2010-04-09 13:25:18 +0200
message:
  1. Import yade.plot when showing graph
  2. Fix bibtex entry
  3. Handle unseen interaction in InteractionDispatchers differently than with requestErase, as that will not work with certain colliders
  4. Add from yade import utils to utils.py docstrings, and show full utils.sphere instead of sphere in session transcripts (thanks to Jerome for pointing that out)
modified:
  core/main/main.py.in
  doc/references.bib
  examples/collider-perf/perf.py
  gui/qt3/GLViewer.cpp
  pkg/common/Engine/Dispatcher/InteractionDispatchers.cpp
  pkg/common/Engine/Dispatcher/InteractionDispatchers.hpp
  pkg/common/RenderingEngine/OpenGLRenderingEngine.cpp
  pkg/dem/Engine/GlobalEngine/NewtonIntegrator.cpp
  pkg/dem/Engine/GlobalEngine/NewtonIntegrator.hpp
  py/utils.py
  scripts/test/facet-sphere.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/main/main.py.in'
--- core/main/main.py.in	2010-03-27 22:18:10 +0000
+++ core/main/main.py.in	2010-04-09 11:25:18 +0000
@@ -141,7 +141,7 @@
 					'"\e[23~": "\C-Uyade.qt.View();\C-M"', # F11
 					'"\e[21~": "\C-Uyade.qt.Controller(), yade.qt.View();\C-M"', # F10
 					'"\e[20~": "\C-Uyade.qt.Generator();\C-M"', #F9
-					'"\e[19~": "\C-Uyade.plot.plot();\C-M"', #F9
+					'"\e[19~": "\C-Uimport yade.plot; yade.plot.plot();\C-M"', #F9
 					'"\e[A": history-search-backward', '"\e[B": history-search-forward', # incremental history forward/backward
 					] if qtEnabled else [])
 			)

=== modified file 'doc/references.bib'
--- doc/references.bib	2010-04-05 10:43:04 +0000
+++ doc/references.bib	2010-04-09 11:25:18 +0000
@@ -88,5 +88,5 @@
 	year={2009},
 	author={Jean-François Jerier and  Didier Imbault and Fréderic-Victor Donzé and Pierre Doremus},
 	doi={10.1007/s10035-008-0116-0},
-	url=http://www.springerlink.com/content/w0x307g110421035}
+	url={http://www.springerlink.com/content/w0x307g110421035}
 }

=== modified file 'examples/collider-perf/perf.py'
--- examples/collider-perf/perf.py	2009-12-09 17:11:51 +0000
+++ examples/collider-perf/perf.py	2010-04-09 11:25:18 +0000
@@ -21,9 +21,9 @@
 TriaxialTest(importFilename=spheresFile,fast=fast,noFiles=True).load()
 O.dt=utils.PWaveTimeStep()
 isc=O.engines[2]
-isc['sweepLength']=1e-1
+isc.sweepLength=1e-1
 
-if not fast: utils.replaceCollider(GlobalEngine(collider))
+if not fast: utils.replaceCollider(eval(collider))
 
 O.step()
 timing.stats()

=== modified file 'gui/qt3/GLViewer.cpp'
--- gui/qt3/GLViewer.cpp	2010-03-29 12:28:06 +0000
+++ gui/qt3/GLViewer.cpp	2010-04-09 11:25:18 +0000
@@ -13,12 +13,6 @@
 #include"YadeCamera.hpp"
 #include"YadeQtMainWindow.hpp"
 
-#ifdef __APPLE__
-#  include <GLUT/glut.h>
-#else
-#  include <GL/glut.h>
-#endif
-
 #include<yade/lib-opengl/FpsTracker.hpp>
 #include<yade/lib-opengl/OpenGLWrapper.hpp>
 #include<yade/core/Body.hpp>

=== modified file 'pkg/common/Engine/Dispatcher/InteractionDispatchers.cpp'
--- pkg/common/Engine/Dispatcher/InteractionDispatchers.cpp	2010-03-20 12:40:44 +0000
+++ pkg/common/Engine/Dispatcher/InteractionDispatchers.cpp	2010-04-09 11:25:18 +0000
@@ -65,7 +65,7 @@
 	#endif
 		#ifdef DISPATCH_CACHE
 			if(removeUnseenIntrs && !I->isReal() && I->iterLastSeen<scene->currentIteration) {
-				scene->interactions->requestErase(I->getId1(),I->getId2());
+				eraseAfterLoop(I->getId1(),I->getId2());
 				continue;
 			}
 
@@ -166,7 +166,7 @@
 			physDispatcher->operator()(Body::byId(I->getId1(),scene)->material, Body::byId(I->getId2(),scene)->material,I);
 			// LawDispatcher
 			lawDispatcher->operator()(I->interactionGeometry,I->interactionPhysics,I.get(),scene);
-			if(!I->isReal() && I->isFresn(scene)) LOG_WARN("Law functor deleted interaction that was just created. Please report bug: either this message is spurious, or the functor (or something else) is buggy.");
+			if(!I->isReal() && I->isFresh(scene)) LOG_WARN("Law functor deleted interaction that was just created. Please report bug: either this message is spurious, or the functor (or something else) is buggy.");
 		#endif
 
 		// process callbacks for this interaction
@@ -175,4 +175,14 @@
 			if(callbackPtrs[i]!=NULL) (*(callbackPtrs[i]))(callbacks[i].get(),I.get());
 		}
 	}
+	// process eraseAfterLoop
+	#ifdef YADE_OPENMP
+		FOREACH(list<idPair>& l, eraseAfterLoopIds){
+			FOREACH(idPair p,l) scene->interactions->erase(p.first,p.second);
+			l.clear();
+		}
+	#else
+		FOREACH(idPair p, eraseAfterLoopIds) scene->interactions->erase(p.first,p.second);
+		eraseAfterLoopIds.clear();
+	#endif
 }

=== modified file 'pkg/common/Engine/Dispatcher/InteractionDispatchers.hpp'
--- pkg/common/Engine/Dispatcher/InteractionDispatchers.hpp	2010-03-20 12:40:44 +0000
+++ pkg/common/Engine/Dispatcher/InteractionDispatchers.hpp	2010-04-09 11:25:18 +0000
@@ -11,6 +11,15 @@
 
 class InteractionDispatchers: public GlobalEngine {
 	bool alreadyWarnedNoCollider;
+	typedef std::pair<body_id_t, body_id_t> idPair;
+	// store interactions that should be deleted after loop in action, not later
+	#ifdef YADE_OPENMP
+		vector<list<idPair> > eraseAfterLoopIds;
+		void eraseAfterLoop(body_id_t id1,body_id_t id2){ eraseAfterLoopIds[omp_get_thread_num()].push_back(idPair(id1,id2)); }
+	#else
+		list<idPair> eraseAfterLoopIds;
+		void eraseAfterLoop(body_id_t id1,body_id_t id2){ eraseAfterLoopIds.push_back(id_pair(id1,id2)); }
+	#endif
 	public:
 		virtual void action();
 		YADE_CLASS_BASE_DOC_ATTRS_CTOR_PY(InteractionDispatchers,GlobalEngine,"Unified dispatcher for handling interaction loop at every step, for parallel performance reasons.",
@@ -23,6 +32,9 @@
 				#ifdef IDISP_TIMING
 					timingDeltas=shared_ptr<TimingDeltas>(new TimingDeltas);
 				#endif
+				#ifdef YADE_OPENMP
+					eraseAfterLoopIds.resize(omp_get_max_threads());
+				#endif
 			,
 			/*py*/
 			.def("__init__",python::make_constructor(InteractionDispatchers_ctor_lists),

=== modified file 'pkg/common/RenderingEngine/OpenGLRenderingEngine.cpp'
--- pkg/common/RenderingEngine/OpenGLRenderingEngine.cpp	2010-03-28 21:22:25 +0000
+++ pkg/common/RenderingEngine/OpenGLRenderingEngine.cpp	2010-04-09 11:25:18 +0000
@@ -50,6 +50,8 @@
 	}
 
 	initDone=true;
+	int e=glGetError();
+	if(e!=GL_NO_ERROR) throw runtime_error((string("OpenGLRenderingEngine::init returned GL error ")+lexical_cast<string>(e)).c_str());
 }
 
 void OpenGLRenderingEngine::setBodiesRefSe3(){

=== modified file 'pkg/dem/Engine/GlobalEngine/NewtonIntegrator.cpp'
--- pkg/dem/Engine/GlobalEngine/NewtonIntegrator.cpp	2010-04-03 16:40:33 +0000
+++ pkg/dem/Engine/GlobalEngine/NewtonIntegrator.cpp	2010-04-09 11:25:18 +0000
@@ -111,13 +111,13 @@
 				state->accel=f/state->mass; 
 				cundallDamp(dt,f,state->vel,state->accel); 
 				leapfrogTranslate(scene,state,id,dt);
-				// rotate equation
-				if (!exactAsphericalRot){ // exactAsphericalRot disabled
+				// rotate equation: exactAsphericalRot is disabled or the body is spherical
+				if (!exactAsphericalRot || (state->inertia[0]==state->inertia[1] && state->inertia[1]==state->inertia[2])){
 					const Vector3r& m=scene->forces.getTorque(id); 
 					state->angAccel=diagDiv(m,state->inertia);
 					cundallDamp(dt,m,state->angVel,state->angAccel);
 					leapfrogSphericalRotate(scene,state,id,dt);
-				} else { // exactAsphericalRot enabled
+				} else { // exactAsphericalRot enabled & aspherical body
 					const Vector3r& m=scene->forces.getTorque(id); 
 					leapfrogAsphericalRotate(scene,state,id,dt,m);
 				}
@@ -130,7 +130,8 @@
 				const Vector3r& m=scene->forces.getTorque(id);
 				Vector3r M(m);
 				// sum force on clump memebrs
-				if (exactAsphericalRot){
+				// exactAsphericalRot enabled and clump is aspherical
+				if (exactAsphericalRot && ((state->inertia[0]!=state->inertia[1] || state->inertia[1]!=state->inertia[2]))){
 					FOREACH(Clump::memberMap::value_type mm, static_cast<Clump*>(b.get())->members){
 						const body_id_t& memberId=mm.first;
 						const shared_ptr<Body>& member=Body::byId(memberId,scene); assert(b->isClumpMember());
@@ -142,7 +143,7 @@
 					// motion
 					leapfrogTranslate(scene,state,id,dt);
 					leapfrogAsphericalRotate(scene,state,id,dt,M);
-				} else { // exactAsphericalRot disabled
+				} else { // exactAsphericalRot disabled or clump is spherical
 					Vector3r dAngAccel=diagDiv(M,state->inertia);
 					cundallDamp(dt,M,state->angVel,dAngAccel);
 					state->angAccel+=dAngAccel;

=== modified file 'pkg/dem/Engine/GlobalEngine/NewtonIntegrator.hpp'
--- pkg/dem/Engine/GlobalEngine/NewtonIntegrator.hpp	2010-04-04 22:05:37 +0000
+++ pkg/dem/Engine/GlobalEngine/NewtonIntegrator.hpp	2010-04-09 11:25:18 +0000
@@ -69,7 +69,7 @@
 	YADE_CLASS_BASE_DOC_ATTRS_CTOR(NewtonIntegrator,GlobalEngine,"Engine integrating newtonian motion equations.",
 		((Real,damping,0.2,"damping coefficient for Cundall's non viscous damping (see [Chareyre2005]_) [-]"))
 		((Real,maxVelocitySq,NaN,"store square of max. velocity, for informative purposes; computed again at every step. |yupdate|"))
-		((bool,exactAsphericalRot,false,"Enable of the exact aspherical body rotation integrator, using formulation from [Allen1989]_, pg. 89."))
+		((bool,exactAsphericalRot,true,"Enable more exact body rotation integrator for aspherical bodies *only*, using formulation from [Allen1989]_, pg. 89."))
 		((int,homotheticCellResize,((void)"disabled",0),"Enable artificially moving all bodies with the periodic cell, such that its resizes are isotropic. 0: disabled, 1: position update, 2: velocity update."))
 		((vector<shared_ptr<BodyCallback> >,callbacks,,"List (std::vector in c++) of :yref:`BodyCallbacks<BodyCallback>` which will be called for each body as it is being processed."))
 		,

=== modified file 'py/utils.py'
--- py/utils.py	2010-04-06 08:32:01 +0000
+++ py/utils.py	2010-04-09 11:25:18 +0000
@@ -27,13 +27,14 @@
 
 	For example, variables a=5, b=66 and c=7.5e-4 are defined. To save those, use::
 
-		>>> saveVars('mark',a=1,b=2,c=3,loadNow=True)
+		>>> from yade import utils
+		>>> utils.saveVars('mark',a=1,b=2,c=3,loadNow=True)
 		>>> a,b,c
 		(1, 2, 3)
 
 	those variables will be save in the .xml file, when the simulation itself is saved. To recover those variables once the .xml is loaded again, use
 
-		>>> loadVars('mark')
+		>>> utils.loadVars('mark')
 
 	and they will be defined in the __builtin__ namespace (i.e. available from anywhere in the python code).
 
@@ -137,15 +138,16 @@
 	Creating default shared material if none exists neither is given::
 
 		>>> O.reset()
+		>>> from yade import utils
 		>>> len(O.materials)
 		0
-		>>> s0=sphere([2,0,0],1)
+		>>> s0=utils.sphere([2,0,0],1)
 		>>> len(O.materials)
 		1
 
 	Instance of material can be given::
 
-		>>> s1=sphere([0,0,0],1,wire=False,color=(0,1,0),material=ElastMat(young=30e9,density=2e3))
+		>>> s1=utils.sphere([0,0,0],1,wire=False,color=(0,1,0),material=ElastMat(young=30e9,density=2e3))
 		>>> s1.shape.wire
 		False
 		>>> s1.shape.color
@@ -157,7 +159,7 @@
 
 		>>> O.materials.append(FrictMat(young=10e9,poisson=.11,label='myMaterial'))
 		1
-		>>> s2=sphere([0,0,2],1,material='myMaterial')
+		>>> s2=utils.sphere([0,0,2],1,material='myMaterial')
 		>>> s2.mat.label
 		'myMaterial'
 		>>> s2.mat.poisson
@@ -172,8 +174,8 @@
 		>>> import random
 		>>> def matFactory(): return ElastMat(young=1e10*random.random(),density=1e3+1e3*random.random())
 		... 
-		>>> s3=sphere([0,2,0],1,material=matFactory)
-		>>> s4=sphere([1,2,0],1,material=matFactory)
+		>>> s3=utils.sphere([0,2,0],1,material=matFactory)
+		>>> s4=utils.sphere([1,2,0],1,material=matFactory)
 
 	"""
 	b=Body()

=== modified file 'scripts/test/facet-sphere.py'
--- scripts/test/facet-sphere.py	2010-03-22 17:39:33 +0000
+++ scripts/test/facet-sphere.py	2010-04-09 11:25:18 +0000
@@ -24,7 +24,7 @@
 import random
 for i in range(0,100):
 	s=utils.sphere([random.gauss(0,1),random.gauss(0,1),random.uniform(1,2)],random.uniform(.02,.05))
-	s.state['vel']=Vector3(random.gauss(0,.1),random.gauss(0,.1),random.gauss(0,.1))
+	s.state.vel=Vector3(random.gauss(0,.1),random.gauss(0,.1),random.gauss(0,.1))
 	O.bodies.append(s)
 
 O.dt=utils.PWaveTimeStep()


Follow ups