Simpatico  v1.10
MdConfigIo.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 "MdConfigIo.h"
9 #include <mcMd/chemistry/Atom.h>
10 #include <util/space/Dimension.h>
11 #include <util/format/Int.h>
12 
13 namespace McMd
14 {
15 
16  using namespace Util;
17 
18  /*
19  * Constructor.
20  */
22  : McMdConfigIo(system)
23  {}
24 
25  /*
26  * Destructor.
27  */
29  {}
30 
31  /*
32  * Read data for one atom.
33  */
34  void MdConfigIo::readAtom(std::istream &in, Atom& atom)
35  {
36  in >> atom.position();
37  in >> atom.velocity();
38  #ifdef MCMD_SHIFT
39  in >> atom.shift();
40  boundary().shift(atom.position(), atom.shift());
41  #else
42  boundary().shift(atom.position());
43  #endif
44  }
45 
46  /*
47  * Write data for one atom.
48  */
49  void MdConfigIo::writeAtom(std::ostream &out, const Atom& atom)
50  {
51  out << atom.position() << std::endl;
52  out << atom.velocity();
53  #ifdef MCMD_SHIFT
54  for (int i = 0; i < Dimension; ++i) {
55  out << Int(atom.shift()[i], 3);
56  }
57  #endif
58  out << std::endl;
59  }
60 
61 }
Boundary & boundary() const
Get the Boundary.
const int Dimension
Dimensionality of space.
Definition: Dimension.h:19
Vector & velocity()
Get atomic velocity Vector by reference.
A set of interacting Molecules enclosed by a Boundary.
Definition: System.h:115
virtual ~MdConfigIo()
Destructor.
Definition: MdConfigIo.cpp:28
virtual void writeAtom(std::ostream &out, const Atom &atom)
Write data for one atom.
Definition: MdConfigIo.cpp:49
Base class for default Mc and Md configIos.
Definition: McMdConfigIo.h:31
A point particle within a Molecule.
Utility classes for scientific computation.
Definition: accumulators.mod:1
virtual void readAtom(std::istream &out, Atom &atom)
Read data for one atom.
Definition: MdConfigIo.cpp:34
Wrapper for an int, for formatted ostream output.
Definition: Int.h:36
void shift(Vector &r) const
Shift Cartesian Vector r to its primary image.
Single-processor Monte Carlo (MC) and molecular dynamics (MD).
const Vector & position() const
Get the position Vector by const reference.
MdConfigIo(System &system)
Constructor.
Definition: MdConfigIo.cpp:21