--- branches/new_design/OOPSE-4/src/primitives/Molecule.cpp 2004/12/03 20:30:07 1842 +++ branches/new_design/OOPSE-4/src/primitives/Molecule.cpp 2004/12/03 21:30:30 1843 @@ -96,9 +96,6 @@ void Molecule::complete() { void Molecule::complete() { - std::set allAtoms; - allAtoms.insert(atoms_.begin(), atoms_.end()); - std::set rigidAtoms; RigidBody* rb; std::vector::iterator rbIter; @@ -108,21 +105,29 @@ void Molecule::complete() { rigidAtoms.insert(rb->getBeginAtomIter(), rb->getEndAtomIter()); } + Atom* atom; + AtomIterator ai; + for (atom = beginAtom(ai); atom != NULL; atom = nextAtom(ai)) { + if (rigidAtoms.find(*ai) != rigidAtoms.end()) { + integrableObjects_.push_back(*ai); + } + } + //find all free atoms (which do not belong to rigid bodies) //performs the "difference" operation from set theory, the output range contains a copy of every //element that is contained in [allAtoms.begin(), allAtoms.end()) and not contained in //[rigidAtoms.begin(), rigidAtoms.end()). - std::set_difference(allAtoms.begin(), allAtoms.end(), rigidAtoms.begin(), rigidAtoms.end(), - std::back_inserter(integrableObjects_)); + //std::set_difference(allAtoms.begin(), allAtoms.end(), rigidAtoms.begin(), rigidAtoms.end(), + // std::back_inserter(integrableObjects_)); - if (integrableObjects_.size() != allAtoms.size() - rigidAtoms.size()) { - //Some atoms in rigidAtoms are not in allAtoms, something must be wrong - sprintf(painCave.errMsg, "Atoms in rigidbody are not in the atom list of the same molecule"); + //if (integrableObjects_.size() != allAtoms.size() - rigidAtoms.size()) { + // //Some atoms in rigidAtoms are not in allAtoms, something must be wrong + // sprintf(painCave.errMsg, "Atoms in rigidbody are not in the atom list of the same molecule"); + // + // painCave.isFatal = 1; + // simError(); + //} - painCave.isFatal = 1; - simError(); - } - integrableObjects_.insert(integrableObjects_.end(), rigidBodies_.begin(), rigidBodies_.end()); } @@ -197,8 +202,20 @@ CutoffGroup* Molecule::nextCutoffGroup(std::vector::iterator i; + double mass = 0.0; + + for (sd = beginIntegrableObject(i); sd != NULL; sd = nextIntegrableObject(i)){ + mass += sd->getMass(); + } + return mass; +} + Vector3d Molecule::getCom() { StuntDouble* sd; std::vector::iterator i; @@ -245,6 +262,33 @@ std::ostream& operator <<(std::ostream& o, Molecule& m return velCom; } +double Molecule::getPotential() { + + Bond* bond; + Bend* bend; + Torsion* torsion; + Molecule::BondIterator bondIter;; + Molecule::BendIterator bendIter; + Molecule::TorsionIterator torsionIter; + + double potential = 0.0; + + for (bond = beginBond(bondIter); bond != NULL; bond = nextBond(bondIter)) { + potential += bond->getPotential(); + } + + for (bend = beginBend(bendIter); bend != NULL; bend = nextBend(bendIter)) { + potential += bend->getPotential(); + } + + for (torsion = beginTorsion(torsionIter); torsion != NULL; torsion = nextTorsion(torsionIter)) { + potential += torsion->getPotential(); + } + + return potential; + +} + std::ostream& operator <<(std::ostream& o, Molecule& mol) { o << std::endl; o << "Molecule " << mol.getGlobalIndex() << "has: " << std::endl;