Simpatico  v1.10
mcMd/analyzers/AnalyzerManager.cpp
1 /*
2 * Simpatico - Simulation Package for Polymeric and Molecular Liquids
3 *
4 * Copyright 2010 - 2017, The Regents of the University of Minnesota
5 * Distributed under the terms of the GNU General Public License.
6 */
7 
8 #include "AnalyzerManager.h"
9 #include "Analyzer.h"
10 #include <util/archives/Serializable_includes.h>
11 
12 namespace McMd
13 {
14 
15  using namespace Util;
16 
17  /*
18  * Constructor.
19  */
21  : Manager<Analyzer>()
22  { setClassName("AnalyzerManager"); }
23 
24  /*
25  * Destructor.
26  */
28  {}
29 
30  /*
31  * Read parameter file.
32  *
33  * \param in input parameter file stream.
34  */
35  void AnalyzerManager::readParameters(std::istream &in)
36  {
37  read<long>(in,"baseInterval", Analyzer::baseInterval);
39  }
40 
41  /*
42  * Call initialize method of each analyzer.
43  */
45  {
46  for (int i = 0; i < size(); ++i) {
47  (*this)[i].setup();
48  }
49  }
50 
51  /*
52  * Call sample method of each analyzer.
53  */
54  void AnalyzerManager::sample(long iStep)
55  {
57  UTIL_CHECK(iStep % Analyzer::baseInterval == 0);
58  for (int i = 0; i < size(); ++i) {
59  (*this)[i].sample(iStep);
60  }
61  }
62 
63  /*
64  * Call output method of each analyzer.
65  */
67  {
68  for (int i = 0; i < size(); ++i) {
69  (*this)[i].output();
70  }
71  }
72 
73  /*
74  * Read instructions for creating objects from file.
75  */
77  {
78  loadParameter<long>(ar, "baseInterval", Analyzer::baseInterval);
80  }
81 
82  /*
83  * Read instructions for creating objects from file.
84  */
86  {
89  }
90 
91 }
virtual void loadParameters(Serializable::IArchive &ar)
Load a set of objects to an output archive.
Definition: Manager.h:411
virtual void save(Serializable::OArchive &ar)
Save a set of objects to an output archive.
Definition: Manager.h:448
static long baseInterval
The interval for an Analyzer must be a multiple of baseInterval.
virtual void readParameters(std::istream &in)
Read parameter file.
virtual void save(Serializable::OArchive &ar)
Save state to an archive.
Saving / output archive for binary ostream.
void output()
Call output method of each analyzer.
Template container for pointers to objects with a common base class.
Definition: Manager.h:38
Abstract base for periodic output and/or analysis actions.
Utility classes for scientific computation.
Definition: accumulators.mod:1
virtual void readParameters(std::istream &in)
Read child blocks, return when closing bracket encountered.
Definition: Manager.h:356
Saving archive for binary istream.
Single-processor Monte Carlo (MC) and molecular dynamics (MD).
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
Definition: global.h:68
void setClassName(const char *className)
Set class name string.
virtual void loadParameters(Serializable::IArchive &ar)
Load state from an archive.
void setup()
Call initialize method of each Analyzer.
int size() const
Get logical size.
void sample(long iStep)
Call sample method of each Analyzer.