Gromacs  2023.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
List of all members | Public Member Functions
gmx::StopHandler Class Referencefinal

#include <gromacs/mdlib/stophandler.h>


Class handling the stop signal.

Loops over the registered stop conditions and sets a signal if requested (currently only done by main rank). All ranks receive the stop signal and set the respective flag. The functions are implemented within this header file to avoid leaving the translation unit unnecessarily.

Public Member Functions

 StopHandler (compat::not_null< SimulationSignal * > signal, bool simulationShareState, std::vector< std::function< StopSignal()>> stopConditions, bool neverUpdateNeighborList)
 StopHandler constructor (will be called by StopHandlerBuilder) More...
void setSignal () const
 Decides whether a stop signal shall be sent. More...
bool stoppingAfterCurrentStep (bool bNS) const
 Decides whether the simulation shall be stopped after the current step. More...

Constructor & Destructor Documentation

gmx::StopHandler::StopHandler ( compat::not_null< SimulationSignal * >  signal,
bool  simulationShareState,
std::vector< std::function< StopSignal()>>  stopConditions,
bool  neverUpdateNeighborList 

StopHandler constructor (will be called by StopHandlerBuilder)

signalNon-null pointer to a signal used for reading and writing of signals
simulationShareStateWhether this signal needs to be shared across multiple simulations
stopConditionsVector of callback functions setting the signal
neverUpdateNeighborListWhether simulation keeps same neighbor list forever

Note: As the StopHandler does not work without this signal, it keeps a non-const reference to it as a member variable.

Member Function Documentation

void gmx::StopHandler::setSignal ( ) const

Decides whether a stop signal shall be sent.

Loops over the stopCondition vector passed at build time (consisting of conditions registered with StopHandlerBuilder, and conditions built by StopHandlerBuilder by default), and sets any signal obtained. Returns as soon as a StopSignal::stopImmediately signal was obtained, or after checking all registered stop conditions.

bool gmx::StopHandler::stoppingAfterCurrentStep ( bool  bNS) const

Decides whether the simulation shall be stopped after the current step.

The simulation is stopped after the current step if

  • the signal for immediate stop was received, or
  • the signal for stop at the next neighbor-searching step was received, and the current step is a neighbor-searching step.

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