yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #00979
[svn] r1669 - in trunk: core/DefaultContainerImplementations gui/py pkg/common/Engine/StandAloneEngine
Author: eudoxos
Date: 2009-02-17 21:47:59 +0100 (Tue, 17 Feb 2009)
New Revision: 1669
Modified:
trunk/core/DefaultContainerImplementations/PhysicalActionVectorVector.cpp
trunk/core/DefaultContainerImplementations/PhysicalActionVectorVector.hpp
trunk/gui/py/yadeControl.cpp
trunk/pkg/common/Engine/StandAloneEngine/PersistentSAPCollider.cpp
Log:
1. Add possibility to change container types from python (for benchmarks) -- code not yet tested!
2. Possible optimization in PhysicalActionVectorVector, now disabled.
Modified: trunk/core/DefaultContainerImplementations/PhysicalActionVectorVector.cpp
===================================================================
--- trunk/core/DefaultContainerImplementations/PhysicalActionVectorVector.cpp 2009-02-17 09:10:50 UTC (rev 1668)
+++ trunk/core/DefaultContainerImplementations/PhysicalActionVectorVector.cpp 2009-02-17 20:47:59 UTC (rev 1669)
@@ -114,16 +114,23 @@
// doesn't not delete all, just resets data
void PhysicalActionVectorVector::reset()
{
- vector< vector< shared_ptr<PhysicalAction> > >::iterator vvi = physicalActions.begin();
- vector< vector< shared_ptr<PhysicalAction> > >::iterator vviEnd = physicalActions.end();
- for( ; vvi != vviEnd ; ++vvi )
- {
- vector< shared_ptr<PhysicalAction> >::iterator vi = (*vvi).begin();
- vector< shared_ptr<PhysicalAction> >::iterator viEnd = (*vvi).end();
- for( ; vi != viEnd ; ++vi)
- //if(*vi) // FIXME ?? do not check - all fields are NOT empty.
- (*vi)->reset();
- }
+ #if 1
+ vector< vector< shared_ptr<PhysicalAction> > >::iterator vvi = physicalActions.begin();
+ vector< vector< shared_ptr<PhysicalAction> > >::iterator vviEnd = physicalActions.end();
+ for( ; vvi != vviEnd ; ++vvi )
+ {
+ vector< shared_ptr<PhysicalAction> >::iterator vi = (*vvi).begin();
+ vector< shared_ptr<PhysicalAction> >::iterator viEnd = (*vvi).end();
+ for( ; vi != viEnd ; ++vi)
+ //if(*vi) // FIXME ?? do not check - all fields are NOT empty.
+ (*vi)->reset();
+ }
+ #else
+ FOREACH(int idx, usedBexIndices){
+ // reset everything
+ FOREACH(shared_ptr<PhysicalAction>& pa,physicalActions[idx]){ pa->reset();}
+ }
+ #endif
}
@@ -142,10 +149,13 @@
maxSize = max(maxSize , actionTypes[i]->getClassIndex() );
++maxSize;
actionTypesResetted.resize(maxSize);
+ usedBexIndices.clear();
for(unsigned int i = 0 ; i < size ; ++i )
{
- actionTypesResetted[actionTypes[i]->getClassIndex()] = actionTypes[i]->clone();
- actionTypesResetted[actionTypes[i]->getClassIndex()] -> reset();
+ int idx=actionTypes[i]->getClassIndex();
+ actionTypesResetted[idx] = actionTypes[i]->clone();
+ actionTypesResetted[idx] -> reset();
+ usedBexIndices.push_back(idx);
}
}
Modified: trunk/core/DefaultContainerImplementations/PhysicalActionVectorVector.hpp
===================================================================
--- trunk/core/DefaultContainerImplementations/PhysicalActionVectorVector.hpp 2009-02-17 09:10:50 UTC (rev 1668)
+++ trunk/core/DefaultContainerImplementations/PhysicalActionVectorVector.hpp 2009-02-17 20:47:59 UTC (rev 1669)
@@ -56,6 +56,7 @@
vector< shared_ptr<PhysicalAction> > actionTypesResetted;
vector< bool > usedIds;
unsigned int current_size;
+ vector<int> usedBexIndices;
public :
PhysicalActionVectorVector();
Modified: trunk/gui/py/yadeControl.cpp
===================================================================
--- trunk/gui/py/yadeControl.cpp 2009-02-17 09:10:50 UTC (rev 1668)
+++ trunk/gui/py/yadeControl.cpp 2009-02-17 20:47:59 UTC (rev 1669)
@@ -526,6 +526,30 @@
}
pyTags tags_get(void){assertRootBody(); return pyTags(OMEGA.getRootBody());}
+
+ void interactionContainer_set(string clss){
+ MetaBody* rb=OMEGA.getRootBody().get();
+ if(rb->transientInteractions->size()>0) throw std::runtime_error("Interaction container not empty, will not change its class.");
+ shared_ptr<InteractionContainer> ic=dynamic_pointer_cast<InteractionContainer>(ClassFactory::instance().createShared(clss));
+ rb->transientInteractions=ic;
+ }
+ string interactionContainer_get(string clss){ return OMEGA.getRootBody()->transientInteractions->getClassName(); }
+
+ void bodyContainer_set(string clss){
+ MetaBody* rb=OMEGA.getRootBody().get();
+ if(rb->bodies->size()>0) throw std::runtime_error("Body container not empty, will not change its class.");
+ shared_ptr<BodyContainer> bc=dynamic_pointer_cast<BodyContainer>(ClassFactory::instance().createShared(clss));
+ rb->bodies=bc;
+ }
+ string bodyContainer_get(string clss){ return OMEGA.getRootBody()->bodies->getClassName(); }
+
+ void physicalActionContainer_set(string clss){
+ MetaBody* rb=OMEGA.getRootBody().get();
+ shared_ptr<PhysicalActionContainer> pac=dynamic_pointer_cast<PhysicalActionContainer>(ClassFactory::instance().createShared(clss));
+ rb->physicalActions=pac;
+ }
+ string physicalActionContainer_get(string clss){ return OMEGA.getRootBody()->physicalActions->getClassName(); }
+
};
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(omega_run_overloads,run,0,2);
@@ -580,6 +604,9 @@
.add_property("actions",&pyOmega::actions_get)
.add_property("tags",&pyOmega::tags_get)
.def("childClasses",&pyOmega::listChildClasses)
+ .add_property("bodyContainer",&pyOmega::bodyContainer_get,&pyOmega::bodyContainer_set)
+ .add_property("interactionContainer",&pyOmega::interactionContainer_get,&pyOmega::interactionContainer_set)
+ .add_property("actionContainer",&pyOmega::physicalActionContainer_get,&pyOmega::physicalActionContainer_set)
;
boost::python::class_<pyTags>("TagsWrapper",python::init<pyTags&>())
.def("__getitem__",&pyTags::getItem)
Modified: trunk/pkg/common/Engine/StandAloneEngine/PersistentSAPCollider.cpp
===================================================================
--- trunk/pkg/common/Engine/StandAloneEngine/PersistentSAPCollider.cpp 2009-02-17 09:10:50 UTC (rev 1668)
+++ trunk/pkg/common/Engine/StandAloneEngine/PersistentSAPCollider.cpp 2009-02-17 20:47:59 UTC (rev 1669)
@@ -191,6 +191,8 @@
int offset1=3*id1, offset2=3*id2;
const shared_ptr<Body>& b1(Body::byId(body_id_t(id1),rootBody)), b2(Body::byId(body_id_t(id2),rootBody));
bool overlap =
+ // only collide if at least one of the bodies is not shadow
+ ((!b1->isShadow()) || (!b2->isShadow())) &&
// 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
@@ -230,8 +232,6 @@
}
-
-
void PersistentSAPCollider::findOverlappingBB(std::vector<shared_ptr<AABBBound> >& bounds, int nbElements){
int i=0,j=0;
while (i<2*nbElements) {