← Back to team overview

yade-users team mailing list archive

Re: Particle displacement during a simulation

 

Lionel Favier said:     (by the date of Mon, 04 Sep 2006 16:56:24 +0200)

> Hi,

Hello,

Sorry for late reply, I was on the conference this week (starting from
monday), and I have just returned. So now I can answer your questions.

> I would like to change coordinates of a discrete element during a 
> simulation (for example after 3 seconds of calculation).
> The problem is I didn't manage to initialize the velocity on the same 
> time whereas there is not any worry to change the coordinates. I give 
> you the class I wrote for this purpose :
> 
> ***********************************************************************
> 
> void ElementTeleportation::action(Body * body)
> {
>     MetaBody * ncb = dynamic_cast<MetaBody*>(body);
> 
>     if( Omega::instance().getCurrentIteration() == iterChange)

Note: currently there is a function isActivated() which serves exactly
the purpose of this check. But when big changes are finished this check
will be unnecessery. So currently it can work as you have written that.
(though not optimal)

>     {


>         BodyContainer::iterator bi    = ncb->bodies->begin();
>         BodyContainer::iterator biEnd = ncb->bodies->end();
>         for(  ; bi!=biEnd ; ++bi )
>         {
>             shared_ptr<Body> body = *bi;
> 
>             if (body->getId() == ballId)
>                 {
>                     ParticleParameters* pp = 
> dynamic_cast<ParticleParameters*>(body->physicalParameters.get());
> 
>                     body->physicalParameters->se3.position[1] = 1.0;
>                     pp->velocity[1] = 2;
>                 }
>         }
>     }

Somrthing like that should work, and is shorter:

   (*(ncb->bodies))[ballId]->physicalParameters->se3.position = newPosition;

Note: this notation should be simpler after global redesign which is forthcoming :)

Oops, look into LeapFrogPositionIntegrator. You have to modify
acceleration not velocity. On each step (except the first one) velocity
is calculated from acceleration. And acceleration is calculated from
force. Just make sure that you modify acceleration *after*
NewtonsForceLaw in the engines, otherwise it will overwrite your
acceleration!

Your problem points an important thing that must be fixed here. I must
remember to split LeapFrogPositionIntegrator, because indeed it is doing
two separate things: calculate velocity, and displace the body.

Sorry about this problem, this is a bug in fact.


> }
> 
> ****************************************************************************
> 
> Moreover I put this class in 
> "yade-all-0.10.0/yade-packages/yade-package-dem/src/Engine/StandAloneEngine", 
> do you think that's a good choice, actually I think I didn't really 
> understood what was the difference between different kind of engines.

well, maybe it's rather DeusExMachina, and I understand your confusion.
I'm open to suggestions on how to simplify that... And I hope it can get
simpler soon. For example maybe the MetaEngine part will get fully
automated and then could be removed, so there will be one less for
confusing people around.

> I have to face another problem, I tried also to eliminate a discrete 
> element during a simulation, but when the particle is deleted Yade is 
> closed by the computer and I can read "segmentation fault". I used the 
> code "BodyContainer->erase(body->getId())" to do it.

Hm, I should have a look at this, because there must be a bug somewhere.
Please send the code that does the removal.

> Here are the question, and I hope the manual to come soon...

me too :) The first real term for that is after I defend my phd, so
that's the beginning of 2007.

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



References