ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/branches/new_design/OOPSE-4/src/primitives/Molecule.cpp
(Generate patch)

Comparing branches/new_design/OOPSE-4/src/primitives/Molecule.cpp (file contents):
Revision 1842 by tim, Wed Nov 24 20:55:03 2004 UTC vs.
Revision 1843 by tim, Fri Dec 3 21:30:30 2004 UTC

# Line 96 | Line 96 | void Molecule::complete() {
96  
97   void Molecule::complete() {
98      
99    std::set<Atom*> allAtoms;
100    allAtoms.insert(atoms_.begin(), atoms_.end());
101
99      std::set<Atom*> rigidAtoms;
100      RigidBody* rb;
101      std::vector<RigidBody*>::iterator rbIter;
# Line 108 | Line 105 | void Molecule::complete() {
105          rigidAtoms.insert(rb->getBeginAtomIter(), rb->getEndAtomIter());
106      }
107  
108 +    Atom* atom;
109 +    AtomIterator ai;
110 +    for (atom = beginAtom(ai); atom != NULL; atom = nextAtom(ai)) {
111 +        if (rigidAtoms.find(*ai) != rigidAtoms.end()) {
112 +            integrableObjects_.push_back(*ai);
113 +        }
114 +    }
115 +
116      //find all free atoms (which do not belong to rigid bodies)  
117      //performs the "difference" operation from set theory,  the output range contains a copy of every
118      //element that is contained in [allAtoms.begin(), allAtoms.end()) and not contained in
119      //[rigidAtoms.begin(), rigidAtoms.end()).
120 <    std::set_difference(allAtoms.begin(), allAtoms.end(), rigidAtoms.begin(), rigidAtoms.end(),
121 <                            std::back_inserter(integrableObjects_));
120 >    //std::set_difference(allAtoms.begin(), allAtoms.end(), rigidAtoms.begin(), rigidAtoms.end(),
121 >    //                        std::back_inserter(integrableObjects_));
122  
123 <    if (integrableObjects_.size() != allAtoms.size() - rigidAtoms.size()) {
124 <        //Some atoms in rigidAtoms are not in allAtoms, something must be wrong
125 <        sprintf(painCave.errMsg, "Atoms in rigidbody are not in the atom list of the same molecule");
123 >    //if (integrableObjects_.size() != allAtoms.size() - rigidAtoms.size()) {
124 >    //    //Some atoms in rigidAtoms are not in allAtoms, something must be wrong
125 >    //    sprintf(painCave.errMsg, "Atoms in rigidbody are not in the atom list of the same molecule");
126 >    //
127 >    //    painCave.isFatal = 1;
128 >    //    simError();        
129 >    //}
130  
122        painCave.isFatal = 1;
123        simError();        
124    }
125
131      integrableObjects_.insert(integrableObjects_.end(), rigidBodies_.begin(), rigidBodies_.end());
132   }
133  
# Line 197 | Line 202 | CutoffGroup* Molecule::nextCutoffGroup(std::vector<Cut
202      ++i;
203      return (i == cutoffGroups_.end()) ? NULL : *i;    
204   }
205 +
206 + double Molecule::getMass() {
207 +    StuntDouble* sd;
208 +    std::vector<StuntDouble*>::iterator i;
209 +    double mass = 0.0;
210 +
211 +    for (sd = beginIntegrableObject(i); sd != NULL; sd = nextIntegrableObject(i)){
212 +        mass += sd->getMass();
213 +    }
214  
215 +    return mass;
216  
217 + }
218 +
219   Vector3d Molecule::getCom() {
220      StuntDouble* sd;
221      std::vector<StuntDouble*>::iterator i;
# Line 245 | Line 262 | std::ostream& operator <<(std::ostream& o, Molecule& m
262      return velCom;
263   }
264  
265 + double Molecule::getPotential() {
266 +
267 +    Bond* bond;
268 +    Bend* bend;
269 +    Torsion* torsion;
270 +    Molecule::BondIterator bondIter;;
271 +    Molecule::BendIterator  bendIter;
272 +    Molecule::TorsionIterator  torsionIter;
273 +
274 +    double potential = 0.0;
275 +
276 +    for (bond = beginBond(bondIter); bond != NULL; bond = nextBond(bondIter)) {
277 +        potential += bond->getPotential();
278 +    }
279 +
280 +    for (bend = beginBend(bendIter); bend != NULL; bend = nextBend(bendIter)) {
281 +        potential += bend->getPotential();
282 +    }
283 +
284 +    for (torsion = beginTorsion(torsionIter); torsion != NULL; torsion = nextTorsion(torsionIter)) {
285 +        potential += torsion->getPotential();
286 +    }
287 +
288 +    return potential;
289 +
290 + }
291 +
292   std::ostream& operator <<(std::ostream& o, Molecule& mol) {
293      o << std::endl;
294      o << "Molecule " << mol.getGlobalIndex() << "has: " << std::endl;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines