Commit a71d521c authored by Václav Šmilauer's avatar Václav Šmilauer
Browse files

1. Fix boost::serialization and postProcessAttributes

2. Add scripts/test/serialization-benchmark.py for comparing serialization time/size (http://www.mail-archive.com/yade-dev@lists.launchpad.net/msg03496.html)
3. Fix bug #557124 (hopefully)
4. Don't call postProcessAttributes on Facet in utils.facet, as that is called automatically when setting vertices now.
parent 2cbf0d00
......@@ -9,6 +9,7 @@
#ifdef YADE_BOOST_SERIALIZATION
BOOST_CLASS_EXPORT(InteractionContainer);
//BOOST_SERIALIZATION_FACTORY_0(InteractionContainer);
#endif
bool InteractionContainer::insert(const shared_ptr<Interaction>& i)
......
......@@ -88,6 +88,17 @@ void quaterniontoGLMatrix(const Quaternionr& q, Real m[16]);
#if !defined(__GCCXML__) and defined(YADE_BOOST_SERIALIZATION)
#include<boost/serialization/nvp.hpp>
#include<boost/serialization/is_bitwise_serializable.hpp>
// fast serialization (no version infor and no tracking) for basic math types
// http://www.boost.org/doc/libs/1_42_0/libs/serialization/doc/traits.html#bitwise
BOOST_IS_BITWISE_SERIALIZABLE(Vector2r);
BOOST_IS_BITWISE_SERIALIZABLE(Vector2<int>);
BOOST_IS_BITWISE_SERIALIZABLE(Vector3r);
BOOST_IS_BITWISE_SERIALIZABLE(Vector3<int>);
BOOST_IS_BITWISE_SERIALIZABLE(Quaternionr);
BOOST_IS_BITWISE_SERIALIZABLE(Se3r);
BOOST_IS_BITWISE_SERIALIZABLE(Matrix3r);
namespace boost {
namespace serialization {
......
......@@ -312,8 +312,8 @@ shared_ptr<T> Serializable_clone(const shared_ptr<T>& self, const python::dict&
// creates boost::introspection::has_non_const_member_function_preProcessAttributes<class>
// which is used to detect that method in serialization code (if using boost::serialization)
// inside attribute registration macros above
BOOST_HAS_NON_CONST_MEMBER_FUNCTION(preProcessAttributes,bool(bool))
BOOST_HAS_NON_CONST_MEMBER_FUNCTION(postProcessAttributes,bool(bool))
BOOST_HAS_NON_CONST_MEMBER_FUNCTION(preProcessAttributes,void(bool))
BOOST_HAS_NON_CONST_MEMBER_FUNCTION(postProcessAttributes,void(bool))
#endif
class Serializable : public Factorable
......
......@@ -80,9 +80,7 @@ def _xlateLabel(l):
else: return l
def plot(noShow=False):
"""Show current plot, returning the figure object.
If *noShow* is true, figure will not be shown on screen at all.
"""Do the actual plot, which is either shown on screen (and nothing is returned: if *noShow* is False) or returned as object (if *noShow* is True).
You can use
......@@ -118,7 +116,7 @@ def plot(noShow=False):
pylab.xlabel(_xlateLabel(p))
if 'title' in O.tags.keys(): pylab.title(O.tags['title'])
if not noShow: pylab.show()
return pylab.gcf() # return current figure
else: return pylab.gcf() # return current figure
updatePeriod=0
def saveGnuplot(baseName,term='wxt',extension=None,timestamp=False,comment=None,title=None,varData=False):
......
......@@ -241,7 +241,7 @@ def facet(vertices,dynamic=False,wire=True,color=None,highlight=False,noBound=Fa
vertices=Vector3(vertices[0])-center,Vector3(vertices[1])-center,Vector3(vertices[2])-center
b.shape=Facet(color=color if color else randomColor(),wire=wire,highlight=highlight)
b.shape.vertices=vertices
b.shape.postProcessAttributes(True)
#b.shape.postProcessAttributes(True)
_commonBodySetup(b,0,Vector3(0,0,0),material,noBound=noBound)
b.state.pos=b.state.refPos=center
b.dynamic=dynamic
......
import time
# change this line to load your reference simulation
O.load2('ref.boost.bin.gz')
base='~sim~'
from yade import log
log.setLevel('Omega',log.WARN)
# http://blogmag.net/blog/read/38/Print_human_readable_file_size
def sizeof_fmt(num):
for x in ['bytes','KB','MB','GB','TB']:
if num<1024.0: return "%3.1f%s"%(num,x)
num/=1024.0
def io(ext,load,noBoost=False):
t0=time.time()
f=base+('.yade.' if noBoost else '.boost.')+ext
((O.load if noBoost else O.load2) if load else (O.save if noBoost else O.save2))(f)
print ('Loaded' if load else 'Saved '),('yade ' if noBoost else 'boost'),'%-7s '%ext,'%7s'%sizeof_fmt(os.path.getsize(f)),'%.1fs'%(time.time()-t0)
for ext in ['xml','xml.bz2']:
io(ext,False,True)
io(ext,True,True)
for ext in ['xml','xml.gz','xml.bz2','bin','bin.gz','bin.bz2']:
io(ext,False)
io(ext,True)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment