Simpatico  v1.10
getAtomGroups.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 "getAtomGroups.h"
9 #include <mcMd/chemistry/Atom.h>
10 #include <mcMd/chemistry/Molecule.h>
11 
12 namespace McMd
13 {
14 
15  using namespace Util;
16 
17  #ifdef SIMP_BOND
18  /*
19  * Fill an array of pointers to Bonds that contain an Atom.
20  */
21  void getAtomBonds(const Atom& atom, AtomBondArray& groups)
22  {
23  groups.clear();
24  const Molecule& molecule = atom.molecule();
25  if (molecule.nBond()) {
26  const Species& species = molecule.species();
27  const int atomId = int( &atom - &molecule.atom(0) );
28  const Species::AtomBondIdArray groupIds = species.atomBondIds(atomId);
29  const int nGroup = groupIds.size();
30  const Bond* firstPtr = &molecule.bond(0); // first group in molecule
31  for (int i = 0; i < nGroup; ++i) {
32  groups.append(firstPtr + groupIds[i]);
33  }
34  }
35  }
36  #endif
37 
38  #ifdef SIMP_ANGLE
39  /*
40  * Fill an array of pointers to Angle objects that contain an atom.
41  */
42  void getAtomAngles(const Atom& atom, AtomAngleArray& groups)
43  {
44  groups.clear();
45  const Molecule& molecule = atom.molecule();
46  if (molecule.nAngle()) {
47  const Species& species = molecule.species();
48  const int atomId = int( &atom - &molecule.atom(0) );
49  const Species::AtomAngleIdArray groupIds = species.atomAngleIds(atomId);
50  const int nGroup = groupIds.size();
51  const Angle* firstPtr = &molecule.angle(0); // first group in molecule
52  for (int i = 0; i < nGroup; ++i) {
53  groups.append(firstPtr + groupIds[i]);
54  }
55  }
56  }
57  #endif
58 
59  #ifdef SIMP_DIHEDRAL
60  /*
61  * Fill an array of pointers to Dihedrals that contain an Atom.
62  */
63  void getAtomDihedrals(const Atom& atom, AtomDihedralArray& groups)
64  {
65  groups.clear();
66  const Molecule& molecule = atom.molecule();
67  if (molecule.nDihedral()) {
68  const Species& species = molecule.species();
69  const int atomId = int( &atom - &molecule.atom(0) );
70  const Species::AtomDihedralIdArray groupIds = species.atomDihedralIds(atomId);
71  const int nGroup = groupIds.size();
72  const Dihedral* firstPtr = &molecule.dihedral(0); // first group in molecule
73  for (int i = 0; i < nGroup; ++i) {
74  groups.append(firstPtr + groupIds[i]);
75  }
76  }
77  }
78  #endif
79 
80 }
Bond & bond(int localId)
Get a specific Bond in this Molecule by non-const reference.
Molecule & molecule() const
Get the parent Molecule by reference.
const AtomDihedralIdArray & atomDihedralIds(int atomId) const
Get array of ids for dihedrals that contain one Atom.
void clear()
Set logical size to zero.
Definition: FSArray.h:271
int nDihedral() const
Get the number of Dihedrals in this Molecule.
int nAngle() const
Get the number of Angles in this Molecule.
Dihedral & dihedral(int localId)
Get a specific Dihedral in this Molecule by reference.
Species & species() const
Get the molecular Species by reference.
void append(const Data &data)
Append data to the end of the array.
Definition: FSArray.h:258
void getAtomDihedrals(const Atom &atom, AtomDihedralArray &groups)
Fill an array of pointers to Dihedrals that contain an Atom.
A fixed capacity (static) contiguous array with a variable logical size.
Definition: FSArray.h:37
void getAtomAngles(const Atom &atom, AtomAngleArray &groups)
Fill an array of pointers to Angles that contain an Atom.
int nBond() const
Get the number of Bonds in this Molecule.
const AtomAngleIdArray & atomAngleIds(int atomId) const
Get array of ids for angles that contain one Atom.
A point particle within a Molecule.
Utility classes for scientific computation.
Definition: accumulators.mod:1
Single-processor Monte Carlo (MC) and molecular dynamics (MD).
A sequence of NAtom covalently interacting atoms.
const AtomBondIdArray & atomBondIds(int atomId) const
Get array of ids for Bonds that contain one Atom.
const Atom & atom(int localId) const
Get a specific Atom in this Molecule.
A physical molecule (a set of covalently bonded Atoms).
A Species represents a set of chemically similar molecules.
Angle & angle(int localId)
Get a specific Angle in this Molecule by non-const reference.
int size() const
Return logical size of this array (i.e., number of elements).
Definition: FSArray.h:207
void getAtomBonds(const Atom &atom, AtomBondArray &groups)
Fill an array of pointers to Bonds that contain an Atom.