[Yade-dev] [svn] r1929 - in trunk: extra gui/qt3 pkg/common/Engine/MetaEngine pkg/common/Engine/StandAloneEngine pkg/common/RenderingEngine/OpenGLRenderingEngine scripts/test

2009-08-07 Thread eudoxos at BerliOS
Author: eudoxos
Date: 2009-08-07 12:27:49 +0200 (Fri, 07 Aug 2009)
New Revision: 1929

Modified:
   trunk/extra/PeriodicInsertionSortCollider.cpp
   trunk/extra/PeriodicInsertionSortCollider.hpp
   trunk/gui/qt3/GLViewer.cpp
   trunk/gui/qt3/GLViewer.hpp
   trunk/pkg/common/Engine/MetaEngine/InteractionDispatchers.cpp
   trunk/pkg/common/Engine/MetaEngine/InteractionGeometryMetaEngine.cpp
   trunk/pkg/common/Engine/StandAloneEngine/InsertionSortCollider.cpp
   
trunk/pkg/common/RenderingEngine/OpenGLRenderingEngine/OpenGLRenderingEngine.cpp
   
trunk/pkg/common/RenderingEngine/OpenGLRenderingEngine/OpenGLRenderingEngine.hpp
   trunk/scripts/test/periodic-simple.py
