Simpatico  v1.10
SystemInterface.h
1 #ifndef MCMD_SYSTEM_INTERFACE_H
2 #define MCMD_SYSTEM_INTERFACE_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 <mcMd/simulation/System.h> // parent (provides typedefs)
12 #include <mcMd/chemistry/Molecule.h> // member template parameter
13 #include <simp/boundary/Boundary.h> // member
14 
15 #include <util/containers/DArray.h> // member template
16 #include <util/containers/PArrayIterator.h> // inline function begin()
17 #include <util/global.h>
18 
19 #include <iostream>
20 #include <string>
21 
22 namespace McMd
23 {
24 
25  class Simulation;
26 
27  using namespace Util;
28  using namespace Simp;
29 
44  {
45 
46  public:
47 
53  SystemInterface(System& parent);
54 
58  virtual ~SystemInterface();
59 
63  System& system() const;
64 
65  protected:
66 
68 
69 
71  Boundary& boundary() const;
72 
74  Simulation& simulation() const;
75 
77 
79 
86  int nMolecule(int speciesId) const;
87 
91  int nAtom() const;
92 
96  bool isEmpty() const;
97 
104  void begin(int speciesId, System::MoleculeIterator& iterator);
105 
112  void begin(int speciesId, System::ConstMoleculeIterator& iterator) const;
113 
115 
117 
118  #ifdef SIMP_BOND
119  bool hasBonds() const;
121  #endif
122 
123  #ifdef SIMP_ANGLE
124  bool hasAngles() const;
126  #endif
127 
128  #ifdef SIMP_DIHEDRAL
129  bool hasDihedrals() const;
131  #endif
132 
133  #ifdef MCMD_LINK
134  bool hasLinks() const;
136  #endif
137 
138  #ifdef SIMP_EXTERNAL
139  bool hasExternal() const;
141  #endif
142 
143  #ifdef SIMP_TETHER
144  bool hasTethers() const;
146  #endif
147 
149 
150  private:
151 
153  Simulation* simulationPtr_;
154 
156  System* systemPtr_;
157 
164  DArray< System::MoleculeSet >* moleculeSetsPtr_;
165 
167  Boundary* boundaryPtr_;
168 
169  #ifdef SIMP_BOND
170  // Does a bond potential exist?
171  bool hasBonds_;
172  #endif
173 
174  #ifdef SIMP_ANGLE
175  // Does an angle potential exist?
176  bool hasAngles_;
177  #endif
178 
179  #ifdef SIMP_DIHEDRAL
180  // Does a dihedral potential exist?
181  bool hasDihedrals_;
182  #endif
183 
184  #ifdef MCMD_LINK
185  // Does a link potential exist?
186  bool hasLinks_;
187  #endif
188 
189  #ifdef SIMP_EXTERNAL
190  // Does an external potential exist?
191  bool hasExternal_;
192  #endif
193 
194  #ifdef SIMP_TETHER
195  // Does a tether potential exist?
196  bool hasTethers_;
197  #endif
198 
199  };
200 
201  // Inline functions
202 
203  /*
204  * Get the parent Simulation by reference.
205  */
207  {
208  assert(simulationPtr_);
209  return *simulationPtr_;
210  }
211 
212  /*
213  * Get the parent System by reference.
214  */
216  {
217  assert(systemPtr_);
218  return *systemPtr_;
219  }
220 
221  /*
222  * Get the Boundary by reference.
223  */
225  {
226  assert(boundaryPtr_);
227  return *boundaryPtr_;
228  }
229 
230  /*
231  * Get the number of molecules of a specific Species in this SystemInterface.
232  */
233  inline int SystemInterface::nMolecule(int speciesId) const
234  {
235  assert(moleculeSetsPtr_);
236  return (*moleculeSetsPtr_)[speciesId].size();
237  }
238 
239  /*
240  * Initialize a System::MoleculeIterator for molecules of one Species.
241  */
242  inline void
244  {
245  assert(moleculeSetsPtr_);
246  (*moleculeSetsPtr_)[speciesId].begin(iterator);
247  }
248 
249  /*
250  * Initialize a System::ConstMoleculeIterator for molecules of one Species.
251  */
252  inline void
254  {
255  assert(moleculeSetsPtr_);
256  (*moleculeSetsPtr_)[speciesId].begin(iterator);
257  }
258 
259  #ifdef SIMP_BOND
260  /*
261  * Does a bond potential exist?
262  */
263  inline bool SystemInterface::hasBonds() const
264  { return hasBonds_; }
265  #endif
266 
267  #ifdef SIMP_ANGLE
268  /*
269  * Does an angle potential exist?
270  */
271  inline bool SystemInterface::hasAngles() const
272  { return hasAngles_; }
273  #endif
274 
275  #ifdef SIMP_DIHEDRAL
276  inline bool SystemInterface::hasDihedrals() const
278  { return hasDihedrals_; }
279  #endif
280 
281  #ifdef MCMD_LINK
282  inline bool SystemInterface::hasLinks() const
284  { return hasLinks_; }
285  #endif
286 
287  #ifdef SIMP_EXTERNAL
288  inline bool SystemInterface::hasExternal() const
290  { return hasExternal_; }
291  #endif
292 
293  #ifdef SIMP_TETHER
294  inline bool SystemInterface::hasTethers() const
296  { return hasTethers_; }
297  #endif
298 
299 }
300 #endif
bool hasExternal() const
Does an external potential exist?
bool hasLinks() const
Does a link potential exist?
An interface to a System.
bool hasBonds() const
Does a bond potential exist?
An orthorhombic periodic unit cell.
bool hasAngles() const
Does an angle potential exist?
A set of interacting Molecules enclosed by a Boundary.
Definition: System.h:115
Forward iterator for a PArray.
File containing preprocessor macros for error handling.
Classes used by all simpatico molecular simulations.
The main object in a simulation, which coordinates others.
bool hasDihedrals() const
Does a dihedral potential exist?
Simulation & simulation() const
Get the parent Simulation by reference.
Utility classes for scientific computation.
Definition: accumulators.mod:1
Forward iterator for a PArray.
Definition: ArraySet.h:19
void begin(int speciesId, System::MoleculeIterator &iterator)
Initialize an iterator for molecules of one species in this SystemInterface.
Dynamically allocatable contiguous array template.
Definition: DArray.h:31
int nMolecule(int speciesId) const
Get the number of molecules of one Species in this SystemInterface.
Single-processor Monte Carlo (MC) and molecular dynamics (MD).
Boundary & boundary() const
Get the Boundary by reference.
System & system() const
Get the parent System by reference.