Bouncers

See also the user interface.

Base class

class Bouncer : public mirheo::MirSimulationObject

Avoid penetration of particles inside onjects.

Interface class for Bouncers. Bouncers are responsible to reflect particles on the surface of the attached object. Each Bouncer class needs to attach exactly one ObjectVector before performing the bounce.

Subclassed by mirheo::BounceFromMesh, mirheo::BounceFromRigidShape< Shape >, mirheo::BounceFromRod

Public Functions

Bouncer(const MirState *state, std::string name)

Base Bouncer constructor.

Parameters
  • state: Simulation state.
  • name: Name of the bouncer.

virtual void setup(ObjectVector *ov)

Second initialization stage.

This method must be called before calling any other method of this class.

Parameters

ObjectVector *getObjectVector()

Return
The attached ObjectVector

virtual void setPrerequisites(ParticleVector *pv)

Setup prerequisites to a given ParticleVector.

Add additional properties to a

ParticleVector to make it compatible with the exec() method. The default implementation does not add any properties.
Parameters

void bounceLocal(ParticleVector *pv, CellList *cl, cudaStream_t stream)

Perform the reflection of local particles onto the local attached objects surface.

Parameters
  • pv: The ParticleVector that will be bounced
  • cl: The CellList attached to pv
  • stream: The cuda stream used for execution

void bounceHalo(ParticleVector *pv, CellList *cl, cudaStream_t stream)

Perform the reflection of local particles onto the halo attached objects surface.

Parameters
  • pv: The ParticleVector that will be bounced
  • cl: The CellList attached to pv
  • stream: The cuda stream used for execution

virtual std::vector<std::string> getChannelsToBeExchanged() const = 0

Return
list of channel names of the attached object needed before bouncing

virtual std::vector<std::string> getChannelsToBeSentBack() const

Return
list of channel names of the attached object that need to be exchanged after bouncing

Derived classes

class BounceFromMesh : public mirheo::Bouncer

Bounce particles against a triangle mesh.

  • if the attached object is a RigidObjectVector, the bounced particles will transfer (atomically) their change of momentum into the force and torque of the rigid object.

  • if the attached object is a not RigidObjectVector, the bounced particles will transfer (atomically) their change of momentum into the force of the three vertices which form the colliding triangle.

    This class will fail if the object does not have a mesh representing its surfece.

Public Functions

BounceFromMesh(const MirState *state, const std::string &name, VarBounceKernel varBounceKernel)

Construct a BounceFromMesh object.

Parameters
  • state: Simulation state
  • name: Name of the bouncer
  • varBounceKernel: How are the particles bounced

void setup(ObjectVector *ov)

If ov is a rigid object, this will ask it to keep its old motions accross exchangers.

Otherwise, ask ov to keep its old positions accross exchangers.

void setPrerequisites(ParticleVector *pv)

Will ask pv to keep its old positions (not in persistent mode)

std::vector<std::string> getChannelsToBeExchanged() const

Return
list of channel names of the attached object needed before bouncing

std::vector<std::string> getChannelsToBeSentBack() const

Return
list of channel names of the attached object that need to be exchanged after bouncing

The following class employs Analytic Shapes implicit surface representation.

template <class Shape>
class BounceFromRigidShape : public mirheo::Bouncer

Bounce particles against an RigidShapedObjectVector.

Particles are bounced against an analytical shape on each object of the attached

ObjectVector. When bounced, the particles will transfer (atomically) their change of momentum into the force and torque of the rigid objects.
Template Parameters
  • Shape: A class following the AnalyticShape interface

This class only works with RigidShapedObjectVector<Shape> objects. It will fail at setup time if the attached object is not rigid.

Public Functions

BounceFromRigidShape(const MirState *state, const std::string &name, VarBounceKernel varBounceKernel, int verbosity)

Construct a BounceFromRigidShape object.

Parameters
  • state: Simulation state
  • name: Name of the bouncer
  • varBounceKernel: How are the particles bounced
  • verbosity: 0: no print; 1 print to console the rescue failures; 2 print to console all failures.

void setup(ObjectVector *ov)

Will ask ov to keep its old motions information persistently.

This method will die if ov is not of type RigidObjectVector.

void setPrerequisites(ParticleVector *pv)

Will ask pv to keep its old positions (not in persistent mode)

std::vector<std::string> getChannelsToBeExchanged() const

Return
list of channel names of the attached object needed before bouncing

std::vector<std::string> getChannelsToBeSentBack() const

Return
list of channel names of the attached object that need to be exchanged after bouncing

class BounceFromRod : public mirheo::Bouncer

Bounce particles against rods.

The particles are reflacted against the set of capsules around each segment forming the rod. This class will fail if the attached object is not a RodObjectVector

Public Functions

BounceFromRod(const MirState *state, const std::string &name, real radius, VarBounceKernel varBounceKernel)

Construct a BounceFromRod object.

Parameters
  • state: Simulation state
  • name: Name of the bouncer
  • radius: The radius of the capsules attached to each segment
  • varBounceKernel: How are the particles bounced

void setup(ObjectVector *ov)

Ask ov to keep its old motions accross persistently.

This method will die if ov is not of type RodObjectVector.

void setPrerequisites(ParticleVector *pv)

Will ask pv to keep its old positions (not in persistent mode)

std::vector<std::string> getChannelsToBeExchanged() const

Return
list of channel names of the attached object needed before bouncing

std::vector<std::string> getChannelsToBeSentBack() const

Return
list of channel names of the attached object that need to be exchanged after bouncing

Utilities

class BounceBack

Implements bounce-back reflection.

This bounce kernel reverses the velocity of the particle in the frame of reference of the surface.

Public Functions

void update(std::mt19937 &rng)

Does nothing, just to be consistent with the inteface.

real3 newVelocity(real3 uOld, real3 uWall, real3 n, real mass) const

Compute the velocity after bouncing the particle.

The velocity is chosen such that the average between the new and old velocities of the particle is that of the wall surface at the collision point.

Parameters
  • uOld: The velocity of the particle at the previous time step.
  • uWall: The velocity of the wall surface at the collision point.
  • n: The wall surface normal at the collision point.
  • mass: The particle mass.

class BounceMaxwell

Implements reflection with Maxwell scattering.

This bounce kernel sets the particle velocity to the surface one with an additional random term drawed from Maxwell distribution. The kernel tries to make the random term have a positive dot product with the surface normal.

Public Functions

BounceMaxwell(real kBT)

Construct a BounceMaxwell object.

Parameters
  • kBT: The temperature used to sample the velocity

void update(std::mt19937 &rng)

Update internal state, must be called before use.

Parameters
  • rng: A random number generator.

real3 newVelocity(real3 uOld, real3 uWall, real3 n, real mass) const

Compute the velocity after bouncing the particle.

The velocity is chosen such that it is sampled by a Maxwelian distribution and has a positive dot product with the wall surface normal.

Parameters
  • uOld: The velocity of the particle at the previous time step.
  • uWall: The velocity of the wall surface at the collision point.
  • n: The wall surface normal at the collision point.
  • mass: The particle mass.