How to get composite force of each particle at each time step?

Asked by Feng Chen

Hi, All:

Is there a good way to get the composite force of each particle at each time step? (e.g. the total force acting on each particle, this equals accelaration*mass, I want to use this to make sth similar to the hysteretic damping, but not exactly) In BodyForceGroup<TmplParticle>::calcForces(), I used a loop like:

typename ParticleArray::ParticleListHandle plh = m_pParticleArray->getAllParticles();
    for (
   ParticleIterator it = plh->begin();
   it != plh->end();
   it++,iterDEMForceList++
    )
    {
                          applyForce(*(*it));
                          Vec3 tmp_vec=(*(*it)).getForce();
     cout << tmp_vec << endl;
    }

However all outputs are
0 0 0
...
0 0 0

I think this might not be the correct way, so what is the correct way to do this?

Thanks in advance for any suggestions!

Feng

Question information

Language:
English Edit question
Status:
Answered
For:
ESyS-Particle Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
SteffenAbe (s-abe) said :
#1

Hi Feng,

what does your applyForce function look like? The one in BodyForceGroup calculates the force applied to the particle from its mass and the m_acceleration member variable of the BodyForceGroup. If you want to add a force from a list to each particle, then I'd suggest the following approach. This assumes that you have your forces in an STL list, one force per particle.

list<Vec3>::iterator f_iter=ListOfForces.begin();
typename ParticleArray::ParticleIterator it =
      m_pParticleArray->getInnerParticleIterator();

while(it.hasNext())
{
  TmplParticle &p=it.next();
  Vec3 pos=p.getPos();
  Vec3 force=*f_iter;
  p.applyForce(force,pos);
  f_iter++;
}

Steffen

Can you help with this problem?

Provide an answer of your own, or ask Feng Chen for more information if necessary.

To post a message you must log in.