← Back to team overview

yade-users team mailing list archive

Re: How to reset a body's velocity?

 

sega a écrit :
> Hi!
> I need to reset a body's velocity to zero when this body is reloaded into a simulation.
> Now can I do it?
> As me seems, a velocity of body is sets _only_ by LeapFrogPositionIntegrator or NewtonsDampedLaw.
> Both have a firsts vector but different parents... 
>
>   
Hi Sega,

If you need to do that during the simulation with a body which has a 
current velocity, acceleration .. Maybe you could add these lines in 
"LeapFrogPositionIntegrator" (additions in italics)

    Real dt = Omega::instance().getTimeStep();

    /ParticleParameters * p = YADE_CAST<ParticleParameters*>(b.get());/

/    if (p->vel_nulle)
    {
        p->acceleration = Vector3r(0,0,0);
        prevVelocities[id] = Vector3r(0,0,0):
    }/

    if (!firsts[id])
        p->velocity = prevVelocities[id]+((Real)0.5)*dt*p->acceleration;

You have also to declare the parameter /vel_nulle/ as a boolean in 
"ParticleParameter"

finally you can initialise your velocity by adding a line, for example 
in "VelocityRecorder.cpp" (additions in italics)

    for(  ; bi!=biEnd ; ++bi )
    {
        shared_ptr<Body> body = *bi;
        if( body->isDynamic )
        {
            size+=1.0;
            ParticleParameters* pp = 
YADE_CAST<ParticleParameters*>(body->physicalParameters.get());

           /pp->vel_nulle = true;/

            x+=pp->velocity[0];
            y+=pp->velocity[1];
            z+=pp->velocity[2];
        }
    }

Normally it works, I just don't know if that is really fits YADE 
philosophy, maybe the YADE's big boss could comment.

good luck

Lionel

//

-- 
Lionel FAVIER
Doctorant
Laboratoire Sols Solides Structures, Risques (3S-R)
Equipe Risques et Vulnérabilité (RV)

Domaine Universitaire - BP 53
38041 Grenoble Cedex 9
France

Tél: +33 (0)4 56 52 86 36
lionel.favier@xxxxxxxxxxx

_______________________________________________
Yade-users mailing list
Yade-users@xxxxxxxxxxxxxxxx
https://lists.berlios.de/mailman/listinfo/yade-users



References