← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-dev/yade/trunk] Rev 1777: 1. Add example of generating randomly-packed tunnel-like scene (6 lines of python code).

 

------------------------------------------------------------
revno: 1777
committer: Václav Šmilauer <vaclav@flux>
branch nick: trunk
timestamp: Fri 2009-10-30 10:54:44 +0100
message:
  1. Add example of generating randomly-packed tunnel-like scene (6 lines of python code).
  2. Add explicit check for physics dispatchers in InteractionDispatcher even in the optimized build.
added:
  examples/tunnel-pack.py
modified:
  pkg/common/Engine/MetaEngine/InteractionDispatchers.cpp


--
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.
=== added file 'examples/tunnel-pack.py'
--- examples/tunnel-pack.py	1970-01-01 00:00:00 +0000
+++ examples/tunnel-pack.py	2009-10-30 09:54:44 +0000
@@ -0,0 +1,28 @@
+from yade import pack
+
+"""Simple script to create tunnel with random dense packing of spheres.
+The tunnel is difference between an axis-aligned box and cylinder, or which
+axis is going through the bottom wall (-z) of the box.
+
+The tunnel hole is oriented along +y, the face is in the xz plane.
+
+The first you run this scipt, a few minutes is neede to generate the packing. It is
+saved in /tmp/triaxPackCache.sqlite and at next time it will be only loaded (fast).
+"""
+# set some geometry parameters: domain box size, tunnel radius, radius of particles
+boxSize=Vector3(5,8,5)
+tunnelRad=2
+rSphere=.1
+# construct spatial predicate as difference of box and cylinder:
+# (see scripts/test/pack-predicates.py for details)
+#
+# http://beta.arcig.cz/~eudoxos/yade/epydoc/yade._packPredicates.inAlignedBox-class.html
+# http://beta.arcig.cz/~eudoxos/yade/epydoc/yade._packPredicates.inCylinder-class.html
+
+pred=pack.inAlignedBox((-.5*boxSize[0],-.5*boxSize[1],0),(.5*boxSize[0],.5*boxSize[1],boxSize[2])) - pack.inCylinder((-.5*boxSize[0],0,0),(.5*boxSize[0],0,0),tunnelRad)
+# Use the predicate to generate sphere packing inside 
+#
+# http://beta.arcig.cz/~eudoxos/yade/epydoc/yade.pack-module.html#randomDensePack
+O.bodies.append(pack.randomDensePack(pred,radius=rSphere,rRelFuzz=.3,memoizeDb='/tmp/triaxPackCache.sqlite',spheresInCell=3000))
+
+

=== modified file 'pkg/common/Engine/MetaEngine/InteractionDispatchers.cpp'
--- pkg/common/Engine/MetaEngine/InteractionDispatchers.cpp	2009-08-21 10:06:00 +0000
+++ pkg/common/Engine/MetaEngine/InteractionDispatchers.cpp	2009-10-30 09:54:44 +0000
@@ -90,7 +90,10 @@
 				I->functorCache.phys=physDispatcher->getFunctor2D(b1->physicalParameters,b2->physicalParameters,swap);
 				assert(!swap); // InteractionPhysicsEngineUnits are symmetric
 			}
-			assert(I->functorCache.phys);
+			//assert(I->functorCache.phys);
+			if(!I->functorCache.phys){
+				throw std::runtime_error("Undefined or ambiguous InteractionPhysics dispatch for types "+b1->physicalParameters->getClassName()+" and "+b2->physicalParameters->getClassName()+".");
+			}
 			I->functorCache.phys->go(b1->physicalParameters,b2->physicalParameters,I);
 			assert(I->interactionPhysics);