← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-dev/yade/trunk] Rev 2593: 1. Add Gl1_L6Geom, and a few params to Gl1_L3Geom as well

 

------------------------------------------------------------
revno: 2593
committer: Václav Šmilauer <eu@xxxxxxxx>
branch nick: yade
timestamp: Tue 2010-12-07 14:38:35 +0100
message:
  1. Add Gl1_L6Geom, and a few params to Gl1_L3Geom as well
  2. Add movie to scripts/test/beam-l6geom.py
modified:
  pkg/dem/L3Geom.cpp
  pkg/dem/L3Geom.hpp
  scripts/test/beam-l6geom.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/dem/L3Geom.cpp'
--- pkg/dem/L3Geom.cpp	2010-12-06 22:58:31 +0000
+++ pkg/dem/L3Geom.cpp	2010-12-07 13:38:35 +0000
@@ -11,7 +11,7 @@
 
 YADE_PLUGIN((L3Geom)(L6Geom)(Ig2_Sphere_Sphere_L3Geom_Inc)(Ig2_Wall_Sphere_L3Geom_Inc)(Ig2_Sphere_Sphere_L6Geom_Inc)(Law2_L3Geom_FrictPhys_ElPerfPl)(Law2_L6Geom_FrictPhys_Linear)
 	#ifdef YADE_OPENGL
-		(Gl1_L3Geom)
+		(Gl1_L3Geom)(Gl1_L6Geom)
 	#endif
 );
 
@@ -265,8 +265,14 @@
 }
 
 #ifdef YADE_OPENGL
-
-void Gl1_L3Geom::go(const shared_ptr<IGeom>& ig, const shared_ptr<Interaction>&, const shared_ptr<Body>&, const shared_ptr<Body>&, bool){
+bool Gl1_L3Geom::axesLabels;
+Real Gl1_L3Geom::uScale;
+Real Gl1_L6Geom::phiScale;
+
+void Gl1_L3Geom::go(const shared_ptr<IGeom>& ig, const shared_ptr<Interaction>&, const shared_ptr<Body>&, const shared_ptr<Body>&, bool){ draw(ig); }
+void Gl1_L6Geom::go(const shared_ptr<IGeom>& ig, const shared_ptr<Interaction>&, const shared_ptr<Body>&, const shared_ptr<Body>&, bool){ draw(ig,true,phiScale); }
+
+void Gl1_L3Geom::draw(const shared_ptr<IGeom>& ig, bool isL6Geom, const Real& phiScale){
 	const L3Geom& g(ig->cast<L3Geom>());
 	glTranslatev(g.contactPoint);
 	#if EIGEN_MAJOR_VERSION<30
@@ -274,15 +280,16 @@
 	#else
  		glMultMatrixd(Eigen::Affine3d(g.trsf.transpose()).data());
 	#endif
-	Real rMin=min(g.refR1,g.refR2);
+	Real rMin=g.refR1<=0?g.refR2:(g.refR2<=0?g.refR1:min(g.refR1,g.refR2));
 	glLineWidth(2.);
 	for(int i=0; i<3; i++){
 		Vector3r pt=Vector3r::Zero(); pt[i]=.5*rMin; Vector3r color=.3*Vector3r::Ones(); color[i]=1;
 		GLUtils::GLDrawLine(Vector3r::Zero(),pt,color);
-		GLUtils::GLDrawText(string(i==0?"x":(i==1?"y":"z")),pt,color);
+		if(axesLabels) GLUtils::GLDrawText(string(i==0?"x":(i==1?"y":"z")),pt,color);
 	}
-	glLineWidth(8.);
-	GLUtils::GLDrawLine(Vector3r::Zero(),g.relU(),Vector3r(0,1,0));
+	glLineWidth(4.);
+	if(uScale!=0) GLUtils::GLDrawLine(Vector3r::Zero(),uScale*g.relU(),Vector3r(0,1,.5));
+	if(isL6Geom && phiScale>0) GLUtils::GLDrawLine(Vector3r::Zero(),ig->cast<L6Geom>().relPhi()/Mathr::PI*rMin*phiScale,Vector3r(.8,0,1));
 	glLineWidth(1.);
 };
 

=== modified file 'pkg/dem/L3Geom.hpp'
--- pkg/dem/L3Geom.hpp	2010-12-05 17:10:06 +0000
+++ pkg/dem/L3Geom.hpp	2010-12-07 13:38:35 +0000
@@ -48,16 +48,6 @@
 };
 REGISTER_SERIALIZABLE(L3Geom);
 
