Interface

class Plugin

Base class to represent a Plugin.

Plugins are functionalities that are not required to run a simulation. Each plugin must have a SimulationPlugin derived class, and, optionally, a compatible PostprocessPlugin derived class. The latter is used to perform potentially expensive work asynchronously while the simulation is running (e.g. I/O).

Subclassed by mirheo::PostprocessPlugin, mirheo::SimulationPlugin

Public Functions

Plugin()

default constructor

virtual void handshake()

Used to communicate initial information between a SimulationPlugin and a PostprocessPlugin.

Does not do anything by default.

void setTag(int tag)

Set the tag that will be used internally to communicate between SimulationPlugin and a PostprocessPlugin.

Must be called before any other methods.

Parameters
  • tag: The tag, must be unique (all plugins using the same intercommunicator must have a different tag, see _setup())

class SimulationPlugin : public mirheo::Plugin, public mirheo::MirSimulationObject

Base class for the simulation side of a Plugin.

A simulation plugin is able to modify the state of the simulation. Depending on its action, one of the “hooks” (e.g. beforeCellLists()) must be overriden (by default they do not do anything).

If a plugin needs reference to objects held by the simulation, it must be saved in its internal structure at setup() time.

Subclassed by mirheo::AddForcePlugin, mirheo::AddFourRollMillForcePlugin, mirheo::AddTorquePlugin, mirheo::AnchorParticlesPlugin, mirheo::Average3D, mirheo::BerendsenThermostatPlugin, mirheo::DensityControlPlugin, mirheo::ExchangePVSFluxPlanePlugin, mirheo::ExternalMagneticTorquePlugin, mirheo::ForceSaverPlugin, mirheo::ImposeProfilePlugin, mirheo::ImposeVelocityPlugin, mirheo::MagneticDipoleInteractionsPlugin, mirheo::MembraneExtraForcePlugin, mirheo::MeshPlugin, mirheo::MsdPlugin, mirheo::ObjStatsPlugin, mirheo::OutletPlugin, mirheo::ParticleChannelAveragerPlugin, mirheo::ParticleChannelSaverPlugin, mirheo::ParticleCheckerPlugin, mirheo::ParticleDisplacementPlugin, mirheo::ParticleDragPlugin, mirheo::ParticleSenderPlugin, mirheo::PinObjectPlugin, mirheo::PinRodExtremityPlugin, mirheo::RdfPlugin, mirheo::SimulationStats, mirheo::SimulationVelocityControl, mirheo::TemperaturizePlugin, mirheo::VacfPlugin, mirheo::VelocityInletPlugin, mirheo::VirialPressurePlugin, mirheo::WallForceCollectorPlugin, mirheo::WallRepulsionPlugin, mirheo::XYZPlugin

Public Functions

SimulationPlugin(const MirState *state, const std::string &name)

Construct a SimulationPlugin.

Parameters
  • state: The global simulation state
  • name: the name of the plugin (must be the same as that of the postprocess plugin)

virtual bool needPostproc() = 0

Return
true if this plugin needs a postprocess side; false otherwise.
Note
The plugin can have a postprocess side but not need it.

virtual void setup(Simulation *simulation, const MPI_Comm &comm, const MPI_Comm &interComm)

setup the internal state of the SimulationPlugin.

This method must be called before any of the hooks of the plugin. This is the place to fetch reference to objects held by the simulation.

Parameters
  • simulation: The simulation to which the plugin is registered.
  • comm: Contains all simulation ranks
  • interComm: used to communicate with the postprocess ranks

virtual void beforeCellLists(cudaStream_t stream)

hook before building the cell lists

virtual void beforeForces(cudaStream_t stream)

hook before computing the forces and after the cell lists are created

virtual void beforeIntegration(cudaStream_t stream)

hook before integrating the particle vectors but after the forces are computed

virtual void afterIntegration(cudaStream_t stream)

hook after the ObjectVector objects are integrated but before redistribution and bounce back

virtual void beforeParticleDistribution(cudaStream_t stream)

hook before redistributing ParticleVector objects and after bounce

virtual void serializeAndSend(cudaStream_t stream)

Pack and send data to the postprocess rank.

Happens between beforeForces() and beforeIntegration().

Note
This may happens while computing the forces.

virtual void finalize()

hook that happens once at the end of the simulation loop

class PostprocessPlugin : public mirheo::Plugin, public mirheo::MirObject

Base class for the postprocess side of a Plugin.

A postprocess plugin can only receive information from its associated SimulationPlugin. The use of such class is to wait for a message and then deserialize it (where additional actions may be performed, such as I/O).

Subclassed by mirheo::AnchorParticlesStatsPlugin, mirheo::MeshDumper, mirheo::MsdDumper, mirheo::ObjStatsDumper, mirheo::ParticleDumperPlugin, mirheo::PostprocessDensityControl, mirheo::PostprocessStats, mirheo::PostprocessVelocityControl, mirheo::RdfDump, mirheo::ReportPinObjectPlugin, mirheo::UniformCartesianDumper, mirheo::VacfDumper, mirheo::VirialPressureDumper, mirheo::WallForceDumperPlugin, mirheo::XYZDumper

Public Functions

PostprocessPlugin(const std::string &name)

Construct a PostprocessPlugin.

Parameters
  • name: the name of the plugin (must be the same as that of the associated simulation plugin)

virtual void setup(const MPI_Comm &comm, const MPI_Comm &interComm)

setup the internal state of the PostprocessPlugin.

This method must be called before any other function call.

Parameters
  • comm: Contains all postprocess ranks
  • interComm: used to communicate with the simulation ranks

void recv()

Post an asynchronous receive request to get a message from the associated SimulationPlugin.

MPI_Request waitData()

wait for the completion of the asynchronous receive request. Must be called after recv() and before deserialize().

virtual void deserialize() = 0

Perform the action implemented by the plugin using the data received from the SimulationPlugin.