NAMD
Public Member Functions | Public Attributes | List of all members
CheckStep Struct Reference

Public Member Functions

int check (int step)
 
int init (int initstep, int initperiod, int delta=0)
 
 CheckStep ()
 

Public Attributes

int period
 period for some step dependent event (e.g. stepsPerCycle) More...
 
int nextstep
 next step value More...
 

Detailed Description

Check the current step number for some periodic event. The idea is to store extra integers to avoid mod operations. Specifically, replace calls like: ! (step % stepsPerCycle) with: stepsPerCycle.check(step) or: stepsPerCycle.init(firstTimestep, simParams->stepsPerCycle) when initializing.

Set up the struct by calling init with initial step and period. Then call once per time step loop in place of mod operation.

Definition at line 142 of file Sequencer.C.

Constructor & Destructor Documentation

◆ CheckStep()

CheckStep::CheckStep ( )
inline

Definition at line 167 of file Sequencer.C.

167 : period(0), nextstep(0) { }
int period
period for some step dependent event (e.g. stepsPerCycle)
Definition: Sequencer.C:143
int nextstep
next step value
Definition: Sequencer.C:144

Member Function Documentation

◆ check()

int CheckStep::check ( int  step)
inline

Check step to see if current step is special for this event. Returns nonzero for true, zero for false. Side effect: might increment nextstep to the next event step.

Definition at line 149 of file Sequencer.C.

References nextstep, and period.

Referenced by Sequencer::integrate_SOA().

149  {
150  if (step == nextstep) return( nextstep += period, 1 );
151  else return 0;
152  }
int period
period for some step dependent event (e.g. stepsPerCycle)
Definition: Sequencer.C:143
int nextstep
next step value
Definition: Sequencer.C:144

◆ init()

int CheckStep::init ( int  initstep,
int  initperiod,
int  delta = 0 
)
inline

Initialize the step checking, e.g., with simParams->firsttimestep and simParams->stepsPerCycle Special case set delta for off boundary shift, needed for half-step-cycle Langevin piston. Returns nonzero if initial step is divisible by period.

Definition at line 159 of file Sequencer.C.

References nextstep, and period.

Referenced by Sequencer::integrate_SOA().

159  {
160  period = initperiod;
161  nextstep = initstep - (initstep % period) - (delta % period);
162  while (nextstep <= initstep) nextstep += period;
163  // returns true if initstep is divisible by period
164  return (initstep + period == nextstep);
165  }
int period
period for some step dependent event (e.g. stepsPerCycle)
Definition: Sequencer.C:143
int nextstep
next step value
Definition: Sequencer.C:144

Member Data Documentation

◆ nextstep

int CheckStep::nextstep

next step value

Definition at line 144 of file Sequencer.C.

Referenced by check(), and init().

◆ period

int CheckStep::period

period for some step dependent event (e.g. stepsPerCycle)

Definition at line 143 of file Sequencer.C.

Referenced by check(), init(), and Sequencer::integrate_SOA().


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