Skip to content

Interactor

Raul edited this page Mar 10, 2021 · 12 revisions

Interactor is one of the base modules of UAMMD[1]. See Interactor.cuh

An Interactor has access to the system state and computes something according to it.
This something can be the force, energy or some arbitrary computation according to some kind of interaction.
If you are looking to set up some interaction look in the list of available Interactors to see if it already exists.

The Interactor interface exposes the following functions:

  • void sumForce(cudaStream_t st);
    • Computes the forces on each particle according to the interaction
  • void sumEnergy();
    • Computes the energy for each particle according to the interaction
  • void sumForceEnergy(cudaStream_t st);
    • Computes both forces and energies at the same time
  • void compute(cudaStream_t st);
    • Performs an arbitrary user-defined computation following the interactions rules, see the wiki page of a given module to know how to use the compute function.

After calling sumForce, sumEnergy, etc, on a given Interactor the relevant particle properties will be updated and can be accesed via ParticleData[5].

The CUDA stream argument can be ignored and the default stream used instead. However, launching GPU kernels in a different stream to the one provided can be dangerous if some particle property is modified. In that case there is no guarantee that no other Interactor is also modifying that property and a race condition might occur.

For users

This is just a base class that cannot be used by its own. Childs of this class are instanced and added to an integrator to configure a simulation. See the wiki page of a particular Interactor or usage instructions.

For developers

In order to create a new Interactor module, just write a class that inherits from it and overrides its virtual functions. You will then have access to all its members, and will be able to use it as an Interactor. See PairForces[4] for an example of an Interactor.

An Interactor is expected to write to the pd->getForce() array when sumForce is called. Always adding to the previous contents.
Similarly sumEnergy must sum to pd->getEnergy().
See [5] on how to access particle properties through ParticleData.


[1] https://github.com/RaulPPelaez/UAMMD/wiki/Base-Modules
[2] https://github.com/RaulPPelaez/UAMMD/wiki/Simulation-File
[3] https://en.wikipedia.org/wiki/Smart_pointer#shared_ptr_and_weak_ptr
[4] https://github.com/RaulPPelaez/UAMMD/wiki/Pair-Forces
[5] https://github.com/RaulPPelaez/UAMMD/wiki/ParticleData









Clone this wiki locally