yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #05867
[Branch ~yade-dev/yade/trunk] Rev 2476: 1. Enhance the gl-drawer for LawTester.
------------------------------------------------------------
revno: 2476
committer: Václav Šmilauer <eu@xxxxxxxx>
branch nick: yade
timestamp: Tue 2010-10-12 16:25:27 +0200
message:
1. Enhance the gl-drawer for LawTester.
modified:
pkg/dem/Engine/GlobalEngine/DomainLimiter.cpp
pkg/dem/Engine/GlobalEngine/DomainLimiter.hpp
scripts/test/law-test.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/Engine/GlobalEngine/DomainLimiter.cpp'
--- pkg/dem/Engine/GlobalEngine/DomainLimiter.cpp 2010-10-12 12:28:40 +0000
+++ pkg/dem/Engine/GlobalEngine/DomainLimiter.cpp 2010-10-12 14:25:27 +0000
@@ -1,4 +1,5 @@
#include<yade/pkg-dem/DomainLimiter.hpp>
+#include<yade/pkg-dem/Shop.hpp>
YADE_PLUGIN((DomainLimiter)(LawTester)
#ifdef YADE_OPENGL
@@ -85,6 +86,7 @@
axZ=axX.cross(axY);
LOG_DEBUG("Initial axes x="<<axX<<", y="<<axY<<", z="<<axZ);
renderLength=.5*(gsc->refR1+gsc->refR2);
+ refLength=gsc->refR1+gsc->refR2;
} else { // udpate of an existing interaction
if(scGeom){
scGeom->rotate(axY); scGeom->rotate(axZ);
@@ -169,36 +171,64 @@
void GlExtra_LawTester::render(){
if(!tester){ FOREACH(shared_ptr<Engine> e, scene->engines){ tester=dynamic_pointer_cast<LawTester>(e); if(tester) break; } }
if(!tester){ LOG_ERROR("No LawTester in O.engines, killing myself."); dead=true; return; }
+
//if(tester->renderLength<=0) return;
glColor3v(Vector3r(1,0,1));
- glLineWidth(2.0f);
- glEnable(GL_LINE_SMOOTH);
- glLoadIdentity();
-
+ // switch to local coordinates
glTranslatev(tester->contPt);
-
- glBegin(GL_LINES); glVertex3v(Vector3r::Zero()); glVertex3v(.1*Vector3r::Ones()); glEnd();
- GLUtils::GLDrawText(string("This is the contact point!"),Vector3r::Zero(),Vector3r(1,0,1));
-
- cerr<<".";
-
- glBegin(GL_LINES);
- glVertex3v(Vector3r::Zero());
- glVertex3v(tester->renderLength*tester->axX);
- glVertex3v(Vector3r::Zero());
- glVertex3v(tester->renderLength*tester->axY);
- glVertex3v(Vector3r::Zero());
- glVertex3v(tester->renderLength*tester->axZ);
- glVertex3v(Vector3r::Zero());
- glVertex3v(tester->ptOurs);
- glEnd();
- #if 1
- GLUtils::GLDrawArrow(Vector3r::Zero(),tester->contPt+tester->renderLength*tester->axX,Vector3r(1,0,0));
- GLUtils::GLDrawArrow(Vector3r::Zero(),tester->contPt+tester->renderLength*tester->axY,Vector3r(0,1,0));
- GLUtils::GLDrawArrow(Vector3r::Zero(),tester->contPt+tester->renderLength*tester->axZ,Vector3r(0,0,1));
- GLUtils::GLDrawArrow(Vector3r::Zero(),tester->contPt+tester->ptOurs,Vector3r(1,1,0));
- GLUtils::GLDrawArrow(Vector3r::Zero(),Vector3r::Ones(),Vector3r(.5,.5,1));
- #endif
+ glMultMatrixd(Eigen::Transform3d(tester->trsf).data());
+
+
+ //glEnable(GL_LIGHTING);
+ //glColor3v(Vector3r(1,0,1));
+ //glBegin(GL_LINES); glVertex3v(Vector3r::Zero()); glVertex3v(.1*Vector3r::Ones()); glEnd();
+ //GLUtils::GLDrawText(string("This is the contact point!"),Vector3r::Zero(),Vector3r(1,0,1));
+
+ // local axes
+ glLineWidth(2.);
+ GLUtils::GLDrawLine(Vector3r::Zero(),.5*tester->renderLength*Vector3r::UnitX(),Vector3r(1,.3,.3));
+ GLUtils::GLDrawLine(Vector3r::Zero(),.5*tester->renderLength*Vector3r::UnitY(),Vector3r(.3,1,.3));
+ GLUtils::GLDrawLine(Vector3r::Zero(),.5*tester->renderLength*Vector3r::UnitZ(),Vector3r(.3,.3,1));
+
+ // put the origin to the initial (no-shear) point, so that the current point appears at the contact point
+ glTranslatev(Vector3r(0,tester->ptOurs[1],tester->ptOurs[2]));
+
+
+ const int t(tester->step); const vector<int>& TT(tester->_pathT); const vector<Vector3r>& VV(tester->_pathV);
+ size_t numSegments=TT.size();
+ const Vector3r colorBefore=Vector3r(.5,1,.5), colorAfter=Vector3r(1,.5,.5);
+
+ // scale displacement, if they have the strain meaning
+ Real scale=1;
+ if(tester->displIsRel) scale=tester->refLength;
+
+ // find maximum displacement, draw axes in the shear plane
+ Real displMax=0;
+ FOREACH(const Vector3r& v, VV) displMax=max(v.squaredNorm(),displMax);
+ displMax=1.2*scale*sqrt(displMax);
+
+ glLineWidth(1.);
+ GLUtils::GLDrawLine(Vector3r(0,-displMax,0),Vector3r(0,displMax,0),Vector3r(.5,0,0));
+ GLUtils::GLDrawLine(Vector3r(0,0,-displMax),Vector3r(0,0,displMax),Vector3r(.5,0,0));
+
+ // draw path
+ glLineWidth(4.);
+ for(size_t segment=0; segment<numSegments-1; segment++){
+ // different colors before and after the current point
+ Real t0=TT[segment],t1=TT[segment+1];
+ const Vector3r &from=-VV[segment]*scale, &to=-VV[segment+1]*scale;
+ // current segment
+ if(t>t0 && t<t1){
+ Real norm=(t-t0)/(t1-t0);
+ GLUtils::GLDrawLine(from,from+(to-from)*norm,colorBefore);
+ GLUtils::GLDrawLine(from+(to-from)*norm,to,colorAfter);
+ } else { // other segment
+ GLUtils::GLDrawLine(from,to,t<t0?colorAfter:colorBefore);
+ }
+ }
+
+ glLineWidth(1.);
}
-#endif
+
+#endif /* YADE_OPENGL */
=== modified file 'pkg/dem/Engine/GlobalEngine/DomainLimiter.hpp'
--- pkg/dem/Engine/GlobalEngine/DomainLimiter.hpp 2010-10-12 12:28:40 +0000
+++ pkg/dem/Engine/GlobalEngine/DomainLimiter.hpp 2010-10-12 14:25:27 +0000
@@ -37,9 +37,10 @@
((size_t,_interpPos,0,(Attr::readonly),"Position for the interpolation routine."))
((Vector3r,prevVal,Vector3r::Zero(),(Attr::readonly),"Value reached in the previous step."))
((Quaternionr,trsfQ,,Attr::noSave,"Transformation quaterion for the local coordinate system. |yupdate|"))
- ((int,step,0,,"Step number in which this engine is active; determines position in path, either using pathStep or pathSteps."))
+ ((int,step,0,,"Step number in which this engine is active; determines position in path, using pathSteps."))
((string,doneHook,,,"Python command (as string) to run when end of the path is achieved. If empty, the engine will be set :yref:`dead<Engine.dead>`."))
((Real,renderLength,0,,"Characteristic length for the purposes of rendering, set equal to the smaller radius."))
+ ((Real,refLength,0,(Attr::readonly),"Reference contact length, for rendering only."))
((Vector3r,contPt,Vector3r::Zero(),,"Contact point (for rendering only)"))
((Real,idWeight,1,,"Float ââ©0,1⪠determining on which particle are displacements applied (0 for id1, 1 for id2); intermediate values will apply respective part to each of them."))
((Real,rotWeight,1,,"Float ââ©0,1⪠determining whether shear displacement is applied as rotation or displacement on arc (0 is displacemetn-only, 1 is rotation-only)."))
=== modified file 'scripts/test/law-test.py'
--- scripts/test/law-test.py 2010-10-12 12:28:40 +0000
+++ scripts/test/law-test.py 2010-10-12 14:25:27 +0000
@@ -13,7 +13,7 @@
#
from yade import utils,plot
import random, yade.log
-yade.log.setLevel('LawTester',yade.log.TRACE)
+#yade.log.setLevel('LawTester',yade.log.TRACE)
# sphere's radii
r1,r2=.1,.2
@@ -23,8 +23,8 @@
# normal=Vector3(random.random()-.5,random.random()-.5,random.random()-.5)
normal=Vector3(1,0,0)
O.bodies.append([
- utils.sphere(pt1,r1,wire=True),
- utils.sphere(pt1+.999999*(r1+r2)*normal.normalized(),r2,wire=True)
+ utils.sphere(pt1,r1,wire=True,color=(.5,.5,.5)),
+ utils.sphere(pt1+.999999*(r1+r2)*normal.normalized(),r2,wire=True,color=(.5,.5,.5))
])
O.engines=[
@@ -36,10 +36,10 @@
[Law2_ScGeom_FrictPhys_Basic()]
),
LawTester(ids=[0,1],path=[
- #(-.1,0,0),(-.1,.1,0) #,(-.1,0,.1)
(-.1,0,0),(-.1,.1,0),(0,.1,0), # towards, shear, back to intial normal distance
- (-.02,.1,.1),(-.02,-.1,.1),(-.02,-.1,-.1),(-.02,.1,-.1),(-.02,.1,.1) # go in square in the shear plane without changing normal deformation
- ],pathSteps=[10],doneHook='tester.dead=True; O.pause()',label='tester',rotWeight=1,idWeight=1),
+ (-.02,.1,.1),(-.02,-.1,.1),(-.02,-.1,-.1),(-.02,.1,-.1),(-.02,.1,.1), # go in square in the shear plane without changing normal deformation
+ (0,0,0) # back to the origin
+ ],pathSteps=[5000],doneHook='tester.dead=True; O.pause()',label='tester',rotWeight=1,idWeight=1),
PyRunner(iterPeriod=1,command='addPlotData()'),
NewtonIntegrator()
]
@@ -56,7 +56,7 @@
rr=qt.Renderer()
rr.extraDrawers=[GlExtra_LawTester()]
except ImportError: pass
-O.dt=1e2
+O.dt=1
O.saveTmp()
O.run()