Gromacs  2026.0-dev-20250116-fa3fd9d
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
List of all members | Public Member Functions | Static Public Member Functions
gmx::StopHandler Class Referencefinal

#include <gromacs/mdlib/stophandler.h>

Description

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, int nstList)
 StopHandler constructor (will be called by StopHandlerBuilder) More...
 
void setSignal () const
 Decides whether a stop signal shall be sent. More...
 
bool stoppingAfterCurrentStep (const int64_t step) const
 Decides whether the simulation shall be stopped after the current step. More...
 

Static Public Member Functions

static bool isSuitableStopStep (const int64_t step, const int nstList)
 Return whether the step is a multiple of nstList or nstList==0.
 

Constructor & Destructor Documentation

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

StopHandler constructor (will be called by StopHandlerBuilder)

Parameters
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
nstListThe pairlist update interval in steps, 0 is never update

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
inline

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 ( const int64_t  step) const
inline

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: