Simpatico  v1.10
tools/analyzers/TrajectoryWriter.h
1 #ifndef TOOLS_TRAJECTORY_WRITER_H
2 #define TOOLS_TRAJECTORY_WRITER_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 <tools/analyzers/Analyzer.h> // base class
12 #include <simp/boundary/Boundary.h> // typedef
13 
14 namespace Tools
15 {
16 
17  class Processor;
18  class Configuration;
19  class AtomStorage;
20  template <int N> class GroupStorage;
21 
22  using namespace Util;
23  using namespace Simp;
24 
30  class TrajectoryWriter : public Analyzer
31  {
32 
33  public:
34 
41  TrajectoryWriter(Processor& processor, bool isBinary);
42 
50  TrajectoryWriter(Configuration& configuration, FileMaster& fileMaster,
51  bool isBinary);
52 
57  {}
58 
64  virtual void readParameters(std::istream& in);
65 
66  #if 0
67 
72  virtual void loadParameters(Serializable::IArchive &ar);
73 
79  virtual void save(Serializable::OArchive &ar);
80  #endif
81 
85  virtual void setup();
86 
92  virtual void sample(long iStep);
93 
97  virtual void clear();
98 
102  virtual void output();
103 
104  protected:
105 
109  bool isBinary() const;
110 
118  virtual void writeHeader(std::ofstream& out)
119  {};
120 
129  virtual void writeFrame(std::ofstream& out, long iStep) = 0;
130 
134  Boundary& boundary();
135 
139  AtomStorage& atoms();
140 
141  #ifdef SIMP_BOND
142 
145  GroupStorage<2>& bonds();
146  #endif
147 
148  #ifdef SIMP_ANGLE
149 
152  GroupStorage<3>& angles();
153  #endif
154 
155  #ifdef SIMP_DIHEDRAL
156 
159  GroupStorage<4>& dihedrals();
160  #endif
161 
162  private:
163 
164  // Output file stream
165  std::ofstream outputFile_;
166 
168  long nSample_;
169 
171  long isInitialized_;
172 
174  bool isBinary_;
175 
176  // Pointers to associated Boundary.
177  Boundary* boundaryPtr_;
178 
179  // Pointers to storage objects.
180  AtomStorage* atomStoragePtr_;
181  #ifdef SIMP_BOND
182  GroupStorage<2>* bondStoragePtr_;
183  #endif
184  #ifdef SIMP_ANGLE
185  GroupStorage<3>* angleStoragePtr_;
186  #endif
187  #ifdef SIMP_DIHEDRAL
188  GroupStorage<4>* dihedralStoragePtr_;
189  #endif
190 
191  };
192 
193  // Inline method definitions
194 
198  inline bool TrajectoryWriter::isBinary() const
199  { return isBinary_; }
200 
202  { return *boundaryPtr_; }
203 
205  { return *atomStoragePtr_; }
206 
207  #ifdef SIMP_BOND
209  { return *bondStoragePtr_; }
210  #endif
211 
212  #ifdef SIMP_ANGLE
214  { return *angleStoragePtr_; }
215  #endif
216 
217  #ifdef SIMP_DIHEDRAL
219  { return *dihedralStoragePtr_; }
220  #endif
221 
222 }
223 #endif
A container for Group<N> objects.
A post-processor for analyzing outputs of MD simulations.
Definition: Processor.h:30
Container for a set of atoms.
An orthorhombic periodic unit cell.
Abstract base for periodic output and/or analysis actions.
Classes used by all simpatico molecular simulations.
An instantaneous molecular dynamics configuration.
Definition: Configuration.h:40
Saving / output archive for binary ostream.
GroupStorage< 4 > & dihedrals()
Get dihedral storage by reference.
Boundary & boundary()
Get Boundary by reference.
virtual void writeHeader(std::ofstream &out)
Write data that should appear once, at beginning of the file.
Utility classes for scientific computation.
Definition: accumulators.mod:1
GroupStorage< 3 > & angles()
Get angle storage by reference.
Single-processor classes for pre- and post-processing MD trajectories.
A FileMaster manages input and output files for a simulation.
Definition: FileMaster.h:142
Saving archive for binary istream.
GroupStorage< 2 > & bonds()
Get bond storage by reference.
Based class for classes that write trajectories to a single file.
AtomStorage & atoms()
Get AtomStorage by reference.
bool isBinary() const
Is the file format binary (true) or text (false)?