ls1-MarDyn
ls1-MarDyn molecular dynamics code
Public Member Functions | List of all members
PluginBase Class Referenceabstract

The PluginBase class provides the interface for any kind of output/plugin classes - called "(output) plugins". More...

#include <PluginBase.h>

Inheritance diagram for PluginBase:
COMaligner CavityWriter CheckpointWriter CommunicationPartnerWriter DecompWriter DirectedPM DistControl DriftCtrl Dropaccelerator Dropaligner EnergyLogWriter ExamplePlugin ExtractPhase FixRegion FlopRateWriter GammaWriter HaloParticleWriter InMemoryCheckpointing KDTreePrinter LoadImbalanceThroughSleepPlugin LoadbalanceWriter MPICheckpointWriter MPI_IOCheckpointWriter MaxCheck MaxWriter MettDeamon MettDeamonFeedrateDirector Mirror MirrorSystem MmpldWriter MmspdBinWriter MmspdWriter ODF Permittivity PosNegComp PovWriter RDF RegionSampling ResultWriter SpatialProfile SysMonOutput TestPlugin TimerWriter VISWriter VTKGridWriter VTKMoleculeWriter VectorizationTuner WallPotential XyzWriter

Public Member Functions

 PluginBase ()
 Subclasses should use their constructur to pass parameters (e.g. filenames)
 
virtual void init (ParticleContainer *particleContainer, DomainDecompBase *domainDecomp, Domain *domain)=0
 Method init will be called at the begin of the simulation. More...
 
virtual void readXML (XMLfileUnits &xmlconfig)=0
 Method readXML will be called once for each plugin section in the input file. More...
 
virtual void beforeEventNewTimestep (ParticleContainer *particleContainer, DomainDecompBase *domainDecomp, unsigned long simstep)
 Method will be called first thing in a new timestep. More...
 
virtual void beforeForces (ParticleContainer *particleContainer, DomainDecompBase *domainDecomp, unsigned long simstep)
 Method beforeForces will be called before forcefields have been applied no alterations w.r.t. Forces shall be made here. More...
 
virtual void siteWiseForces (ParticleContainer *particleContainer, DomainDecompBase *domainDecomp, unsigned long simstep)
 Method siteWiseForces will be called before forcefields have been applied alterations to sitewise forces and fullMolecule forces can be made here. More...
 
virtual void afterForces (ParticleContainer *particleContainer, DomainDecompBase *domainDecomp, unsigned long simstep)
 Method afterForces will be called after forcefields have been applied no sitewise Forces can be applied here. More...
 
virtual void endStep (ParticleContainer *particleContainer, DomainDecompBase *domainDecomp, Domain *domain, unsigned long simstep)=0
 Method endStep will be called at the end of each time step. More...
 
virtual void finish (ParticleContainer *particleContainer, DomainDecompBase *domainDecomp, Domain *domain)=0
 Method finish will be called at the end of the simulation. More...
 
virtual std::string getPluginName ()=0
 return the name of the plugin More...
 
virtual void registerCallbacks (std::map< std::string, FunctionWrapper > &callbackMap)
 
virtual void accessAllCallbacks (const std::map< std::string, FunctionWrapper > &callbackMap)
 

Detailed Description

The PluginBase class provides the interface for any kind of output/plugin classes - called "(output) plugins".

Todo:
Mark all parameters as const: output plugins should not modify the state of the simulation.
Todo:
get rid of the domain parameter
Todo:
clean up all classes implementing this interface

There are a lot of different things that one might want to write out during a simulation, e.g. thermodynamic values, graphical information, time measurements, ... For all cases in which this output happens regularly at the end of each time step the PluginBase class provides a common interface. The interface provides access to the most important data: the particle container and the domain decomposition.

Of course, several plugins plugins will be needed in some cases. So the idea is, that all available plugins are registered in the PluginFactory and initialized in the Simulation at runtime as requested by the input file. The plugin will then be called at the respective points in the simulation automatically.

Therefore, each plugin has to implement at least the following five methods:

Member Function Documentation

◆ accessAllCallbacks()

virtual void PluginBase::accessAllCallbacks ( const std::map< std::string, FunctionWrapper > &  callbackMap)
inlinevirtual

