← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-dev/yade/trunk] Rev 1888: 1. Fix https://bugs.launchpad.net/bugs/495358 (seems like concurrent access with Anton ; -) )

 

------------------------------------------------------------
revno: 1888
committer: Václav Šmilauer <eudoxos@xxxxxxxx>
branch nick: trunk
timestamp: Fri 2009-12-11 08:27:29 +0100
message:
  1. Fix https://bugs.launchpad.net/bugs/495358 (seems like concurrent access with Anton ;-) )
  2. Add mask check to the collider 
  3. Initialize Body::id with Body::ID_NONE rather than -1
  4. First attempt at doctest (for utils.sphere)
modified:
  core/Body.cpp
  core/Collider.cpp
  doc/yade-epydoc.py
  pkg/common/Engine/Dispatcher/InteractionDispatchers.cpp
  py/tests/__init__.py
  py/utils.py
  py/yadeWrapper/yadeWrapper.cpp
  py/ymport.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/Body.cpp'
--- core/Body.cpp	2009-12-04 23:46:45 +0000
+++ core/Body.cpp	2009-12-11 07:27:29 +0000
@@ -25,6 +25,6 @@
 #endif
 
 // we must initialize id = 0, otherwise BodyContainer will crash.
-Body::Body(): id(0),groupMask(1),clumpId(ID_NONE), state(shared_ptr<State>(new State)), interactingGeometry(shape), boundingVolume(bound){}
+Body::Body(): id(Body::ID_NONE),groupMask(1),clumpId(ID_NONE), state(shared_ptr<State>(new State)), interactingGeometry(shape), boundingVolume(bound){}
 Body::Body(body_id_t newId, int newGroup): id(newId), groupMask(newGroup), clumpId(ID_NONE), state(shared_ptr<State>(new State)), interactingGeometry(shape), boundingVolume(bound){}
 

=== modified file 'core/Collider.cpp'
--- core/Collider.cpp	2009-12-06 22:02:12 +0000
+++ core/Collider.cpp	2009-12-11 07:27:29 +0000
@@ -42,7 +42,9 @@
 		// only collide if at least one particle is standalone or they belong to different clumps
 		(b1->isStandalone() || b2->isStandalone() || b1->clumpId!=b2->clumpId ) &&
 		 // do not collide clumps, since they are just containers, never interact
-		!b1->isClump() && !b2->isClump()
+		!b1->isClump() && !b2->isClump() &&
+		// masks must have at least 1 bit in common
+		(b1->groupMask & b2->groupMask)!=0 
 	;
 
 }

=== modified file 'doc/yade-epydoc.py'
--- doc/yade-epydoc.py	2009-07-18 07:35:07 +0000
+++ doc/yade-epydoc.py	2009-12-11 07:27:29 +0000
@@ -4,10 +4,11 @@
 #  yade-trunk yade-epydoc.py
 #
 #
+from yade import *
 
 import sys
 # add the configuration file
-sys.argv+=['--config=yade-epydoc.conf'] # '-v'
+sys.argv+=['--config=yade-epydoc.conf','-v'] # '-v'
 from epydoc.cli import cli
 cli()
 quit()

=== modified file 'pkg/common/Engine/Dispatcher/InteractionDispatchers.cpp'
--- pkg/common/Engine/Dispatcher/InteractionDispatchers.cpp	2009-12-09 16:43:25 +0000
+++ pkg/common/Engine/Dispatcher/InteractionDispatchers.cpp	2009-12-11 07:27:29 +0000
@@ -58,8 +58,11 @@
 
 			if(!b1_ || !b2_){ LOG_DEBUG("Body #"<<(b1_?I->getId2():I->getId1())<<" vanished, erasing intr #"<<I->getId1()<<"+#"<<I->getId2()<<"!"); scene->interactions->requestErase(I->getId1(),I->getId2(),/*force*/true); continue; }
 
-			// go fast if this pair of bodies cannot interact at all
-			if((b1_->getGroupMask() & b2_->getGroupMask())==0) continue;
+			// already in Collider::mayCollider, no need to check here anymore
+			#if 0
+				// go fast if this pair of bodies cannot interact at all
+				if((b1_->getGroupMask() & b2_->getGroupMask())==0) continue;
+			#endif
 
 			// we know there is no geometry functor already, take the short path
 			if(!I->functorCache.geomExists) { assert(!I->isReal()); continue; }

=== modified file 'py/tests/__init__.py'
--- py/tests/__init__.py	2009-11-23 12:32:14 +0000
+++ py/tests/__init__.py	2009-12-11 07:27:29 +0000
@@ -23,6 +23,9 @@
 	"""Run all tests defined in all yade.tests.* modules and return
 	TestResult object for further examination."""
 	suite=unittest.defaultTestLoader.loadTestsFromNames(allTestsFQ)
+	import doctest
+	import yade.utils
+	suite.addTest(doctest.DocTestSuite(yade.utils))
 	return unittest.TextTestRunner(verbosity=2).run(suite)
 
 	

=== modified file 'py/utils.py'
--- py/utils.py	2009-12-10 15:13:23 +0000
+++ py/utils.py	2009-12-11 07:27:29 +0000
@@ -17,6 +17,7 @@
 	import psyco
 	psyco.full()
 except ImportError: pass
+import doctest
 
 # c++ implementations for performance reasons
 from yade._utils import *
@@ -81,7 +82,7 @@
 	#if 'materialClass' in matKw.keys(): raise ArgumentError("You as passing materialClass as argument, but it is no longer used. Use material instead.")
 	if material==0 and len(O.materials)==0: O.materials.append(defaultMaterial());
 	if isinstance(material,int): b.mat=O.materials[material]
