Simpatico  v1.10
Integrator.h
1 #ifndef DDMD_INTEGRATOR_H
2 #define DDMD_INTEGRATOR_H
3 
4 #include <util/param/ParamComposite.h> // base class
5 #include <ddMd/simulation/SimulationAccess.h> // base class
6 #include <ddMd/misc/DdTimer.h> // member
7 
8 #include <iostream>
9 
10 /*
11 * Simpatico - Simulation Package for Polymeric and Molecular Liquids
12 *
13 * Copyright 2010 - 2017, The Regents of the University of Minnesota
14 * Distributed under the terms of the GNU General Public License.
15 */
16 
17 namespace DdMd
18 {
19 
20  using namespace Util;
21 
22  class Simulation;
23 
30  {
31 
32  public:
33 
37  Integrator(Simulation& simulation);
38 
42  ~Integrator();
43 
49  void readParameters(std::istream& in);
50 
56  void loadParameters(Serializable::IArchive& ar);
57 
63  void save(Serializable::OArchive& ar);
64 
70  virtual void run(int nStep) = 0;
71 
81  virtual void clear();
82 
83  /*
84  * Reduce timing statistics data from all domain processors.
85  *
86  * This method must be called simultaneously on all processors. It should
87  * always be called immediately before calling outputStatistics on the
88  * master processor.
89  *
90  * On return, the value of each of the time intervals stored by the
91  * internal DdMd::Timer is replaced by its average over all processors.
92  * It does not reset the timer to zero, and may thus be called more
93  * than once while contining to accumulate statistics.
94  */
95  void computeStatistics();
96 
104  virtual void outputStatistics(std::ostream& out);
105 
109  double time() const;
110 
114  int iStep() const;
115 
116  protected:
117 
119  enum TimeId {ANALYZER, INTEGRATE1, CHECK, ALLREDUCE, TRANSFORM_F,
120  EXCHANGE, CELLLIST, TRANSFORM_R, PAIRLIST, UPDATE,
121  ZERO_FORCE, PAIR_FORCE, BOND_FORCE, ANGLE_FORCE,
122  DIHEDRAL_FORCE, EXTERNAL_FORCE, INTEGRATE2,
123  MODIFIER, DEBUG, SIGNAL, MISC, NTime};
124 
132  virtual void initDynamicalState();
133 
141  virtual void setup() = 0;
142 
148  void setIsSetup();
149 
153  bool isSetup() const;
154 
161  void setupAtoms();
162 
171  void computeForces();
172 
181  void computeForcesAndVirial();
182 
189  bool isExchangeNeeded(double skin);
190 
194  const std::string& saveFileName() const;
195 
199  int saveInterval() const;
200 
201  /*
202  * Return the timer by reference.
203  */
204  DdTimer& timer();
205 
207  int iStep_;
208 
209  private:
210 
211  // Performance timer
212  DdTimer timer_;
213 
214  // Has setup been called at least once?
215  bool isSetup_;
216 
218  std::string saveFileName_;
219 
221  int saveInterval_;
222 
223  };
224 
225  /*
226  * Get current step index.
227  */
228  inline int Integrator::iStep() const
229  { return iStep_ ; }
230 
231  /*
232  * Has setup been called at least once?
233  */
234  inline bool Integrator::isSetup() const
235  { return isSetup_ ; }
236 
237  /*
238  * Mark as having been setup at least once.
239  */
241  { isSetup_ = true; }
242 
243  /*
244  * Set any internal dynamical state variables to default initial values.
245  *
246  * Empty default implementation. This virtual method is called by clear().
247  */
249 
250  /*
251  * Return the timer by reference.
252  */
253  inline DdTimer& Integrator::timer()
254  { return timer_; }
255 
256  /*
257  * Get restart file base name.
258  */
259  inline const std::string& Integrator::saveFileName() const
260  { return saveFileName_; }
261 
262  /*
263  * Get interval for writing a restart file.
264  */
265  inline int Integrator::saveInterval() const
266  { return saveInterval_; }
267 
268 }
269 #endif
int iStep_
Current step number.
Definition: Integrator.h:207
Provides access to members of Simulation object.
virtual void initDynamicalState()
Set any internal dynamical to default initial values.
Definition: Integrator.h:248
void setIsSetup()
Mark the integrator as having been setup at least once.
Definition: Integrator.h:240
int iStep() const
Get current time step index.
Definition: Integrator.h:228
Parallel domain decomposition (DD) MD simulation.
Main object for a domain-decomposition MD simulation.
Saving / output archive for binary ostream.
An Integrator numerically integrates the equations of motion.
Definition: Integrator.h:29
Utility classes for scientific computation.
Definition: accumulators.mod:1
int saveInterval() const
Get interval for writing a restart file.
Definition: Integrator.h:265
bool isSetup() const
Has the setup() method been called at least once previously?
Definition: Integrator.h:234
Saving archive for binary istream.
TimeId
Timestamps for loop timing.
Definition: Integrator.h:119
Class for measuring time intervals.
Definition: DdTimer.h:24
An object that can read multiple parameters from file.
const std::string & saveFileName() const
Get restart file base name.
Definition: Integrator.h:259