yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #01170
[svn] r1733 - in trunk: core extra gui/py pkg/common/Engine/MetaEngine
Author: eudoxos
Date: 2009-03-27 09:59:17 +0100 (Fri, 27 Mar 2009)
New Revision: 1733
Modified:
trunk/core/EngineUnit.hpp
trunk/core/EngineUnit1D.hpp
trunk/core/EngineUnit2D.hpp
trunk/extra/Brefcom.cpp
trunk/gui/py/yadeControl.cpp
trunk/pkg/common/Engine/MetaEngine/BoundingVolumeMetaEngine.hpp
trunk/pkg/common/Engine/MetaEngine/ConstitutiveLaw.hpp
trunk/pkg/common/Engine/MetaEngine/InteractionGeometryMetaEngine.hpp
trunk/pkg/common/Engine/MetaEngine/InteractionPhysicsMetaEngine.hpp
Log:
Add label attribute to engine units. Python wrapper updated.
Modified: trunk/core/EngineUnit.hpp
===================================================================
--- trunk/core/EngineUnit.hpp 2009-03-26 09:56:16 UTC (rev 1732)
+++ trunk/core/EngineUnit.hpp 2009-03-27 08:59:17 UTC (rev 1733)
@@ -19,7 +19,10 @@
public: virtual vector<std::string> getFunctorTypes(){throw;}
virtual list<string> getNeededBex(){return list<string>();}
shared_ptr<TimingDeltas> timingDeltas;
+ // label to be able to retrieve an engine unit by its label
+ string label;
REGISTER_CLASS_AND_BASE(EngineUnit,Serializable);
+ REGISTER_ATTRIBUTES(/* no base class attributes */,(label));
};
REGISTER_SERIALIZABLE(EngineUnit);
Modified: trunk/core/EngineUnit1D.hpp
===================================================================
--- trunk/core/EngineUnit1D.hpp 2009-03-26 09:56:16 UTC (rev 1732)
+++ trunk/core/EngineUnit1D.hpp 2009-03-27 08:59:17 UTC (rev 1733)
@@ -26,6 +26,7 @@
virtual std::string get1DFunctorType1(void){throw runtime_error("Class "+this->getClassName()+" did not use FUNCTOR1D to declare its argument type?"); }
virtual vector<string> getFunctorTypes(void){vector<string> ret; ret.push_back(get1DFunctorType1()); return ret;};
REGISTER_CLASS_AND_BASE(EngineUnit1D,EngineUnit FunctorWrapper);
+ REGISTER_ATTRIBUTES(EngineUnit,/*no attributes here*/);
};
Modified: trunk/core/EngineUnit2D.hpp
===================================================================
--- trunk/core/EngineUnit2D.hpp 2009-03-26 09:56:16 UTC (rev 1732)
+++ trunk/core/EngineUnit2D.hpp 2009-03-27 08:59:17 UTC (rev 1733)
@@ -28,6 +28,7 @@
virtual std::string get2DFunctorType2(void){throw runtime_error("Class "+this->getClassName()+" did not use FUNCTOR2D to declare its argument types?");}
virtual vector<string> getFunctorTypes(){vector<string> ret; ret.push_back(get2DFunctorType1()); ret.push_back(get2DFunctorType2()); return ret;};
REGISTER_CLASS_AND_BASE(EngineUnit2D,EngineUnit FunctorWrapper);
+ REGISTER_ATTRIBUTES(EngineUnit,/*no attributes here*/);
};
Modified: trunk/extra/Brefcom.cpp
===================================================================
--- trunk/extra/Brefcom.cpp 2009-03-26 09:56:16 UTC (rev 1732)
+++ trunk/extra/Brefcom.cpp 2009-03-27 08:59:17 UTC (rev 1733)
@@ -236,6 +236,8 @@
rootBody=_rootBody;
if(!functor) functor=shared_ptr<ef2_Spheres_Brefcom_BrefcomLaw>(new ef2_Spheres_Brefcom_BrefcomLaw);
functor->logStrain=logStrain;
+ LOG_FATAL("Deprecated BrefcomLaw doesn't pass its parameters to the functor, results would be garbage. Fix me or use ef2_Spheres_Brefcom_BrercomLaw directly instead.");
+ throw;
FOREACH(const shared_ptr<Interaction>& I, *rootBody->interactions){
if(!I->isReal) continue;
functor->go(I->interactionGeometry, I->interactionPhysics, I.get(), rootBody);
Modified: trunk/gui/py/yadeControl.cpp
===================================================================
--- trunk/gui/py/yadeControl.cpp 2009-03-26 09:56:16 UTC (rev 1732)
+++ trunk/gui/py/yadeControl.cpp 2009-03-27 08:59:17 UTC (rev 1733)
@@ -474,6 +474,16 @@
PyRun_SimpleString(("__builtins__."+e->label+"=Omega().labeledEngine('"+e->label+"')").c_str());
PyGILState_Release(gstate);
}
+ if(isChildClassOf(e->getClassName(),"MetaEngine")){
+ shared_ptr<MetaEngine> ee=dynamic_pointer_cast<MetaEngine>(e);
+ FOREACH(const shared_ptr<EngineUnit>& f, ee->functorArguments){
+ if(!f->label.empty()){
+ PyGILState_STATE gstate; gstate = PyGILState_Ensure();
+ PyRun_SimpleString(("__builtins__."+f->label+"=Omega().labeledEngine('"+f->label+"')").c_str());
+ PyGILState_Release(gstate);
+ }
+ }
+ }
}
}
@@ -576,11 +586,15 @@
RETURN_ENGINE_IF_POSSIBLE(ParallelEngine,pyParallelEngine);
throw std::runtime_error("Unable to cast engine to MetaEngine, StandAloneEngine, DeusExMachina or ParallelEngine? ??");
}
+ shared_ptr<MetaEngine> me=dynamic_pointer_cast<MetaEngine>(eng);
+ if(me){
+ FOREACH(const shared_ptr<EngineUnit>& eu, me->functorArguments){
+ if(eu->label==label) return python::object(pyEngineUnit(eu));
+ }
+ }
}
throw std::invalid_argument(string("No engine labeled `")+label+"'");
}
-
-
pyBodyContainer bodies_get(void){assertRootBody(); return pyBodyContainer(OMEGA.getRootBody()->bodies); }
pyInteractionContainer interactions_get(void){assertRootBody(); return pyInteractionContainer(OMEGA.getRootBody()->interactions); }
@@ -722,6 +736,7 @@
boost::python::class_<pyBexContainer>("BexContainer",python::init<pyBexContainer&>())
.def("f",&pyBexContainer::force_get)
.def("t",&pyBexContainer::torque_get)
+ .def("m",&pyBexContainer::torque_get) // for compatibility with ActionContainer
.def("addF",&pyBexContainer::force_add)
.def("addT",&pyBexContainer::torque_add);
#endif
Modified: trunk/pkg/common/Engine/MetaEngine/BoundingVolumeMetaEngine.hpp
===================================================================
--- trunk/pkg/common/Engine/MetaEngine/BoundingVolumeMetaEngine.hpp 2009-03-26 09:56:16 UTC (rev 1732)
+++ trunk/pkg/common/Engine/MetaEngine/BoundingVolumeMetaEngine.hpp 2009-03-27 08:59:17 UTC (rev 1733)
@@ -36,6 +36,7 @@
REGISTER_CLASS_NAME(BoundingVolumeMetaEngine);
REGISTER_BASE_CLASS_NAME(MetaEngine2D);
+ REGISTER_ATTRIBUTES(MetaEngine,/* no attributes here */);
};
REGISTER_SERIALIZABLE(BoundingVolumeMetaEngine);
Modified: trunk/pkg/common/Engine/MetaEngine/ConstitutiveLaw.hpp
===================================================================
--- trunk/pkg/common/Engine/MetaEngine/ConstitutiveLaw.hpp 2009-03-26 09:56:16 UTC (rev 1732)
+++ trunk/pkg/common/Engine/MetaEngine/ConstitutiveLaw.hpp 2009-03-27 08:59:17 UTC (rev 1733)
@@ -37,6 +37,7 @@
addTorque(id1,(contactPoint-pos1).Cross(force),rb);
addTorque(id2,-(contactPoint-pos2).Cross(force),rb);
}
+ REGISTER_ATTRIBUTES(EngineUnit,/* no attributes here */);
};
REGISTER_SERIALIZABLE(ConstitutiveLaw);
Modified: trunk/pkg/common/Engine/MetaEngine/InteractionGeometryMetaEngine.hpp
===================================================================
--- trunk/pkg/common/Engine/MetaEngine/InteractionGeometryMetaEngine.hpp 2009-03-26 09:56:16 UTC (rev 1732)
+++ trunk/pkg/common/Engine/MetaEngine/InteractionGeometryMetaEngine.hpp 2009-03-27 08:59:17 UTC (rev 1733)
@@ -40,6 +40,7 @@
REGISTER_CLASS_NAME(InteractionGeometryMetaEngine);
REGISTER_BASE_CLASS_NAME(MetaEngine2D);
+ REGISTER_ATTRIBUTES(MetaEngine,/* no attributes here*/ );
};
REGISTER_SERIALIZABLE(InteractionGeometryMetaEngine);
Modified: trunk/pkg/common/Engine/MetaEngine/InteractionPhysicsMetaEngine.hpp
===================================================================
--- trunk/pkg/common/Engine/MetaEngine/InteractionPhysicsMetaEngine.hpp 2009-03-26 09:56:16 UTC (rev 1732)
+++ trunk/pkg/common/Engine/MetaEngine/InteractionPhysicsMetaEngine.hpp 2009-03-27 08:59:17 UTC (rev 1733)
@@ -33,6 +33,7 @@
REGISTER_CLASS_NAME(InteractionPhysicsMetaEngine);
REGISTER_BASE_CLASS_NAME(MetaEngine2D);
+ REGISTER_ATTRIBUTES(MetaEngine, /* no attributes here */);
};
REGISTER_SERIALIZABLE(InteractionPhysicsMetaEngine);