Simpatico  v1.10
mcMd/analyzers/trajectory/TrajectoryWriter.h
1 #ifndef MCMD_CONFIG_WRITER_H
2 #define MCMD_CONFIG_WRITER_H
3 
4 /*
5 * Simpatico - Simulation Package for Polymeric and Molecular Liquids
6 *
7 * Copyright 2010 - 2014, The Regents of the University of Minnesota
8 * Distributed under the terms of the GNU General Public License.
9 */
10 
11 #include <mcMd/analyzers/SystemAnalyzer.h>
12 #include <mcMd/simulation/System.h>
13 
14 namespace McMd
15 {
16 
17  using namespace Util;
18 
24  class TrajectoryWriter : public SystemAnalyzer<System>
25  {
26 
27  public:
28 
34  TrajectoryWriter(System& system);
35 
40  {}
41 
47  virtual void readParameters(std::istream& in);
48 
54  virtual void save(Serializable::OArchive& ar);
55 
61  virtual void loadParameters(Serializable::IArchive& ar);
62 
69  template <class Archive>
70  void serialize(Archive& ar, const unsigned int version);
71 
75  virtual void setup();
76 
82  virtual void sample(long iStep);
83 
87  virtual void output();
88 
89  protected:
90 
91  // Output file stream
92  std::ofstream outputFile_;
93 
95  long nSample_;
96 
99 
100  protected:
101 
105  bool isBinary() const;
106 
114  virtual void writeHeader(std::ofstream& out)
115  {};
116 
123  virtual void writeFrame(std::ofstream& out, long iStep) = 0;
124 
126  bool isBinary_;
127 
128  };
129 
130  /*
131  * Serialize to/from an archive.
132  */
133  template <class Archive>
134  void TrajectoryWriter::serialize(Archive& ar, const unsigned int version)
135  {
136  Analyzer::serialize(ar, version);
137  ar & nSample_;
138  }
139 
140 }
141 #endif
Periodically write snapshots to a lammps dump (i.e., trajectory) file.
A set of interacting Molecules enclosed by a Boundary.
Definition: System.h:115
void serialize(Archive &ar, const unsigned int version)
Serialize to/from an archive.
virtual void writeHeader(std::ofstream &out)
Write data that should appear once, at beginning of the file.
void serialize(Archive &ar, PairSelector &selector, const unsigned int version)
Serialize a PairSelector.
Definition: PairSelector.h:167
Saving / output archive for binary ostream.
void serialize(Archive &ar, const unsigned int version)
Serialize to/from an archive.
Utility classes for scientific computation.
Definition: accumulators.mod:1
Template for Analyzer associated with one System.
Saving archive for binary istream.
Single-processor Monte Carlo (MC) and molecular dynamics (MD).
long nSample_
Number of configurations dumped thus far (first dump is zero).
bool isBinary_
Is the trajectory file a binary file?
long isInitialized_
Has readParam been called?