← Back to team overview

yade-users team mailing list archive

Particle displacement during a simulation

 

Hi,
 
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 :

***********************************************************************

ElementTeleportation::ElementTeleportation() : StandAloneEngine()
{
   ballId = 1;
   iterChange = 0;
   newPosition = Vector3r(2,0.06,0);
   //newVelocity = Vector3r(0,0,0);
}

ElementTeleportation::~ElementTeleportation()
{
}

void ElementTeleportation::registerAttributes()
{
   StandAloneEngine::registerAttributes();
   REGISTER_ATTRIBUTE(ballId);
   REGISTER_ATTRIBUTE(iterChange);
   REGISTER_ATTRIBUTE(newPosition);
   //REGISTER_ATTRIBUTE(newVelocity);
}

void ElementTeleportation::action(Body * body)
{
   MetaBody * ncb = dynamic_cast<MetaBody*>(body);

   if( Omega::instance().getCurrentIteration() == iterChange)
   {
       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;
               }
       }
   }
}

**************************************************************************** 


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.
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.

Here are my questions, and I hope you could answer me...

Thanks


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