void NewtonIntegrator::ensureSync() { if (syncEnsured) return; YADE_PARALLEL_FOREACH_BODY_BEGIN(const shared_ptr<Body>& b, scene->bodies){ // if(b->isClump()) continue; scene->forces.addForce(b->getId(),Vector3r(0,0,0)); } YADE_PARALLEL_FOREACH_BODY_END(); syncEnsured=true; }
void GravityEngine::action(){ if (warnOnce) {warnOnce=false; LOG_WARN("GravityEngine is deprecated, consider using Newton::gravity instead (unless gravitational energy has to be tracked - not implemented with the newton attribute).")} const bool trackEnergy(scene->trackEnergy); const Real dt(scene->dt); YADE_PARALLEL_FOREACH_BODY_BEGIN(const shared_ptr<Body>& b, scene->bodies){ // skip clumps, only apply forces on their constituents if(b->isClump()) continue; if(mask!=0 && !b->maskCompatible(mask)) continue; scene->forces.addForce(b->getId(),gravity*b->state->mass); // work done by gravity is "negative", since the energy appears in the system from outside if(trackEnergy) scene->energy->add(-gravity.dot(b->state->vel)*b->state->mass*dt,"gravWork",fieldWorkIx,/*non-incremental*/false); } YADE_PARALLEL_FOREACH_BODY_END(); }