yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #04296
[Branch ~yade-dev/yade/trunk] Rev 2204: 1. Fix bug with facet import Luc reported (thanks)
------------------------------------------------------------
revno: 2204
committer: Václav Šmilauer <eudoxos@xxxxxxxx>
branch nick: trunk
timestamp: Thu 2010-05-06 12:11:20 +0200
message:
1. Fix bug with facet import Luc reported (thanks)
2. Add None to separate y1 and y2 axis (instead of |||, which will still work, but is not documented anymore)
3. Add the possibility to plot multiple x axes with the save variable by adding spaces to the name in yade.plots
4. Rename TestWm3Wrapper to TestEigenWrapper
modified:
pkg/common/DataClass/Shape/Facet.cpp
pkg/common/Engine/Dispatcher/InteractionDispatchers.hpp
pkg/dem/PreProcessor/STLImporter.cpp
py/plot.py
py/tests/wrapper.py
scripts/simple-scene-plot.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/common/DataClass/Shape/Facet.cpp'
--- pkg/common/DataClass/Shape/Facet.cpp 2010-05-03 12:17:44 +0000
+++ pkg/common/DataClass/Shape/Facet.cpp 2010-05-06 10:11:20 +0000
@@ -16,6 +16,10 @@
void Facet::postProcessAttributes(bool deserializing)
{
+ // if this fails, it means someone did vertices push_back, but they are resized to 3 at Facet initialization already
+ // in the future, a fixed-size array should be used instead of vector<Vector3r> for vertices
+ // this is prevented by yade::serialization now IIRC
+ assert(vertices.size()==3);
if (deserializing)
{
Vector3r e[3] = {vertices[1]-vertices[0] ,vertices[2]-vertices[1] ,vertices[0]-vertices[2]};
=== modified file 'pkg/common/Engine/Dispatcher/InteractionDispatchers.hpp'
--- pkg/common/Engine/Dispatcher/InteractionDispatchers.hpp 2010-04-09 11:25:18 +0000
+++ pkg/common/Engine/Dispatcher/InteractionDispatchers.hpp 2010-05-06 10:11:20 +0000
@@ -18,7 +18,7 @@
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)); }
+ void eraseAfterLoop(body_id_t id1,body_id_t id2){ eraseAfterLoopIds.push_back(idPair(id1,id2)); }
#endif
public:
virtual void action();
=== modified file 'pkg/dem/PreProcessor/STLImporter.cpp'
--- pkg/dem/PreProcessor/STLImporter.cpp 2010-05-04 13:56:05 +0000
+++ pkg/dem/PreProcessor/STLImporter.cpp 2010-05-06 10:11:20 +0000
@@ -36,7 +36,7 @@
iFacet->color = Vector3r(0.8,0.3,0.3);
for (int j=0; j<3; ++j)
{
- iFacet->vertices.push_back(v[j]-icc);
+ iFacet->vertices[j]=v[j]-icc;
}
//iFacet->postProcessAttributes(true); //postProcessAttributes is protected
shared_ptr<Body> b(new Body());
=== modified file 'py/plot.py'
--- py/plot.py 2010-04-24 20:22:40 +0000
+++ py/plot.py 2010-05-06 10:11:20 +0000
@@ -11,13 +11,12 @@
matplotlib.rc('axes',grid=True) # put grid in all figures
import pylab
+data={}
"Global dictionary containing all data values, common for all plots, in the form {'name':[value,...],...}. Data should be added using plot.addData function. All [value,...] columns have the same length, they are padded with NaN if unspecified."
-data={}
+plots={} # dictionary x-name -> (yspec,...), where yspec is either y-name or (y-name,'line-specification')
"dictionary x-name -> (yspec,...), where yspec is either y-name or (y-name,'line-specification')"
-plots={} # dictionary x-name -> (yspec,...), where yspec is either y-name or (y-name,'line-specification')
+labels={}
"Dictionary converting names in data to human-readable names (TeX names, for instance); if a variable is not specified, it is left untranslated."
-labels={}
-#plotLines={} # dictionary x-name -> Line2d objects (that hopefully still correspond to yspec in plots)
def reset():
"Reset all plot-related variables (data, plots, labels)"
@@ -91,11 +90,12 @@
"""
if not noShow: pylab.ion() ## # no interactive mode (hmmm, I don't know why actually...)
for p in plots:
+ p=p.strip()
pylab.figure()
plots_p=[_addPointTypeSpecifier(o) for o in _tuplifyYAxis(plots[p])]
plots_p_y1,plots_p_y2=[],[]; y1=True
for d in plots_p:
- if d[0]=='|||':
+ if d[0]=='|||' or d[0]==None:
y1=False; continue
if y1: plots_p_y1.append(d)
else: plots_p_y2.append(d)
@@ -160,7 +160,7 @@
if not extension: extension=term
i=0
for p in plots:
- # print p
+ p=p.strip()
plots_p=[_addPointTypeSpecifier(o) for o in _tuplifyYAxis(plots[p])]
if term in ['wxt','x11']: fPlot.write("set term %s %d persist\n"%(term,i))
else: fPlot.write("set term %s; set output '%s.%d.%s'\n"%(term,baseNameNoPath,i,extension))
@@ -170,7 +170,7 @@
if title: fPlot.write("set title '%s'\n"%title)
y1=True; plots_y1,plots_y2=[],[]
for d in plots_p:
- if d[0]=='|||':
+ if d[0]=='|||' or d[0]==None:
y1=False; continue
if y1: plots_y1.append(d)
else: plots_y2.append(d)
=== modified file 'py/tests/wrapper.py'
--- py/tests/wrapper.py 2010-05-05 21:36:25 +0000
+++ py/tests/wrapper.py 2010-05-06 10:11:20 +0000
@@ -3,7 +3,7 @@
"""
This test module covers python/c++ transitions, for both classes deriving from Serializable,
-but also for other classes that we wrap (like Wm3).
+but also for other classes that we wrap (like miniEigen).
"""
import unittest
@@ -66,7 +66,7 @@
self.assertRaises(AttributeError,lambda: Sphere(attributeThatDoesntExist=42))
self.assertRaises(AttributeError,lambda: Sphere().attributeThatDoesntExist)
-class TestWm3Wrapper(unittest.TestCase):
+class TestEigenWrapper(unittest.TestCase):
def assertSeqAlmostEqual(self,v1,v2):
"floating-point comparison of vectors/quaterions"
self.assertEqual(len(v1),len(v2));
=== modified file 'scripts/simple-scene-plot.py'
--- scripts/simple-scene-plot.py 2010-02-12 10:18:46 +0000
+++ scripts/simple-scene-plot.py 2010-05-06 10:11:20 +0000
@@ -37,7 +37,7 @@
## we will have 2 plots:
## 1. t as function of i (joke test function)
## 2. i as function of t on left y-axis ('|||' makes the separation) and z_sph, v_sph (as green circles connected with line) and z_sph_half again as function of t
-plot.plots={'i':('t'),'t':('z_sph','|||',('v_sph','go-'),'z_sph_half')}
+plot.plots={'i':('t'),'t':('z_sph',None,('v_sph','go-'),'z_sph_half')}
## this function is called by plotDataCollector
## it should add data with the labels that we will plot
@@ -45,7 +45,7 @@
def myAddPlotData():
sph=O.bodies[1]
## store some numbers under some labels
- plot.addData(t=O.time,i=O.iter,z_sph=sph.state.pos[2],z_sph_half=.5*sph.state.pos[2],v_sph=sqrt(sum([v**2 for v in sph.state['vel']])))
+ plot.addData(t=O.time,i=O.iter,z_sph=sph.state.pos[2],z_sph_half=.5*sph.state.pos[2],v_sph=sph.state.vel.Length())
O.run(int(2./O.dt),True);
print "Now calling plot.plot() to show the figures (close them to continue)."