Simpatico  v1.10
ddMd/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 "AnalyzerFactory.h"
10 
11 namespace DdMd
12 {
13 
14  using namespace Util;
15 
16  /*
17  * Constructor.
18  */
20  : Manager<Analyzer>(),
21  simulationPtr_(&simulation)
22  { setClassName("AnalyzerManager"); }
23 
24  /*
25  * Destructor.
26  */
28  {}
29 
30  /*
31  * Read parameter block (without begin and end).
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  * Load internal state from an archive.
43  */
45  {
46  loadParameter<long>(ar, "baseInterval", Analyzer::baseInterval);
48  }
49 
50  /*
51  * Save internal state to an archive.
52  */
54  {
57  }
58 
59  /*
60  * Call setup method of each analyzer.
61  */
63  {
64  for (int i = 0; i < size(); ++i) {
65  (*this)[i].setup();
66  }
67  }
68 
69  /*
70  * Call clear method of each analyzer.
71  */
73  {
74  for (int i = 0; i < size(); ++i) {
75  (*this)[i].clear();
76  }
77  }
78 
79  /*
80  * Call sample method of each analyzer.
81  */
82  void AnalyzerManager::sample(long iStep)
83  {
84  if (Analyzer::baseInterval > 0) {
85  if (iStep % Analyzer::baseInterval == 0) {
86  for (int i=0; i < size(); ++i) {
87  if ((*this)[i].isAtInterval(iStep)) {
88  (*this)[i].sample(iStep);
89  }
90  }
91  }
92  }
93  }
94 
95  /*
96  * Call output method of each analyzer.
97  */
99  {
100  for (int i=0; i < size(); ++i) {
101  (*this)[i].output();
102  }
103  }
104 
105  /*
106  * Return pointer to default factory.
107  */
109  {
110  return new AnalyzerFactory(*simulationPtr_);
111  }
112 
113 }
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
Abstract base for periodic output and/or analysis actions.
Factory for DdMd::Analyzer objects.
virtual void loadParameters(Serializable::IArchive &ar)
Load internal state from an archive.
void setup()
Call setup method of each Analyzer.
AnalyzerManager(Simulation &simulation)
Constructor.
virtual void readParameters(std::istream &in)
Read parameter block (without begin and end).
Parallel domain decomposition (DD) MD simulation.
virtual void save(Serializable::OArchive &ar)
Save internal state to an archive.
Main object for a domain-decomposition MD simulation.
static long baseInterval
The interval for an Analyzer must be a multiple of baseInterval.
Saving / output archive for binary ostream.
Template container for pointers to objects with a common base class.
Definition: Manager.h:38
void sample(long iStep)
Call sample method of each Analyzer, if scheduled.
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
virtual Factory< Analyzer > * newDefaultFactory() const
Return pointer to a new default factory.
void output()
Call output method of each analyzer.
Saving archive for binary istream.
void clear()
Call clear method of each Analyzer.
void setClassName(const char *className)
Set class name string.
int size() const
Get logical size.