Molecular Dynamics Simulation  1.0
Public Member Functions | Protected Attributes | List of all members
SimulationInterceptor Class Referenceabstract

#include <SimulationInterceptor.h>

Inheritance diagram for SimulationInterceptor:
Inheritance graph
Collaboration diagram for SimulationInterceptor:
Collaboration graph

Public Member Functions

virtual ~SimulationInterceptor ()=default
 Destroy the Simulation Interceptor object. More...
 
virtual void onSimulationStart (Simulation &simulation)=0
 Called before the simulation loop starts. More...
 
virtual void operator() (size_t iteration, Simulation &simulation)=0
 Called on every nth iteration. This function should perform the desired action. More...
 
virtual void onSimulationEnd (size_t iteration, Simulation &simulation)=0
 Called after the simulation loop ends. More...
 
void notify (size_t iteration, Simulation &simulation)
 This function is called by the simulation loop on every iteration. Whenever the iteration is a multiple of every_nth_iteration, the operator() function is called. More...
 
virtual operator std::string () const =0
 The string representation of this interceptor. More...
 
virtual void logSummary (int depth) const =0
 Summary of the interceptor. More...
 

Protected Attributes

size_t every_nth_iteration = 1
 

Detailed Description

Definition at line 8 of file SimulationInterceptor.h.

Constructor & Destructor Documentation

◆ ~SimulationInterceptor()

virtual SimulationInterceptor::~SimulationInterceptor ( )
virtualdefault

Destroy the Simulation Interceptor object.

Member Function Documentation

◆ logSummary()

virtual void SimulationInterceptor::logSummary ( int  depth) const
pure virtual

◆ notify()

void SimulationInterceptor::notify ( size_t  iteration,
Simulation simulation 
)
inline

This function is called by the simulation loop on every iteration. Whenever the iteration is a multiple of every_nth_iteration, the operator() function is called.

Parameters
iterationThe current iteration
simulationThe simulation object
See also
operator()

Definition at line 50 of file SimulationInterceptor.h.

50  {
51  if (iteration % every_nth_iteration == 0) {
52  (*this)(iteration, simulation);
53  }
54  }

◆ onSimulationEnd()

virtual void SimulationInterceptor::onSimulationEnd ( size_t  iteration,
Simulation simulation 
)
pure virtual

Called after the simulation loop ends.

Parameters
iterationThe current iteration
simulationThe simulation object

Implemented in VelocityProfileInterceptor, ThermostatInterceptor, TemperatureSensorInterceptor, RadialDistributionFunctionInterceptor, ProgressBarInterceptor, ParticleUpdateCounterInterceptor, FrameWriterInterceptor, and DiffusionFunctionInterceptor.

◆ onSimulationStart()

virtual void SimulationInterceptor::onSimulationStart ( Simulation simulation)
pure virtual

◆ operator std::string()

virtual SimulationInterceptor::operator std::string ( ) const
explicitpure virtual

The string representation of this interceptor.

Returns
std::string

This is used to write the final summary of the Interceptors to the console.

Implemented in VelocityProfileInterceptor, ThermostatInterceptor, TemperatureSensorInterceptor, RadialDistributionFunctionInterceptor, ProgressBarInterceptor, ParticleUpdateCounterInterceptor, FrameWriterInterceptor, and DiffusionFunctionInterceptor.

◆ operator()()

virtual void SimulationInterceptor::operator() ( size_t  iteration,
Simulation simulation 
)
pure virtual

Called on every nth iteration. This function should perform the desired action.

Parameters
iterationThe current iteration
simulationThe simulation object

Implemented in VelocityProfileInterceptor, ThermostatInterceptor, TemperatureSensorInterceptor, RadialDistributionFunctionInterceptor, ProgressBarInterceptor, ParticleUpdateCounterInterceptor, FrameWriterInterceptor, and DiffusionFunctionInterceptor.

Member Data Documentation

◆ every_nth_iteration

size_t SimulationInterceptor::every_nth_iteration = 1
protected

Definition at line 74 of file SimulationInterceptor.h.


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