Save callbacks from the callbackMap locally. This allows a plugin to call functions from other plugins. Example syntax:

  • store a function that returns an unsigned long:
    std::function<unsigned long(void)> myFunction;
    myFunction = callbackMap.at("getSomeLocalValue").get<unsigned long>();
  • store a function that calls some function of another plugin with an input value (int):
    std::function<void(int)> myFunction;
    myFunction = callbackMap.at("doSth").get<void, int>();
    Parameters
    callbackMapGet callbacks from this map.

Reimplemented in SpatialProfile.

◆ afterForces()

virtual void PluginBase::afterForces ( ParticleContainer particleContainer,
DomainDecompBase domainDecomp,
unsigned long  simstep 
)
inlinevirtual

◆ beforeEventNewTimestep()

virtual void PluginBase::beforeEventNewTimestep ( ParticleContainer particleContainer,
DomainDecompBase domainDecomp,
unsigned long  simstep 
)
inlinevirtual

Method will be called first thing in a new timestep.

Reimplemented in ExamplePlugin, InMemoryCheckpointing, TestPlugin, CavityWriter, MaxCheck, MirrorSystem, DistControl, and MettDeamon.

◆ beforeForces()

virtual void PluginBase::beforeForces ( ParticleContainer particleContainer,
DomainDecompBase domainDecomp,
unsigned long  simstep 
)
inlinevirtual

Method beforeForces will be called before forcefields have been applied no alterations w.r.t. Forces shall be made here.

Reimplemented in ExamplePlugin, InMemoryCheckpointing, TestPlugin, COMaligner, DirectedPM, Dropaligner, FixRegion, Mirror, MirrorSystem, DistControl, DriftCtrl, ExtractPhase, MettDeamon, MettDeamonFeedrateDirector, and PosNegComp.

◆ endStep()

virtual void PluginBase::endStep ( ParticleContainer particleContainer,
DomainDecompBase domainDecomp,
Domain domain,
unsigned long  simstep 
)
pure virtual

Method endStep will be called at the end of each time step.

This method will be called every time step passing the simstep as an additional parameter. It can be used e.g. to write per time step data to a file or perform additional computations.

Parameters
particleContainerparticle container storing the (local) molecules
domainDecompdomain decomposition in use
domain

Implemented in VectorizationTuner, CheckpointWriter, DecompWriter, EnergyLogWriter, FlopRateWriter, GammaWriter, MaxWriter, MmpldWriter, MmspdBinWriter, MmspdWriter, MPI_IOCheckpointWriter, MPICheckpointWriter, PovWriter, ResultWriter, SysMonOutput, VISWriter, VTKGridWriter, VTKMoleculeWriter, ExamplePlugin, InMemoryCheckpointing, TestPlugin, CavityWriter, CommunicationPartnerWriter, HaloParticleWriter, KDTreePrinter, LoadbalanceWriter, ODF, TimerWriter, XyzWriter, COMaligner, DirectedPM, Dropaccelerator, Dropaligner, FixRegion, LoadImbalanceThroughSleepPlugin, MaxCheck, Mirror, MirrorSystem, DistControl, DriftCtrl, ExtractPhase, MettDeamon, MettDeamonFeedrateDirector, PosNegComp, RegionSampling, Permittivity, SpatialProfile, WallPotential, and RDF.

◆ finish()

virtual void PluginBase::finish ( ParticleContainer particleContainer,
DomainDecompBase domainDecomp,
Domain domain 
)
pure virtual

Method finish will be called at the end of the simulation.

This method will be called once at the end of the simulation. It can be used e.g. to closing output files or writing final statistics.

Parameters
particleContainerparticle container storing the (local) molecules
domainDecompdomain decomposition in use
domain

Implemented in VectorizationTuner, CavityWriter, CheckpointWriter, DecompWriter, EnergyLogWriter, FlopRateWriter, GammaWriter, MaxWriter, MmpldWriter, MmspdBinWriter, MmspdWriter, MPI_IOCheckpointWriter, MPICheckpointWriter, PovWriter, RDF, ResultWriter, SysMonOutput, VISWriter, VTKGridWriter, VTKMoleculeWriter, ExamplePlugin, InMemoryCheckpointing, TestPlugin, CommunicationPartnerWriter, HaloParticleWriter, KDTreePrinter, LoadbalanceWriter, ODF, TimerWriter, XyzWriter, COMaligner, DirectedPM, Dropaccelerator, Dropaligner, FixRegion, LoadImbalanceThroughSleepPlugin, MaxCheck, Mirror, MirrorSystem, DistControl, DriftCtrl, ExtractPhase, MettDeamon, MettDeamonFeedrateDirector, PosNegComp, RegionSampling, Permittivity, SpatialProfile, and WallPotential.

