yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #10872
[Branch ~yade-pkg/yade/git-trunk] Rev 3977: Remove some more `using namespace boost`.
------------------------------------------------------------
revno: 3977
committer: Anton Gladky <gladky.anton@xxxxxxxxx>
timestamp: Fri 2014-05-23 15:03:50 +0200
message:
Remove some more `using namespace boost`.
modified:
core/Dispatcher.hpp
core/Omega.cpp
core/Omega.hpp
core/main/pyboot.cpp
gui/qt4/GLViewer.cpp
gui/qt4/GLViewerDisplay.cpp
gui/qt4/GLViewerMouse.cpp
lib/factory/DynLibManager.cpp
lib/serialization/ObjectIO.hpp
lib/serialization/Serializable.cpp
lib/triangulation/Network.ipp
pkg/common/MatchMaker.cpp
pkg/common/OpenGLRenderer.cpp
pkg/common/ParallelEngine.cpp
pkg/common/ParallelEngine.hpp
pkg/dem/CapillaryTriaxialTest.cpp
pkg/dem/CohesiveTriaxialTest.cpp
pkg/dem/ConcretePM.cpp
pkg/dem/Integrator.cpp
pkg/dem/SampleCapillaryPressureEngine.cpp
pkg/dem/Shop_01.cpp
pkg/dem/SpherePack.cpp
pkg/dem/SpherePack.hpp
pkg/dem/TriaxialTest.cpp
py/pack/_packObb.cpp
py/pack/_packSpheres.cpp
py/wrapper/customConverters.cpp
py/wrapper/yadeWrapper.cpp
--
lp:yade
https://code.launchpad.net/~yade-pkg/yade/git-trunk
Your team Yade developers is subscribed to branch lp:yade.
To unsubscribe from this branch go to https://code.launchpad.net/~yade-pkg/yade/git-trunk/+edit-subscription
=== modified file 'core/Dispatcher.hpp'
--- core/Dispatcher.hpp 2010-11-07 11:46:20 +0000
+++ core/Dispatcher.hpp 2014-05-23 13:03:50 +0000
@@ -40,7 +40,7 @@
#define _YADE_DIM_DISPATCHER_FUNCTOR_DOC_ATTRS_CTOR_PY(Dim,DispatcherT,FunctorT,doc,attrs,ctor,py) \
typedef FunctorT FunctorType; \
void updateScenePtr(){ FOREACH(shared_ptr<FunctorT> f, functors){ f->scene=scene; }} \
- void postLoad(DispatcherT&){ clearMatrix(); FOREACH(shared_ptr<FunctorT> f, functors) add(static_pointer_cast<FunctorT>(f)); } \
+ void postLoad(DispatcherT&){ clearMatrix(); FOREACH(shared_ptr<FunctorT> f, functors) add(boost::static_pointer_cast<FunctorT>(f)); } \
virtual void add(FunctorT* f){ add(shared_ptr<FunctorT>(f)); } \
virtual void add(shared_ptr<FunctorT> f){ bool dupe=false; string fn=f->getClassName(); FOREACH(const shared_ptr<FunctorT>& f, functors) { if(fn==f->getClassName()) dupe=true; } if(!dupe) functors.push_back(f); addFunctor(f); } \
BOOST_PP_CAT(_YADE_DISPATCHER,BOOST_PP_CAT(Dim,D_FUNCTOR_ADD))(FunctorT,f) \
=== modified file 'core/Omega.cpp'
--- core/Omega.cpp 2012-02-13 11:17:02 +0000
+++ core/Omega.cpp 2014-05-23 13:03:50 +0000
@@ -167,7 +167,7 @@
if(getenv("YADE_DEBUG")) cerr<<endl<<"[[[ Round "<<i<<" ]]]: ";
std::list<string> done;
for(std::list<string>::iterator I=pythonables.begin(); I!=pythonables.end(); ){
- shared_ptr<Serializable> s=static_pointer_cast<Serializable>(ClassFactory::instance().createShared(*I));
+ shared_ptr<Serializable> s=boost::static_pointer_cast<Serializable>(ClassFactory::instance().createShared(*I));
try{
if(getenv("YADE_DEBUG")) cerr<<"{{"<<*I<<"}}";
s->pyRegisterClass(wrapperScope);
=== modified file 'core/Omega.hpp'
--- core/Omega.hpp 2012-02-13 11:17:02 +0000
+++ core/Omega.hpp 2014-05-23 13:03:50 +0000
@@ -48,7 +48,6 @@
class Scene;
class ThreadRunner;
-using namespace boost;
using namespace boost::posix_time;
using namespace std;
=== modified file 'core/main/pyboot.cpp'
--- core/main/pyboot.cpp 2012-04-13 16:27:00 +0000
+++ core/main/pyboot.cpp 2014-05-23 13:03:50 +0000
@@ -26,7 +26,7 @@
#endif
/* Initialize yade, loading given plugins */
-void yadeInitialize(python::list& pp, const std::string& confDir){
+void yadeInitialize(boost::python::list& pp, const std::string& confDir){
PyEval_InitThreads();
@@ -42,12 +42,12 @@
signal(SIGABRT,crashHandler);
signal(SIGSEGV,crashHandler);
#endif
- vector<string> ppp; for(int i=0; i<python::len(pp); i++) ppp.push_back(python::extract<string>(pp[i]));
+ vector<string> ppp; for(int i=0; i<boost::python::len(pp); i++) ppp.push_back(boost::python::extract<string>(pp[i]));
Omega::instance().loadPlugins(ppp);
}
void yadeFinalize(){ Omega::instance().cleanupTemps(); }
BOOST_PYTHON_MODULE(boot){
- python::scope().attr("initialize")=&yadeInitialize;
- python::scope().attr("finalize")=&yadeFinalize; //,"Finalize yade (only to be used internally).")
+ boost::python::scope().attr("initialize")=&yadeInitialize;
+ boost::python::scope().attr("finalize")=&yadeFinalize; //,"Finalize yade (only to be used internally).")
}
=== modified file 'gui/qt4/GLViewer.cpp'
--- gui/qt4/GLViewer.cpp 2014-05-15 14:47:33 +0000
+++ gui/qt4/GLViewer.cpp 2014-05-23 13:03:50 +0000
@@ -27,8 +27,6 @@
#include<yade/lib/pyutil/gil.hpp>
#include<QtGui/qevent.h>
-using namespace boost;
-
#ifdef YADE_GL2PS
#include<gl2ps.h>
#endif
=== modified file 'gui/qt4/GLViewerDisplay.cpp'
--- gui/qt4/GLViewerDisplay.cpp 2014-02-16 14:03:41 +0000
+++ gui/qt4/GLViewerDisplay.cpp 2014-05-23 13:03:50 +0000
@@ -29,8 +29,6 @@
#include<QtGui/qevent.h>
-using namespace boost;
-
#ifdef YADE_GL2PS
#include<gl2ps.h>
#endif
=== modified file 'gui/qt4/GLViewerMouse.cpp'
--- gui/qt4/GLViewerMouse.cpp 2014-05-06 16:53:02 +0000
+++ gui/qt4/GLViewerMouse.cpp 2014-05-23 13:03:50 +0000
@@ -29,8 +29,6 @@
#include<QtGui/qevent.h>
-using namespace boost;
-
#ifdef YADE_GL2PS
#include<gl2ps.h>
#endif
=== modified file 'lib/factory/DynLibManager.cpp'
--- lib/factory/DynLibManager.cpp 2009-11-29 15:46:19 +0000
+++ lib/factory/DynLibManager.cpp 2014-05-23 13:03:50 +0000
@@ -20,7 +20,6 @@
//using namespace std;
-using namespace boost;
CREATE_LOGGER(DynLibManager);
=== modified file 'lib/serialization/ObjectIO.hpp'
--- lib/serialization/ObjectIO.hpp 2011-12-19 17:02:15 +0000
+++ lib/serialization/ObjectIO.hpp 2014-05-23 13:03:50 +0000
@@ -52,9 +52,9 @@
template<class T>
static void save(const string fileName, const string& objectTag, T& object){
boost::iostreams::filtering_ostream out;
- if(boost::algorithm::ends_with(fileName,".bz2")) out.push(iostreams::bzip2_compressor());
- if(boost::algorithm::ends_with(fileName,".gz")) out.push(iostreams::gzip_compressor());
- out.push(iostreams::file_sink(fileName));
+ if(boost::algorithm::ends_with(fileName,".bz2")) out.push(boost::iostreams::bzip2_compressor());
+ if(boost::algorithm::ends_with(fileName,".gz")) out.push(boost::iostreams::gzip_compressor());
+ out.push(boost::iostreams::file_sink(fileName));
if(!out.good()) throw std::runtime_error("Error opening file "+fileName+" for writing.");
if(isXmlFilename(fileName)) save<T,boost::archive::xml_oarchive>(out,objectTag,object);
else save<T,boost::archive::binary_oarchive>(out,objectTag,object);
@@ -63,9 +63,9 @@
template<class T>
static void load(const string& fileName, const string& objectTag, T& object){
boost::iostreams::filtering_istream in;
- if(boost::algorithm::ends_with(fileName,".bz2")) in.push(iostreams::bzip2_decompressor());
- if(boost::algorithm::ends_with(fileName,".gz")) in.push(iostreams::gzip_decompressor());
- in.push(iostreams::file_source(fileName));
+ if(boost::algorithm::ends_with(fileName,".bz2")) in.push(boost::iostreams::bzip2_decompressor());
+ if(boost::algorithm::ends_with(fileName,".gz")) in.push(boost::iostreams::gzip_decompressor());
+ in.push(boost::iostreams::file_source(fileName));
if(!in.good()) throw std::runtime_error("Error opening file "+fileName+" for reading.");
if(isXmlFilename(fileName)) load<T,boost::archive::xml_iarchive>(in,objectTag,object);
else load<T,boost::archive::binary_iarchive>(in,objectTag,object);
=== modified file 'lib/serialization/Serializable.cpp'
--- lib/serialization/Serializable.cpp 2014-05-23 13:03:50 +0000
+++ lib/serialization/Serializable.cpp 2014-05-23 13:03:50 +0000
@@ -14,7 +14,7 @@
void Serializable::pyRegisterClass(boost::python::object _scope) {
checkPyClassRegistersItself("Serializable");
boost::python::scope thisScope(_scope);
- boost::python::class_<Serializable, shared_ptr<Serializable>, noncopyable >("Serializable")
+ boost::python::class_<Serializable, shared_ptr<Serializable>, boost::noncopyable >("Serializable")
.def("__str__",&Serializable::pyStr).def("__repr__",&Serializable::pyStr)
.def("dict",&Serializable::pyDict,"Return dictionary of attributes.")
.def("updateAttrs",&Serializable::pyUpdateAttrs,"Update object attributes from given dictionary")
@@ -40,8 +40,8 @@
void Serializable::pyUpdateAttrs(const boost::python::dict& d){
boost::python::list l=d.items(); size_t ll=boost::python::len(l); if(ll==0) return;
for(size_t i=0; i<ll; i++){
- boost::python::tuple t=boost::python::extract<python::tuple>(l[i]);
- string key=python::extract<string>(t[0]);
+ boost::python::tuple t=boost::python::extract<boost::python::tuple>(l[i]);
+ string key=boost::python::extract<string>(t[0]);
pySetAttr(key,t[1]);
}
callPostLoad();
=== modified file 'lib/triangulation/Network.ipp'
--- lib/triangulation/Network.ipp 2014-03-23 02:00:05 +0000
+++ lib/triangulation/Network.ipp 2014-05-23 13:03:50 +0000
@@ -16,7 +16,6 @@
using namespace std;
-// using namespace boost;
namespace CGT {
// template<class Tesselation> const double Network<Tesselation>::FAR = 50000;
=== modified file 'pkg/common/MatchMaker.cpp'
--- pkg/common/MatchMaker.cpp 2010-12-06 20:05:12 +0000
+++ pkg/common/MatchMaker.cpp 2014-05-23 13:03:50 +0000
@@ -14,7 +14,7 @@
if(((int)m[0]==id1 && (int)m[1]==id2) || ((int)m[0]==id2 && (int)m[1]==id1)) return m[2];
}
// no match
- if(fbNeedsValues && (isnan(val1) || isnan(val2))) throw std::invalid_argument("MatchMaker: no match for ("+lexical_cast<string>(id1)+","+lexical_cast<string>(id2)+"), and values required for algo computation '"+algo+"' not specified.");
+ if(fbNeedsValues && (isnan(val1) || isnan(val2))) throw std::invalid_argument("MatchMaker: no match for ("+boost::lexical_cast<string>(id1)+","+boost::lexical_cast<string>(id2)+"), and values required for algo computation '"+algo+"' not specified.");
return computeFallback(val1,val2);
}
=== modified file 'pkg/common/OpenGLRenderer.cpp'
--- pkg/common/OpenGLRenderer.cpp 2014-04-16 19:53:59 +0000
+++ pkg/common/OpenGLRenderer.cpp 2014-05-23 13:03:50 +0000
@@ -68,7 +68,7 @@
void OpenGLRenderer::initgl(){
LOG_DEBUG("(re)initializing GL for gldraw methods.\n");
- #define _SETUP_DISPATCHER(names,FunctorType,dispatcher) dispatcher.clearMatrix(); FOREACH(string& s,names) {shared_ptr<FunctorType> f(static_pointer_cast<FunctorType>(ClassFactory::instance().createShared(s))); f->initgl(); dispatcher.add(f);}
+ #define _SETUP_DISPATCHER(names,FunctorType,dispatcher) dispatcher.clearMatrix(); FOREACH(string& s,names) {shared_ptr<FunctorType> f(boost::static_pointer_cast<FunctorType>(ClassFactory::instance().createShared(s))); f->initgl(); dispatcher.add(f);}
// _SETUP_DISPATCHER(stateFunctorNames,GlStateFunctor,stateDispatcher);
_SETUP_DISPATCHER(boundFunctorNames,GlBoundFunctor,boundDispatcher);
_SETUP_DISPATCHER(shapeFunctorNames,GlShapeFunctor,shapeDispatcher);
=== modified file 'pkg/common/ParallelEngine.cpp'
--- pkg/common/ParallelEngine.cpp 2013-01-29 19:03:26 +0000
+++ pkg/common/ParallelEngine.cpp 2014-05-23 13:03:50 +0000
@@ -1,6 +1,6 @@
#include"ParallelEngine.hpp"
#include<boost/python.hpp>
-using namespace boost;
+
#ifdef YADE_OPENMP
#include<omp.h>
#endif
@@ -8,7 +8,7 @@
YADE_PLUGIN((ParallelEngine));
//! ParallelEngine's pseudo-ctor (factory), taking nested lists of slave engines (might be moved to real ctor perhaps)
-shared_ptr<ParallelEngine> ParallelEngine_ctor_list(const python::list& slaves){ shared_ptr<ParallelEngine> instance(new ParallelEngine); instance->slaves_set(slaves); return instance; }
+shared_ptr<ParallelEngine> ParallelEngine_ctor_list(const boost::python::list& slaves){ shared_ptr<ParallelEngine> instance(new ParallelEngine); instance->slaves_set(slaves); return instance; }
void ParallelEngine::action(){
// openMP warns if the iteration variable is unsigned...
@@ -29,24 +29,24 @@
}
}
-void ParallelEngine::slaves_set(const python::list& slaves2){
- int len=python::len(slaves2);
+void ParallelEngine::slaves_set(const boost::python::list& slaves2){
+ int len=boost::python::len(slaves2);
slaves.clear();
for(int i=0; i<len; i++){
- python::extract<std::vector<shared_ptr<Engine> > > serialGroup(slaves2[i]);
+ boost::python::extract<std::vector<shared_ptr<Engine> > > serialGroup(slaves2[i]);
if (serialGroup.check()){ slaves.push_back(serialGroup()); continue; }
- python::extract<shared_ptr<Engine> > serialAlone(slaves2[i]);
+ boost::python::extract<shared_ptr<Engine> > serialAlone(slaves2[i]);
if (serialAlone.check()){ vector<shared_ptr<Engine> > aloneWrap; aloneWrap.push_back(serialAlone()); slaves.push_back(aloneWrap); continue; }
PyErr_SetString(PyExc_TypeError,"List elements must be either\n (a) sequences of engines to be executed one after another\n(b) alone engines.");
- python::throw_error_already_set();
+ boost::python::throw_error_already_set();
}
}
-python::list ParallelEngine::slaves_get(){
- python::list ret;
+boost::python::list ParallelEngine::slaves_get(){
+ boost::python::list ret;
FOREACH(vector<shared_ptr<Engine > >& grp, slaves){
- if(grp.size()==1) ret.append(python::object(grp[0]));
- else ret.append(python::object(grp));
+ if(grp.size()==1) ret.append(boost::python::object(grp[0]));
+ else ret.append(boost::python::object(grp));
}
return ret;
}
=== modified file 'pkg/common/ParallelEngine.hpp'
--- pkg/common/ParallelEngine.hpp 2012-10-31 12:31:50 +0000
+++ pkg/common/ParallelEngine.hpp 2014-05-23 13:03:50 +0000
@@ -3,7 +3,7 @@
#include<boost/python.hpp>
class ParallelEngine;
-shared_ptr<ParallelEngine> ParallelEngine_ctor_list(const python::list& slaves);
+shared_ptr<ParallelEngine> ParallelEngine_ctor_list(const boost::python::list& slaves);
class ParallelEngine: public Engine {
public:
@@ -20,7 +20,7 @@
ompThreads=2;
,
/*py*/
- .def("__init__",python::make_constructor(ParallelEngine_ctor_list),"Construct from (possibly nested) list of slaves.")
+ .def("__init__",boost::python::make_constructor(ParallelEngine_ctor_list),"Construct from (possibly nested) list of slaves.")
.add_property("slaves",&ParallelEngine::slaves_get,&ParallelEngine::slaves_set,"List of lists of Engines; each top-level group will be run in parallel with other groups, while Engines inside each group will be run sequentially, in given order.");
);
};
=== modified file 'pkg/dem/CapillaryTriaxialTest.cpp'
--- pkg/dem/CapillaryTriaxialTest.cpp 2013-05-30 20:17:45 +0000
+++ pkg/dem/CapillaryTriaxialTest.cpp 2014-05-23 13:03:50 +0000
@@ -53,12 +53,8 @@
#include <boost/random/variate_generator.hpp>
#include <boost/random/normal_distribution.hpp>
-
-
-using namespace boost;
using namespace std;
-
typedef pair<Vector3r, Real> BasicSphere;
//! generate a list of non-overlapping spheres
string GenerateCloud_water(vector<BasicSphere>& sphere_list, Vector3r lowerCorner, Vector3r upperCorner, long number, Real rad_std_dev, Real porosity);
=== modified file 'pkg/dem/CohesiveTriaxialTest.cpp'
--- pkg/dem/CohesiveTriaxialTest.cpp 2013-01-07 15:19:31 +0000
+++ pkg/dem/CohesiveTriaxialTest.cpp 2014-05-23 13:03:50 +0000
@@ -49,9 +49,6 @@
#include <boost/random/variate_generator.hpp>
#include <boost/random/normal_distribution.hpp>
-
-
-using namespace boost;
using namespace std;
@@ -391,14 +388,14 @@
break;
}
}
- if (t==tries) return "More than " + lexical_cast<string>(tries) +
+ if (t==tries) return "More than " + boost::lexical_cast<string>(tries) +
" tries while generating sphere number " +
- lexical_cast<string>(i+1) + "/" + lexical_cast<string>(number) + ".";
+ boost::lexical_cast<string>(i+1) + "/" + boost::lexical_cast<string>(number) + ".";
}
- return "Generated a sample with " + lexical_cast<string>(number) + "spheres inside box of dimensions: ("
- + lexical_cast<string>(dimensions[0]) + ","
- + lexical_cast<string>(dimensions[1]) + ","
- + lexical_cast<string>(dimensions[2]) + ").";
+ return "Generated a sample with " + boost::lexical_cast<string>(number) + "spheres inside box of dimensions: ("
+ + boost::lexical_cast<string>(dimensions[0]) + ","
+ + boost::lexical_cast<string>(dimensions[1]) + ","
+ + boost::lexical_cast<string>(dimensions[2]) + ").";
}
=== modified file 'pkg/dem/ConcretePM.cpp'
--- pkg/dem/ConcretePM.cpp 2013-10-04 12:03:13 +0000
+++ pkg/dem/ConcretePM.cpp 2014-05-23 13:03:50 +0000
@@ -465,7 +465,7 @@
void Gl1_CpmPhys::go(const shared_ptr<IPhys>& ip, const shared_ptr<Interaction>& i, const shared_ptr<Body>& b1, const shared_ptr<Body>& b2, bool wireFrame){
- const shared_ptr<CpmPhys>& phys = static_pointer_cast<CpmPhys>(ip);
+ const shared_ptr<CpmPhys>& phys = boost::static_pointer_cast<CpmPhys>(ip);
const shared_ptr<GenericSpheresContact>& geom = YADE_PTR_CAST<GenericSpheresContact>(i->geom);
// FIXME: get the scene for periodicity; ugly!
Scene* scene=Omega::instance().getScene().get();
@@ -518,7 +518,7 @@
glPopMatrix();
}
- Vector3r cp = static_pointer_cast<GenericSpheresContact>(i->geom)->contactPoint;
+ Vector3r cp = boost::static_pointer_cast<GenericSpheresContact>(i->geom)->contactPoint;
if (scene->isPeriodic) {cp = scene->cell->wrapShearedPt(cp);}
if (epsT) {
Real maxShear = (phys->undamagedCohesion-phys->sigmaN*phys->tanFrictionAngle)/phys->G;
=== modified file 'pkg/dem/Integrator.cpp'
--- pkg/dem/Integrator.cpp 2014-05-20 06:35:16 +0000
+++ pkg/dem/Integrator.cpp 2014-05-23 13:03:50 +0000
@@ -2,7 +2,7 @@
#include<yade/core/Scene.hpp>
#include<yade/pkg/dem/Integrator.hpp>
#include<boost/python.hpp>
-using namespace boost;
+
#ifdef YADE_OPENMP
#include<omp.h>
#endif
@@ -325,25 +325,25 @@
maxVelocitySq=max(maxVelocitySq,maxDisp);
}
-void Integrator::slaves_set(const python::list& slaves2){
+void Integrator::slaves_set(const boost::python::list& slaves2){
std::cout<<"Adding slaves";
- int len=python::len(slaves2);
+ int len=boost::python::len(slaves2);
slaves.clear();
for(int i=0; i<len; i++){
- python::extract<std::vector<shared_ptr<Engine> > > serialGroup(slaves2[i]);
+ boost::python::extract<std::vector<shared_ptr<Engine> > > serialGroup(slaves2[i]);
if (serialGroup.check()){ slaves.push_back(serialGroup()); continue; }
- python::extract<shared_ptr<Engine> > serialAlone(slaves2[i]);
+ boost::python::extract<shared_ptr<Engine> > serialAlone(slaves2[i]);
if (serialAlone.check()){ vector<shared_ptr<Engine> > aloneWrap; aloneWrap.push_back(serialAlone()); slaves.push_back(aloneWrap); continue; }
PyErr_SetString(PyExc_TypeError,"Engines that are given to Integrator should be in two cases (a) in an ordered group, (b) alone engines");
- python::throw_error_already_set();
+ boost::python::throw_error_already_set();
}
}
-python::list Integrator::slaves_get(){
- python::list ret;
+boost::python::list Integrator::slaves_get(){
+ boost::python::list ret;
FOREACH(vector<shared_ptr<Engine > >& grp, slaves){
- if(grp.size()==1) ret.append(python::object(grp[0]));
- else ret.append(python::object(grp));
+ if(grp.size()==1) ret.append(boost::python::object(grp[0]));
+ else ret.append(boost::python::object(grp));
}
return ret;
}
=== modified file 'pkg/dem/SampleCapillaryPressureEngine.cpp'
--- pkg/dem/SampleCapillaryPressureEngine.cpp 2013-05-30 20:17:45 +0000
+++ pkg/dem/SampleCapillaryPressureEngine.cpp 2014-05-23 13:03:50 +0000
@@ -16,7 +16,6 @@
#include<yade/lib/base/Math.hpp>
#include <boost/lexical_cast.hpp>
-using namespace boost;
using namespace std;
YADE_PLUGIN((SampleCapillaryPressureEngine));
@@ -43,7 +42,7 @@
if ((S > (sigma_iso - (sigma_iso*SigmaPrecision))) && (S < (sigma_iso + (sigma_iso*SigmaPrecision)))) {
string fileName = "../data/" + Phase1End + "_" +
- lexical_cast<string>(scene->iter) + ".xml";
+ boost::lexical_cast<string>(scene->iter) + ".xml";
cerr << "saving snapshot: " << fileName << " ...";
Omega::instance().saveSimulation(fileName);
pressureVariationActivated = true;
@@ -74,4 +73,4 @@
UnbalancedForce = ComputeUnbalancedForce(scene);
}
-#endif //DEPREC CODE
\ No newline at end of file
+#endif //DEPREC CODE
=== modified file 'pkg/dem/Shop_01.cpp'
--- pkg/dem/Shop_01.cpp 2013-10-23 09:49:41 +0000
+++ pkg/dem/Shop_01.cpp 2014-05-23 13:03:50 +0000
@@ -247,7 +247,7 @@
/*! Create body - sphere. */
shared_ptr<Body> Shop::sphere(Vector3r center, Real radius, shared_ptr<Material> mat){
shared_ptr<Body> body(new Body);
- body->material=mat ? mat : static_pointer_cast<Material>(defaultGranularMat());
+ body->material=mat ? mat : boost::static_pointer_cast<Material>(defaultGranularMat());
body->state->pos=center;
body->state->mass=4.0/3.0*Mathr::PI*radius*radius*radius*body->material->density;
body->state->inertia=Vector3r(2.0/5.0*body->state->mass*radius*radius,2.0/5.0*body->state->mass*radius*radius,2.0/5.0*body->state->mass*radius*radius);
@@ -259,7 +259,7 @@
/*! Create body - box. */
shared_ptr<Body> Shop::box(Vector3r center, Vector3r extents, shared_ptr<Material> mat){
shared_ptr<Body> body(new Body);
- body->material=mat ? mat : static_pointer_cast<Material>(defaultGranularMat());
+ body->material=mat ? mat : boost::static_pointer_cast<Material>(defaultGranularMat());
body->state->pos=center;
Real mass=8.0*extents[0]*extents[1]*extents[2]*body->material->density;
body->state->mass=mass;
@@ -272,7 +272,7 @@
/*! Create body - tetrahedron. */
shared_ptr<Body> Shop::tetra(Vector3r v_global[4], shared_ptr<Material> mat){
shared_ptr<Body> body(new Body);
- body->material=mat ? mat : static_pointer_cast<Material>(defaultGranularMat());
+ body->material=mat ? mat : boost::static_pointer_cast<Material>(defaultGranularMat());
Vector3r centroid=(v_global[0]+v_global[1]+v_global[2]+v_global[3])*.25;
Vector3r v[4]; for(int i=0; i<4; i++) v[i]=v_global[i]-centroid;
body->state->pos=centroid;
=== modified file 'pkg/dem/SpherePack.cpp'
--- pkg/dem/SpherePack.cpp 2013-09-23 17:39:59 +0000
+++ pkg/dem/SpherePack.cpp 2014-05-23 13:03:50 +0000
@@ -18,7 +18,7 @@
CREATE_LOGGER(SpherePack);
using namespace std;
-using namespace boost;
+
namespace py=boost::python;
@@ -36,7 +36,7 @@
void SpherePack::fromLists(const vector<Vector3r>& centers, const vector<Real>& radii){
pack.clear();
- if(centers.size()!=radii.size()) throw std::invalid_argument(("The same number of centers and radii must be given (is "+lexical_cast<string>(centers.size())+", "+lexical_cast<string>(radii.size())+")").c_str());
+ if(centers.size()!=radii.size()) throw std::invalid_argument(("The same number of centers and radii must be given (is "+boost::lexical_cast<string>(centers.size())+", "+boost::lexical_cast<string>(radii.size())+")").c_str());
size_t l=centers.size();
for(size_t i=0; i<l; i++){
add(centers[i],radii[i]);
@@ -118,7 +118,7 @@
// transform sizes and cummulated fractions values in something convenient for the generation process
if(psdSizes.size()>0){
err=(mode>=0); mode=RDIST_PSD;
- if(psdSizes.size()!=psdCumm.size()) throw invalid_argument(("SpherePack.makeCloud: psdSizes and psdCumm must have same dimensions ("+lexical_cast<string>(psdSizes.size())+"!="+lexical_cast<string>(psdCumm.size())).c_str());
+ if(psdSizes.size()!=psdCumm.size()) throw invalid_argument(("SpherePack.makeCloud: psdSizes and psdCumm must have same dimensions ("+boost::lexical_cast<string>(psdSizes.size())+"!="+boost::lexical_cast<string>(psdCumm.size())).c_str());
if(psdSizes.size()<=1) throw invalid_argument("SpherePack.makeCloud: psdSizes must have at least 2 items");
if((*psdCumm.begin())!=0. && (*psdCumm.rbegin())!=1.) throw invalid_argument("SpherePack.makeCloud: first and last items of psdCumm *must* be exactly 0 and 1.");
psdRadii.reserve(psdSizes.size());
@@ -129,7 +129,7 @@
if (i==0) psdCumm2.push_back(0);
else psdCumm2.push_back(psdCumm2[i-1] + 3.0* (volume?volume:(area*psdSizes[psdSizes.size()-1])) *(1-porosity)/Mathr::PI*(psdCumm[i]-psdCumm[i-1])/(psdSizes[i]-psdSizes[i-1])*(pow(psdSizes[i-1],-2)-pow(psdSizes[i],-2)));
}
- LOG_DEBUG(i<<". "<<psdRadii[i]<<", cdf="<<psdCumm[i]<<", cdf2="<<(distributeMass?lexical_cast<string>(psdCumm2[i]):string("--")));
+ LOG_DEBUG(i<<". "<<psdRadii[i]<<", cdf="<<psdCumm[i]<<", cdf2="<<(distributeMass?boost::lexical_cast<string>(psdCumm2[i]):string("--")));
// check monotonicity
if(i>0 && (psdSizes[i-1]>psdSizes[i] || psdCumm[i-1]>psdCumm[i])) throw invalid_argument("SpherePack:makeCloud: psdSizes and psdCumm must be both non-decreasing.");
}
@@ -540,7 +540,7 @@
}
bool SpherePack::hasClumps() const { FOREACH(const Sph& s, pack){ if(s.clumpId>=0) return true; } return false; }
-python::tuple SpherePack::getClumps() const{
+py::tuple SpherePack::getClumps() const{
std::map<int,py::list> clumps;
py::list standalone; size_t packSize=pack.size();
for(size_t i=0; i<packSize; i++){
@@ -552,6 +552,6 @@
py::list clumpList;
typedef std::pair<int,py::list> intListPair;
FOREACH(const intListPair& c, clumps) clumpList.append(c.second);
- return python::make_tuple(standalone,clumpList);
+ return py::make_tuple(standalone,clumpList);
}
=== modified file 'pkg/dem/SpherePack.hpp'
--- pkg/dem/SpherePack.hpp 2013-05-29 09:48:51 +0000
+++ pkg/dem/SpherePack.hpp 2014-05-23 13:03:50 +0000
@@ -11,13 +11,20 @@
#include<boost/python.hpp>
#include<boost/python/object.hpp>
#include<boost/version.hpp>
-using namespace boost;
#include<boost/foreach.hpp>
#ifndef FOREACH
#define FOREACH BOOST_FOREACH
#endif
+#ifndef __GXX_EXPERIMENTAL_CXX0X__
+# include<boost/shared_ptr.hpp>
+ using boost::shared_ptr;
+#else
+# include<memory>
+ using std::shared_ptr;
+#endif
+
#include<yade/lib/base/Logging.hpp>
#include<yade/lib/base/Math.hpp>
@@ -41,25 +48,25 @@
struct Sph{
Vector3r c; Real r; int clumpId;
Sph(const Vector3r& _c, Real _r, int _clumpId=-1): c(_c), r(_r), clumpId(_clumpId) {};
- python::tuple asTuple() const {
- if(clumpId<0) return python::make_tuple(c,r);
- return python::make_tuple(c,r,clumpId);
+ boost::python::tuple asTuple() const {
+ if(clumpId<0) return boost::python::make_tuple(c,r);
+ return boost::python::make_tuple(c,r,clumpId);
}
- python::tuple asTupleNoClump() const { return python::make_tuple(c,r); }
+ boost::python::tuple asTupleNoClump() const { return boost::python::make_tuple(c,r); }
};
std::vector<Sph> pack;
Vector3r cellSize;
Real appliedPsdScaling;//a scaling factor that can be applied on size distribution
bool isPeriodic;
SpherePack(): cellSize(Vector3r::Zero()), appliedPsdScaling(1.), isPeriodic(0) {};
- SpherePack(const python::list& l):cellSize(Vector3r::Zero()){ fromList(l); }
+ SpherePack(const boost::python::list& l):cellSize(Vector3r::Zero()){ fromList(l); }
// add single sphere
void add(const Vector3r& c, Real r){ pack.push_back(Sph(c,r)); }
// I/O
- void fromList(const python::list& l);
+ void fromList(const boost::python::list& l);
void fromLists(const vector<Vector3r>& centers, const vector<Real>& radii); // used as ctor in python
- python::list toList() const;
+ boost::python::list toList() const;
void fromFile(const string file);
void toFile(const string file) const;
void fromSimulation();
@@ -89,7 +96,7 @@
// spatial characteristics
Vector3r dim() const {Vector3r mn,mx; aabb(mn,mx); return mx-mn;}
- python::tuple aabb_py() const { Vector3r mn,mx; aabb(mn,mx); return python::make_tuple(mn,mx); }
+ boost::python::tuple aabb_py() const { Vector3r mn,mx; aabb(mn,mx); return boost::python::make_tuple(mn,mx); }
void aabb(Vector3r& mn, Vector3r& mx) const {
Real inf=std::numeric_limits<Real>::infinity(); mn=Vector3r(inf,inf,inf); mx=Vector3r(-inf,-inf,-inf);
FOREACH(const Sph& s, pack){
@@ -105,9 +112,9 @@
sphVol*=(4/3.)*Mathr::PI;
return sphVol/(dd[0]*dd[1]*dd[2]);
}
- python::tuple psd(int bins=10, bool mass=false) const;
+ boost::python::tuple psd(int bins=10, bool mass=false) const;
bool hasClumps() const;
- python::tuple getClumps() const;
+ boost::python::tuple getClumps() const;
// transformations
void translate(const Vector3r& shift){ FOREACH(Sph& s, pack) s.c+=shift; }
@@ -133,13 +140,13 @@
// iteration
size_t len() const{ return pack.size(); }
- python::tuple getitem(size_t idx){ if(idx>=pack.size()) throw runtime_error("Index "+lexical_cast<string>(idx)+" out of range 0.."+lexical_cast<string>(pack.size()-1)); return pack[idx].asTuple(); }
+ boost::python::tuple getitem(size_t idx){ if(idx>=pack.size()) throw runtime_error("Index "+boost::lexical_cast<string>(idx)+" out of range 0.."+boost::lexical_cast<string>(pack.size()-1)); return pack[idx].asTuple(); }
struct _iterator{
const SpherePack& sPack; size_t pos;
_iterator(const SpherePack& _sPack): sPack(_sPack), pos(0){}
_iterator iter(){ return *this;}
- python::tuple next(){
- if(pos==sPack.pack.size()){ PyErr_SetNone(PyExc_StopIteration); python::throw_error_already_set(); }
+ boost::python::tuple next(){
+ if(pos==sPack.pack.size()){ PyErr_SetNone(PyExc_StopIteration); boost::python::throw_error_already_set(); }
return sPack.pack[pos++].asTupleNoClump();
}
};
=== modified file 'pkg/dem/TriaxialTest.cpp'
--- pkg/dem/TriaxialTest.cpp 2013-03-06 20:39:22 +0000
+++ pkg/dem/TriaxialTest.cpp 2014-05-23 13:03:50 +0000
@@ -56,7 +56,6 @@
CREATE_LOGGER(TriaxialTest);
YADE_PLUGIN((TriaxialTest));
-using namespace boost;
using namespace std;
TriaxialTest::~TriaxialTest () {}
=== modified file 'py/pack/_packObb.cpp'
--- py/pack/_packObb.cpp 2013-03-07 18:28:01 +0000
+++ py/pack/_packObb.cpp 2014-05-23 13:03:50 +0000
@@ -12,7 +12,7 @@
#include<vector>
#include<stdexcept>
-using namespace boost;
+
#ifndef FOREACH
#define FOREACH BOOST_FOREACH
#endif
@@ -63,19 +63,19 @@
}
}
-python::tuple bestFitOBB_py(const python::tuple& _pts){
- int l=python::len(_pts);
+boost::python::tuple bestFitOBB_py(const boost::python::tuple& _pts){
+ int l=boost::python::len(_pts);
if(l<=1) throw std::runtime_error("Cloud must have at least 2 points.");
std::vector<Vector3r> pts; pts.resize(l);
- for(int i=0; i<l; i++) pts[i]=python::extract<Vector3r>(_pts[i]);
+ for(int i=0; i<l; i++) pts[i]=boost::python::extract<Vector3r>(_pts[i]);
Quaternionr rot; Vector3r halfSize, center;
bestFitOBB(pts,center,halfSize,rot);
- return python::make_tuple(center,halfSize,rot);
+ return boost::python::make_tuple(center,halfSize,rot);
}
BOOST_PYTHON_MODULE(_packObb){
YADE_SET_DOCSTRING_OPTS;
- python::scope().attr("__doc__")="Computation of oriented bounding box for cloud of points.";
- python::def("cloudBestFitOBB",bestFitOBB_py,"Return (Vector3 center, Vector3 halfSize, Quaternion orientation) of\nbest-fit oriented bounding-box for given tuple of points\n(uses brute-force velome minimization, do not use for very large clouds).");
+ boost::python::scope().attr("__doc__")="Computation of oriented bounding box for cloud of points.";
+ boost::python::def("cloudBestFitOBB",bestFitOBB_py,"Return (Vector3 center, Vector3 halfSize, Quaternion orientation) of\nbest-fit oriented bounding-box for given tuple of points\n(uses brute-force velome minimization, do not use for very large clouds).");
};
=== modified file 'py/pack/_packSpheres.cpp'
--- py/pack/_packSpheres.cpp 2013-08-14 08:01:55 +0000
+++ py/pack/_packSpheres.cpp 2014-05-23 13:03:50 +0000
@@ -5,26 +5,27 @@
#include<yade/lib/base/Math.hpp>
BOOST_PYTHON_MODULE(_packSpheres){
- python::scope().attr("__doc__")="Creation, manipulation, IO for generic sphere packings.";
+ boost::python::scope().attr("__doc__")="Creation, manipulation, IO for generic sphere packings.";
YADE_SET_DOCSTRING_OPTS;
- python::class_<SpherePack>("SpherePack","Set of spheres represented as centers and radii. This class is returned by :yref:`yade.pack.randomDensePack`, :yref:`yade.pack.randomPeriPack` and others. The object supports iteration over spheres, as in \n\n\t>>> sp=SpherePack()\n\t>>> for center,radius in sp: print center,radius\n\n\t>>> for sphere in sp: print sphere[0],sphere[1] ## same, but without unpacking the tuple automatically\n\n\t>>> for i in range(0,len(sp)): print sp[i][0], sp[i][1] ## same, but accessing spheres by index\n\n\n.. admonition:: Special constructors\n\n\tConstruct from list of ``[(c1,r1),(c2,r2),…]``. To convert two same-length lists of ``centers`` and ``radii``, construct with ``zip(centers,radii)``.\n",python::init<python::optional<python::list> >(python::args("list"),"Empty constructor, optionally taking list [ ((cx,cy,cz),r), … ] for initial data." ))
+ boost::python::class_<SpherePack>("SpherePack","Set of spheres represented as centers and radii. This class is returned by :yref:`yade.pack.randomDensePack`, :yref:`yade.pack.randomPeriPack` and others. The object supports iteration over spheres, as in \n\n\t>>> sp=SpherePack()\n\t>>> for center,radius in sp: print center,radius\n\n\t>>> for sphere in sp: print sphere[0],sphere[1] ## same, but without unpacking the tuple automatically\n\n\t>>> for i in range(0,len(sp)): print sp[i][0], sp[i][1] ## same, but accessing spheres by index\n\n\n.. admonition:: Special constructors\n\n\tConstruct from list of ``[(c1,r1),(c2,r2),…]``. To convert two same-length lists of ``centers`` and ``radii``, construct with ``zip(centers,radii)``.\n",boost::python::init<boost::python::optional<boost::python::list> >(boost::python::args("list"),"Empty constructor, optionally taking list [ ((cx,cy,cz),r), … ] for initial data." ))
.def("add",&SpherePack::add,"Add single sphere to packing, given center as 3-tuple and radius")
.def("toList",&SpherePack::toList,"Return packing data as python list.")
.def("fromList",&SpherePack::fromList,"Make packing from given list, same format as for constructor. Discards current data.")
- .def("fromList",&SpherePack::fromLists,(python::arg("centers"),python::arg("radii")),"Make packing from given list, same format as for constructor. Discards current data.")
- .def("load",&SpherePack::fromFile,(python::arg("fileName")),"Load packing from external text file (current data will be discarded).")
- .def("save",&SpherePack::toFile,(python::arg("fileName")),"Save packing to external text file (will be overwritten).")
+ .def("fromList",&SpherePack::fromLists,(boost::python::arg("centers"),boost::python::arg("radii")),"Make packing from given list, same format as for constructor. Discards current data.")
+ .def("load",&SpherePack::fromFile,(boost::python::arg("fileName")),"Load packing from external text file (current data will be discarded).")
+ .def("save",&SpherePack::toFile,(boost::python::arg("fileName")),"Save packing to external text file (will be overwritten).")
.def("fromSimulation",&SpherePack::fromSimulation,"Make packing corresponding to the current simulation. Discards current data.")
- .def("makeCloud",&SpherePack::makeCloud,(python::arg("minCorner")=Vector3r(Vector3r::Zero()),python::arg("maxCorner")=Vector3r(Vector3r::Zero()),python::arg("rMean")=-1,python::arg("rRelFuzz")=0,python::arg("num")=-1,python::arg("periodic")=false,python::arg("porosity")=0.65,python::arg("psdSizes")=vector<Real>(),python::arg("psdCumm")=vector<Real>(),python::arg("distributeMass")=false,python::arg("seed")=0,python::arg("hSize")=Matrix3r(Matrix3r::Zero())),"Create random loose packing enclosed in a parallelepiped (also works in 2D if minCorner[k]=maxCorner[k] for one coordinate)."
+ .def("makeCloud",&SpherePack::makeCloud,(boost::python::arg("minCorner")=Vector3r(Vector3r::Zero()),boost::python::arg("maxCorner")=Vector3r(Vector3r::Zero()),boost::python::arg("rMean")=-1,boost::python::arg("rRelFuzz")=0,boost::python::arg("num")=-1,boost::python::arg("periodic")=false,boost::python::arg("porosity")=0.65,boost::python::arg("psdSizes")=vector<Real>(),boost::python::arg("psdCumm")=vector<Real>(),boost::python::arg("distributeMass")=false,boost::python::arg("seed")=0,boost::python::arg("hSize")=Matrix3r(Matrix3r::Zero())),"Create random loose packing enclosed in a parallelepiped (also works in 2D if minCorner[k]=maxCorner[k] for one coordinate)."
"\nSphere radius distribution can be specified using one of the following ways:\n\n#. *rMean*, *rRelFuzz* and *num* gives uniform radius distribution in *rMean×(1 ± rRelFuzz)*. Less than *num* spheres can be generated if it is too high.\n#. *rRelFuzz*, *num* and (optional) *porosity*, which estimates mean radius so that *porosity* is attained at the end. *rMean* must be less than 0 (default). *porosity* is only an initial guess for the generation algorithm, which will retry with higher porosity until the prescibed *num* is obtained.\n#. *psdSizes* and *psdCumm*, two arrays specifying points of the `particle size distribution <http://en.wikipedia.org/wiki/Particle_size_distribution>`__ function. As many spheres as possible are generated.\n#. *psdSizes*, *psdCumm*, *num*, and (optional) *porosity*, like above but if *num* is not obtained, *psdSizes* will be scaled down uniformly, until *num* is obtained (see :yref:`appliedPsdScaling<yade._packSpheres.SpherePack.appliedPsdScaling>`).\n\nBy default (with ``distributeMass==False``), the distribution is applied to particle radii. The usual sense of \"particle size distribution\" is the distribution of *mass fraction* (rather than particle count); this can be achieved with ``distributeMass=True``."
"\n\nIf *num* is defined, then sizes generation is deterministic, giving the best fit of target distribution. It enables spheres placement in descending size order, thus giving lower porosity than the random generation."
"\n\n:param Vector3 minCorner: lower corner of an axis-aligned box\n:param Vector3 maxCorner: upper corner of an axis-aligned box\n:param Matrix3 hSize: base vectors of a generalized box (arbitrary parallelepiped, typically :yref:`Cell::hSize`), superseeds minCorner and maxCorner if defined. For periodic boundaries only.\n:param float rMean: mean radius or spheres\n:param float rRelFuzz: dispersion of radius relative to rMean\n:param int num: number of spheres to be generated. If negavite (default), generate as many as possible with stochastic sizes, ending after a fixed number of tries to place the sphere in space, else generate exactly *num* spheres with deterministic size distribution.\n:param bool periodic: whether the packing to be generated should be periodic\n:param float porosity: initial guess for the iterative generation procedure (if *num*>1). The algorithm will be retrying until the number of generated spheres is *num*. The first iteration tries with the provided porosity, but next iterations increase it if necessary (hence an initialy high porosity can speed-up the algorithm). If *psdSizes* is not defined, *rRelFuzz* ($z$) and *num* ($N$) are used so that the porosity given ($\\rho$) is approximately achieved at the end of generation, $r_m=\\sqrt[3]{\\frac{V(1-\\rho)}{\\frac{4}{3}\\pi(1+z^2)N}}$. The default is $\\rho$=0.5. The optimal value depends on *rRelFuzz* or *psdSizes*.\n:param psdSizes: sieve sizes (particle diameters) when particle size distribution (PSD) is specified\n:param psdCumm: cummulative fractions of particle sizes given by *psdSizes*; must be the same length as *psdSizes* and should be non-decreasing\n:param bool distributeMass: if ``True``, given distribution will be used to distribute sphere's mass rather than radius of them.\n:param seed: number used to initialize the random number generator.\n:returns: number of created spheres, which can be lower than *num* depending on the method used.\n")
- .def("psd",&SpherePack::psd,(python::arg("bins")=50,python::arg("mass")=true),"Return `particle size distribution <http://en.wikipedia.org/wiki/Particle_size_distribution>`__ of the packing.\n:param int bins: number of bins between minimum and maximum diameter\n:param mass: Compute relative mass rather than relative particle count for each bin. Corresponds to :yref:`distributeMass parameter for makeCloud<yade.pack.SpherePack.makeCloud>`.\n:returns: tuple of ``(cumm,edges)``, where ``cumm`` are cummulative fractions for respective diameters and ``edges`` are those diameter values. Dimension of both arrays is equal to ``bins+1``.")
+ .def("psd",&SpherePack::psd,(boost::python::arg("bins")=50,boost::python::arg("mass")=true),"Return `particle size distribution <http://en.wikipedia.org/wiki/Particle_size_distribution>`__ of the packing.\n:param int bins: number of bins between minimum and maximum diameter\n:param mass: Compute relative mass rather than relative particle count for each bin. Corresponds to :yref:`distributeMass parameter for makeCloud<yade.pack.SpherePack.makeCloud>`.\n:returns: tuple of ``(cumm,edges)``, where ``cumm`` are cummulative fractions for respective diameters and ``edges`` are those diameter values. Dimension of both arrays is equal to ``bins+1``.")
// new psd
- .def("particleSD",&SpherePack::particleSD,(python::arg("minCorner"),python::arg("maxCorner"),python::arg("rMean"),python::arg("periodic")=false,python::arg("name"),python::arg("numSph"),python::arg("radii")=vector<Real>(),python::arg("passing")=vector<Real>(),python::arg("passingIsNotPercentageButCount")=false,python::arg("seed")=0),"Create random packing enclosed in box given by minCorner and maxCorner, containing numSph spheres. Returns number of created spheres, which can be < num if the packing is too tight. The computation is done according to the given psd.")
- .def("particleSD2",&SpherePack::particleSD2,(python::arg("radii"),python::arg("passing"),python::arg("numSph"),python::arg("periodic")=false,python::arg("cloudPorosity")=.8,python::arg("seed")=0),"Create random packing following the given particle size distribution (radii and volume/mass passing for each fraction) and total number of particles *numSph*. The cloud size (periodic or aperiodic) is computed from the PSD and is always cubic.")
- .def("particleSD_2d",&SpherePack::particleSD_2d,(python::arg("minCorner"),python::arg("maxCorner"),python::arg("rMean"),python::arg("periodic")=false,python::arg("name"),python::arg("numSph"),python::arg("radii")=vector<Real>(),python::arg("passing")=vector<Real>(),python::arg("passingIsNotPercentageButCount")=false,python::arg("seed")=0),"Create random packing on XY plane, defined by minCorner and maxCorner, containing numSph spheres. Returns number of created spheres, which can be < num if the packing is too tight. The computation is done according to the given psd.")
- .def("makeClumpCloud",&SpherePack::makeClumpCloud,(python::arg("minCorner"),python::arg("maxCorner"),python::arg("clumps"),python::arg("periodic")=false,python::arg("num")=-1,python::arg("seed")=0),"Create random loose packing of clumps within box given by *minCorner* and *maxCorner*. Clumps are selected with equal probability. At most *num* clumps will be positioned if *num* is positive; otherwise, as many clumps as possible will be put in space, until maximum number of attempts to place a new clump randomly is attained.\n:param seed: number used to initialize the random number generator.")
+ .def("particleSD",&SpherePack::particleSD,(boost::python::arg("minCorner"),boost::python::arg("maxCorner"),boost::python::arg("rMean"),boost::python::arg("periodic")=false,boost::python::arg("name"),boost::python::arg("numSph"),boost::python::arg("radii")=vector<Real>(),boost::python::arg("passing")=vector<Real>(),boost::python::arg("passingIsNotPercentageButCount")=false, boost::python::arg("seed")=0),"Create random packing enclosed in box given by minCorner and maxCorner, containing numSph spheres. Returns number of created spheres, which can be < num if the packing is too tight. The computation is done according to the given psd.")
+ .def("particleSD2",&SpherePack::particleSD2,(boost::python::arg("radii"),boost::python::arg("passing"),boost::python::arg("numSph"),boost::python::arg("periodic")=false,boost::python::arg("cloudPorosity")=.8,boost::python::arg("seed")=0),"Create random packing following the given particle size distribution (radii and volume/mass passing for each fraction) and total number of particles *numSph*. The cloud size (periodic or aperiodic) is computed from the PSD and is always cubic.")
+ .def("particleSD_2d",&SpherePack::particleSD_2d,(boost::python::arg("minCorner"),boost::python::arg("maxCorner"),boost::python::arg("rMean"),boost::python::arg("periodic")=false,boost::python::arg("name"),boost::python::arg("numSph"),boost::python::arg("radii")=vector<Real>(),boost::python::arg("passing")=vector<Real>(),boost::python::arg("passingIsNotPercentageButCount")=false,boost::python::arg("seed")=0),"Create random packing on XY plane, defined by minCorner and maxCorner, containing numSph spheres. Returns number of created spheres, which can be < num if the packing is too tight. The computation is done according to the given psd.")
+
+ .def("makeClumpCloud",&SpherePack::makeClumpCloud,(boost::python::arg("minCorner"),boost::python::arg("maxCorner"),boost::python::arg("clumps"),boost::python::arg("periodic")=false,boost::python::arg("num")=-1,boost::python::arg("seed")=0),"Create random loose packing of clumps within box given by *minCorner* and *maxCorner*. Clumps are selected with equal probability. At most *num* clumps will be positioned if *num* is positive; otherwise, as many clumps as possible will be put in space, until maximum number of attempts to place a new clump randomly is attained.\n:param seed: number used to initialize the random number generator.")
//
.def("aabb",&SpherePack::aabb_py,"Get axis-aligned bounding box coordinates, as 2 3-tuples.")
.def("dim",&SpherePack::dim,"Return dimensions of the packing in terms of aabb(), as a 3-tuple.")
@@ -35,7 +36,7 @@
.def("cellRepeat",&SpherePack::cellRepeat,"Repeat the packing given number of times in each dimension. Periodicity is retained, cellSize changes. Raises exception for non-periodic packing.")
.def("relDensity",&SpherePack::relDensity,"Relative packing density, measured as sum of spheres' volumes / aabb volume.\n(Sphere overlaps are ignored.)")
.def("translate",&SpherePack::translate,"Translate all spheres by given vector.")
- .def("rotate",&SpherePack::rotate,(python::arg("axis"),python::arg("angle")),"Rotate all spheres around packing center (in terms of aabb()), given axis and angle of the rotation.")
+ .def("rotate",&SpherePack::rotate,(boost::python::arg("axis"),boost::python::arg("angle")),"Rotate all spheres around packing center (in terms of aabb()), given axis and angle of the rotation.")
.def("scale",&SpherePack::scale,"Scale the packing around its center (in terms of aabb()) by given factor (may be negative).")
.def("hasClumps",&SpherePack::hasClumps,"Whether this object contains clumps.")
.def("getClumps",&SpherePack::getClumps,"Return lists of sphere ids sorted by clumps they belong to. The return value is (standalones,[clump1,clump2,…]), where each item is list of id's of spheres.")
@@ -44,7 +45,7 @@
.def("__iter__",&SpherePack::getIterator,"Return iterator over spheres.")
.def_readonly("appliedPsdScaling",&SpherePack::appliedPsdScaling,"A factor between 0 and 1, uniformly applied on all sizes of of the PSD.")
;
- python::class_<SpherePack::_iterator>("SpherePackIterator",python::init<SpherePack::_iterator&>())
+ boost::python::class_<SpherePack::_iterator>("SpherePackIterator",boost::python::init<SpherePack::_iterator&>())
.def("__iter__",&SpherePack::_iterator::iter)
.def("next",&SpherePack::_iterator::next)
;
=== modified file 'py/wrapper/customConverters.cpp'
--- py/wrapper/customConverters.cpp 2012-01-31 18:21:29 +0000
+++ py/wrapper/customConverters.cpp 2014-05-23 13:03:50 +0000
@@ -43,12 +43,8 @@
#endif
#include<yade/pkg/common/MatchMaker.hpp>
-
-
-
using namespace boost::python;
-
// move this to the miniEigen wrapper later
/* two-way se3 handling */
@@ -154,44 +150,8 @@
}
};
-#if 0
-template<typename numT, int dim>
-struct custom_numpyBoost_to_py{
- static PyObject* convert(numpy_boost<numT, dim> nb){
- return nb.py_ptr(); // handles incref internally
- }
-};
-#endif
-
-#if 0
-template<typename T>
-std::string vectorRepr(const vector<T>& v){ std::string ret("["); for(size_t i=0; i<v.size(); i++) { if(i>0) ret+=","; ret+=lexical_cast<string>(v[i]); } return ret+"]"; }
-template<>
-std::string vectorRepr(const vector<std::string>& v){ std::string ret("["); for(size_t i=0; i<v.size(); i++) { if(i>0) ret+=","; ret+="'"+lexical_cast<string>(v[i])+"'"; } return ret+"]"; }
-
-// is not picked up?
-bool operator<(const Vector3r& a, const Vector3r& b){ return a[0]<b[0]; }
-#endif
-
-
-using namespace boost::python;
-
BOOST_PYTHON_MODULE(_customConverters){
- // syntax ??
- // http://language-binding.net/pyplusplus/documentation/indexing_suite_v2.html.html#container_proxy
- // http://www.mail-archive.com/cplusplus-sig@xxxxxxxxxx/msg00862.html
- //class_<indexing::container_proxy<std::vector<string> >,bases<class_<std::vector<string> > > >("vecStr").def(indexing::container_suite<indexing::container_proxy<std::vector<string> > >());
- //class_<std::vector<string> >("vecStr").def(indexing::container_suite<std::vector<string> >());
-
- #if 0
- custom_vector_from_seq<string>(); class_<std::vector<string> >("vector_" "string").def(indexing::container_suite<std::vector<string> >()).def("__repr__",&vectorRepr<string>);
- custom_vector_from_seq<int>(); class_<std::vector<int> >("vector_" "int").def(indexing::container_suite<std::vector<int> >()).def("__repr__",&vectorRepr<int>);
- custom_vector_from_seq<Real>(); class_<std::vector<Real> >("vector_" "Real").def(indexing::container_suite<std::vector<Real> >()).def("__repr__",&vectorRepr<Real>);
- // this needs operator< for Vector3r (defined above, but not picked up for some reason)
- custom_vector_from_seq<Vector3r>(); class_<std::vector<Vector3r> >("vector_" "Vector3r").def(indexing::container_suite<std::vector<Vector3r> >()).def("__repr__",&vectorRepr<Vector3r>);
- #endif
-
custom_Se3r_from_seq(); to_python_converter<Se3r,custom_se3_to_tuple>();
custom_OpenMPAccumulator_from_float(); to_python_converter<OpenMPAccumulator<Real>, custom_OpenMPAccumulator_to_float>();
=== modified file 'py/wrapper/yadeWrapper.cpp'
--- py/wrapper/yadeWrapper.cpp 2014-05-16 17:03:55 +0000
+++ py/wrapper/yadeWrapper.cpp 2014-05-23 13:03:50 +0000
@@ -63,7 +63,6 @@
#include<locale>
#include<boost/archive/codecvt_null.hpp>
-using namespace boost;
using namespace std;
namespace py = boost::python;
@@ -84,7 +83,7 @@
shared_ptr<Body> pyNext(){
BodyContainer::iterator ret;
while(I!=Iend){ ret=I; ++I; if(*ret) return *ret; }
- PyErr_SetNone(PyExc_StopIteration); python::throw_error_already_set(); /* never reached, but makes the compiler happier */ throw;
+ PyErr_SetNone(PyExc_StopIteration); py::throw_error_already_set(); /* never reached, but makes the compiler happier */ throw;
}
};
@@ -93,7 +92,7 @@
void checkClump(shared_ptr<Body> b){
if (!(b->isClump())){
PyErr_SetString(PyExc_TypeError,("Error: Body"+lexical_cast<string>(b->getId())+" is not a clump.").c_str());
- python::throw_error_already_set();
+ py::throw_error_already_set();
}
}
typedef std::map<Body::id_t,Se3r> MemberMap;
@@ -103,12 +102,12 @@
pyBodyContainer(const shared_ptr<BodyContainer>& _proxee): proxee(_proxee){}
shared_ptr<Body> pyGetitem(Body::id_t _id){
int id=(_id>=0 ? _id : proxee->size()+_id);
- if(id<0 || (size_t)id>=proxee->size()){ PyErr_SetString(PyExc_IndexError, "Body id out of range."); python::throw_error_already_set(); /* make compiler happy; never reached */ return shared_ptr<Body>(); }
+ if(id<0 || (size_t)id>=proxee->size()){ PyErr_SetString(PyExc_IndexError, "Body id out of range."); py::throw_error_already_set(); /* make compiler happy; never reached */ return shared_ptr<Body>(); }
else return (*proxee)[id];
}
Body::id_t append(shared_ptr<Body> b){
// shoud be >=0, but Body is by default created with id 0... :-|
- if(b->getId()>=0){ PyErr_SetString(PyExc_IndexError,("Body already has id "+lexical_cast<string>(b->getId())+" set; appending such body (for the second time) is not allowed.").c_str()); python::throw_error_already_set(); }
+ if(b->getId()>=0){ PyErr_SetString(PyExc_IndexError,("Body already has id "+lexical_cast<string>(b->getId())+" set; appending such body (for the second time) is not allowed.").c_str()); py::throw_error_already_set(); }
return proxee->insert(b);
}
vector<Body::id_t> appendList(vector<shared_ptr<Body> > bb){
@@ -152,16 +151,16 @@
Clump::updateProperties(clumpBody, discretization);
return clumpBody->getId();
}
- python::tuple appendClump(vector<shared_ptr<Body> > bb, unsigned int discretization){
+ py::tuple appendClump(vector<shared_ptr<Body> > bb, unsigned int discretization){
// append constituent particles
vector<Body::id_t> ids(appendList(bb));
// clump them together (the clump fcn) and return
- return python::make_tuple(clump(ids, discretization),ids);
+ return py::make_tuple(clump(ids, discretization),ids);
}
- void updateClumpProperties(python::list excludeList,unsigned int discretization){
+ void updateClumpProperties(py::list excludeList,unsigned int discretization){
//convert excludeList to a c++ list
vector<Body::id_t> excludeListC;
- for (int ii = 0; ii < python::len(excludeList); ii++) excludeListC.push_back(python::extract<Body::id_t>(excludeList[ii])());
+ for (int ii = 0; ii < py::len(excludeList); ii++) excludeListC.push_back(py::extract<Body::id_t>(excludeList[ii])());
FOREACH(const shared_ptr<Body>& b, *proxee){
if ( !(std::find(excludeListC.begin(), excludeListC.end(), b->getId()) != excludeListC.end()) ) {
if (b->isClump()) Clump::updateProperties(b, discretization);
@@ -208,23 +207,23 @@
} else { PyErr_Warn(PyExc_UserWarning,("Warning: Body "+lexical_cast<string>(bid)+" must be a clump member of clump "+lexical_cast<string>(cid)+". Body was not released.").c_str()); return;}
} else { PyErr_Warn(PyExc_UserWarning,("Warning: Body "+lexical_cast<string>(bid)+" is not a clump member. Body was not released.").c_str()); return;}
}
- python::list replaceByClumps(python::list ctList, vector<Real> amounts, unsigned int discretization){
- python::list ret;
+ py::list replaceByClumps(py::list ctList, vector<Real> amounts, unsigned int discretization){
+ py::list ret;
Real checkSum = 0.0;
FOREACH(Real amount, amounts) {
if (amount < 0.0) {
PyErr_SetString(PyExc_ValueError,("Error: One or more of given amounts are negative!"));
- python::throw_error_already_set();
+ py::throw_error_already_set();
}
else checkSum += amount;
}
if (checkSum > 1.0){
PyErr_SetString(PyExc_ValueError,("Error: Sum of amounts "+lexical_cast<string>(checkSum)+" should not be bigger than 1.0!").c_str());
- python::throw_error_already_set();
+ py::throw_error_already_set();
}
- if (python::len(ctList) != (unsigned) amounts.size()) {//avoid unsigned comparison warning
- PyErr_SetString(PyExc_ValueError,("Error: Length of amounts list ("+lexical_cast<string>(amounts.size())+") differs from length of template list ("+lexical_cast<string>(python::len(ctList))+").").c_str());
- python::throw_error_already_set();
+ if (py::len(ctList) != (unsigned) amounts.size()) {//avoid unsigned comparison warning
+ PyErr_SetString(PyExc_ValueError,("Error: Length of amounts list ("+lexical_cast<string>(amounts.size())+") differs from length of template list ("+lexical_cast<string>(py::len(ctList))+").").c_str());
+ py::throw_error_already_set();
}
//set a random generator (code copied from pkg/dem/SpherePack.cpp):
static boost::minstd_rand randGen((int)TimingInfo::getNow(/* get the number even if timing is disabled globally */ true));
@@ -247,10 +246,10 @@
//relPosList: [relPos1,relPos2, ...] (list of vectors)
//extract attributes from python objects:
- python::object ctTmp = ctList[ii];
- int numCM = python::extract<int>(ctTmp.attr("numCM"))();// number of clump members
- python::list relRadListTmp = python::extract<python::list>(ctTmp.attr("relRadii"))();
- python::list relPosListTmp = python::extract<python::list>(ctTmp.attr("relPositions"))();
+ py::object ctTmp = ctList[ii];
+ int numCM = py::extract<int>(ctTmp.attr("numCM"))();// number of clump members
+ py::list relRadListTmp = py::extract<py::list>(ctTmp.attr("relRadii"))();
+ py::list relPosListTmp = py::extract<py::list>(ctTmp.attr("relPositions"))();
//get relative radii and positions; calculate volumes; get balance point: get axis aligned bounding box; get minimum radius;
vector<Real> relRadTmp(numCM), relVolTmp(numCM);
@@ -258,9 +257,9 @@
Vector3r relPosTmpMean = Vector3r::Zero();
Real rMin=1./0.; AlignedBox3r aabb;
for (int jj = 0; jj < numCM; jj++) {
- relRadTmp[jj] = python::extract<Real>(relRadListTmp[jj])();
+ relRadTmp[jj] = py::extract<Real>(relRadListTmp[jj])();
relVolTmp[jj] = (4./3.)*Mathr::PI*pow(relRadTmp[jj],3.);
- relPosTmp[jj] = python::extract<Vector3r>(relPosListTmp[jj])();
+ relPosTmp[jj] = py::extract<Vector3r>(relPosListTmp[jj])();
relPosTmpMean += relPosTmp[jj];
aabb.extend(relPosTmp[jj] + Vector3r::Constant(relRadTmp[jj]));
aabb.extend(relPosTmp[jj] - Vector3r::Constant(relRadTmp[jj]));
@@ -384,19 +383,19 @@
omp_unset_lock(&locker);//end of critical section
#endif
Body::id_t newClumpId = clump(idsTmp, discretization);
- ret.append(python::make_tuple(newClumpId,idsTmp));
+ ret.append(py::make_tuple(newClumpId,idsTmp));
erase(b->id,false);
}
}
return ret;
}
- Real getRoundness(python::list excludeList){
+ Real getRoundness(py::list excludeList){
Scene* scene(Omega::instance().getScene().get()); // get scene
shared_ptr<Sphere> sph (new Sphere);
int Sph_Index = sph->getClassIndexStatic(); // get sphere index for checking if bodies are spheres
//convert excludeList to a c++ list
vector<Body::id_t> excludeListC;
- for (int ii = 0; ii < python::len(excludeList); ii++) excludeListC.push_back(python::extract<Body::id_t>(excludeList[ii])());
+ for (int ii = 0; ii < py::len(excludeList); ii++) excludeListC.push_back(py::extract<Body::id_t>(excludeList[ii])());
Real RC_sum = 0.0; //sum of local roundnesses
Real R1, R2, vol, dens;
int c = 0; //counter
@@ -444,18 +443,18 @@
if(algorithm::starts_with(val,key+"=")){ string val1(val); algorithm::erase_head(val1,key.size()+1); return val1;}
}
PyErr_SetString(PyExc_KeyError,("Invalid key: "+key+".").c_str());
- python::throw_error_already_set(); /* make compiler happy; never reached */ return string();
+ py::throw_error_already_set(); /* make compiler happy; never reached */ return string();
}
void setItem(const string& key,const string& item){
if(key.find("=")!=string::npos) {
PyErr_SetString(PyExc_KeyError, "Key must not contain the '=' character (implementation limitation; sorry).");
- python::throw_error_already_set();
+ py::throw_error_already_set();
}
FOREACH(string& val, mb->tags){if(algorithm::starts_with(val,key+"=")){ val=key+"="+item; return; } }
mb->tags.push_back(key+"="+item);
}
- python::list keys(){
- python::list ret;
+ py::list keys(){
+ py::list ret;
FOREACH(string val, mb->tags){
size_t i=val.find("=");
if(i==string::npos) throw runtime_error("Tags must be in the key=value format (internal error?)");
@@ -474,7 +473,7 @@
shared_ptr<Interaction> pyNext(){
InteractionContainer::iterator ret;
while(I!=Iend){ ret=I; ++I; if((*ret)->isReal()) return *ret; }
- PyErr_SetNone(PyExc_StopIteration); python::throw_error_already_set();
+ PyErr_SetNone(PyExc_StopIteration); py::throw_error_already_set();
throw; // to avoid compiler warning; never reached
//InteractionContainer::iterator ret=I; ++I; return *ret;
}
@@ -487,11 +486,11 @@
pyInteractionIterator pyIter(){return pyInteractionIterator(proxee);}
shared_ptr<Interaction> pyGetitem(vector<Body::id_t> id12){
//if(!PySequence_Check(id12.ptr())) throw invalid_argument("Key must be a tuple");
- //if(python::len(id12)!=2) throw invalid_argument("Key must be a 2-tuple: id1,id2.");
+ //if(py::len(id12)!=2) throw invalid_argument("Key must be a 2-tuple: id1,id2.");
if(id12.size()==2){
//if(max(id12[0],id12[1])>
shared_ptr<Interaction> i=proxee->find(id12[0],id12[1]);
- if(i) return i; else { PyErr_SetString(PyExc_IndexError,"No such interaction"); python::throw_error_already_set(); /* make compiler happy; never reached */ return shared_ptr<Interaction>(); }
+ if(i) return i; else { PyErr_SetString(PyExc_IndexError,"No such interaction"); py::throw_error_already_set(); /* make compiler happy; never reached */ return shared_ptr<Interaction>(); }
}
else if(id12.size()==1){ return (*proxee)[id12[0]];}
else throw invalid_argument("2 integers (id1,id2) or 1 integer (nth) required.");
@@ -500,12 +499,12 @@
shared_ptr<Interaction> pyNth(long n){
long i=0; FOREACH(shared_ptr<Interaction> I, *proxee){ if(!I->isReal()) continue; if(i++==n) return I; }
PyErr_SetString(PyExc_IndexError,(string("Interaction number out of range (")+lexical_cast<string>(n)+">="+lexical_cast<string>(i)+").").c_str());
- python::throw_error_already_set(); /* make compiler happy; never reached */ return shared_ptr<Interaction>();
+ py::throw_error_already_set(); /* make compiler happy; never reached */ return shared_ptr<Interaction>();
}
long len(){return proxee->size();}
void clear(){proxee->clear();}
- python::list withBody(long id){ python::list ret; FOREACH(const shared_ptr<Interaction>& I, *proxee){ if(I->isReal() && (I->getId1()==id || I->getId2()==id)) ret.append(I);} return ret;}
- python::list withBodyAll(long id){ python::list ret; FOREACH(const shared_ptr<Interaction>& I, *proxee){ if(I->getId1()==id || I->getId2()==id) ret.append(I);} return ret; }
+ py::list withBody(long id){ py::list ret; FOREACH(const shared_ptr<Interaction>& I, *proxee){ if(I->isReal() && (I->getId1()==id || I->getId2()==id)) ret.append(I);} return ret;}
+ py::list withBodyAll(long id){ py::list ret; FOREACH(const shared_ptr<Interaction>& I, *proxee){ if(I->getId1()==id || I->getId2()==id) ret.append(I);} return ret; }
long countReal(){ long ret=0; FOREACH(const shared_ptr<Interaction>& I, *proxee){ if(I->isReal()) ret++; } return ret; }
bool serializeSorted_get(){return proxee->serializeSorted;}
void serializeSorted_set(bool ss){proxee->serializeSorted=ss;}
@@ -517,7 +516,7 @@
shared_ptr<Scene> scene;
public:
pyForceContainer(shared_ptr<Scene> _scene): scene(_scene) { }
- void checkId(long id){ if(id<0 || (size_t)id>=scene->bodies->size()){ PyErr_SetString(PyExc_IndexError, "Body id out of range."); python::throw_error_already_set(); /* never reached */ throw; } }
+ void checkId(long id){ if(id<0 || (size_t)id>=scene->bodies->size()){ PyErr_SetString(PyExc_IndexError, "Body id out of range."); py::throw_error_already_set(); /* never reached */ throw; } }
Vector3r force_get(long id, bool sync){ checkId(id); if (!sync) return scene->forces.getForceSingle(id); scene->forces.sync(); return scene->forces.getForce(id);}
Vector3r torque_get(long id, bool sync){ checkId(id); if (!sync) return scene->forces.getTorqueSingle(id); scene->forces.sync(); return scene->forces.getTorque(id);}
Vector3r move_get(long id){ checkId(id); return scene->forces.getMoveSingle(id); }
@@ -538,11 +537,11 @@
shared_ptr<Scene> scene;
public:
pyMaterialContainer(shared_ptr<Scene> _scene): scene(_scene) { }
- shared_ptr<Material> getitem_id(int _id){ int id=(_id>=0 ? _id : scene->materials.size()+_id); if(id<0 || (size_t)id>=scene->materials.size()){ PyErr_SetString(PyExc_IndexError, "Material id out of range."); python::throw_error_already_set(); /* never reached */ throw; } return Material::byId(id,scene); }
+ shared_ptr<Material> getitem_id(int _id){ int id=(_id>=0 ? _id : scene->materials.size()+_id); if(id<0 || (size_t)id>=scene->materials.size()){ PyErr_SetString(PyExc_IndexError, "Material id out of range."); py::throw_error_already_set(); /* never reached */ throw; } return Material::byId(id,scene); }
shared_ptr<Material> getitem_label(string label){
// translate runtime_error to KeyError (instead of RuntimeError) if the material doesn't exist
try { return Material::byLabel(label,scene); }
- catch (std::runtime_error& e){ PyErr_SetString(PyExc_KeyError,e.what()); python::throw_error_already_set(); /* never reached; avoids warning */ throw; }
+ catch (std::runtime_error& e){ PyErr_SetString(PyExc_KeyError,e.what()); py::throw_error_already_set(); /* never reached; avoids warning */ throw; }
}
int append(shared_ptr<Material> m){ scene->materials.push_back(m); m->id=scene->materials.size()-1; return m->id; }
vector<int> appendList(vector<shared_ptr<Material> > mm){ vector<int> ret; FOREACH(shared_ptr<Material>& m, mm) ret.push_back(append(m)); return ret; }
@@ -598,11 +597,11 @@
#undef _TRY_DISPATCHER
}
}
- python::object labeled_engine_get(string label){
+ py::object labeled_engine_get(string label){
FOREACH(const shared_ptr<Engine>& e, OMEGA.getScene()->engines){
- #define _DO_FUNCTORS(functors,FunctorT){ FOREACH(const shared_ptr<FunctorT>& f, functors){ if(f->label==label) return python::object(f); }}
+ #define _DO_FUNCTORS(functors,FunctorT){ FOREACH(const shared_ptr<FunctorT>& f, functors){ if(f->label==label) return py::object(f); }}
#define _TRY_DISPATCHER(DispatcherT) { DispatcherT* d=dynamic_cast<DispatcherT*>(e.get()); if(d){ _DO_FUNCTORS(d->functors,DispatcherT::FunctorType); } }
- if(e->label==label){ return python::object(e); }
+ if(e->label==label){ return py::object(e); }
_TRY_DISPATCHER(BoundDispatcher); _TRY_DISPATCHER(IGeomDispatcher); _TRY_DISPATCHER(IPhysDispatcher); _TRY_DISPATCHER(LawDispatcher);
InteractionLoop* id=dynamic_cast<InteractionLoop*>(e.get());
if(id){
@@ -666,7 +665,7 @@
LOG_ERROR("Simulation error encountered."); OMEGA.simulationLoop->workerThrew=false; throw OMEGA.simulationLoop->workerException;
}
bool isRunning(){ return OMEGA.isRunning(); }
- python::object get_filename(){ string f=OMEGA.sceneFile; if(f.size()>0) return python::object(f); return python::object();}
+ py::object get_filename(){ string f=OMEGA.sceneFile; if(f.size()>0) return py::object(f); return py::object();}
void load(std::string fileName,bool quiet=false) {
Py_BEGIN_ALLOW_THREADS; OMEGA.stop(); Py_END_ALLOW_THREADS;
OMEGA.loadSimulation(fileName,quiet);
@@ -676,7 +675,7 @@
void reload(bool quiet=false){ load(OMEGA.sceneFile,quiet);}
void saveTmp(string mark="", bool quiet=false){ save(":memory:"+mark,quiet);}
void loadTmp(string mark="", bool quiet=false){ load(":memory:"+mark,quiet);}
- python::list lsTmp(){ python::list ret; typedef pair<std::string,string> strstr; FOREACH(const strstr& sim,OMEGA.memSavedSimulations){ string mark=sim.first; boost::algorithm::replace_first(mark,":memory:",""); ret.append(mark); } return ret; }
+ py::list lsTmp(){ py::list ret; typedef pair<std::string,string> strstr; FOREACH(const strstr& sim,OMEGA.memSavedSimulations){ string mark=sim.first; boost::algorithm::replace_first(mark,":memory:",""); ret.append(mark); } return ret; }
void tmpToFile(string mark, string filename){
if(OMEGA.memSavedSimulations.count(":memory:"+mark)==0) throw runtime_error("No memory-saved simulation named "+mark);
iostreams::filtering_ostream out;
@@ -720,8 +719,8 @@
// OMEGA.sceneFile=fileName; // done in Omega::saveSimulation;
}
- python::list miscParams_get(){
- python::list ret;
+ py::list miscParams_get(){
+ py::list ret;
FOREACH(shared_ptr<Serializable>& s, OMEGA.getScene()->miscParams){
ret.append(s);
}
@@ -755,8 +754,8 @@
pyMaterialContainer materials_get(void){return pyMaterialContainer(OMEGA.getScene());}
- python::list listChildClassesNonrecursive(const string& base){
- python::list ret;
+ py::list listChildClassesNonrecursive(const string& base){
+ py::list ret;
for(map<string,DynlibDescriptor>::const_iterator di=Omega::instance().getDynlibsDescriptor().begin();di!=Omega::instance().getDynlibsDescriptor().end();++di) if (Omega::instance().isInheritingFrom((*di).first,base)) ret.append(di->first);
return ret;
}
@@ -765,9 +764,9 @@
return (Omega::instance().isInheritingFrom_recursive(child,base));
}
- python::list plugins_get(){
+ py::list plugins_get(){
const map<string,DynlibDescriptor>& plugins=Omega::instance().getDynlibsDescriptor();
- std::pair<string,DynlibDescriptor> p; python::list ret;
+ std::pair<string,DynlibDescriptor> p; py::list ret;
FOREACH(p, plugins) ret.append(p.first);
return ret;
}
@@ -825,18 +824,18 @@
BOOST_PYTHON_MODULE(wrapper)
{
- python::scope().attr("__doc__")="Wrapper for c++ internals of yade.";
+ py::scope().attr("__doc__")="Wrapper for c++ internals of yade.";
YADE_SET_DOCSTRING_OPTS;
- python::enum_<yade::Attr::flags>("AttrFlags")
+ py::enum_<yade::Attr::flags>("AttrFlags")
.value("noSave",yade::Attr::noSave)
.value("readonly",yade::Attr::readonly)
.value("triggerPostLoad",yade::Attr::triggerPostLoad)
.value("noResize",yade::Attr::noResize)
;
- python::class_<pyOmega>("Omega")
+ py::class_<pyOmega>("Omega")
.add_property("iter",&pyOmega::iter,"Get current step number")
.add_property("subStep",&pyOmega::subStep,"Get the current subStep number (only meaningful if O.subStepping==True); -1 when outside the loop, otherwise either 0 (O.subStepping==False) or number of engine to be run (O.subStepping==True)")
.add_property("subStepping",&pyOmega::subStepping_get,&pyOmega::subStepping_set,"Get/set whether subStepping is active.")
@@ -854,9 +853,9 @@
.def("loadTmp",&pyOmega::loadTmp,(py::arg("mark")="",py::arg("quiet")=false),"Load simulation previously stored in memory by saveTmp. *mark* optionally distinguishes multiple saved simulations")
.def("saveTmp",&pyOmega::saveTmp,(py::arg("mark")="",py::arg("quiet")=false),"Save simulation to memory (disappears at shutdown), can be loaded later with loadTmp. *mark* optionally distinguishes different memory-saved simulations.")
.def("lsTmp",&pyOmega::lsTmp,"Return list of all memory-saved simulations.")
- .def("tmpToFile",&pyOmega::tmpToFile,(python::arg("fileName"),python::arg("mark")=""),"Save XML of :yref:`saveTmp<Omega.saveTmp>`'d simulation into *fileName*.")
- .def("tmpToString",&pyOmega::tmpToString,(python::arg("mark")=""),"Return XML of :yref:`saveTmp<Omega.saveTmp>`'d simulation as string.")
- .def("run",&pyOmega::run,(python::arg("nSteps")=-1,python::arg("wait")=false),"Run the simulation. *nSteps* how many steps to run, then stop (if positive); *wait* will cause not returning to python until simulation will have stopped.")
+ .def("tmpToFile",&pyOmega::tmpToFile,(py::arg("fileName"),py::arg("mark")=""),"Save XML of :yref:`saveTmp<Omega.saveTmp>`'d simulation into *fileName*.")
+ .def("tmpToString",&pyOmega::tmpToString,(py::arg("mark")=""),"Return XML of :yref:`saveTmp<Omega.saveTmp>`'d simulation as string.")
+ .def("run",&pyOmega::run,(py::arg("nSteps")=-1,py::arg("wait")=false),"Run the simulation. *nSteps* how many steps to run, then stop (if positive); *wait* will cause not returning to python until simulation will have stopped.")
.def("pause",&pyOmega::pause,"Stop simulation execution. (May be called from within the loop, and it will stop after the current step).")
.def("step",&pyOmega::step,"Advance the simulation by one step. Returns after the step will have finished.")
.def("wait",&pyOmega::wait,"Don't return until the simulation will have been paused. (Returns immediately if not running).")
@@ -870,7 +869,7 @@
.def("switchToScene",&pyOmega::switchToScene,"Switch to defined scene. Default scene has number 0, other scenes have to be created by addScene method.")
.def("switchScene",&pyOmega::switchScene,"Switch to alternative simulation (while keeping the old one). Calling the function again switches back to the first one. Note that most variables from the first simulation will still refer to the first simulation even after the switch\n(e.g. b=O.bodies[4]; O.switchScene(); [b still refers to the body in the first simulation here])")
.def("sceneToString",&pyOmega::sceneToString,"Return the entire scene as a string. Equivalent to using O.save(...) except that the scene goes to a string instead of a file. (see also stringToScene())")
- .def("stringToScene",&pyOmega::stringToScene,(python::arg("mark")=""),"Load simulation from a string passed as argument (see also sceneToString).")
+ .def("stringToScene",&pyOmega::stringToScene,(py::arg("mark")=""),"Load simulation from a string passed as argument (see also sceneToString).")
.def("labeledEngine",&pyOmega::labeled_engine_get,"Return instance of engine/functor with the given label. This function shouldn't be called by the user directly; every ehange in O.engines will assign respective global python variables according to labels.\n\nFor example:\n\n\t *O.engines=[InsertionSortCollider(label='collider')]*\n\n\t *collider.nBins=5 # collider has become a variable after assignment to O.engines automatically*")
.def("resetTime",&pyOmega::resetTime,"Reset simulation time: step number, virtual and real time. (Doesn't touch anything else, including timings).")
.def("plugins",&pyOmega::plugins_get,"Return list of all plugins registered in the class factory.")
@@ -893,36 +892,36 @@
.add_property("numThreads",&pyOmega::numThreads_get /* ,&pyOmega::numThreads_set*/ ,"Get maximum number of threads openMP can use.")
.add_property("cell",&pyOmega::cell_get,"Periodic cell of the current scene (None if the scene is aperiodic).")
.add_property("periodic",&pyOmega::periodic_get,&pyOmega::periodic_set,"Get/set whether the scene is periodic or not (True/False).")
- .def("exitNoBacktrace",&pyOmega::exitNoBacktrace,(python::arg("status")=0),"Disable SEGV handler and exit, optionally with given status number.")
+ .def("exitNoBacktrace",&pyOmega::exitNoBacktrace,(py::arg("status")=0),"Disable SEGV handler and exit, optionally with given status number.")
.def("disableGdb",&pyOmega::disableGdb,"Revert SEGV and ABRT handlers to system defaults.")
.def("runEngine",&pyOmega::runEngine,"Run given engine exactly once; simulation time, step number etc. will not be incremented (use only if you know what you do).")
.def("tmpFilename",&pyOmega::tmpFilename,"Return unique name of file in temporary directory which will be deleted when yade exits.")
;
- python::class_<pyTags>("TagsWrapper","Container emulating dictionary semantics for accessing tags associated with simulation. Tags are accesed by strings.",python::init<pyTags&>())
+ py::class_<pyTags>("TagsWrapper","Container emulating dictionary semantics for accessing tags associated with simulation. Tags are accesed by strings.",py::init<pyTags&>())
.def("__getitem__",&pyTags::getItem)
.def("__setitem__",&pyTags::setItem)
.def("keys",&pyTags::keys)
.def("has_key",&pyTags::hasKey);
- python::class_<pyBodyContainer>("BodyContainer",python::init<pyBodyContainer&>())
+ py::class_<pyBodyContainer>("BodyContainer",py::init<pyBodyContainer&>())
.def("__getitem__",&pyBodyContainer::pyGetitem)
.def("__len__",&pyBodyContainer::length)
.def("__iter__",&pyBodyContainer::pyIter)
.def("append",&pyBodyContainer::append,"Append one Body instance, return its id.")
.def("append",&pyBodyContainer::appendList,"Append list of Body instance, return list of ids")
- .def("appendClumped",&pyBodyContainer::appendClump,(python::arg("discretization")=0),"Append given list of bodies as a clump (rigid aggregate); returns a tuple of ``(clumpId,[memberId1,memberId2,...])``. Clump masses and inertia are adapted automatically (for details see :yref:`clump()<BodyContainer.clump>`).")
- .def("clump",&pyBodyContainer::clump,(python::arg("discretization")=0),"Clump given bodies together (creating a rigid aggregate); returns ``clumpId``. Clump masses and inertia are adapted automatically when discretization>0. If clump members are overlapping this is done by integration/summation over mass points using a regular grid of cells (number of grid cells in one direction is defined as $R_{min}/discretization$, where $R_{min}$ is minimum clump member radius). For non-overlapping members inertia of the clump is the sum of inertias from members. If discretization<=0 sum of inertias from members is used (faster, but inaccurate).")
- .def("updateClumpProperties",&pyBodyContainer::updateClumpProperties,(python::arg("excludeList")=python::list(),python::arg("discretization")=5),"Update clump properties mass, volume and inertia (for details of 'discretization' value see :yref:`clump()<BodyContainer.clump>`). Clumps can be excluded from the calculation by giving a list of ids: *O.bodies.updateProperties([ids])*.")
- .def("addToClump",&pyBodyContainer::addToClump,(python::arg("discretization")=0),"Add body b (or a list of bodies) to an existing clump c. c must be clump and b may not be a clump member of c. Clump masses and inertia are adapted automatically (for details see :yref:`clump()<BodyContainer.clump>`).\n\nSee :ysrc:`examples/clumps/addToClump-example.py` for an example script.\n\n.. note:: If b is a clump itself, then all members will be added to c and b will be deleted. If b is a clump member of clump d, then all members from d will be added to c and d will be deleted. If you need to add just clump member b, :yref:`release<BodyContainer.releaseFromClump>` this member from d first.")
- .def("releaseFromClump",&pyBodyContainer::releaseFromClump,(python::arg("discretization")=0),"Release body b from clump c. b must be a clump member of c. Clump masses and inertia are adapted automatically (for details see :yref:`clump()<BodyContainer.clump>`).\n\nSee :ysrc:`examples/clumps/releaseFromClump-example.py` for an example script.\n\n.. note:: If c contains only 2 members b will not be released and a warning will appear. In this case clump c should be :yref:`erased<BodyContainer.erase>`.")
- .def("replaceByClumps",&pyBodyContainer::replaceByClumps,(python::arg("discretization")=0),"Replace spheres by clumps using a list of clump templates and a list of amounts; returns a list of tuples: ``[(clumpId1,[memberId1,memberId2,...]),(clumpId2,[memberId1,memberId2,...]),...]``. A new clump will have the same volume as the sphere, that was replaced. Clump masses and inertia are adapted automatically (for details see :yref:`clump()<BodyContainer.clump>`). \n\n\t *O.bodies.replaceByClumps( [utils.clumpTemplate([1,1],[.5,.5])] , [.9] ) #will replace 90 % of all standalone spheres by 'dyads'*\n\nSee :ysrc:`examples/clumps/replaceByClumps-example.py` for an example script.")
- .def("getRoundness",&pyBodyContainer::getRoundness,(python::arg("excludeList")=python::list()),"Returns roundness coefficient RC = R2/R1. R1 is the theoretical radius of a sphere, with same volume as clump. R2 is the minimum radius of a sphere, that imbeds clump. If just spheres are present RC = 1. If clumps are present 0 < RC < 1. Bodies can be excluded from the calculation by giving a list of ids: *O.bodies.getRoundness([ids])*.\n\nSee :ysrc:`examples/clumps/replaceByClumps-example.py` for an example script.")
+ .def("appendClumped",&pyBodyContainer::appendClump,(py::arg("discretization")=0),"Append given list of bodies as a clump (rigid aggregate); returns a tuple of ``(clumpId,[memberId1,memberId2,...])``. Clump masses and inertia are adapted automatically (for details see :yref:`clump()<BodyContainer.clump>`).")
+ .def("clump",&pyBodyContainer::clump,(py::arg("discretization")=0),"Clump given bodies together (creating a rigid aggregate); returns ``clumpId``. Clump masses and inertia are adapted automatically when discretization>0. If clump members are overlapping this is done by integration/summation over mass points using a regular grid of cells (number of grid cells in one direction is defined as $R_{min}/discretization$, where $R_{min}$ is minimum clump member radius). For non-overlapping members inertia of the clump is the sum of inertias from members. If discretization<=0 sum of inertias from members is used (faster, but inaccurate).")
+ .def("updateClumpProperties",&pyBodyContainer::updateClumpProperties,(py::arg("excludeList")=py::list(),py::arg("discretization")=5),"Update clump properties mass, volume and inertia (for details of 'discretization' value see :yref:`clump()<BodyContainer.clump>`). Clumps can be excluded from the calculation by giving a list of ids: *O.bodies.updateProperties([ids])*.")
+ .def("addToClump",&pyBodyContainer::addToClump,(py::arg("discretization")=0),"Add body b (or a list of bodies) to an existing clump c. c must be clump and b may not be a clump member of c. Clump masses and inertia are adapted automatically (for details see :yref:`clump()<BodyContainer.clump>`).\n\nSee :ysrc:`examples/clumps/addToClump-example.py` for an example script.\n\n.. note:: If b is a clump itself, then all members will be added to c and b will be deleted. If b is a clump member of clump d, then all members from d will be added to c and d will be deleted. If you need to add just clump member b, :yref:`release<BodyContainer.releaseFromClump>` this member from d first.")
+ .def("releaseFromClump",&pyBodyContainer::releaseFromClump,(py::arg("discretization")=0),"Release body b from clump c. b must be a clump member of c. Clump masses and inertia are adapted automatically (for details see :yref:`clump()<BodyContainer.clump>`).\n\nSee :ysrc:`examples/clumps/releaseFromClump-example.py` for an example script.\n\n.. note:: If c contains only 2 members b will not be released and a warning will appear. In this case clump c should be :yref:`erased<BodyContainer.erase>`.")
+ .def("replaceByClumps",&pyBodyContainer::replaceByClumps,(py::arg("discretization")=0),"Replace spheres by clumps using a list of clump templates and a list of amounts; returns a list of tuples: ``[(clumpId1,[memberId1,memberId2,...]),(clumpId2,[memberId1,memberId2,...]),...]``. A new clump will have the same volume as the sphere, that was replaced. Clump masses and inertia are adapted automatically (for details see :yref:`clump()<BodyContainer.clump>`). \n\n\t *O.bodies.replaceByClumps( [utils.clumpTemplate([1,1],[.5,.5])] , [.9] ) #will replace 90 % of all standalone spheres by 'dyads'*\n\nSee :ysrc:`examples/clumps/replaceByClumps-example.py` for an example script.")
+ .def("getRoundness",&pyBodyContainer::getRoundness,(py::arg("excludeList")=py::list()),"Returns roundness coefficient RC = R2/R1. R1 is the theoretical radius of a sphere, with same volume as clump. R2 is the minimum radius of a sphere, that imbeds clump. If just spheres are present RC = 1. If clumps are present 0 < RC < 1. Bodies can be excluded from the calculation by giving a list of ids: *O.bodies.getRoundness([ids])*.\n\nSee :ysrc:`examples/clumps/replaceByClumps-example.py` for an example script.")
.def("clear", &pyBodyContainer::clear,"Remove all bodies (interactions not checked)")
- .def("erase", &pyBodyContainer::erase,(python::arg("eraseClumpMembers")=0),"Erase body with the given id; all interaction will be deleted by InteractionLoop in the next step. If a clump is erased use *O.bodies.erase(clumpId,True)* to erase the clump AND its members.")
+ .def("erase", &pyBodyContainer::erase,(py::arg("eraseClumpMembers")=0),"Erase body with the given id; all interaction will be deleted by InteractionLoop in the next step. If a clump is erased use *O.bodies.erase(clumpId,True)* to erase the clump AND its members.")
.def("replace",&pyBodyContainer::replace);
- python::class_<pyBodyIterator>("BodyIterator",python::init<pyBodyIterator&>())
+ py::class_<pyBodyIterator>("BodyIterator",py::init<pyBodyIterator&>())
.def("__iter__",&pyBodyIterator::pyIter)
.def("next",&pyBodyIterator::pyNext);
- python::class_<pyInteractionContainer>("InteractionContainer","Access to :yref:`interactions<Interaction>` of simulation, by using \n\n#. id's of both :yref:`Bodies<Body>` of the interactions, e.g. ``O.interactions[23,65]``\n#. iteraction over the whole container::\n\n\tfor i in O.interactions: print i.id1,i.id2\n\n.. note::\n\tIteration silently skips interactions that are not :yref:`real<Interaction.isReal>`.",python::init<pyInteractionContainer&>())
+ py::class_<pyInteractionContainer>("InteractionContainer","Access to :yref:`interactions<Interaction>` of simulation, by using \n\n#. id's of both :yref:`Bodies<Body>` of the interactions, e.g. ``O.interactions[23,65]``\n#. iteraction over the whole container::\n\n\tfor i in O.interactions: print i.id1,i.id2\n\n.. note::\n\tIteration silently skips interactions that are not :yref:`real<Interaction.isReal>`.",py::init<pyInteractionContainer&>())
.def("__iter__",&pyInteractionContainer::pyIter)
.def("__getitem__",&pyInteractionContainer::pyGetitem)
.def("__len__",&pyInteractionContainer::len)
@@ -934,28 +933,28 @@
.def("erase",&pyInteractionContainer::erase,"Erase one interaction, given by id1, id2 (internally, ``requestErase`` is called -- the interaction might still exist as potential, if the :yref:`Collider` decides so).")
.add_property("serializeSorted",&pyInteractionContainer::serializeSorted_get,&pyInteractionContainer::serializeSorted_set)
.def("clear",&pyInteractionContainer::clear,"Remove all interactions, and invalidate persistent collider data (if the collider supports it).");
- python::class_<pyInteractionIterator>("InteractionIterator",python::init<pyInteractionIterator&>())
+ py::class_<pyInteractionIterator>("InteractionIterator",py::init<pyInteractionIterator&>())
.def("__iter__",&pyInteractionIterator::pyIter)
.def("next",&pyInteractionIterator::pyNext);
- python::class_<pyForceContainer>("ForceContainer",python::init<pyForceContainer&>())
- .def("f",&pyForceContainer::force_get,(python::arg("id"),python::arg("sync")=false),"Force applied on body. For clumps in openMP, synchronize the force container with sync=True, else the value will be wrong.")
- .def("t",&pyForceContainer::torque_get,(python::arg("id"),python::arg("sync")=false),"Torque applied on body. For clumps in openMP, synchronize the force container with sync=True, else the value will be wrong.")
- .def("m",&pyForceContainer::torque_get,(python::arg("id"),python::arg("sync")=false),"Deprecated alias for t (torque).")
- .def("move",&pyForceContainer::move_get,(python::arg("id")),"Displacement applied on body.")
- .def("rot",&pyForceContainer::rot_get,(python::arg("id")),"Rotation applied on body.")
- .def("addF",&pyForceContainer::force_add,(python::arg("id"),python::arg("f"),python::arg("permanent")=false),"Apply force on body (accumulates).\n\n # If permanent=false (default), the force applies for one iteration, then it is reset by ForceResetter. \n # If permanent=true, it persists over iterations, until it is overwritten by another call to addF(id,f,True) or removed by reset(resetAll=True). The permanent force on a body can be checked with permF(id).")
- .def("addT",&pyForceContainer::torque_add,(python::arg("id"),python::arg("t"),python::arg("permanent")=false),"Apply torque on body (accumulates). \n\n # If permanent=false (default), the torque applies for one iteration, then it is reset by ForceResetter. \n # If permanent=true, it persists over iterations, until it is overwritten by another call to addT(id,f,True) or removed by reset(resetAll=True). The permanent torque on a body can be checked with permT(id).")
- .def("permF",&pyForceContainer::permForce_get,(python::arg("id")),"read the value of permanent force on body (set with setPermF()).")
- .def("permT",&pyForceContainer::permTorque_get,(python::arg("id")),"read the value of permanent torque on body (set with setPermT()).")
- .def("addMove",&pyForceContainer::move_add,(python::arg("id"),python::arg("m")),"Apply displacement on body (accumulates).")
- .def("addRot",&pyForceContainer::rot_add,(python::arg("id"),python::arg("r")),"Apply rotation on body (accumulates).")
- .def("reset",&pyForceContainer::reset,(python::arg("resetAll")=true),"Reset the force container, including user defined permanent forces/torques. resetAll=False will keep permanent forces/torques unchanged.")
+ py::class_<pyForceContainer>("ForceContainer",py::init<pyForceContainer&>())
+ .def("f",&pyForceContainer::force_get,(py::arg("id"),py::arg("sync")=false),"Force applied on body. For clumps in openMP, synchronize the force container with sync=True, else the value will be wrong.")
+ .def("t",&pyForceContainer::torque_get,(py::arg("id"),py::arg("sync")=false),"Torque applied on body. For clumps in openMP, synchronize the force container with sync=True, else the value will be wrong.")
+ .def("m",&pyForceContainer::torque_get,(py::arg("id"),py::arg("sync")=false),"Deprecated alias for t (torque).")
+ .def("move",&pyForceContainer::move_get,(py::arg("id")),"Displacement applied on body.")
+ .def("rot",&pyForceContainer::rot_get,(py::arg("id")),"Rotation applied on body.")
+ .def("addF",&pyForceContainer::force_add,(py::arg("id"),py::arg("f"),py::arg("permanent")=false),"Apply force on body (accumulates).\n\n # If permanent=false (default), the force applies for one iteration, then it is reset by ForceResetter. \n # If permanent=true, it persists over iterations, until it is overwritten by another call to addF(id,f,True) or removed by reset(resetAll=True). The permanent force on a body can be checked with permF(id).")
+ .def("addT",&pyForceContainer::torque_add,(py::arg("id"),py::arg("t"),py::arg("permanent")=false),"Apply torque on body (accumulates). \n\n # If permanent=false (default), the torque applies for one iteration, then it is reset by ForceResetter. \n # If permanent=true, it persists over iterations, until it is overwritten by another call to addT(id,f,True) or removed by reset(resetAll=True). The permanent torque on a body can be checked with permT(id).")
+ .def("permF",&pyForceContainer::permForce_get,(py::arg("id")),"read the value of permanent force on body (set with setPermF()).")
+ .def("permT",&pyForceContainer::permTorque_get,(py::arg("id")),"read the value of permanent torque on body (set with setPermT()).")
+ .def("addMove",&pyForceContainer::move_add,(py::arg("id"),py::arg("m")),"Apply displacement on body (accumulates).")
+ .def("addRot",&pyForceContainer::rot_add,(py::arg("id"),py::arg("r")),"Apply rotation on body (accumulates).")
+ .def("reset",&pyForceContainer::reset,(py::arg("resetAll")=true),"Reset the force container, including user defined permanent forces/torques. resetAll=False will keep permanent forces/torques unchanged.")
.def("getPermForceUsed",&pyForceContainer::getPermForceUsed,"Check wether permanent forces are present.")
.add_property("syncCount",&pyForceContainer::syncCount_get,&pyForceContainer::syncCount_set,"Number of synchronizations of ForceContainer (cummulative); if significantly higher than number of steps, there might be unnecessary syncs hurting performance.")
;
- python::class_<pyMaterialContainer>("MaterialContainer","Container for :yref:`Materials<Material>`. A material can be accessed using \n\n #. numerical index in range(0,len(cont)), like cont[2]; \n #. textual label that was given to the material, like cont['steel']. This etails traversing all materials and should not be used frequently.",python::init<pyMaterialContainer&>())
+ py::class_<pyMaterialContainer>("MaterialContainer","Container for :yref:`Materials<Material>`. A material can be accessed using \n\n #. numerical index in range(0,len(cont)), like cont[2]; \n #. textual label that was given to the material, like cont['steel']. This etails traversing all materials and should not be used frequently.",py::init<pyMaterialContainer&>())
.def("append",&pyMaterialContainer::append,"Add new shared :yref:`Material`; changes its id and return it.")
.def("append",&pyMaterialContainer::appendList,"Append list of :yref:`Material` instances, return list of ids.")
.def("index",&pyMaterialContainer::index,"Return id of material, given its label.")
@@ -963,14 +962,14 @@
.def("__getitem__",&pyMaterialContainer::getitem_label)
.def("__len__",&pyMaterialContainer::len);
- python::class_<STLImporter>("STLImporter").def("ymport",&STLImporter::import);
+ py::class_<STLImporter>("STLImporter").def("ymport",&STLImporter::import);
//////////////////////////////////////////////////////////////
///////////// proxyless wrappers
- Serializable().pyRegisterClass(python::scope());
-
- python::class_<TimingDeltas, shared_ptr<TimingDeltas>, noncopyable >("TimingDeltas").add_property("data",&TimingDeltas::pyData,"Get timing data as list of tuples (label, execTime[nsec], execCount) (one tuple per checkpoint)").def("reset",&TimingDeltas::reset,"Reset timing information");
-
- python::scope().attr("O")=pyOmega();
+ Serializable().pyRegisterClass(py::scope());
+
+ py::class_<TimingDeltas, shared_ptr<TimingDeltas>, noncopyable >("TimingDeltas").add_property("data",&TimingDeltas::pyData,"Get timing data as list of tuples (label, execTime[nsec], execCount) (one tuple per checkpoint)").def("reset",&TimingDeltas::reset,"Reset timing information");
+
+ py::scope().attr("O")=pyOmega();
}