Simpatico  v1.10
ddMd/chemistry/AtomType.h
1 #ifndef DDMD_ATOM_TYPE_H
2 #define DDMD_ATOM_TYPE_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/global.h>
12 #include <string>
13 #include <iostream>
14 
15 namespace DdMd
16 {
17 
26  class AtomType
27  {
28 
29  public:
30 
34  AtomType();
35 
37 
38 
44  void setId(int Id);
45 
51  void setMass(double mass);
52 
58  void setName(std::string name);
59 
61 
63 
65  double mass() const;
66 
68  const std::string& name() const;
69 
71  int id() const;
72 
74 
75  #ifdef UTIL_MPI
76 
79  static void initStatic();
80  #endif
81 
82  private:
83 
85  double mass_;
86 
88  std::string name_;
89 
91  int id_;
92 
93  //friends:
94 
95  friend std::istream& operator>>(std::istream& in, AtomType &atomType);
96  friend std::ostream& operator<<(std::ostream& out, const AtomType &atomType);
97 
98  template <class Archive> friend
99  void serialize(Archive& ar, AtomType& atomType, const unsigned int version);
100 
101  };
102 
103  // Inline methods
104 
105  // Set the mass.
106  inline void AtomType::setMass(double mass)
107  { mass_ = mass; }
108 
109  // Set the name string.
110  inline void AtomType::setName(std::string name)
111  { name_ = name; }
112 
113  // Get the mass.
114  inline double AtomType::mass() const
115  { return mass_; }
116 
117  // Get the name string.
118  inline const std::string& AtomType::name() const
119  { return name_; }
120 
121  // Get the type id.
122  inline int AtomType::id() const
123  { return id_; }
124 
125  // Friend operator declarations
126 
138  std::istream& operator>>(std::istream& in, AtomType &atomType);
139 
151  std::ostream& operator<<(std::ostream& out, const AtomType &atomType);
152 
160  template <class Archive>
161  void serialize(Archive& ar, AtomType& atomType, const unsigned int version)
162  {
163  ar & atomType.name_;
164  ar & atomType.mass_;
165  }
166 
167 }
168 
169 #ifdef UTIL_MPI
170 #include <util/mpi/MpiSendRecv.h>
171 #include <util/mpi/MpiTraits.h>
172 #include <mpi.h>
173 
174 namespace Util
175 {
176 
177  template <>
178  void send<DdMd::AtomType>(MPI::Comm& comm, DdMd::AtomType& data, int dest, int tag);
179 
180  template <>
181  void recv<DdMd::AtomType>(MPI::Comm& comm, DdMd::AtomType& data, int source, int tag);
182 
183  template <>
184  void bcast<DdMd::AtomType>(MPI::Intracomm& comm, DdMd::AtomType& data, int root);
185 
189  template <>
191  {
192  public:
193  static MPI::Datatype type;
194  static bool hasType;
195  };
196 
197 }
198 #endif
199 
200 #endif
friend void serialize(Archive &ar, AtomType &atomType, const unsigned int version)
Serialize an AtomType.
static void initStatic()
Call this to guarantee initialization of static data.
const std::string & name() const
Get the name string.
double mass() const
Get the mass.
File containing preprocessor macros for error handling.
Parallel domain decomposition (DD) MD simulation.
friend std::istream & operator>>(std::istream &in, AtomType &atomType)
istream extractor (>>) for an AtomType.
Utility classes for scientific computation.
Definition: accumulators.mod:1
Default MpiTraits class.
Definition: MpiTraits.h:39
static MPI::Datatype type
Initialize MPI Datatype.
This file contains templates for global functions send<T>, recv<T> and bcast<T>.
friend std::ostream & operator<<(std::ostream &out, const AtomType &atomType)
ostream inserter (<<) for an AtomType.
void setName(std::string name)
Set the name string.
Descriptor for a type of Atom.
void setId(int Id)
Set the type index.
int id() const
Get the index.
void setMass(double mass)
Set the mass.