◆ getPluginName()

virtual std::string PluginBase::getPluginName ( )
pure virtual

◆ init()

virtual void PluginBase::init ( ParticleContainer particleContainer,
DomainDecompBase domainDecomp,
Domain domain 
)
pure virtual

Method init will be called at the begin of the simulation.

This method will be called once at the begin of the simulation just right before the main time step loop. It can be used e.g. to open output files or initialize statistics.

Parameters
particleContainerparticle container storing the (local) molecules
domainDecompdomain decomposition in use
domain

Implemented in CheckpointWriter, DecompWriter, EnergyLogWriter, FlopRateWriter, GammaWriter, MaxWriter, MmpldWriter, MmspdBinWriter, MmspdWriter, MPI_IOCheckpointWriter, MPICheckpointWriter, PovWriter, RDF, ResultWriter, SysMonOutput, VISWriter, VTKGridWriter, VTKMoleculeWriter, ExamplePlugin, InMemoryCheckpointing, TestPlugin, CavityWriter, CommunicationPartnerWriter, HaloParticleWriter, KDTreePrinter, LoadbalanceWriter, ODF, TimerWriter, XyzWriter, COMaligner, DirectedPM, Dropaccelerator, Dropaligner, FixRegion, LoadImbalanceThroughSleepPlugin, MaxCheck, Mirror, MirrorSystem, DistControl, DriftCtrl, ExtractPhase, MettDeamon, MettDeamonFeedrateDirector, PosNegComp, RegionSampling, Permittivity, SpatialProfile, VectorizationTuner, and WallPotential.

◆ readXML()

virtual void PluginBase::readXML ( XMLfileUnits xmlconfig)
pure virtual

Method readXML will be called once for each plugin section in the input file.

This method can be used to read in parameters from the corresponding plugin section in the xml config file. The method will be called once after an instance of the plugin is created.

Note
The same plugins may be specified multiple times in the xml config file. It is the responsibility of the plugin to handle this case in a propper way.

The following xml object structure will be provided to the plugin:

<plugin name="plugin name">
<!-- options for the specific plugin -->
</plugin>
Parameters
xmlconfigsection of the xml file

Implemented in FlopRateWriter, CheckpointWriter, DecompWriter, EnergyLogWriter, GammaWriter, MaxWriter, MmpldWriter, MmspdBinWriter, MmspdWriter, MPI_IOCheckpointWriter, MPICheckpointWriter, PovWriter, RDF, ResultWriter, SysMonOutput, VISWriter, VTKGridWriter, VTKMoleculeWriter, ExamplePlugin, InMemoryCheckpointing, TestPlugin, CavityWriter, CommunicationPartnerWriter, HaloParticleWriter, KDTreePrinter, LoadbalanceWriter, ODF, TimerWriter, XyzWriter, COMaligner, DirectedPM, Dropaccelerator, Dropaligner, FixRegion, LoadImbalanceThroughSleepPlugin, MaxCheck, Mirror, MirrorSystem, DistControl, DriftCtrl, ExtractPhase, MettDeamon, MettDeamonFeedrateDirector, PosNegComp, RegionSampling, Permittivity, SpatialProfile, VectorizationTuner, and WallPotential.

◆ registerCallbacks()

virtual void PluginBase::registerCallbacks ( std::map< std::string, FunctionWrapper > &  callbackMap)
inlinevirtual

Register callbacks to callbackMap. This allows to make functions of a plugin accessible to other plugins. New callbacks should be added to callbackMap. Example syntax:

  • register a function that returns a local value:
    callbackMap["getMyLocalValue"] = [this] { return _myLocalValue; };
  • register a function that calls a local function and returns its return value:
    callbackMap["callMyFunct"] = [this] { return myFunct(); };
    Parameters
    callbackMapAdd callbacks to this map.

Reimplemented in FixRegion.

◆ siteWiseForces()

virtual void PluginBase::siteWiseForces ( ParticleContainer particleContainer,
DomainDecompBase domainDecomp,
unsigned long  simstep 
)
inlinevirtual

Method siteWiseForces will be called before forcefields have been applied alterations to sitewise forces and fullMolecule forces can be made here.

Reimplemented in MaxCheck, DistControl, MettDeamon, and WallPotential.


The documentation for this class was generated from the following file: