| 1 | /* | 
| 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 |  | 
| 26 | /** | 
| 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 | #include <vector> | 
| 36 | #include <iostream> | 
| 37 | #include "math/Vector3.hpp" | 
| 38 |  | 
| 39 | namespace oopse{ | 
| 40 |  | 
| 41 | /** | 
| 42 | * @class Molecule Molecule.hpp "primitives/Molecule.hpp" | 
| 43 | * @brief | 
| 44 | */ | 
| 45 | class Molecule { | 
| 46 | public: | 
| 47 |  | 
| 48 | Molecule(); | 
| 49 | virtual ~Molecule(); | 
| 50 |  | 
| 51 | /** | 
| 52 | * Returns the global index of this molecule. | 
| 53 | * @return  the global index of this molecule | 
| 54 | */ | 
| 55 | int getGlobalIndex() { | 
| 56 | return globalIndex_; | 
| 57 | } | 
| 58 |  | 
| 59 | /** | 
| 60 | * Sets the global index of this molecule. | 
| 61 | * @param new global index to be set | 
| 62 | */ | 
| 63 | void setGlobalIndex(int index) { | 
| 64 | return globalIndex_; | 
| 65 | } | 
| 66 |  | 
| 67 | /** | 
| 68 | * Returns the local index of this molecule | 
| 69 | * @return the local index of this molecule | 
| 70 | */ | 
| 71 | int getLocalIndex() { | 
| 72 | return localIndex_; | 
| 73 | } | 
| 74 |  | 
| 75 | /** add an atom into this molecule */ | 
| 76 | void addAtom(Atom* atom); | 
| 77 |  | 
| 78 | /** add a bond into this molecule */ | 
| 79 | void addBond(Bond* bond); | 
| 80 |  | 
| 81 | /** add a bend into this molecule */ | 
| 82 | void addBend(Bend* bend); | 
| 83 |  | 
| 84 | /** add a torsion into this molecule*/ | 
| 85 | void addTorsion(Torsion* torsion); | 
| 86 |  | 
| 87 | /** add a rigidbody into this molecule */ | 
| 88 | void addRigidBody(RigidBody *rb); | 
| 89 |  | 
| 90 | /** add a cutoff group into this molecule */ | 
| 91 | void addCutoffGroup(CutoffGroup* cp) | 
| 92 |  | 
| 93 | /** */ | 
| 94 | void complete(); | 
| 95 |  | 
| 96 | /** Returns the total number of atoms in this molecule */ | 
| 97 | unsigned int getNAtoms() { | 
| 98 | return atoms_.size(); | 
| 99 | } | 
| 100 |  | 
| 101 | /** Returns the total number of bonds in this molecule */ | 
| 102 | unsigned int getNBonds(){ | 
| 103 | return bonds_.size(); | 
| 104 | } | 
| 105 |  | 
| 106 | /** Returns the total number of bends in this molecule */ | 
| 107 | unsigned int getNBends() { | 
| 108 | return bends_.size(); | 
| 109 | } | 
| 110 |  | 
| 111 | /** Returns the total number of torsions in this molecule */ | 
| 112 | unsigned int getNTorsions() { | 
| 113 | return torsions_.size(); | 
| 114 | } | 
| 115 |  | 
| 116 | /** Returns the total number of rigid bodies in this molecule */ | 
| 117 | unsigned int getNRigidBodies() { | 
| 118 | return rigidBodies_.size(); | 
| 119 | } | 
| 120 |  | 
| 121 | /** Returns the total number of integrable objects in this molecule */ | 
| 122 | unsigned int getNIntegrableObjects() { | 
| 123 | return integrableObjects_.size(); | 
| 124 | } | 
| 125 |  | 
| 126 | /** Returns the total number of cutoff groups in this molecule */ | 
| 127 | unsigned int getNCutoffGroups() { | 
| 128 | return cutoffGroups_.size(); | 
| 129 | } | 
| 130 |  | 
| 131 | /** | 
| 132 | * Returns the first atom in this molecule and initialize the iterator. | 
| 133 | * @return the first atom, return NULL if there is not cut off group in this molecule | 
| 134 | * @param i iteraotr | 
| 135 | */ | 
| 136 | Atom* beginAtom(std::vector<Atom*>::iterator& i); | 
| 137 |  | 
| 138 | Atom* nextAtom(std::vector<Atom*>::iterator& i); | 
| 139 |  | 
| 140 | /** | 
| 141 | * Returns the first bond in this molecule and initialize the iterator. | 
| 142 | * @return the first bond, return NULL if there is not cut off group in this molecule | 
| 143 | * @param i iteraotr | 
| 144 | */ | 
| 145 | Bond* beginBond(std::vector<Bond*>::iterator& i); | 
| 146 |  | 
| 147 | Bond* nextBond(std::vector<Bond*>::iterator& i); | 
| 148 |  | 
| 149 | /** | 
| 150 | * Returns the first bend in this molecule and initialize the iterator. | 
| 151 | * @return the first bend, return NULL if there is not cut off group in this molecule | 
| 152 | * @param i iteraotr | 
| 153 | */ | 
| 154 | Bend* beginBend(std::vector<Bend*>::iterator& i); | 
| 155 |  | 
| 156 | Bend* nextBend(std::vector<Bend*>::iterator& i); | 
| 157 |  | 
| 158 | /** | 
| 159 | * Returns the first torsion in this molecule and initialize the iterator. | 
| 160 | * @return the first torsion, return NULL if there is not cut off group in this molecule | 
| 161 | * @param i iteraotr | 
| 162 | */ | 
| 163 | Torsion* beginTorsion(std::vector<Torsion*>::iterator& i); | 
| 164 | Torsion* nextTorsion(std::vector<Torsion*>::iterator& i); | 
| 165 |  | 
| 166 | /** | 
| 167 | * Returns the first rigid body in this molecule and initialize the iterator. | 
| 168 | * @return the first rigid body, return NULL if there is not cut off group in this molecule | 
| 169 | * @param i iteraotr | 
| 170 | */ | 
| 171 | RigidBody* beginRigidBody(std::vector<RigidBody*>::iterator& i); | 
| 172 |  | 
| 173 | RigidBody* nextRigidBody(std::vector<RigidBody*>::iterator& i); | 
| 174 |  | 
| 175 | /** | 
| 176 | * Returns the first integrable object in this molecule and initialize the iterator. | 
| 177 | * @return the first integrable object, return NULL if there is not cut off group in this molecule | 
| 178 | * @param i iteraotr | 
| 179 | */ | 
| 180 | StuntDouble* beginIntegrableObject(std::vector<StuntDouble*>::iterator& i); | 
| 181 |  | 
| 182 | StuntDouble* nextIntegrableObject(std::vector<StuntDouble*>::iterator& i); | 
| 183 |  | 
| 184 | /** | 
| 185 | * Returns the first cutoff group in this molecule and initialize the iterator. | 
| 186 | * @return the first cutoff group, return NULL if there is not cut off group in this molecule | 
| 187 | * @param i iteraotr | 
| 188 | */ | 
| 189 | CutoffGroup* beginCutoffGroup(std::vector<CutoffGroup*>::iterator& i); | 
| 190 |  | 
| 191 | /** | 
| 192 | * Returns next cutoff group based on the iterator | 
| 193 | * @return next cutoff group | 
| 194 | * @param i | 
| 195 | */ | 
| 196 | CutoffGroup* nextCutoffGroup(std::vector<CutoffGroup*>::iterator& i); | 
| 197 |  | 
| 198 | //void setStampID( int info ) {stampID = info;} | 
| 199 |  | 
| 200 | void calcForces( void ); | 
| 201 |  | 
| 202 | void atoms2rigidBodies( void ); | 
| 203 |  | 
| 204 | /** return the total potential energy of short range interaction of this molecule */ | 
| 205 | double getPotential(); | 
| 206 |  | 
| 207 |  | 
| 208 | /** return the center of mass of this molecule */ | 
| 209 | Vector3d getCom(); | 
| 210 |  | 
| 211 | /** Moves the center of this molecule */ | 
| 212 | void moveCom(const Vetor3d& delta); | 
| 213 |  | 
| 214 | /** Returns the velocity of center of mass of this molecule */ | 
| 215 | Vector3d getComVel(); | 
| 216 |  | 
| 217 | /** Returns the total mass of this molecule */ | 
| 218 | double getTotalMass(); | 
| 219 |  | 
| 220 | friend std::ostream& operator <<(std::ostream& o, const Molecule& mol); | 
| 221 |  | 
| 222 | private: | 
| 223 | int localIndex_; | 
| 224 | int globalIndex_; | 
| 225 |  | 
| 226 | std::vector<Atom*> atoms_; | 
| 227 | std::vector<Bond*> bonds_; | 
| 228 | std::vector<Bend*> bends_; | 
| 229 | std::vector<Torsion*> torsions_; | 
| 230 | std::vector<RigidBody*> rigidBodies_; | 
| 231 | std::vector<StuntDouble*> integrableObjects_; | 
| 232 | std::vector<CutoffGroup*> cutoffGroups_; | 
| 233 | }; | 
| 234 |  | 
| 235 | } //namespace oopse | 
| 236 | #endif // |