------------------------------------------------------------ revno: 3829 committer: Christian Jakob <ja...@ifgt.tu-freiberg.de> timestamp: Thu 2014-02-27 09:27:24 +0100 message: absorb bool integrateInertia from Clump::updateProperties by int discretization modified: core/Clump.cpp core/Clump.hpp pkg/dem/Shop.hpp pkg/dem/Shop_02.cpp py/_utils.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/Clump.cpp' --- core/Clump.cpp 2014-02-26 17:56:22 +0000 +++ core/Clump.cpp 2014-02-27 08:27:24 +0000 @@ -82,7 +82,7 @@ */ -void Clump::updateProperties(const shared_ptr<Body>& clumpBody, unsigned int discretization, bool integrateInertia){ +void Clump::updateProperties(const shared_ptr<Body>& clumpBody, unsigned int discretization){ LOG_DEBUG("Updating clump #"<<clumpBody->id<<" parameters"); const shared_ptr<State> state(clumpBody->state); const shared_ptr<Clump> clump(YADE_PTR_CAST<Clump>(clumpBody->shape)); @@ -110,7 +110,7 @@ bool intersecting = false; shared_ptr<Sphere> sph (new Sphere); int Sph_Index = sph->getClassIndexStatic(); // get sphere index for checking if bodies are spheres - if (integrateInertia){ + if (discretization>0){ FOREACH(MemberMap::value_type& mm, clump->members){ const shared_ptr<Body> subBody1=Body::byId(mm.first); FOREACH(MemberMap::value_type& mm, clump->members){ === modified file 'core/Clump.hpp' --- core/Clump.hpp 2013-10-04 11:41:10 +0000 +++ core/Clump.hpp 2014-02-27 08:27:24 +0000 @@ -61,7 +61,7 @@ static void add(const shared_ptr<Body>& clump, const shared_ptr<Body>& subBody); static void del(const shared_ptr<Body>& clump, const shared_ptr<Body>& subBody); //! Recalculate physical properties of Clump. - static void updateProperties(const shared_ptr<Body>& clump, unsigned int discretization, bool integrateInertia); + static void updateProperties(const shared_ptr<Body>& clump, unsigned int discretization); //! Calculate positions and orientations of members based on relative Se3; newton pointer (if non-NULL) calls NewtonIntegrator::saveMaximaVelocity // done as template to avoid cross-dependency between clump and newton (not necessary if all plugins are linked together) template<class IntegratorT> === modified file 'pkg/dem/Shop.hpp' --- pkg/dem/Shop.hpp 2013-10-30 23:25:56 +0000 +++ pkg/dem/Shop.hpp 2014-02-27 08:27:24 +0000 @@ -145,7 +145,7 @@ static void setContactFriction(Real angleRad); //! Homothetic change of sizes of spheres and clumps - static void growParticles(Real multiplier, bool updateMass, bool dynamicOnly, unsigned int discretization, bool integrateInertia); + static void growParticles(Real multiplier, bool updateMass, bool dynamicOnly, unsigned int discretization); //! Change of size of a single sphere or a clump static void growParticle(Body::id_t bodyID, Real multiplier, bool updateMass); }; === modified file 'pkg/dem/Shop_02.cpp' --- pkg/dem/Shop_02.cpp 2013-10-30 23:25:56 +0000 +++ pkg/dem/Shop_02.cpp 2014-02-27 08:27:24 +0000 @@ -477,7 +477,7 @@ } } -void Shop::growParticles(Real multiplier, bool updateMass, bool dynamicOnly, unsigned int discretization, bool integrateInertia) +void Shop::growParticles(Real multiplier, bool updateMass, bool dynamicOnly, unsigned int discretization) { Scene* scene = Omega::instance().getScene().get(); FOREACH(const shared_ptr<Body>& b,*scene->bodies){ @@ -492,7 +492,7 @@ FOREACH(const shared_ptr<Body>& b,*scene->bodies){ if(b->isClump()){ Clump* clumpSt = YADE_CAST<Clump*>(b->shape.get()); - clumpSt->updateProperties(b, discretization, integrateInertia); + clumpSt->updateProperties(b, discretization); } } FOREACH(const shared_ptr<Interaction>& ii, *scene->interactions){ === modified file 'py/_utils.cpp' --- py/_utils.cpp 2014-01-21 15:18:44 +0000 +++ py/_utils.cpp 2014-02-27 08:27:24 +0000 @@ -545,7 +545,7 @@ py::def("calm",Shop__calm,(py::arg("mask")=-1),"Set translational and rotational velocities of all bodies to zero."); py::def("setNewVerticesOfFacet",setNewVerticesOfFacet,(py::arg("b"),py::arg("v1"),py::arg("v2"),py::arg("v3")),"Sets new vertices (in global coordinates) to given facet."); py::def("setContactFriction",Shop::setContactFriction,py::arg("angleRad"),"Modify the friction angle (in radians) inside the material classes and existing contacts. The friction for non-dynamic bodies is not modified."); - py::def("growParticles",Shop::growParticles,(py::args("multiplier"), py::args("updateMass")=true, py::args("dynamicOnly")=true, py::args("discretization")=15, py::args("integrateInertia")=true), "Change the size of spheres and sphere clumps by the multiplier. If updateMass=True, then the mass is updated. dynamicOnly=True is mandatory in many cases since in current implementation the function would crash on the non-spherical and non-dynamic bodies (e.g. facets, boxes, etc.). For clumps the masses and inertias are adapted automatically (for details of inertia tensor integration scheme see :yref:`clump()<BodyContainer.clump>`)."); + py::def("growParticles",Shop::growParticles,(py::args("multiplier"), py::args("updateMass")=true, py::args("dynamicOnly")=true, py::args("discretization")=0), "Change the size of spheres and sphere clumps by the multiplier. If updateMass=True, then the mass is updated. dynamicOnly=True is mandatory in many cases since in current implementation the function would crash on the non-spherical and non-dynamic bodies (e.g. facets, boxes, etc.). For clumps the masses and inertias are adapted automatically when discretization>0 (for details of inertia tensor integration scheme see :yref:`clump()<BodyContainer.clump>`)."); py::def("growParticle",Shop::growParticle,(py::args("bodyID"),py::args("multiplier"), py::args("updateMass")=true), "Change the size of a single sphere (to be implemented: single clump). If updateMass=True, then the mass is updated."); py::def("intrsOfEachBody",intrsOfEachBody,"returns list of lists of interactions of each body"); py::def("numIntrsOfEachBody",numIntrsOfEachBody,"returns list of number of interactions of each body"); === modified file 'py/wrapper/yadeWrapper.cpp' --- py/wrapper/yadeWrapper.cpp 2014-02-26 17:56:22 +0000 +++ py/wrapper/yadeWrapper.cpp 2014-02-27 08:27:24 +0000 @@ -133,7 +133,7 @@ #endif vector<Body::id_t> ret; FOREACH(shared_ptr<Body>& b, bb){ret.push_back(append(b));} return ret; } - Body::id_t clump(vector<Body::id_t> ids, unsigned int discretization, bool integrateInertia){ + Body::id_t clump(vector<Body::id_t> ids, unsigned int discretization){ // create and add clump itself Scene* scene(Omega::instance().getScene().get()); shared_ptr<Body> clumpBody=shared_ptr<Body>(new Body()); @@ -149,16 +149,16 @@ }; FOREACH(Body::id_t id, ids) Clump::add(clumpBody,Body::byId(id,scene)); - Clump::updateProperties(clumpBody, discretization, integrateInertia); + Clump::updateProperties(clumpBody, discretization); return clumpBody->getId(); } - python::tuple appendClump(vector<shared_ptr<Body> > bb, unsigned int discretization, bool integrateInertia){ + python::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, integrateInertia),ids); + return python::make_tuple(clump(ids, discretization),ids); } - void addToClump(vector<Body::id_t> bids, Body::id_t cid, unsigned int discretization, bool integrateInertia){ + void addToClump(vector<Body::id_t> bids, Body::id_t cid, unsigned int discretization){ Scene* scene(Omega::instance().getScene().get()); // get scene shared_ptr<Body> clp = Body::byId(cid,scene); // get clump pointer checkClump(clp); @@ -179,10 +179,10 @@ } else Clump::add(clp,bp);// bp must be a standalone! } - Clump::updateProperties(clp, discretization, integrateInertia); + Clump::updateProperties(clp, discretization); FOREACH(Body::id_t bid, eraseList) proxee->erase(bid);//erase old clumps } - void releaseFromClump(Body::id_t bid, Body::id_t cid, unsigned int discretization, bool integrateInertia){ + void releaseFromClump(Body::id_t bid, Body::id_t cid, unsigned int discretization){ Scene* scene(Omega::instance().getScene().get()); // get scene shared_ptr<Body> bp = Body::byId(bid,scene); // get body pointer shared_ptr<Body> clp = Body::byId(cid,scene); // get clump pointer @@ -194,11 +194,11 @@ std::map<Body::id_t,Se3r>& members = clump->members; if (members.size() == 2) {PyErr_Warn(PyExc_UserWarning,("Warning: Body "+lexical_cast<string>(bid)+" not released from clump "+lexical_cast<string>(cid)+", because number of clump members would get < 2!").c_str()); return;} Clump::del(clp,bp);//release bid from cid - Clump::updateProperties(clp, discretization, integrateInertia); + Clump::updateProperties(clp, discretization); } 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, bool integrateInertia){ + python::list replaceByClumps(python::list ctList, vector<Real> amounts, unsigned int discretization){ python::list ret; Real checkSum = 0.0; FOREACH(Real amount, amounts) { @@ -359,7 +359,7 @@ LOG_DEBUG("New body (sphere) "<<newSphere->id<<" added."); idsTmp[jj] = newSphere->id; } - Body::id_t newClumpId = clump(idsTmp, discretization, integrateInertia); + Body::id_t newClumpId = clump(idsTmp, discretization); ret.append(python::make_tuple(newClumpId,idsTmp)); erase(b->id); } @@ -882,11 +882,11 @@ .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")=15,python::arg("integrateInertia")=true),"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")=15,python::arg("integrateInertia")=true),"Clump given bodies together (creating a rigid aggregate); returns ``clumpId``. Clump masses and inertia are adapted automatically (default with integrateInertia=True). 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 integrateInertia=False sum of inertias from members is used (faster, but inaccurate).") - .def("addToClump",&pyBodyContainer::addToClump,(python::arg("discretization")=15,python::arg("integrateInertia")=true),"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")=15,python::arg("integrateInertia")=true),"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")=15,python::arg("integrateInertia")=true),"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("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("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("clear", &pyBodyContainer::clear,"Remove all bodies (interactions not checked)") .def("erase", &pyBodyContainer::erase,"Erase body with the given id; all interaction will be deleted by InteractionLoop in the next step.")
_______________________________________________ Mailing list: https://launchpad.net/~yade-dev Post to : yade-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-dev More help : https://help.launchpad.net/ListHelp