Gromacs
2026.0-dev-20250116-fa3fd9d
|
#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, 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 . | |
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)
signal | Non-null pointer to a signal used for reading and writing of signals |
simulationShareState | Whether this signal needs to be shared across multiple simulations |
stopConditions | Vector of callback functions setting the signal |
nstList | The 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.
|
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.
|
inline |
Decides whether the simulation shall be stopped after the current step.
The simulation is stopped after the current step if