Author: eudoxos
Date: 2009-08-07 15:22:16 +0200 (Fri, 07 Aug 2009)
New Revision: 1930

Modified:
   trunk/extra/PeriodicInsertionSortCollider.hpp
   trunk/gui/py/PythonUI_rc.py
   trunk/py/yadeWrapper/yadeWrapper.cpp
   trunk/scripts/test/periodic-simple.py
Log:
1. Assign new function O.exitNoBacktrace to sys.exit. Fixes partially 
https://bugs.launchpad.net/yade/+bug/410250
2. Add some more comments to periodic stuff.


Modified: trunk/extra/PeriodicInsertionSortCollider.hpp
===================================================================
--- trunk/extra/PeriodicInsertionSortCollider.hpp       2009-08-07 10:27:49 UTC 
(rev 1929)
+++ trunk/extra/PeriodicInsertionSortCollider.hpp       2009-08-07 13:22:16 UTC 
(rev 1930)
@@ -4,6 +4,74 @@
 #include<yade/core/Collider.hpp>
 class InteractionContainer;
 
+/*! Collider with periodic boundary conditions.
+
+This colider is based on the code of InsertionSortCollider and it should be,
+at some point, integrated back into its code (given that the performance impact
+is negligible, which I think might be true).
+
+Use
+===
+* scripts/test/periodic-simple.py
+* In the future, triaxial compression working by growing/shrinking the cell 
should be implemented.
+
+Architecture
+============
+Bounding boxes carry information about period in which they are. Their 
container (VecBounds)
+holds position of where the space wraps. The sorting algorithm is changed in 
such way that
+periods are changed when body crosses cell boundary.
+
+Interaction::cellDist holds information about relative cell coordinates of the 
2nd body
+relative to the 1st one. Dispatchers (InteractionGeometryMetaEngine and 
InteractionDispatchers)
+use this information to pass modified position of the 2nd body to 
InteractionGeometryEngineUnits.
+Since properly behaving InteractionGeometryEngineUnit's and ConstitutiveLaw's 
do not take positions
+directly from Body::physicalParameters, the interaction is computed with the 
periodic positions.
+
+Positions of bodies (in the sense of Body::physicalParameters) are not wrapped 
to the periodic cell,
+they can be anywhere (but not "too far" in the sense of int overflow).
+
+Since Interaction::cellDists holds cell coordinates, it is possible to change 
the cell boundaries
+at runtime. This should make it easy to implement some stress control on the 
top.
+
+Clumps do not interfere with periodicity in any way.
+
+Rendering
+---------
+OpenGLRenderingEngine renders GeometricalModel at all periodic positions that 
touch the
+periodic cell (i.e. BoundingVolume crosses its boundary).
+
+Periodicity control
+===================
+c++:
+       MetaBody::isPeriodic, MetaBody::cellMin, MetaBody::cellMax
+python:
+       O.periodicCell=((0,0,0),(10,10,10)  # activates periodic boundary
+       O.periodicCell=() # deactivates periodic boundary
+
+Requirements
+============
+* No body can have AABB larger than about .499*cellSize. This is currently not 
checked, only asserted.
+* Constitutive law must not get body positions from Body::physicalParameters.
+       If it does, it uses Interaction::cellDist to compute periodic position.
+       Dem3Dof family of Ig2 functors and Law2_* engines are known to behave 
well.
+* No body can get further away than MAXINT periods. It will do horrible things 
if there is overflow.
+
+Possible performance improvements & bugs
+========================================
+This collider was not at all tuned to give decent performance (yet?)
+
+* We don't enforce that bounding boxes are inside the cell; that means that 
every 
+       spatialOverlap call has to wrap values, and that is probably quite slow.
+* PeriodicInsertionSortCollider::{cellWrap,cellWrapRel} 
OpenGLRenderingEngine::{wrapCell,wrapCellPt} Shop::PeriodicWrap
+       are all very similar functions. They should be put into separate header 
and included from all those places.
+* The aforementioned functions might not be the fastest implementations. In 
particular, I heard that (int) is
+       rather low-performance for making conversion of floating-point to 
integer.
+* Until this code is integrated with plain InsertionSortCollider, it will not 
support striding via VelocityBins
+       Those 2 features are orthogonal, the integration shouldn't be diffucult.
+
+
+*/
+
 class PeriodicInsertionSortCollider: public Collider{
        //! struct for storing bounds of bodies
        struct Bound{

Modified: trunk/gui/py/PythonUI_rc.py
===================================================================
--- trunk/gui/py/PythonUI_rc.py 2009-08-07 10:27:49 UTC (rev 1929)
+++ trunk/gui/py/PythonUI_rc.py 2009-08-07 13:22:16 UTC (rev 1930)
@@ -14,6 +14,7 @@
 from yade import runtime
 from yade import utils
 __builtins__.O=Omega()
+sys.exit=O.exitNoBacktrace
 
 ### direct object creation through automatic wrapper functions
 def listChildClassesRecursive(base):

Modified: trunk/py/yadeWrapper/yadeWrapper.cpp
===================================================================
--- trunk/py/yadeWrapper/yadeWrapper.cpp        2009-08-07 10:27:49 UTC (rev 
1929)
+++ trunk/py/yadeWrapper/yadeWrapper.cpp        2009-08-07 13:22:16 UTC (rev 
1930)
@@ -232,6 +232,8 @@
                void rot_add(long id, const Vector3r& t){    
rb->bex.addRot(id,t);}
 };
 
+void termHandler(int sig){cerr<<"terminating..."<<endl; raise(SIGTERM);}
+
 class pyOmega{
        private:
                // can be safely removed now, since pyOmega makes an empty 
rootBody in the constructor, if there is none
@@ -456,10 +458,15 @@
                if(OMEGA.getRootBody()->isPeriodic){ return 
python::make_tuple(OMEGA.getRootBody()->cellMin,OMEGA.getRootBody()->cellMax); }
                return python::make_tuple();
        }
+       void exitNoBacktrace(int status=0){
+               signal(SIGSEGV,termHandler); /* unset the handler that runs gdb 
and prints backtrace */
+               exit(status);
+       }
 };
 BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(omega_run_overloads,run,0,2);
 BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(omega_saveTmp_overloads,saveTmp,0,1);
 BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(omega_loadTmp_overloads,loadTmp,0,1);
+BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(omega_exitNoBacktrace_overloads,exitNoBacktrace,0,1);
 
 class pySTLImporter : public STLImporter {
     public:
@@ -636,7 +643,8 @@
                
.add_property("timingEnabled",&pyOmega::timingEnabled_get,&pyOmega::timingEnabled_set,"Globally
 enable/disable timing services (see documentation of yade.timing).")
                
.add_property("bexSyncCount",&pyOmega::bexSyncCount_get,&pyOmega::bexSyncCount_set,"Counter
 for number of syncs in BexContainer, for profiling purposes.")
                .add_property("numThreads",&pyOmega::numThreads_get /* 
,&pyOmega::numThreads_set*/ ,"Get maximum number of threads openMP can use.")
-               
.add_property("periodicCell",&pyOmega::periodicCell_get,&pyOmega::periodicCell_set,
 "Get/set periodic cell minimum and maximum (tuple of 2 Vector3's), or () for 
no periodicity.");
+               
.add_property("periodicCell",&pyOmega::periodicCell_get,&pyOmega::periodicCell_set,
 "Get/set periodic cell minimum and maximum (tuple of 2 Vector3's), or () for 
no periodicity.")
+               
.def("exitNoBacktrace",&pyOmega::exitNoBacktrace,omega_exitNoBacktrace_overloads(python::args("status"),"Disable
 our SEGV handler and exit."))
                #ifdef YADE_BOOST_SERIALIZATION
                        .def("saveXML",&pyOmega::saveXML,"[EXPERIMENTAL] 
function saving to XML file using boost::serialization.")
                #endif

Modified: trunk/scripts/test/periodic-simple.py
===================================================================
--- trunk/scripts/test/periodic-simple.py       2009-08-07 10:27:49 UTC (rev 
1929)
+++ trunk/scripts/test/periodic-simple.py       2009-08-07 13:22:16 UTC (rev 
1930)
@@ -1,5 +1,11 @@
-from yade import log
-log.setLevel("PeriodicInsertionSortCollider",log.TRACE)
+"""Simple test of periodic collider.
+A few spheres falling down in gravity field and one moving accross.
+Includes a clump.
+"""
+
+from yade import log,timing
+
+#log.setLevel("PeriodicInsertionSortCollider",log.TRACE)
 O.engines=[
        BexResetter(),
        
BoundingVolumeMetaEngine([InteractingSphere2AABB(),MetaInteractingGeometry2AABB()]),
@@ -14,11 +20,14 @@
        NewtonsDampedLaw(damping=.4)
 ]
 O.bodies.append(utils.sphere([-4,0,11],2,dynamic=False,density=1000))
-O.bodies.append(utils.sphere([0,-1,5.5],2,density=1000))
+O.bodies.append(utils.sphere([0,-2,5.5],2,density=1000))
 O.bodies.append(utils.sphere([0,2,5.5],2,density=2000))
+O.bodies.appendClumped([utils.sphere([0,4,8],.8,density=1000),utils.sphere([0,5,7],.6,density=1000)])
+# sets up the periodic cell
 O.periodicCell=((-5,-5,0),(5,5,10))
 O.dt=.1*utils.PWaveTimeStep()
 O.saveTmp()
 from yade import qt
 qt.Controller()
 qt.View()
+#O.timingEnabled=True; timing.reset(); O.run(200000,True); timing.stats()


_______________________________________________
Mailing list: https://launchpad.net/~yade-dev
Post to     : yade-dev@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-dev
More help   : https://help.launchpad.net/ListHelp

Reply via email to