Simpatico  v1.10
mcMd/chemistry/Atom.h
1 #ifndef MCMD_ATOM_H
2 #define MCMD_ATOM_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 "Mask.h"
12 #include <util/space/Vector.h>
13 #ifdef MCMD_SHIFT
14 #include <util/space/IntVector.h>
15 #endif
16 #include <util/global.h>
17 
18 namespace Util {
19  template <class Data> class RArray;
20 }
21 
22 namespace McMd
23 {
24 
25  using namespace Util;
26 
27  class Molecule;
28 
79  class Atom
80  {
81 
82  public:
83 
84  // Non-static Methods
85 
86  // Private default and copy constructors.
87 
88  // Default destructor.
89 
91 
92 
98  void setMolecule(Molecule& molecule);
99 
105  void setTypeId(int typeId);
106 
108 
110 
112  int id() const;
113 
115  int indexInMolecule() const;
116 
118  int typeId() const;
119 
121  Molecule& molecule() const;
122 
124  const Vector& position() const;
125 
127  Vector& position();
128 
130  Mask& mask();
131 
133  const Mask& mask() const;
134 
136  Vector& velocity();
137 
139  const Vector& velocity() const;
140 
142  Vector& force();
143 
145  const Vector& force() const;
146 
148  bool isActive() const;
149 
150  #ifdef MCMD_SHIFT
151  IntVector& shift();
153 
155  const IntVector& shift() const;
156  #endif
157 
159 
161 
165  static void initStatic();
166 
182  static void allocate(int capacity, RArray<Atom>& atoms);
183 
189  static void deallocate();
190 
194  static int capacity();
195 
197 
198  private:
199 
200  // Static members
201 
203  static const int NullIndex = -1;
204 
206  static Atom* atoms_;
207 
209  static Mask* masks_;
210 
212  static Molecule** moleculePtrs_;
213 
215  static Vector* forces_;
216 
218  static Vector* velocities_;
219 
221  static bool* isActives_;
222 
223  #ifdef MCMD_SHIFT
224  static IntVector* shifts_;
226  #endif
227 
229  static int capacity_;
230 
231  // Non-static member variables
232 
234  Vector position_;
235 
237  int typeId_;
238 
240  int id_;
241 
242  // Private non-static member functions
243 
245  Atom();
246 
248  Atom(const Atom& other);
249 
255  void setIsActive(bool isActive);
256 
257  // friends:
258 
259  friend class Activate;
260 
261  };
262 
263  // Inline pubic member functions
264 
265  // Set type index for Atom.
266  inline void Atom:: setTypeId(int typeId)
267  { typeId_ = typeId; }
268 
269  // Get global id for Atom.
270  inline int Atom::id() const
271  { return id_; }
272 
273  // Get type Id.
274  inline int Atom::typeId() const
275  { return typeId_; }
276 
277  // Get const reference to position.
278  inline const Vector& Atom::position() const
279  { return position_; }
280 
281  // Get reference to position.
282  inline Vector& Atom::position()
283  { return position_; }
284 
285  // Get const reference to velocity.
286  inline const Vector& Atom::velocity() const
287  { return velocities_[id_]; }
288 
289  // Get reference to velocity.
290  inline Vector& Atom::velocity()
291  { return velocities_[id_]; }
292 
293  // Get const reference to force.
294  inline const Vector& Atom::force() const
295  { return forces_[id_]; }
296 
297  // Get reference to force.
298  inline Vector& Atom::force()
299  { return forces_[id_]; }
300 
301  // Get the associated mask.
302  inline Mask& Atom::mask()
303  { return masks_[id_]; }
304 
305  // Get a const reference to the mask.
306  inline const Mask& Atom::mask() const
307  { return masks_[id_]; }
308 
309  // Get a reference to the parent Molecule.
310  inline Molecule& Atom::molecule() const
311  { return *moleculePtrs_[id_]; }
312 
313  // Get the isActive flag (true == active).
314  inline bool Atom::isActive() const
315  { return isActives_[id_]; }
316 
317  #ifdef MCMD_SHIFT
318  // Get the shift IntVector by reference.
319  inline IntVector& Atom::shift()
320  { return shifts_[id_]; }
321 
322  // Get the shift IntVector by const reference.
323  inline const IntVector& Atom::shift() const
324  { return shifts_[id_]; }
325  #endif
326 
327  // Inline private member functions
328 
329  // Set the atom as active (true) or inactive (false) (private)
330  inline void Atom::setIsActive(bool isActive)
331  { isActives_[id_] = isActive; }
332 
333 }
334 #endif
A Vector is a Cartesian vector.
Definition: Vector.h:75
Set of Atoms for which pair interactions with a target Atom are "masked".
Static member functions to de-active and re-active atoms.
Definition: Activate.h:41
File containing preprocessor macros for error handling.
void initStatic()
Guarantee initialization of all static class members in Util namespace.
A point particle within a Molecule.
Utility classes for scientific computation.
Definition: accumulators.mod:1
Single-processor Monte Carlo (MC) and molecular dynamics (MD).
An IntVector is an integer Cartesian vector.
Definition: IntVector.h:73
An Array that acts as a reference to another Array or C array.
Definition: RArray.h:46
A physical molecule (a set of covalently bonded Atoms).