Simpatico  v1.10
tools/storage/AtomStorage.h
1 #ifndef TOOLS_ATOM_STORAGE_H
2 #define TOOLS_ATOM_STORAGE_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/chemistry/Atom.h> // member (template argument)
12 #include <tools/chemistry/Group.h> // member (template argument)
13 
14 #include <util/containers/DArray.h> // member (template)
15 #include <util/containers/DSArray.h> // member (template)
16 #include <util/containers/ArrayIterator.h> // inline function
17 
18 
19 namespace Tools
20 {
21 
22  using namespace Util;
23 
30  {
31 
32  public:
33 
35 
39  AtomStorage();
40 
44  ~AtomStorage();
45 
51  void allocate(int capacity);
52 
58  Atom* newPtr();
59 
63  void add();
64 
68  void clear();
69 
77  Atom* ptr(int id);
78 
82  void begin(Iterator& iter);
83 
87  int capacity() const;
88 
92  int size() const;
93 
94  private:
95 
97  DSArray<Atom> atoms_;
98 
100  DArray<Atom*> atomPtrs_;
101 
103  Atom* newPtr_;
104 
105  };
106 
107  // inline functions
108 
109  /*
110  * Return number of atoms.
111  */
112  inline int AtomStorage::size() const
113  { return atoms_.size(); }
114 
115  /*
116  * Get atom capacity (maximum id + 1).
117  */
118  inline
120  { return atoms_.capacity(); }
121 
122  /*
123  * Return a pointer to an atom with a specific id.
124  */
125  inline Atom* AtomStorage::ptr(int id)
126  { return atomPtrs_[id]; }
127 
128  /*
129  * Initialize an iterator for atoms.
130  */
131  inline
133  { atoms_.begin(iter); }
134 
135 }
136 #endif
Container for a set of atoms.
int size() const
Get number of atoms.
Atom * ptr(int id)
Get a pointer to an atom by global id.
int capacity() const
Get atom capacity (maximum id + 1).
Utility classes for scientific computation.
Definition: accumulators.mod:1
Forward iterator for an Array or a C array.
Definition: ArrayIterator.h:39
Single-processor classes for pre- and post-processing MD trajectories.
A point particle in an MD simulation.
void begin(Iterator &iter)
Initialize an iterator for atoms.
Dynamically allocatable contiguous array template.
Definition: DArray.h:31
Dynamically allocated array with variable logical size.
Definition: DSArray.h:30