Log:
1. Beta version of periodic boundary conditions (try 
scripts/test/periodic-simple.py


Modified: trunk/extra/PeriodicInsertionSortCollider.cpp
===
--- trunk/extra/PeriodicInsertionSortCollider.cpp   2009-08-06 22:05:28 UTC 
(rev 1928)
+++ trunk/extra/PeriodicInsertionSortCollider.cpp   2009-08-07 10:27:49 UTC 
(rev 1929)
@@ -18,34 +18,33 @@
 YADE_PLUGIN((PeriodicInsertionSortCollider))
 CREATE_LOGGER(PeriodicInsertionSortCollider);
 
-Real PeriodicInsertionSortCollider::cellWrap(const Real x, const Real x0, 
const Real x1, long& period){
+Real PeriodicInsertionSortCollider::cellWrap(const Real x, const Real x0, 
const Real x1, int& period){
Real xNorm=(x-x0)/(x1-x0);
-   period=(long)floor(xNorm); // FIXME: some people say this is very slow
+   period=(int)floor(xNorm); // FIXME: some people say this is very slow
return x0+(xNorm-period)*(x1-x0);
 }
 
+Real PeriodicInsertionSortCollider::cellWrapRel(const Real x, const Real x0, 
const Real x1){
+   Real xNorm=(x-x0)/(x1-x0);
+   return (xNorm-floor(xNorm))*(x1-x0);
+}
 
+
 // return true if bodies bb overlap in all 3 dimensions
 bool PeriodicInsertionSortCollider::spatialOverlap(body_id_t id1, body_id_t 
id2,MetaBody* rb, Vector3& periods) const {
-   assert(id1!=id2) // programming error, or weird bodies (too large?)
+   assert(id1!=id2); // programming error, or weird bodies (too large?)
for(int axis=0; axis<3; axis++){
Real dim=rb->cellMax[axis]-rb->cellMin[axis];
-   // wrap all 4 numbers to the period starting and the most 
minimal number
-   #if 0
-   Real 
mn=min(minima[3*id1+axis],minima[3*id2+axis])-0.001*dim; // avoid rounding 
issues
-   Real mx=max(maxima[3*id1+axis],maxima[3*id2+axis]);
-   TRVAR2(mn,mx);
-   #endif
// too big bodies in interaction
assert(maxima[3*id1+axis]-minima[3*id1+axis]<.99*dim); 
assert(maxima[3*id2+axis]-minima[3*id2+axis]<.99*dim);
// different way: find body of which when taken as period start 
will make the gap smaller
-   long p;
-   Real mn1w=cellWrap(minima[3*id1+axis],0,dim,p), 
mn2w=cellWrap(minima[3*id2+axis],0,dim,p);
-   Real wMn=(abs(mn2w-mn1w)&) 
const;
-   static Real cellWrap(Real,Real,Real,long&);
+   static Real cellWrap(const Real, const Real, const Real, int&);
+   static Real cellWrapRel(const Real, const Real, const Real);
 
+
public:
//! axis for the initial sort
int sortAxis;

Modified: trunk/gui/qt3/GLViewer.cpp
===
--- trunk/gui/qt3/GLViewer.cpp  2009-08-06 22:05:28 UTC (rev 1928)
+++ trunk/gui/qt3/GLViewer.cpp  2009-08-07 10:27:49 UTC (rev 1929)
@@ -323,6 +323,18 @@
else if(e->key()!=Qt::Key_Escape && e->key()!=Qt::Key_Space) 
QGLViewer::keyPressEvent(e);
updateGL();
 }
+/* Center the scene such that periodic cell is contained in the view */
+void GLViewer::centerPeriodic(){
+   MetaBody* rb=Omega::instance().getRootBody().get();
+   assert(rb->isPeriodic);
+   Vector3r center=.5*(rb->cellMin+rb->cellMax);
+   Vector3r halfSize=.5*(rb->cellMax-rb->cellMin);
+   float radius=std::max(halfSize[0],std::max(halfSize[1],halfSize[2]));
+   LOG_DEBUG("Periodic scene center="bodies->size();
if(nBodies<4) {
LOG_INFO("Less than 4 bodies, median makes no sense; calling 
centerScene() instead.");
@@ -357,6 +370,7 @@
 void GLViewer::centerScene(){
MetaBody* rb=Omega::instance().getRootBody().get();
if (!rb) return;
+   if(rb->isPeriodic){ centerPeriodic(); return; }
 
if(rb->bodies->size()selectBodyLimit){LOG_INFO("Less than 
"+lexical_cast(renderer->selectBodyLimit)+" bodies, moving possible. 
Select with shift, press 'm' to move.");}
else{LOG_INFO("More than 
"+lexical_cast(renderer->selectBodyLimit)+" 
(OpenGLRenderingEngine::selectBodyLimit) bodies. Moving not possible.");}

Modified: trunk/gui/qt3/GLViewer.hpp

Re: [Yade-dev] [svn] r1929 - in trunk: extra gui/qt3 pkg/common/Engine/MetaEngine pkg/common/Engine/StandAloneEngine pkg/common/RenderingEngine/OpenGLRenderingEngine scripts/test

2009-08-07 Thread Anton Gladky
It works for me. But what can it be useful for?

__
[ENG] Best Regards
[GER] Mit freundlichen Grüßen
[RUS] С наилучшими пожеланиями
[UKR] З найкращими побажаннями

Anton Gladkyy


2009/8/7 eudoxos at BerliOS 

> Author: eudoxos
> Date: 2009-08-07 12:27:49 +0200 (Fri, 07 Aug 2009)
> New Revision: 1929
>
> Modified:
>   trunk/extra/PeriodicInsertionSortCollider.cpp
>   trunk/extra/PeriodicInsertionSortCollider.hpp
>   trunk/gui/qt3/GLViewer.cpp
>   trunk/gui/qt3/GLViewer.hpp
>   trunk/pkg/common/Engine/MetaEngine/InteractionDispatchers.cpp
>   trunk/pkg/common/Engine/MetaEngine/InteractionGeometryMetaEngine.cpp
>   trunk/pkg/common/Engine/StandAloneEngine/InsertionSortCollider.cpp
>
> trunk/pkg/common/RenderingEngine/OpenGLRenderingEngine/OpenGLRenderingEngine.cpp
>
> trunk/pkg/common/RenderingEngine/OpenGLRenderingEngine/OpenGLRenderingEngine.hpp
>   trunk/scripts/test/periodic-simple.py
> Log:
> 1. Beta version of periodic boundary conditions (try
> scripts/test/periodic-simple.py
>
>
___
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