Skip to content

Reply To: Particle – Wall Interaction


Dear Henderson,

Yes, you can change all the fields provided by the PARTICLETYPE used. The following simple example iterates over all particles and gets and sets the position, velocity and force field. The latter corresponds to the acceleration of the particle according to Newton’s second law of motion.

constexpr unsigned D = 3; // or 2 depending on your setup
using namespace descriptors;

// Iterate over all particles
for(int iP = 0; iP < particleSystem.size(); ++iP) {
    // Get the particle
    auto particle = particleSystem.get(iP);

    // Get and set position
    Vector<T,D> position = particle.template getField<GENERAL,POSITION>();
    particle.template setField<GENERAL,POSITION>( position );

    // Get and set velocity
    Vector<T,D> velocity = particle.template getField<MOBILITY,VELOCITY>();
    particle.template setField<MOBILITY,VELOCITY>( velocity );

    // Get and set force
    Vector<T,D> force = particle.template getField<FORCING,FORCE>();
    particle.template setField<FORCING,FORCE>( force );

Best regards,