Simpatico  v1.10
tools/analyzers/Analyzer.h
1 #ifndef TOOLS_ANALYZER_H
2 #define TOOLS_ANALYZER_H
3 
4 /*
5 * Simpatico - Simulation Package for Polymeric and Molecular Liquids
6 *
7 * Copyright 2010 - 2017, The Regents of the University of Minnesota
8 * Distributed under the terms of the GNU General Public License.
9 */
10 
11 #include <util/param/ParamComposite.h> // base class
12 #include <util/misc/FileMaster.h> // member variable
13 
14 #include <string>
15 #include <iostream>
16 #include <fstream>
17 
18 namespace Util { class FileMaster; }
19 
20 namespace Tools
21 {
22 
23  using namespace Util;
24  class Configuration;
25  class Processor;
26 
45  class Analyzer : public ParamComposite
46  {
47 
48  public:
49 
50  // Non-static Methods
51 
57  Analyzer(Configuration& configuration);
58 
64  Analyzer(Processor& processor);
65 
72  Analyzer(Configuration& configuration, FileMaster& fileMaster);
73 
77  virtual ~Analyzer();
78 
88  virtual void setup()
89  {}
90 
96  virtual void clear()
97  {}
98 
108  virtual void sample(long iStep) = 0;
109 
115  virtual void output()
116  {}
117 
121  int interval() const;
122 
128  bool isAtInterval(long counter) const;
129 
130  // Static members
131 
132  protected:
133 
143  void readInterval(std::istream &in);
144 
150  void readOutputFileName(std::istream &in);
151 
155  Configuration& configuration();
156 
160  FileMaster& fileMaster();
161 
165  const std::string& outputFileName() const;
166 
170  std::string outputFileName(const std::string& suffix) const;
171 
172  private:
173 
175  std::string outputFileName_;
176 
178  Configuration* configurationPtr_;
179 
181  FileMaster* fileMasterPtr_;
182 
184  long interval_;
185 
187  bool ownsFileMaster_;
188 
189  };
190 
191  // Inline methods
192 
193  /*
194  * Return interval value.
195  */
196  inline int Analyzer::interval() const
197  { return interval_; }
198 
199  /*
200  * Return true iff the counter parameter is a multiple of the interval.
201  */
202  inline bool Analyzer::isAtInterval(long counter) const
203  { return (counter%interval_ == 0); }
204 
205  /*
206  * Get the outputFileName string.
207  */
208  inline const std::string& Analyzer::outputFileName() const
209  { return outputFileName_; }
210 
211  /*
212  * Get the parent Configuration by reference.
213  */
214  inline Configuration& Analyzer::configuration()
215  { return *configurationPtr_; }
216 
217 }
218 #endif
A post-processor for analyzing outputs of MD simulations.
Definition: Processor.h:30
Abstract base for periodic output and/or analysis actions.
An instantaneous molecular dynamics configuration.
Definition: Configuration.h:40
Utility classes for scientific computation.
Definition: accumulators.mod:1
Single-processor classes for pre- and post-processing MD trajectories.
A FileMaster manages input and output files for a simulation.
Definition: FileMaster.h:142
virtual void setup()
Setup before configuration.
An object that can read multiple parameters from file.
virtual void clear()
Clear statistical accumulators.
virtual void output()
Output any results at the end of an analysis.