| 1 | < | #include <stdlib.h> | 
| 1 | > | /* | 
| 2 | > | * Copyright (c) 2005 The University of Notre Dame. All Rights Reserved. | 
| 3 | > | * | 
| 4 | > | * The University of Notre Dame grants you ("Licensee") a | 
| 5 | > | * non-exclusive, royalty free, license to use, modify and | 
| 6 | > | * redistribute this software in source and binary code form, provided | 
| 7 | > | * that the following conditions are met: | 
| 8 | > | * | 
| 9 | > | * 1. Acknowledgement of the program authors must be made in any | 
| 10 | > | *    publication of scientific results based in part on use of the | 
| 11 | > | *    program.  An acceptable form of acknowledgement is citation of | 
| 12 | > | *    the article in which the program was described (Matthew | 
| 13 | > | *    A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher | 
| 14 | > | *    J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented | 
| 15 | > | *    Parallel Simulation Engine for Molecular Dynamics," | 
| 16 | > | *    J. Comput. Chem. 26, pp. 252-271 (2005)) | 
| 17 | > | * | 
| 18 | > | * 2. Redistributions of source code must retain the above copyright | 
| 19 | > | *    notice, this list of conditions and the following disclaimer. | 
| 20 | > | * | 
| 21 | > | * 3. Redistributions in binary form must reproduce the above copyright | 
| 22 | > | *    notice, this list of conditions and the following disclaimer in the | 
| 23 | > | *    documentation and/or other materials provided with the | 
| 24 | > | *    distribution. | 
| 25 | > | * | 
| 26 | > | * This software is provided "AS IS," without a warranty of any | 
| 27 | > | * kind. All express or implied conditions, representations and | 
| 28 | > | * warranties, including any implied warranty of merchantability, | 
| 29 | > | * fitness for a particular purpose or non-infringement, are hereby | 
| 30 | > | * excluded.  The University of Notre Dame and its licensors shall not | 
| 31 | > | * be liable for any damages suffered by licensee as a result of | 
| 32 | > | * using, modifying or distributing the software or its | 
| 33 | > | * derivatives. In no event will the University of Notre Dame or its | 
| 34 | > | * licensors be liable for any lost revenue, profit or data, or for | 
| 35 | > | * direct, indirect, special, consequential, incidental or punitive | 
| 36 | > | * damages, however caused and regardless of the theory of liability, | 
| 37 | > | * arising out of the use of or inability to use software, even if the | 
| 38 | > | * University of Notre Dame has been advised of the possibility of | 
| 39 | > | * such damages. | 
| 40 | > | */ | 
| 41 | > |  | 
| 42 | > | /** | 
| 43 | > | * @file Molecule.cpp | 
| 44 | > | * @author    tlin | 
| 45 | > | * @date  10/28/2004 | 
| 46 | > | * @version 1.0 | 
| 47 | > | */ | 
| 48 |  |  | 
| 49 | + | #include <algorithm> | 
| 50 | + | #include <set> | 
| 51 |  |  | 
| 52 |  | #include "primitives/Molecule.hpp" | 
| 53 | + | #include "utils/MemoryUtils.hpp" | 
| 54 |  | #include "utils/simError.h" | 
| 55 |  |  | 
| 56 | < |  | 
| 57 | < |  | 
| 58 | < | Molecule::Molecule( void ){ | 
| 59 | < |  | 
| 11 | < | myAtoms = NULL; | 
| 12 | < | myBonds = NULL; | 
| 13 | < | myBends = NULL; | 
| 14 | < | myTorsions = NULL; | 
| 15 | < | } | 
| 16 | < |  | 
| 17 | < | Molecule::~Molecule( void ){ | 
| 18 | < | int i; | 
| 19 | < | CutoffGroup* cg; | 
| 20 | < | vector<CutoffGroup*>::iterator iter; | 
| 56 | > | namespace oopse { | 
| 57 | > | Molecule::Molecule(int stampId, int globalIndex, const std::string& molName) | 
| 58 | > | : stampId_(stampId), globalIndex_(globalIndex), moleculeName_(molName) { | 
| 59 | > | } | 
| 60 |  |  | 
| 61 | < | if( myAtoms != NULL ){ | 
| 62 | < | for(i=0; i<nAtoms; i++) if(myAtoms[i] != NULL ) delete myAtoms[i]; | 
| 63 | < | delete[] myAtoms; | 
| 61 | > | Molecule::~Molecule() { | 
| 62 | > |  | 
| 63 | > | MemoryUtils::deletePointers(atoms_); | 
| 64 | > | MemoryUtils::deletePointers(bonds_); | 
| 65 | > | MemoryUtils::deletePointers(bends_); | 
| 66 | > | MemoryUtils::deletePointers(torsions_); | 
| 67 | > | MemoryUtils::deletePointers(inversions_); | 
| 68 | > | MemoryUtils::deletePointers(rigidBodies_); | 
| 69 | > | MemoryUtils::deletePointers(cutoffGroups_); | 
| 70 | > | MemoryUtils::deletePointers(constraintPairs_); | 
| 71 | > | MemoryUtils::deletePointers(constraintElems_); | 
| 72 | > | // integrableObjects_ don't own the objects | 
| 73 | > | integrableObjects_.clear(); | 
| 74 | > |  | 
| 75 |  | } | 
| 76 | < |  | 
| 77 | < | if( myBonds != NULL ){ | 
| 78 | < | for(i=0; i<nBonds; i++) if(myBonds[i] != NULL ) delete myBonds[i]; | 
| 79 | < | delete[] myBonds; | 
| 76 | > |  | 
| 77 | > | void Molecule::addAtom(Atom* atom) { | 
| 78 | > | if (std::find(atoms_.begin(), atoms_.end(), atom) == atoms_.end()) { | 
| 79 | > | atoms_.push_back(atom); | 
| 80 | > | } | 
| 81 |  | } | 
| 82 | < |  | 
| 83 | < | if( myBends != NULL ){ | 
| 84 | < | for(i=0; i<nBends; i++) if(myBends[i] != NULL ) delete myBends[i]; | 
| 85 | < | delete[] myBends; | 
| 82 | > |  | 
| 83 | > | void Molecule::addBond(Bond* bond) { | 
| 84 | > | if (std::find(bonds_.begin(), bonds_.end(), bond) == bonds_.end()) { | 
| 85 | > | bonds_.push_back(bond); | 
| 86 | > | } | 
| 87 |  | } | 
| 88 | < |  | 
| 89 | < | if( myTorsions != NULL ){ | 
| 90 | < | for(i=0; i<nTorsions; i++) if(myTorsions[i] != NULL ) delete myTorsions[i]; | 
| 91 | < | delete[] myTorsions; | 
| 88 | > |  | 
| 89 | > | void Molecule::addBend(Bend* bend) { | 
| 90 | > | if (std::find(bends_.begin(), bends_.end(), bend) == bends_.end()) { | 
| 91 | > | bends_.push_back(bend); | 
| 92 | > | } | 
| 93 |  | } | 
| 41 | – |  | 
| 42 | – | for(cg = beginCutoffGroup(iter);  cg != NULL; cg = nextCutoffGroup(iter)) | 
| 43 | – | delete cg; | 
| 44 | – | myCutoffGroups.clear(); | 
| 94 |  |  | 
| 95 | < | } | 
| 95 | > | void Molecule::addTorsion(Torsion* torsion) { | 
| 96 | > | if (std::find(torsions_.begin(), torsions_.end(), torsion) == | 
| 97 | > | torsions_.end()) { | 
| 98 | > | torsions_.push_back(torsion); | 
| 99 | > | } | 
| 100 | > | } | 
| 101 |  |  | 
| 102 | < |  | 
| 103 | < | void Molecule::initialize( molInit &theInit ){ | 
| 104 | < |  | 
| 105 | < | CutoffGroup* curCutoffGroup; | 
| 106 | < | vector<CutoffGroup*>::iterator iterCutoff; | 
| 107 | < | Atom* cutoffAtom; | 
| 54 | < | vector<Atom*>::iterator iterAtom; | 
| 55 | < | int atomIndex; | 
| 102 | > | void Molecule::addInversion(Inversion* inversion) { | 
| 103 | > | if (std::find(inversions_.begin(), inversions_.end(), inversion) == | 
| 104 | > | inversions_.end()) { | 
| 105 | > | inversions_.push_back(inversion); | 
| 106 | > | } | 
| 107 | > | } | 
| 108 |  |  | 
| 109 | < | nAtoms = theInit.nAtoms; | 
| 110 | < | nMembers = nAtoms; | 
| 111 | < | nBonds = theInit.nBonds; | 
| 112 | < | nBends = theInit.nBends; | 
| 113 | < | nTorsions = theInit.nTorsions; | 
| 114 | < | nRigidBodies = theInit.nRigidBodies; | 
| 63 | < | nOriented = theInit.nOriented; | 
| 64 | < |  | 
| 65 | < | myAtoms = theInit.myAtoms; | 
| 66 | < | myBonds = theInit.myBonds; | 
| 67 | < | myBends = theInit.myBends; | 
| 68 | < | myTorsions = theInit.myTorsions; | 
| 69 | < | myRigidBodies = theInit.myRigidBodies; | 
| 70 | < |  | 
| 71 | < | myIntegrableObjects = theInit.myIntegrableObjects; | 
| 72 | < |  | 
| 73 | < | for (int i = 0; i < myRigidBodies.size(); i++) | 
| 74 | < | myRigidBodies[i]->calcRefCoords(); | 
| 75 | < |  | 
| 76 | < | myCutoffGroups = theInit.myCutoffGroups; | 
| 77 | < | nCutoffGroups = myCutoffGroups.size(); | 
| 78 | < |  | 
| 79 | < | } | 
| 80 | < |  | 
| 81 | < | void Molecule::calcForces( void ){ | 
| 109 | > | void Molecule::addRigidBody(RigidBody *rb) { | 
| 110 | > | if (std::find(rigidBodies_.begin(), rigidBodies_.end(), rb) == | 
| 111 | > | rigidBodies_.end()) { | 
| 112 | > | rigidBodies_.push_back(rb); | 
| 113 | > | } | 
| 114 | > | } | 
| 115 |  |  | 
| 116 | < | int i; | 
| 117 | < | double com[3]; | 
| 118 | < |  | 
| 119 | < | for(i=0; i<myRigidBodies.size(); i++) { | 
| 120 | < | myRigidBodies[i]->updateAtoms(); | 
| 116 | > | void Molecule::addCutoffGroup(CutoffGroup* cp) { | 
| 117 | > | if (std::find(cutoffGroups_.begin(), cutoffGroups_.end(), cp) == | 
| 118 | > | cutoffGroups_.end()) { | 
| 119 | > | cutoffGroups_.push_back(cp); | 
| 120 | > | } | 
| 121 |  | } | 
| 122 | < |  | 
| 123 | < | for(i=0; i<nBonds; i++){ | 
| 124 | < | myBonds[i]->calc_forces(); | 
| 122 | > |  | 
| 123 | > | void Molecule::addConstraintPair(ConstraintPair* cp) { | 
| 124 | > | if (std::find(constraintPairs_.begin(), constraintPairs_.end(), cp) == | 
| 125 | > | constraintPairs_.end()) { | 
| 126 | > | constraintPairs_.push_back(cp); | 
| 127 | > | } | 
| 128 |  | } | 
| 129 | < |  | 
| 130 | < | for(i=0; i<nBends; i++){ | 
| 131 | < | myBends[i]->calc_forces(); | 
| 129 | > |  | 
| 130 | > | void Molecule::addConstraintElem(ConstraintElem* cp) { | 
| 131 | > | if (std::find(constraintElems_.begin(), constraintElems_.end(), cp) == | 
| 132 | > | constraintElems_.end()) { | 
| 133 | > | constraintElems_.push_back(cp); | 
| 134 | > | } | 
| 135 |  | } | 
| 136 | + |  | 
| 137 | + | void Molecule::complete() { | 
| 138 | + |  | 
| 139 | + | std::set<Atom*> rigidAtoms; | 
| 140 | + | RigidBody* rb; | 
| 141 | + | std::vector<RigidBody*>::iterator rbIter; | 
| 142 |  |  | 
| 143 | < | for(i=0; i<nTorsions; i++){ | 
| 144 | < | myTorsions[i]->calc_forces(); | 
| 145 | < | } | 
| 143 | > |  | 
| 144 | > | for (rb = beginRigidBody(rbIter); rb != NULL; rb = nextRigidBody(rbIter)) { | 
| 145 | > | rigidAtoms.insert(rb->getBeginAtomIter(), rb->getEndAtomIter()); | 
| 146 | > | } | 
| 147 | > |  | 
| 148 | > | Atom* atom; | 
| 149 | > | AtomIterator ai; | 
| 150 | > | for (atom = beginAtom(ai); atom != NULL; atom = nextAtom(ai)) { | 
| 151 | > |  | 
| 152 | > | if (rigidAtoms.find(*ai) == rigidAtoms.end()) { | 
| 153 |  |  | 
| 154 | < | // Rigid Body forces and torques are done after the fortran force loop | 
| 154 | > | // If an atom does not belong to a rigid body, it is an | 
| 155 | > | // integrable object | 
| 156 |  |  | 
| 157 | < | } | 
| 158 | < |  | 
| 159 | < |  | 
| 160 | < | double Molecule::getPotential( void ){ | 
| 161 | < |  | 
| 162 | < | int i; | 
| 163 | < | double myPot = 0.0; | 
| 164 | < |  | 
| 165 | < | for(i=0; i<myRigidBodies.size(); i++) { | 
| 166 | < | myRigidBodies[i]->updateAtoms(); | 
| 167 | < | } | 
| 115 | < |  | 
| 116 | < | for(i=0; i<nBonds; i++){ | 
| 117 | < | myPot += myBonds[i]->get_potential(); | 
| 118 | < | } | 
| 157 | > | integrableObjects_.push_back(*ai); | 
| 158 | > | } | 
| 159 | > | } | 
| 160 | > |  | 
| 161 | > | //find all free atoms (which do not belong to rigid bodies) | 
| 162 | > | // performs the "difference" operation from set theory, the output | 
| 163 | > | // range contains a copy of every element that is contained in | 
| 164 | > | // [allAtoms.begin(), allAtoms.end()) and not contained in | 
| 165 | > | // [rigidAtoms.begin(), rigidAtoms.end()). | 
| 166 | > | //std::set_difference(allAtoms.begin(), allAtoms.end(), rigidAtoms.begin(), rigidAtoms.end(), | 
| 167 | > | //                        std::back_inserter(integrableObjects_)); | 
| 168 |  |  | 
| 169 | < | for(i=0; i<nBends; i++){ | 
| 170 | < | myPot += myBends[i]->get_potential(); | 
| 169 | > | //if (integrableObjects_.size() != allAtoms.size() - rigidAtoms.size()) { | 
| 170 | > | //    //Some atoms in rigidAtoms are not in allAtoms, something must be wrong | 
| 171 | > | //    sprintf(painCave.errMsg, "Atoms in rigidbody are not in the atom list of the same molecule"); | 
| 172 | > | // | 
| 173 | > | //    painCave.isFatal = 1; | 
| 174 | > | //    simError(); | 
| 175 | > | //} | 
| 176 | > | for (rb = beginRigidBody(rbIter); rb != NULL; rb = nextRigidBody(rbIter)) { | 
| 177 | > | integrableObjects_.push_back(rb); | 
| 178 | > | } | 
| 179 | > | //integrableObjects_.insert(integrableObjects_.end(), rigidBodies_.begin(), rigidBodies_.end()); | 
| 180 |  | } | 
| 181 |  |  | 
| 182 | < | for(i=0; i<nTorsions; i++){ | 
| 183 | < | myPot += myTorsions[i]->get_potential(); | 
| 182 | > | RealType Molecule::getMass() { | 
| 183 | > | StuntDouble* sd; | 
| 184 | > | std::vector<StuntDouble*>::iterator i; | 
| 185 | > | RealType mass = 0.0; | 
| 186 | > |  | 
| 187 | > | for (sd = beginIntegrableObject(i); sd != NULL; sd = | 
| 188 | > | nextIntegrableObject(i)){ | 
| 189 | > | mass += sd->getMass(); | 
| 190 | > | } | 
| 191 | > |  | 
| 192 | > | return mass; | 
| 193 |  | } | 
| 194 |  |  | 
| 195 | < | return myPot; | 
| 196 | < | } | 
| 195 | > | Vector3d Molecule::getCom() { | 
| 196 | > | StuntDouble* sd; | 
| 197 | > | std::vector<StuntDouble*>::iterator i; | 
| 198 | > | Vector3d com; | 
| 199 | > | RealType totalMass = 0; | 
| 200 | > | RealType mass; | 
| 201 | > |  | 
| 202 | > | for (sd = beginIntegrableObject(i); sd != NULL; sd = | 
| 203 | > | nextIntegrableObject(i)){ | 
| 204 | > | mass = sd->getMass(); | 
| 205 | > | totalMass += mass; | 
| 206 | > | com += sd->getPos() * mass; | 
| 207 | > | } | 
| 208 | > |  | 
| 209 | > | com /= totalMass; | 
| 210 |  |  | 
| 211 | < | void Molecule::printMe( void ){ | 
| 132 | < |  | 
| 133 | < | int i; | 
| 134 | < |  | 
| 135 | < | for(i=0; i<nBonds; i++){ | 
| 136 | < | myBonds[i]->printMe(); | 
| 211 | > | return com; | 
| 212 |  | } | 
| 213 |  |  | 
| 214 | < | for(i=0; i<nBends; i++){ | 
| 215 | < | myBends[i]->printMe(); | 
| 214 | > | void Molecule::moveCom(const Vector3d& delta) { | 
| 215 | > | StuntDouble* sd; | 
| 216 | > | std::vector<StuntDouble*>::iterator i; | 
| 217 | > |  | 
| 218 | > | for (sd = beginIntegrableObject(i); sd != NULL; sd = | 
| 219 | > | nextIntegrableObject(i)){ | 
| 220 | > | sd->setPos(sd->getPos() + delta); | 
| 221 | > | } | 
| 222 |  | } | 
| 223 |  |  | 
| 224 | < | for(i=0; i<nTorsions; i++){ | 
| 225 | < | myTorsions[i]->printMe(); | 
| 224 | > | Vector3d Molecule::getComVel() { | 
| 225 | > | StuntDouble* sd; | 
| 226 | > | std::vector<StuntDouble*>::iterator i; | 
| 227 | > | Vector3d velCom; | 
| 228 | > | RealType totalMass = 0; | 
| 229 | > | RealType mass; | 
| 230 | > |  | 
| 231 | > | for (sd = beginIntegrableObject(i); sd != NULL; sd = | 
| 232 | > | nextIntegrableObject(i)){ | 
| 233 | > | mass = sd->getMass(); | 
| 234 | > | totalMass += mass; | 
| 235 | > | velCom += sd->getVel() * mass; | 
| 236 | > | } | 
| 237 | > |  | 
| 238 | > | velCom /= totalMass; | 
| 239 | > |  | 
| 240 | > | return velCom; | 
| 241 |  | } | 
| 242 |  |  | 
| 243 | < | } | 
| 243 | > | RealType Molecule::getPotential() { | 
| 244 |  |  | 
| 245 | < | void Molecule::moveCOM(double delta[3]){ | 
| 246 | < | double aPos[3]; | 
| 247 | < | int i, j; | 
| 245 | > | Bond* bond; | 
| 246 | > | Bend* bend; | 
| 247 | > | Torsion* torsion; | 
| 248 | > | Inversion* inversion; | 
| 249 | > | Molecule::BondIterator bondIter;; | 
| 250 | > | Molecule::BendIterator  bendIter; | 
| 251 | > | Molecule::TorsionIterator  torsionIter; | 
| 252 | > | Molecule::InversionIterator  inversionIter; | 
| 253 |  |  | 
| 254 | < | for(i=0; i<myIntegrableObjects.size(); i++) { | 
| 154 | < | if(myIntegrableObjects[i] != NULL ) { | 
| 155 | < |  | 
| 156 | < | myIntegrableObjects[i]->getPos( aPos ); | 
| 157 | < |  | 
| 158 | < | for (j=0; j< 3; j++) | 
| 159 | < | aPos[j] += delta[j]; | 
| 254 | > | RealType potential = 0.0; | 
| 255 |  |  | 
| 256 | < | myIntegrableObjects[i]->setPos( aPos ); | 
| 256 | > | for (bond = beginBond(bondIter); bond != NULL; bond = nextBond(bondIter)) { | 
| 257 | > | potential += bond->getPotential(); | 
| 258 |  | } | 
| 163 | – | } | 
| 259 |  |  | 
| 260 | < | for(i=0; i<myRigidBodies.size(); i++) { | 
| 261 | < |  | 
| 167 | < | myRigidBodies[i]->getPos( aPos ); | 
| 168 | < |  | 
| 169 | < | for (j=0; j< 3; j++) | 
| 170 | < | aPos[j] += delta[j]; | 
| 171 | < |  | 
| 172 | < | myRigidBodies[i]->setPos( aPos ); | 
| 260 | > | for (bend = beginBend(bendIter); bend != NULL; bend = nextBend(bendIter)) { | 
| 261 | > | potential += bend->getPotential(); | 
| 262 |  | } | 
| 174 | – | } | 
| 263 |  |  | 
| 264 | < | void Molecule::atoms2rigidBodies( void ) { | 
| 265 | < | int i; | 
| 266 | < | for (i = 0; i < myRigidBodies.size(); i++) { | 
| 179 | < | myRigidBodies[i]->calcForcesAndTorques(); | 
| 180 | < | } | 
| 181 | < | } | 
| 182 | < |  | 
| 183 | < | void Molecule::getCOM( double COM[3] ) { | 
| 184 | < |  | 
| 185 | < | double mass, mtot; | 
| 186 | < | double aPos[3]; | 
| 187 | < | int i, j; | 
| 188 | < |  | 
| 189 | < | for (j=0; j<3; j++) | 
| 190 | < | COM[j] = 0.0; | 
| 191 | < |  | 
| 192 | < | mtot   = 0.0; | 
| 193 | < |  | 
| 194 | < | for (i=0; i < myIntegrableObjects.size(); i++) { | 
| 195 | < | if (myIntegrableObjects[i] != NULL) { | 
| 196 | < |  | 
| 197 | < | mass = myIntegrableObjects[i]->getMass(); | 
| 198 | < | mtot   += mass; | 
| 199 | < |  | 
| 200 | < | myIntegrableObjects[i]->getPos( aPos ); | 
| 201 | < |  | 
| 202 | < | for( j = 0; j < 3; j++) | 
| 203 | < | COM[j] += aPos[j] * mass; | 
| 204 | < |  | 
| 264 | > | for (torsion = beginTorsion(torsionIter); torsion != NULL; torsion = | 
| 265 | > | nextTorsion(torsionIter)) { | 
| 266 | > | potential += torsion->getPotential(); | 
| 267 |  | } | 
| 268 | < | } | 
| 269 | < |  | 
| 270 | < | for (j = 0; j < 3; j++) | 
| 271 | < | COM[j] /= mtot; | 
| 210 | < | } | 
| 211 | < |  | 
| 212 | < | double Molecule::getCOMvel( double COMvel[3] ) { | 
| 213 | < |  | 
| 214 | < | double mass, mtot; | 
| 215 | < | double aVel[3]; | 
| 216 | < | int i, j; | 
| 217 | < |  | 
| 218 | < |  | 
| 219 | < | for (j=0; j<3; j++) | 
| 220 | < | COMvel[j] = 0.0; | 
| 221 | < |  | 
| 222 | < | mtot   = 0.0; | 
| 223 | < |  | 
| 224 | < | for (i=0; i < myIntegrableObjects.size(); i++) { | 
| 225 | < | if (myIntegrableObjects[i] != NULL) { | 
| 226 | < |  | 
| 227 | < | mass = myIntegrableObjects[i]->getMass(); | 
| 228 | < | mtot   += mass; | 
| 229 | < |  | 
| 230 | < | myIntegrableObjects[i]->getVel(aVel); | 
| 231 | < |  | 
| 232 | < | for (j=0; j<3; j++) | 
| 233 | < | COMvel[j] += aVel[j]*mass; | 
| 234 | < |  | 
| 268 | > |  | 
| 269 | > | for (inversion = beginInversion(inversionIter); torsion != NULL; | 
| 270 | > | inversion =  nextInversion(inversionIter)) { | 
| 271 | > | potential += inversion->getPotential(); | 
| 272 |  | } | 
| 273 | + |  | 
| 274 | + | return potential; | 
| 275 | + |  | 
| 276 |  | } | 
| 237 | – |  | 
| 238 | – | for (j=0; j<3; j++) | 
| 239 | – | COMvel[j] /= mtot; | 
| 240 | – |  | 
| 241 | – | return mtot; | 
| 242 | – |  | 
| 243 | – | } | 
| 244 | – |  | 
| 245 | – | double Molecule::getTotalMass() | 
| 246 | – | { | 
| 247 | – |  | 
| 248 | – | double totalMass; | 
| 277 |  |  | 
| 278 | < | totalMass = 0; | 
| 279 | < | for(int i =0; i < myIntegrableObjects.size(); i++){ | 
| 280 | < | totalMass += myIntegrableObjects[i]->getMass(); | 
| 278 | > | std::ostream& operator <<(std::ostream& o, Molecule& mol) { | 
| 279 | > | o << std::endl; | 
| 280 | > | o << "Molecule " << mol.getGlobalIndex() << "has: " << std::endl; | 
| 281 | > | o << mol.getNAtoms() << " atoms" << std::endl; | 
| 282 | > | o << mol.getNBonds() << " bonds" << std::endl; | 
| 283 | > | o << mol.getNBends() << " bends" << std::endl; | 
| 284 | > | o << mol.getNTorsions() << " torsions" << std::endl; | 
| 285 | > | o << mol.getNInversions() << " inversions" << std::endl; | 
| 286 | > | o << mol.getNRigidBodies() << " rigid bodies" << std::endl; | 
| 287 | > | o << mol.getNIntegrableObjects() << "integrable objects" << std::endl; | 
| 288 | > | o << mol.getNCutoffGroups() << "cutoff groups" << std::endl; | 
| 289 | > | o << mol.getNConstraintPairs() << "constraint pairs" << std::endl; | 
| 290 | > | return o; | 
| 291 |  | } | 
| 292 | < |  | 
| 293 | < | return totalMass; | 
| 256 | < | } | 
| 292 | > |  | 
| 293 | > | }//end namespace oopse |