| 1 | tim | 1692 | /* | 
| 2 |  |  | * Copyright (C) 2000-2004  Object Oriented Parallel Simulation Engine (OOPSE) project | 
| 3 |  |  | * | 
| 4 |  |  | * Contact: oopse@oopse.org | 
| 5 |  |  | * | 
| 6 |  |  | * This program is free software; you can redistribute it and/or | 
| 7 |  |  | * modify it under the terms of the GNU Lesser General Public License | 
| 8 |  |  | * as published by the Free Software Foundation; either version 2.1 | 
| 9 |  |  | * of the License, or (at your option) any later version. | 
| 10 |  |  | * All we ask is that proper credit is given for our work, which includes | 
| 11 |  |  | * - but is not limited to - adding the above copyright notice to the beginning | 
| 12 |  |  | * of your source code files, and to any copyright notice that you may distribute | 
| 13 |  |  | * with programs based on this work. | 
| 14 |  |  | * | 
| 15 |  |  | * This program is distributed in the hope that it will be useful, | 
| 16 |  |  | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
| 17 |  |  | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
| 18 |  |  | * GNU Lesser General Public License for more details. | 
| 19 |  |  | * | 
| 20 |  |  | * You should have received a copy of the GNU Lesser General Public License | 
| 21 |  |  | * along with this program; if not, write to the Free Software | 
| 22 |  |  | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. | 
| 23 |  |  | * | 
| 24 |  |  | */ | 
| 25 | gezelter | 1490 |  | 
| 26 | tim | 1692 | /** | 
| 27 |  |  | * @file Molecule.hpp | 
| 28 |  |  | * @author    tlin | 
| 29 |  |  | * @date  10/25/2004 | 
| 30 |  |  | * @version 1.0 | 
| 31 |  |  | */ | 
| 32 |  |  |  | 
| 33 |  |  | #ifndef PRIMITIVES_MOLECULE_HPP | 
| 34 |  |  | #define PRIMITIVES_MOLECULE_HPP | 
| 35 | gezelter | 1490 | #include <vector> | 
| 36 | tim | 1692 | #include <iostream> | 
| 37 | gezelter | 1490 |  | 
| 38 | tim | 1692 | #include "math/Vector3.hpp" | 
| 39 | tim | 1492 | #include "primitives/Atom.hpp" | 
| 40 |  |  | #include "primitives/RigidBody.hpp" | 
| 41 | tim | 1701 | //#include "primitives/Bond.hpp" | 
| 42 |  |  | //#include "primitives/Bend.hpp" | 
| 43 |  |  | //#include "primitives/Torsion.hpp" | 
| 44 |  |  | #include "primitives/SRI.hpp" | 
| 45 | tim | 1695 | #include "primitives/CutoffGroup.hpp" | 
| 46 | gezelter | 1490 |  | 
| 47 | tim | 1692 | namespace oopse{ | 
| 48 | gezelter | 1490 |  | 
| 49 | tim | 1701 | class Constraint; | 
| 50 |  |  |  | 
| 51 | tim | 1692 | /** | 
| 52 |  |  | * @class Molecule Molecule.hpp "primitives/Molecule.hpp" | 
| 53 |  |  | * @brief | 
| 54 |  |  | */ | 
| 55 |  |  | class Molecule { | 
| 56 |  |  | public: | 
| 57 | gezelter | 1490 |  | 
| 58 | tim | 1692 | Molecule(); | 
| 59 |  |  | virtual ~Molecule(); | 
| 60 | gezelter | 1490 |  | 
| 61 | tim | 1692 | /** | 
| 62 |  |  | * Returns the global index of this molecule. | 
| 63 |  |  | * @return  the global index of this molecule | 
| 64 |  |  | */ | 
| 65 |  |  | int getGlobalIndex() { | 
| 66 |  |  | return globalIndex_; | 
| 67 |  |  | } | 
| 68 | gezelter | 1490 |  | 
| 69 | tim | 1692 | /** | 
| 70 |  |  | * Sets the global index of this molecule. | 
| 71 |  |  | * @param new global index to be set | 
| 72 |  |  | */ | 
| 73 | tim | 1695 | int setGlobalIndex(int index) { | 
| 74 | tim | 1692 | return globalIndex_; | 
| 75 |  |  | } | 
| 76 |  |  |  | 
| 77 |  |  | /** | 
| 78 |  |  | * Returns the local index of this molecule | 
| 79 |  |  | * @return the local index of this molecule | 
| 80 |  |  | */ | 
| 81 |  |  | int getLocalIndex() { | 
| 82 |  |  | return localIndex_; | 
| 83 |  |  | } | 
| 84 | gezelter | 1490 |  | 
| 85 | tim | 1692 | /** add an atom into this molecule */ | 
| 86 |  |  | void addAtom(Atom* atom); | 
| 87 | gezelter | 1490 |  | 
| 88 | tim | 1692 | /** add a bond into this molecule */ | 
| 89 |  |  | void addBond(Bond* bond); | 
| 90 | gezelter | 1490 |  | 
| 91 | tim | 1692 | /** add a bend into this molecule */ | 
| 92 |  |  | void addBend(Bend* bend); | 
| 93 | gezelter | 1490 |  | 
| 94 | tim | 1692 | /** add a torsion into this molecule*/ | 
| 95 |  |  | void addTorsion(Torsion* torsion); | 
| 96 | gezelter | 1490 |  | 
| 97 | tim | 1692 | /** add a rigidbody into this molecule */ | 
| 98 |  |  | void addRigidBody(RigidBody *rb); | 
| 99 | gezelter | 1490 |  | 
| 100 | tim | 1692 | /** add a cutoff group into this molecule */ | 
| 101 |  |  | void addCutoffGroup(CutoffGroup* cp); | 
| 102 | gezelter | 1490 |  | 
| 103 | tim | 1692 | /** */ | 
| 104 |  |  | void complete(); | 
| 105 | gezelter | 1490 |  | 
| 106 | tim | 1692 | /** Returns the total number of atoms in this molecule */ | 
| 107 |  |  | unsigned int getNAtoms() { | 
| 108 |  |  | return atoms_.size(); | 
| 109 |  |  | } | 
| 110 | gezelter | 1490 |  | 
| 111 | tim | 1692 | /** Returns the total number of bonds in this molecule */ | 
| 112 |  |  | unsigned int getNBonds(){ | 
| 113 |  |  | return bonds_.size(); | 
| 114 |  |  | } | 
| 115 | gezelter | 1490 |  | 
| 116 | tim | 1692 | /** Returns the total number of bends in this molecule */ | 
| 117 |  |  | unsigned int getNBends() { | 
| 118 |  |  | return bends_.size(); | 
| 119 |  |  | } | 
| 120 | gezelter | 1490 |  | 
| 121 | tim | 1692 | /** Returns the total number of torsions in this molecule */ | 
| 122 |  |  | unsigned int getNTorsions() { | 
| 123 |  |  | return torsions_.size(); | 
| 124 |  |  | } | 
| 125 | gezelter | 1490 |  | 
| 126 | tim | 1692 | /** Returns the total number of rigid bodies in this molecule */ | 
| 127 |  |  | unsigned int getNRigidBodies() { | 
| 128 |  |  | return rigidBodies_.size(); | 
| 129 |  |  | } | 
| 130 | gezelter | 1490 |  | 
| 131 | tim | 1692 | /** Returns the total number of integrable objects in this molecule */ | 
| 132 |  |  | unsigned int getNIntegrableObjects() { | 
| 133 |  |  | return integrableObjects_.size(); | 
| 134 |  |  | } | 
| 135 |  |  |  | 
| 136 |  |  | /** Returns the total number of cutoff groups in this molecule */ | 
| 137 |  |  | unsigned int getNCutoffGroups() { | 
| 138 |  |  | return cutoffGroups_.size(); | 
| 139 |  |  | } | 
| 140 |  |  |  | 
| 141 | tim | 1696 | /** Returns the total number of constraints in this molecule */ | 
| 142 |  |  | unsigned int getNConstraints() { | 
| 143 |  |  | return constraints_.size(); | 
| 144 |  |  | } | 
| 145 |  |  |  | 
| 146 | tim | 1692 | /** | 
| 147 |  |  | * Returns the first atom in this molecule and initialize the iterator. | 
| 148 |  |  | * @return the first atom, return NULL if there is not cut off group in this molecule | 
| 149 |  |  | * @param i iteraotr | 
| 150 |  |  | */ | 
| 151 |  |  | Atom* beginAtom(std::vector<Atom*>::iterator& i); | 
| 152 |  |  |  | 
| 153 |  |  | Atom* nextAtom(std::vector<Atom*>::iterator& i); | 
| 154 |  |  |  | 
| 155 |  |  | /** | 
| 156 |  |  | * Returns the first bond in this molecule and initialize the iterator. | 
| 157 |  |  | * @return the first bond, return NULL if there is not cut off group in this molecule | 
| 158 |  |  | * @param i iteraotr | 
| 159 |  |  | */ | 
| 160 |  |  | Bond* beginBond(std::vector<Bond*>::iterator& i); | 
| 161 |  |  |  | 
| 162 |  |  | Bond* nextBond(std::vector<Bond*>::iterator& i); | 
| 163 |  |  |  | 
| 164 |  |  | /** | 
| 165 |  |  | * Returns the first bend in this molecule and initialize the iterator. | 
| 166 |  |  | * @return the first bend, return NULL if there is not cut off group in this molecule | 
| 167 |  |  | * @param i iteraotr | 
| 168 |  |  | */ | 
| 169 |  |  | Bend* beginBend(std::vector<Bend*>::iterator& i); | 
| 170 |  |  |  | 
| 171 |  |  | Bend* nextBend(std::vector<Bend*>::iterator& i); | 
| 172 |  |  |  | 
| 173 |  |  | /** | 
| 174 |  |  | * Returns the first torsion in this molecule and initialize the iterator. | 
| 175 |  |  | * @return the first torsion, return NULL if there is not cut off group in this molecule | 
| 176 |  |  | * @param i iteraotr | 
| 177 |  |  | */ | 
| 178 |  |  | Torsion* beginTorsion(std::vector<Torsion*>::iterator& i); | 
| 179 |  |  | Torsion* nextTorsion(std::vector<Torsion*>::iterator& i); | 
| 180 |  |  |  | 
| 181 |  |  | /** | 
| 182 |  |  | * Returns the first rigid body in this molecule and initialize the iterator. | 
| 183 |  |  | * @return the first rigid body, return NULL if there is not cut off group in this molecule | 
| 184 |  |  | * @param i iteraotr | 
| 185 |  |  | */ | 
| 186 |  |  | RigidBody* beginRigidBody(std::vector<RigidBody*>::iterator& i); | 
| 187 |  |  |  | 
| 188 |  |  | RigidBody* nextRigidBody(std::vector<RigidBody*>::iterator& i); | 
| 189 |  |  |  | 
| 190 |  |  | /** | 
| 191 |  |  | * Returns the first integrable object in this molecule and initialize the iterator. | 
| 192 |  |  | * @return the first integrable object, return NULL if there is not cut off group in this molecule | 
| 193 |  |  | * @param i iteraotr | 
| 194 |  |  | */ | 
| 195 |  |  | StuntDouble* beginIntegrableObject(std::vector<StuntDouble*>::iterator& i); | 
| 196 |  |  |  | 
| 197 |  |  | StuntDouble* nextIntegrableObject(std::vector<StuntDouble*>::iterator& i); | 
| 198 |  |  |  | 
| 199 |  |  | /** | 
| 200 |  |  | * Returns the first cutoff group in this molecule and initialize the iterator. | 
| 201 |  |  | * @return the first cutoff group, return NULL if there is not cut off group in this molecule | 
| 202 |  |  | * @param i iteraotr | 
| 203 |  |  | */ | 
| 204 |  |  | CutoffGroup* beginCutoffGroup(std::vector<CutoffGroup*>::iterator& i); | 
| 205 |  |  |  | 
| 206 |  |  | /** | 
| 207 |  |  | * Returns next cutoff group based on the iterator | 
| 208 |  |  | * @return next cutoff group | 
| 209 |  |  | * @param i | 
| 210 |  |  | */ | 
| 211 |  |  | CutoffGroup* nextCutoffGroup(std::vector<CutoffGroup*>::iterator& i); | 
| 212 |  |  |  | 
| 213 | tim | 1696 | Constraint* beginConstraint(std::vector<Constraint*>::iterator& i); | 
| 214 |  |  |  | 
| 215 |  |  | Constraint* nextConstraint(std::vector<Constraint*>::iterator& i); | 
| 216 |  |  |  | 
| 217 | tim | 1692 | //void setStampID( int info ) {stampID = info;} | 
| 218 |  |  |  | 
| 219 |  |  | void calcForces( void ); | 
| 220 |  |  |  | 
| 221 |  |  | void atoms2rigidBodies( void ); | 
| 222 |  |  |  | 
| 223 |  |  | /** return the total potential energy of short range interaction of this molecule */ | 
| 224 |  |  | double getPotential(); | 
| 225 |  |  |  | 
| 226 |  |  |  | 
| 227 |  |  | /** return the center of mass of this molecule */ | 
| 228 |  |  | Vector3d getCom(); | 
| 229 |  |  |  | 
| 230 |  |  | /** Moves the center of this molecule */ | 
| 231 | tim | 1695 | void moveCom(const Vector3d& delta); | 
| 232 | tim | 1692 |  | 
| 233 |  |  | /** Returns the velocity of center of mass of this molecule */ | 
| 234 |  |  | Vector3d getComVel(); | 
| 235 |  |  |  | 
| 236 |  |  | /** Returns the total mass of this molecule */ | 
| 237 |  |  | double getTotalMass(); | 
| 238 |  |  |  | 
| 239 | tim | 1695 | friend std::ostream& operator <<(std::ostream& o, Molecule& mol); | 
| 240 | tim | 1692 |  | 
| 241 |  |  | private: | 
| 242 |  |  | int localIndex_; | 
| 243 |  |  | int globalIndex_; | 
| 244 |  |  |  | 
| 245 |  |  | std::vector<Atom*> atoms_; | 
| 246 |  |  | std::vector<Bond*> bonds_; | 
| 247 |  |  | std::vector<Bend*> bends_; | 
| 248 |  |  | std::vector<Torsion*> torsions_; | 
| 249 |  |  | std::vector<RigidBody*> rigidBodies_; | 
| 250 |  |  | std::vector<StuntDouble*> integrableObjects_; | 
| 251 |  |  | std::vector<CutoffGroup*> cutoffGroups_; | 
| 252 | tim | 1696 | std::vector<Constraint*> constraints_; | 
| 253 | gezelter | 1490 | }; | 
| 254 |  |  |  | 
| 255 | tim | 1692 | } //namespace oopse | 
| 256 |  |  | #endif // |