← Back to team overview

yade-users team mailing list archive

Re: How to reset a body's velocity?

 

Ok I see.
I think the simplest way is to scan metabody->engines, get the 
integrator engine and set integrator->prevVelocities[id]=0. The same 
thing is done in some preprocessors, to get TriaxialCompressionEngine's 
member data from another engine for instance.
I don't remember if prevVelocities is private or public atm, perhaps 
you'll need to make it public.
Your solution would do the job, but it will add useless operations for 
all users.

Bruno


sega a écrit :
>> What/why do you want to do exactly?
> Unloaded particles (from hopper, silo, etc...) should be loaded back with 0 initial velocity.
> 
>> I don't really understand the problem. Can't you just set p->velocity = 
>> 0 somwhere in the code
> 
> No, because a integrator will set back the old value.
> Currently, the veloctiy can not be changed outside integrator.
> 
> I propose the following (inspired by Lionel):
> 
> To declare the parameter /bool resetVelocity/ in 
> "ParticleParameter". If resetVelocity=true a intergator should set the velocity as first time.
> And add these lines in LeapFrogPositionIntergator" and "NewtonsDampedLaw":
> 
>     ParticleParameters * p = YADE_CAST<ParticleParameters*>(b.get());
> 
> /    if (p->resetVelocity)
>     {
> 	firsts[id]=true;
> 	p->resetVelocity=false
>     }/
> 
>     if (!firsts[id])
>         p->velocity = prevVelocities[id]+((Real)0.5)*dt*p->acceleration;
>     
>     prevVelocities[id] = p->velocity+((Real)0.5)*dt*p->acceleration;
> 
> We can even abandon "firsts" and use resetVelocity instead...
> For angular velocity similar flag should be added in RigidBodyParameters...
> 
> Are there any thoughts about this?
> 


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



Follow ups

References