-	elif isinstance(material,string): b.mat=O.materials[material]
+	elif isinstance(material,str): b.mat=O.materials[material]
 	elif isinstance(material,Material): b.mat=material
 	else: raise TypeError("The 'material' argument must be None (for defaultMaterial), string (for shared material label), int (for shared material id) or Material instance.");
 	## resets state (!!)
@@ -102,6 +103,38 @@
 			random color will be assigned if None
 		`material`: int or string or Material instance
 			if int, O.materials[material] will be used; as a special case, if material==0 and there is no shared materials defined, utils.defaultMaterial() will be assigned to O.materials[0].
+
+	>>> O.reset()
+	>>> from yade import utils
+
+	Creating default shared material if none exists neither is given::
+
+	>>> len(O.materials)
+	0
+	>>> s0=utils.sphere([2,0,0],1)
+	>>> len(O.materials)
+	1
+
+	Instance of material can be given::
+
+	>>> s1=utils.sphere([0,0,0],1,wire=False,color=(0,1,0),material=ElasticMat(young=30e9,density=2e3))
+	>>> s1.shape['wire']
+	False
+	>>> s1.shape['diffuseColor']
+	Vector3(0,1,0)
+	>>> s1.mat['density']
+	2000.0
+
+	Material can be given by label::
+
+	>>> O.materials.append(GranularMat(young=10e9,poisson=.11,label='myMaterial'))
+	1
+	>>> s2=utils.sphere([0,0,2],1,material='myMaterial')
+	>>> s2.mat['label']
+	'myMaterial'
+	>>> s2.mat['poisson']
+	0.11
+
 	"""
 	b=Body()
 	b.shape=InteractingSphere(radius=radius,diffuseColor=color if color else randomColor(),wire=wire,highlight=highlight)

=== modified file 'py/yadeWrapper/yadeWrapper.cpp'
--- py/yadeWrapper/yadeWrapper.cpp	2009-12-10 15:13:23 +0000
+++ py/yadeWrapper/yadeWrapper.cpp	2009-12-11 07:27:29 +0000
@@ -260,11 +260,10 @@
 		void serializeSorted_set(bool ss){proxee->serializeSorted=ss;}
 };
 
-
-class pyBexContainer{
+class pyForceContainer{
 		shared_ptr<Scene> rb;
 	public:
-		pyBexContainer(){ rb=Omega::instance().getScene(); }
+		pyForceContainer(){ rb=Omega::instance().getScene(); }
 		Vector3r force_get(long id){  rb->bex.sync(); return rb->bex.getForce(id); }
 		Vector3r torque_get(long id){ rb->bex.sync(); return rb->bex.getTorque(id); }
 		Vector3r move_get(long id){   rb->bex.sync(); return rb->bex.getMove(id); }
@@ -469,7 +468,7 @@
 	pyBodyContainer bodies_get(void){assertRootBody(); return pyBodyContainer(OMEGA.getScene()->bodies); }
 	pyInteractionContainer interactions_get(void){assertRootBody(); return pyInteractionContainer(OMEGA.getScene()->interactions); }
 	
-	pyBexContainer bex_get(void){return pyBexContainer();}
+	pyForceContainer bex_get(void){return pyForceContainer();}
 	pyMaterialContainer materials_get(void){return pyMaterialContainer();}
 	
 
@@ -771,16 +770,16 @@
 		.def("__iter__",&pyInteractionIterator::pyIter)
 		.def("next",&pyInteractionIterator::pyNext);
 
-	python::class_<pyBexContainer>("BexContainer",python::init<pyBexContainer&>())
-		.def("f",&pyBexContainer::force_get)
-		.def("t",&pyBexContainer::torque_get)
-		.def("m",&pyBexContainer::torque_get)
-		.def("move",&pyBexContainer::move_get)
-		.def("rot",&pyBexContainer::rot_get)
-		.def("addF",&pyBexContainer::force_add)
-		.def("addT",&pyBexContainer::torque_add)
-		.def("addMove",&pyBexContainer::move_add)
-		.def("addRot",&pyBexContainer::rot_add);
+	python::class_<pyForceContainer>("BexContainer",python::init<pyForceContainer&>())
+		.def("f",&pyForceContainer::force_get)
+		.def("t",&pyForceContainer::torque_get)
+		.def("m",&pyForceContainer::torque_get)
+		.def("move",&pyForceContainer::move_get)
+		.def("rot",&pyForceContainer::rot_get)
+		.def("addF",&pyForceContainer::force_add)
+		.def("addT",&pyForceContainer::torque_add)
+		.def("addMove",&pyForceContainer::move_add)
+		.def("addRot",&pyForceContainer::rot_add);
 
 	python::class_<pyMaterialContainer>("MaterialContainer",python::init<pyMaterialContainer&>())
 		.def("append",&pyMaterialContainer::append,"Add new shared material; changes its id and return it.")

=== modified file 'py/ymport.py'
--- py/ymport.py	2009-12-11 07:25:18 +0000
+++ py/ymport.py	2009-12-11 07:27:29 +0000
@@ -23,7 +23,7 @@
 	for l in open(filename):
 		ss=[float(i) for i in l.split()]
 		if wenjieFormat and len(ss)==5 and ss[4]==1.0: continue
-		ret.append(utils.sphere([scale*ss[0],scale*ss[1],scale*ss[2]],scale*ss[3],**kw))
+		ret.append(sphere([scale*ss[0],scale*ss[1],scale*ss[2]],scale*ss[3],**kw))
 	return ret
 
 def stl(file, dynamic=False,wire=True,color=None,highlight=False,noBound=False,material=0):