------------------------------------------------------------ revno: 3749 committer: Anton Gladky <gladky.an...@gmail.com> timestamp: Sun 2015-12-06 10:19:36 +0100 message: Remove flags and preSteps from scene They are not actually used by anything modified: core/Scene.hpp pkg/common/Dispatching.hpp pkg/common/InteractionLoop.cpp pkg/dem/L3Geom.hpp
-- 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/Scene.hpp' --- core/Scene.hpp 2014-11-17 11:34:44 +0000 +++ core/Scene.hpp 2015-12-06 09:19:36 +0000 @@ -73,13 +73,6 @@ void postLoad(Scene&); - // bits for Scene::flags - enum { LOCAL_COORDS=1, COMPRESSION_NEGATIVE=2 }; /* add powers of 2 as needed */ - // convenience accessors - bool usesLocalCoords() const { return flags & LOCAL_COORDS; } - void setLocalCoords(bool d){ if(d) flags|=LOCAL_COORDS; else flags&=~(LOCAL_COORDS); } - bool compressionNegative() const { return flags & COMPRESSION_NEGATIVE; } - void setCompressionNegative(bool d){ if(d) flags|=COMPRESSION_NEGATIVE; else flags&=~(COMPRESSION_NEGATIVE); } boost::posix_time::ptime prevTime; //Time value on the previous step YADE_CLASS_BASE_DOC_ATTRS_CTOR_PY(Scene,Serializable,"Object comprising the whole simulation.", @@ -96,7 +89,6 @@ ((bool,doSort,false,Attr::readonly,"Used, when new body is added to the scene.")) ((bool,runInternalConsistencyChecks,true,Attr::hidden,"Run internal consistency check, right before the very first simulation step.")) ((Body::id_t,selectedBody,-1,,"Id of body that is selected by the user")) - ((int,flags,0,Attr::readonly,"Various flags of the scene; 1 (Scene::LOCAL_COORDS): use local coordinate system rather than global one for per-interaction quantities (set automatically from the functor).")) ((list<string>,tags,,,"Arbitrary key=value associations (tags like mp3 tags: author, date, version, description etc.)")) ((vector<shared_ptr<Engine> >,engines,,Attr::hidden,"Engines sequence in the simulation.")) @@ -118,8 +110,6 @@ SpeedElements.Zero(); , /* py */ - .add_property("localCoords",&Scene::usesLocalCoords,"Whether local coordianate system is used on interactions (set by :yref:`IGeomFunctor`).") - .add_property("compressionNegative",&Scene::usesLocalCoords,"Whether the convention is that compression has negative sign (set by :yref:`IGeomFunctor`).") ); DECLARE_LOGGER; }; === modified file 'pkg/common/Dispatching.hpp' --- pkg/common/Dispatching.hpp 2014-10-15 06:44:01 +0000 +++ pkg/common/Dispatching.hpp 2015-12-06 09:19:36 +0000 @@ -56,8 +56,6 @@ /*argument types*/ TYPELIST_3(shared_ptr<IGeom>&, shared_ptr<IPhys>&, Interaction*) >{ public: virtual ~LawFunctor(); - // called before every step once, from InteractionLoop (used to set Scene::flags & Scene::COMPRESSION_NEGATIVE) - virtual void preStep(){}; /*! Convenience functions to get forces/torques quickly. */ void addForce (const Body::id_t id, const Vector3r& f,Scene* rb){rb->forces.addForce (id,f);} void addTorque(const Body::id_t id, const Vector3r& t,Scene* rb){rb->forces.addTorque(id,t);} === modified file 'pkg/common/InteractionLoop.cpp' --- pkg/common/InteractionLoop.cpp 2014-07-18 18:18:50 +0000 +++ pkg/common/InteractionLoop.cpp 2015-12-06 09:19:36 +0000 @@ -22,14 +22,14 @@ void InteractionLoop::action(){ // update Scene* of the dispatchers - geomDispatcher->scene=physDispatcher->scene=lawDispatcher->scene=scene; + lawDispatcher->scene=scene; + physDispatcher->scene=scene; + geomDispatcher->scene=scene; + // ask dispatchers to update Scene* of their functors - geomDispatcher->updateScenePtr(); physDispatcher->updateScenePtr(); lawDispatcher->updateScenePtr(); - - // call Ig2Functor::preStep - FOREACH(const shared_ptr<IGeomFunctor>& ig2, geomDispatcher->functors) ig2->preStep(); - // call LawFunctor::preStep - FOREACH(const shared_ptr<LawFunctor>& law2, lawDispatcher->functors) law2->preStep(); + geomDispatcher->updateScenePtr(); + physDispatcher->updateScenePtr(); + lawDispatcher->updateScenePtr(); /* initialize callbacks; they return pointer (used only in this timestep) to the function to be called @@ -42,14 +42,17 @@ callbackPtrs.push_back(cb->stepInit()); } assert(callbackPtrs.size()==callbacks.size()); - size_t callbacksSize=callbacks.size(); + const size_t callbacksSize=callbacks.size(); // cache transformed cell size - Matrix3r cellHsize; if(scene->isPeriodic) cellHsize=scene->cell->hSize; + Matrix3r cellHsize = Matrix3r::Zero(); + if(scene->isPeriodic) { + cellHsize=scene->cell->hSize; + } // force removal of interactions that were not encountered by the collider // (only for some kinds of colliders; see comment for InteractionContainer::iterColliderLastRun) - bool removeUnseenIntrs=(scene->interactions->iterColliderLastRun>=0 && scene->interactions->iterColliderLastRun==scene->iter); + const bool removeUnseenIntrs=(scene->interactions->iterColliderLastRun>=0 && scene->interactions->iterColliderLastRun==scene->iter); #ifdef YADE_OPENMP const long size=scene->interactions->size(); @@ -59,8 +62,6 @@ #else FOREACH(const shared_ptr<Interaction>& I, *scene->interactions){ #endif - // keep the following newline, my (edx) preprocessor outputs garbage code otherwise! - if(removeUnseenIntrs && !I->isReal() && I->iterLastSeen<scene->iter) { eraseAfterLoop(I->getId1(),I->getId2()); continue; @@ -69,12 +70,18 @@ const shared_ptr<Body>& b1_=Body::byId(I->getId1(),scene); const shared_ptr<Body>& b2_=Body::byId(I->getId2(),scene); - if(!b1_ || !b2_){ LOG_DEBUG("Body #"<<(b1_?I->getId2():I->getId1())<<" vanished, erasing intr #"<<I->getId1()<<"+#"<<I->getId2()<<"!"); scene->interactions->requestErase(I); continue; } + if(!b1_ || !b2_){ + LOG_DEBUG("Body #"<<(b1_?I->getId2():I->getId1())<<" vanished, erasing intr #"<<I->getId1()<<"+#"<<I->getId2()<<"!"); + scene->interactions->requestErase(I); + continue; + } // Skip interaction with clumps if (b1_->isClump() || b2_->isClump()) { continue; } + // we know there is no geometry functor already, take the short path if(!I->functorCache.geomExists) { assert(!I->isReal()); continue; } + // no interaction geometry for either of bodies; no interaction possible if(!b1_->shape || !b2_->shape) { assert(!I->isReal()); continue; } @@ -83,8 +90,10 @@ if(!I->functorCache.geom){ I->functorCache.geom=geomDispatcher->getFunctor2D(b1_->shape,b2_->shape,swap); // returns NULL ptr if no functor exists; remember that and shortcut - if(!I->functorCache.geom) {I->functorCache.geomExists=false; continue; } - + if(!I->functorCache.geom) { + I->functorCache.geomExists=false; + continue; + } } // arguments for the geom functor are in the reverse order (dispatcher would normally call goReverse). // we don't remember the fact that is reverse, so we swap bodies within the interaction @@ -95,11 +104,13 @@ const shared_ptr<Body>& b2=swap?b1_:b2_; assert(I->functorCache.geom); + bool wasReal=I->isReal(); bool geomCreated; if(!scene->isPeriodic){ geomCreated=I->functorCache.geom->go(b1->shape,b2->shape, *b1->state, *b2->state, Vector3r::Zero(), /*force*/false, I); - } else { // handle periodicity + } else { + // handle periodicity Vector3r shift2=cellHsize*I->cellDist.cast<Real>(); // in sheared cell, apply shear on the mutual position as well geomCreated=I->functorCache.geom->go(b1->shape,b2->shape,*b1->state,*b2->state,shift2,/*force*/false,I); @@ -115,7 +126,7 @@ I->functorCache.phys=physDispatcher->getFunctor2D(b1->material,b2->material,swap); assert(!swap); // InteractionPhysicsEngineUnits are symmetric } - //assert(I->functorCache.phys); + if(!I->functorCache.phys){ throw std::runtime_error("Undefined or ambiguous IPhys dispatch for types "+b1->material->getClassName()+" and "+b2->material->getClassName()+"."); } @@ -131,12 +142,12 @@ I->functorCache.constLaw=lawDispatcher->getFunctor2D(I->geom,I->phys,swap); if(!I->functorCache.constLaw){ LOG_FATAL("None of given Law2 functors can handle interaction #"<<I->getId1()<<"+"<<I->getId2()<<", types geom:"<<I->geom->getClassName()<<"="<<I->geom->getClassIndex()<<" and phys:"<<I->phys->getClassName()<<"="<<I->phys->getClassIndex()<<" (LawDispatcher::getFunctor2D returned empty functor)"); - //abort(); exit(1); } assert(!swap); // reverse call would make no sense, as the arguments are of different types } assert(I->functorCache.constLaw); + //If the functor return false, the interaction is reset if (!I->functorCache.constLaw->go(I->geom,I->phys,I.get())) scene->interactions->requestErase(I); === modified file 'pkg/dem/L3Geom.hpp' --- pkg/dem/L3Geom.hpp 2015-11-18 07:06:16 +0000 +++ pkg/dem/L3Geom.hpp 2015-12-06 09:19:36 +0000 @@ -110,8 +110,6 @@ // common code for {sphere,facet,wall}+sphere contacts // facet&wall will get separated if L3Geom subclass with exact branch vector is created void handleSpheresLikeContact(const shared_ptr<Interaction>& I, const State& state1, const State& state2, const Vector3r& shift2, bool is6Dof, const Vector3r& normal, const Vector3r& contPt, Real uN, Real r1, Real r2); - virtual void preStep(){ scene->setLocalCoords(true); } - enum { APPROX_NO_MID_TRSF=1, APPROX_NO_MID_NORMAL=2, APPROX_NO_RENORM_MID_NORMAL=4 };
_______________________________________________ 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