-#ifdef YADE_OPENGL
-struct Gl1_L3Geom: public GlIGeomFunctor{
-	FUNCTOR1D(L3Geom);
-	void go(const shared_ptr<IGeom>&, const shared_ptr<Interaction>&, const shared_ptr<Body>&, const shared_ptr<Body>&, bool);
-	YADE_CLASS_BASE_DOC_STATICATTRS(Gl1_L3Geom,GlIGeomFunctor,"Render :yref:`L3Geom` geometry.",
-	);
-};
-REGISTER_SERIALIZABLE(Gl1_L3Geom);
-#endif
-
 struct L6Geom: public L3Geom{
 	virtual ~L6Geom();
 	Vector3r relPhi() const{ return phi-phi0; }
@@ -68,6 +58,28 @@
 };
 REGISTER_SERIALIZABLE(L6Geom);
 
+#ifdef YADE_OPENGL
+struct Gl1_L3Geom: public GlIGeomFunctor{
+	FUNCTOR1D(L3Geom);
+	void go(const shared_ptr<IGeom>&, const shared_ptr<Interaction>&, const shared_ptr<Body>&, const shared_ptr<Body>&, bool);
+	void draw(const shared_ptr<IGeom>&, bool isL6Geom=false, const Real& phiScale=0);
+	YADE_CLASS_BASE_DOC_STATICATTRS(Gl1_L3Geom,GlIGeomFunctor,"Render :yref:`L3Geom` geometry.",
+		((bool,axesLabels,true,,"Whether to display labels for local axes (x,y,z)"))
+		((Real,uScale,1.,,"Scale local displacements (:yref:`u<L3Geom.u>` - :yref:`u0<L3Geom.u0>`); 1 means the true scale, 0 disables drawing local displacements; negative values are permissible."))
+	);
+};
+REGISTER_SERIALIZABLE(Gl1_L3Geom);
+
+struct Gl1_L6Geom: public Gl1_L3Geom{
+	FUNCTOR1D(L6Geom);
+	void go(const shared_ptr<IGeom>&, const shared_ptr<Interaction>&, const shared_ptr<Body>&, const shared_ptr<Body>&, bool);
+	YADE_CLASS_BASE_DOC_STATICATTRS(Gl1_L6Geom,Gl1_L3Geom,"Render :yref:`L6Geom` geometry.",
+		((Real,phiScale,1.,,"Scale local rotations (:yref:`phi<L3Geom.phi>` - :yref:`phi0<L3Geom.phi0>`). The default scale is to draw $\\pi$ rotation with length equal to minimum radius."))
+	);
+};
+REGISTER_SERIALIZABLE(Gl1_L6Geom);
+#endif
+
 
 struct Ig2_Sphere_Sphere_L3Geom_Inc: public IGeomFunctor{
 		virtual bool go(const shared_ptr<Shape>& s1, const shared_ptr<Shape>& s2, const State& state1, const State& state2, const Vector3r& shift2, const bool& force, const shared_ptr<Interaction>& I);

=== modified file 'scripts/test/beam-l6geom.py'
--- scripts/test/beam-l6geom.py	2010-12-06 22:58:31 +0000
+++ scripts/test/beam-l6geom.py	2010-12-07 13:38:35 +0000
@@ -11,19 +11,31 @@
 # support sphere
 O.bodies[0].state.blockedDOFs=['x','y','z','rx','ry','rz']
 # small dt to see in realtime how it swings; real critical is higher, but much less than p-wave
-O.dt=.001*utils.PWaveTimeStep() 
+O.dt=.01*utils.PWaveTimeStep() 
 
 O.engines=[
 	ForceResetter(),
 	InsertionSortCollider([Bo1_Sphere_Aabb()]),
 	InteractionLoop([Ig2_Sphere_Sphere_L6Geom_Inc()],[Ip2_FrictMat_FrictMat_FrictPhys()],[Law2_L6Geom_FrictPhys_Linear(charLen=1)]),
 	GravityEngine(gravity=(0,0,-9.81)),
-	NewtonIntegrator(damping=0.03),
+	NewtonIntegrator(damping=0.1),
 ]
 O.saveTmp()
 
 try:
 	from yade import qt
 	v=qt.View(); v.axes=True
-except: pass
+	v.viewDir=Vector3(-0.888,-0.2,-0.4144)
+	v.eyePosition=Vector3(18.16,8.235,5.12)
+	v.sceneRadius=7.5
+	v.upVector=Vector3(-0.46,0.3885,0.798)
+	v.screenSize=(900,900)
+	rr=qt.Renderer()
+	rr.intrGeom=True
+	Gl1_L6Geom.phiScale=30; Gl1_L3Geom.uScale=20
+	O.engines=O.engines+[
+		qt.SnapshotEngine(fileBase=O.tmpFilename(),label='snapper',iterPeriod=300,deadTimeout=20),
+		PyRunner(iterPeriod=330000,command='utils.makeVideo(snapper.snapshots,out="beam-l6geom.avi"); snapper.dead=True; O.pause()')
+	]
+except ImportError: pass
 O.run()