← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-dev/yade/trunk] Rev 2177: 1. Fix boost::serialization and postProcessAttributes

 

------------------------------------------------------------
revno: 2177
fixes bug(s): https://launchpad.net/bugs/557124
committer: Václav Šmilauer <eudoxos@xxxxxxxx>
branch nick: trunk
timestamp: Sat 2010-04-24 22:22:40 +0200
message:
  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@xxxxxxxxxxxxxxxxxxx/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.
added:
  scripts/test/serialization-benchmark.py
modified:
  core/InteractionContainer.cpp
  lib/base/yadeWm3Extra_dont_include_directly.hpp
  lib/serialization/Serializable.hpp
  py/plot.py
  py/utils.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/InteractionContainer.cpp'
--- core/InteractionContainer.cpp	2010-03-21 15:25:50 +0000
+++ core/InteractionContainer.cpp	2010-04-24 20:22:40 +0000
@@ -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)

=== modified file 'lib/base/yadeWm3Extra_dont_include_directly.hpp'
--- lib/base/yadeWm3Extra_dont_include_directly.hpp	2010-04-20 08:55:02 +0000
+++ lib/base/yadeWm3Extra_dont_include_directly.hpp	2010-04-24 20:22:40 +0000
@@ -88,6 +88,17 @@
 #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 {

=== modified file 'lib/serialization/Serializable.hpp'
--- lib/serialization/Serializable.hpp	2010-04-23 11:23:15 +0000
+++ lib/serialization/Serializable.hpp	2010-04-24 20:22:40 +0000
@@ -312,8 +312,8 @@
 // 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

=== modified file 'py/plot.py'
--- py/plot.py	2010-04-23 11:43:58 +0000
+++ py/plot.py	2010-04-24 20:22:40 +0000
@@ -80,9 +80,7 @@
 	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 @@
 		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):

=== modified file 'py/utils.py'
--- py/utils.py	2010-04-20 16:21:29 +0000
+++ py/utils.py	2010-04-24 20:22:40 +0000
@@ -241,7 +241,7 @@
 	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

=== added file 'scripts/test/serialization-benchmark.py'
--- scripts/test/serialization-benchmark.py	1970-01-01 00:00:00 +0000
+++ scripts/test/serialization-benchmark.py	2010-04-24 20:22:40 +0000
@@ -0,0 +1,25 @@
+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)