ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-4/src/brains/MoleculeCreator.cpp
(Generate patch)

Comparing trunk/OOPSE-4/src/brains/MoleculeCreator.cpp (file contents):
Revision 1957 by tim, Tue Jan 25 17:45:23 2005 UTC vs.
Revision 2469 by tim, Fri Dec 2 15:38:03 2005 UTC

# Line 1 | Line 1
1 < /*
1 > /*
2   * Copyright (c) 2005 The University of Notre Dame. All Rights Reserved.
3   *
4   * The University of Notre Dame grants you ("Licensee") a
# Line 39 | Line 39
39   * such damages.
40   */
41    
42 < /**
43 <  * @file MoleculeCreator.cpp
44 <  * @author tlin
45 <  * @date 11/04/2004
46 <  * @time 13:44am
47 <  * @version 1.0
48 <  */
42 > /**
43 > * @file MoleculeCreator.cpp
44 > * @author tlin
45 > * @date 11/04/2004
46 > * @time 13:44am
47 > * @version 1.0
48 > */
49  
50   #include <cassert>
51   #include <set>
# Line 59 | Line 59 | namespace oopse {
59   #include "utils/StringUtils.hpp"
60  
61   namespace oopse {
62 +  
63 +  Molecule* MoleculeCreator::createMolecule(ForceField* ff, MoleculeStamp *molStamp,
64 +                                            int stampId, int globalIndex, LocalIndexManager* localIndexMan) {
65  
66 < Molecule* MoleculeCreator::createMolecule(ForceField* ff, MoleculeStamp *molStamp,
64 <    int stampId, int globalIndex, LocalIndexManager* localIndexMan) {
65 <
66 <    Molecule* mol = new Molecule(stampId, globalIndex, molStamp->getID());
66 >    Molecule* mol = new Molecule(stampId, globalIndex, molStamp->getName());
67      
68      //create atoms
69      Atom* atom;
70      AtomStamp* currentAtomStamp;
71      int nAtom = molStamp->getNAtoms();
72      for (int i = 0; i < nAtom; ++i) {
73 <        currentAtomStamp = molStamp->getAtom(i);
74 <        atom = createAtom(ff, mol, currentAtomStamp, localIndexMan);
75 <        mol->addAtom(atom);
73 >      currentAtomStamp = molStamp->getAtomStamp(i);
74 >      atom = createAtom(ff, mol, currentAtomStamp, localIndexMan);
75 >      mol->addAtom(atom);
76      }
77  
78      //create rigidbodies
# Line 81 | Line 81 | Molecule* MoleculeCreator::createMolecule(ForceField*
81      int nRigidbodies = molStamp->getNRigidBodies();
82  
83      for (int i = 0; i < nRigidbodies; ++i) {
84 <        currentRigidBodyStamp = molStamp->getRigidBody(i);
85 <        rb = createRigidBody(molStamp, mol, currentRigidBodyStamp, localIndexMan);
86 <        mol->addRigidBody(rb);
84 >      currentRigidBodyStamp = molStamp->getRigidBodyStamp(i);
85 >      rb = createRigidBody(molStamp, mol, currentRigidBodyStamp, localIndexMan);
86 >      mol->addRigidBody(rb);
87      }
88  
89      //create bonds
# Line 92 | Line 92 | Molecule* MoleculeCreator::createMolecule(ForceField*
92      int nBonds = molStamp->getNBonds();
93  
94      for (int i = 0; i < nBonds; ++i) {
95 <        currentBondStamp = molStamp->getBond(i);
96 <        bond = createBond(ff, mol, currentBondStamp);
97 <        mol->addBond(bond);
95 >      currentBondStamp = molStamp->getBondStamp(i);
96 >      bond = createBond(ff, mol, currentBondStamp);
97 >      mol->addBond(bond);
98      }
99  
100      //create bends
# Line 102 | Line 102 | Molecule* MoleculeCreator::createMolecule(ForceField*
102      BendStamp* currentBendStamp;
103      int nBends = molStamp->getNBends();
104      for (int i = 0; i < nBends; ++i) {
105 <        currentBendStamp = molStamp->getBend(i);
106 <        bend = createBend(ff, mol, currentBendStamp);
107 <        mol->addBend(bend);
105 >      currentBendStamp = molStamp->getBendStamp(i);
106 >      bend = createBend(ff, mol, currentBendStamp);
107 >      mol->addBend(bend);
108      }
109  
110      //create torsions
# Line 112 | Line 112 | Molecule* MoleculeCreator::createMolecule(ForceField*
112      TorsionStamp* currentTorsionStamp;
113      int nTorsions = molStamp->getNTorsions();
114      for (int i = 0; i < nTorsions; ++i) {
115 <        currentTorsionStamp = molStamp->getTorsion(i);
116 <        torsion = createTorsion(ff, mol, currentTorsionStamp);
117 <        mol->addTorsion(torsion);
115 >      currentTorsionStamp = molStamp->getTorsionStamp(i);
116 >      torsion = createTorsion(ff, mol, currentTorsionStamp);
117 >      mol->addTorsion(torsion);
118      }
119  
120      //create cutoffGroups
# Line 122 | Line 122 | Molecule* MoleculeCreator::createMolecule(ForceField*
122      CutoffGroupStamp* currentCutoffGroupStamp;
123      int nCutoffGroups = molStamp->getNCutoffGroups();
124      for (int i = 0; i < nCutoffGroups; ++i) {
125 <        currentCutoffGroupStamp = molStamp->getCutoffGroup(i);
126 <        cutoffGroup = createCutoffGroup(mol, currentCutoffGroupStamp);
127 <        mol->addCutoffGroup(cutoffGroup);
125 >      currentCutoffGroupStamp = molStamp->getCutoffGroupStamp(i);
126 >      cutoffGroup = createCutoffGroup(mol, currentCutoffGroupStamp);
127 >      mol->addCutoffGroup(cutoffGroup);
128      }
129  
130      //every free atom is a cutoff group    
131 <    std::set<Atom*> allAtoms;
132 <     Molecule::AtomIterator ai;
131 >    std::vector<Atom*> freeAtoms;
132 >    std::vector<Atom*>::iterator ai;
133 >    std::vector<Atom*>::iterator fai;
134  
135      //add all atoms into allAtoms set
136 <    for(atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) {
137 <        allAtoms.insert(atom);
136 >    for(atom = mol->beginAtom(fai); atom != NULL; atom = mol->nextAtom(fai)) {
137 >      freeAtoms.push_back(atom);
138      }
139  
140      Molecule::CutoffGroupIterator ci;
141      CutoffGroup* cg;
141    std::set<Atom*> cutoffAtoms;    
142      
143    //add all of the atoms belong to cutoff groups into cutoffAtoms set
143      for (cg = mol->beginCutoffGroup(ci); cg != NULL; cg = mol->nextCutoffGroup(ci)) {
144  
145 <        for(atom = cg->beginAtom(ai); atom != NULL; atom = cg->nextAtom(ai)) {
146 <            cutoffAtoms.insert(atom);
147 <        }
145 >      for(atom = cg->beginAtom(ai); atom != NULL; atom = cg->nextAtom(ai)) {
146 >           //erase the atoms belong to cutoff groups from freeAtoms vector
147 >           freeAtoms.erase(std::remove(freeAtoms.begin(), freeAtoms.end(), atom), freeAtoms.end());
148 >      }
149  
150      }      
151      
152    //find all free atoms (which do not belong to cutoff groups)  
153    //performs the "difference" operation from set theory,  the output range contains a copy of every
154    //element that is contained in [allAtoms.begin(), allAtoms.end()) and not contained in
155    //[cutoffAtoms.begin(), cutoffAtoms.end()).
156    std::vector<Atom*> freeAtoms;    
157    std::set_difference(allAtoms.begin(), allAtoms.end(), cutoffAtoms.begin(), cutoffAtoms.end(),
158                            std::back_inserter(freeAtoms));
159
160    if (freeAtoms.size() != allAtoms.size() - cutoffAtoms.size()) {
161        //Some atoms in rigidAtoms are not in allAtoms, something must be wrong
162        sprintf(painCave.errMsg, "Atoms in cutoff groups are not in the atom list of the same molecule");
163
164        painCave.isFatal = 1;
165        simError();        
166    }
167
152      //loop over the free atoms and then create one cutoff group for every single free atom
153 <    std::vector<Atom*>::iterator fai;
170 <
153 >    
154      for (fai = freeAtoms.begin(); fai != freeAtoms.end(); ++fai) {
155 <        cutoffGroup = createCutoffGroup(mol, *fai);
156 <        mol->addCutoffGroup(cutoffGroup);
155 >      cutoffGroup = createCutoffGroup(mol, *fai);
156 >      mol->addCutoffGroup(cutoffGroup);
157      }
158      //create constraints
159      createConstraintPair(mol);
# Line 180 | Line 163 | Molecule* MoleculeCreator::createMolecule(ForceField*
163      mol->complete();
164  
165      return mol;
166 < }    
166 >  }    
167  
168  
169 < Atom* MoleculeCreator::createAtom(ForceField* ff, Molecule* mol, AtomStamp* stamp,
170 <                                                                  LocalIndexManager* localIndexMan) {
169 >  Atom* MoleculeCreator::createAtom(ForceField* ff, Molecule* mol, AtomStamp* stamp,
170 >                                    LocalIndexManager* localIndexMan) {
171      AtomType * atomType;
172      Atom* atom;
173  
174      atomType =  ff->getAtomType(stamp->getType());
175  
176      if (atomType == NULL) {
177 <        sprintf(painCave.errMsg, "Can not find Matching Atom Type for[%s]",
178 <                   stamp->getType());
177 >      sprintf(painCave.errMsg, "Can not find Matching Atom Type for[%s]",
178 >              stamp->getType().c_str());
179  
180 <        painCave.isFatal = 1;
181 <        simError();
180 >      painCave.isFatal = 1;
181 >      simError();
182      }
183      
184      //below code still have some kind of hard-coding smell
185      if (atomType->isDirectional()){
186      
187 <        DirectionalAtomType* dAtomType = dynamic_cast<DirectionalAtomType*>(atomType);
187 >      DirectionalAtomType* dAtomType = dynamic_cast<DirectionalAtomType*>(atomType);
188          
189 <        if (dAtomType == NULL) {
190 <            sprintf(painCave.errMsg, "Can not cast AtomType to DirectionalAtomType");
189 >      if (dAtomType == NULL) {
190 >        sprintf(painCave.errMsg, "Can not cast AtomType to DirectionalAtomType");
191  
192 <            painCave.isFatal = 1;
193 <            simError();
194 <        }
192 >        painCave.isFatal = 1;
193 >        simError();
194 >      }
195  
196 <        DirectionalAtom* dAtom;
197 <        dAtom = new DirectionalAtom(dAtomType);
198 <        atom = dAtom;    
196 >      DirectionalAtom* dAtom;
197 >      dAtom = new DirectionalAtom(dAtomType);
198 >      atom = dAtom;    
199      }
200      else{
201 <        atom = new Atom(atomType);
201 >      atom = new Atom(atomType);
202      }
203  
204      atom->setLocalIndex(localIndexMan->getNextAtomIndex());
205  
206      return atom;
207 < }
207 >  }
208  
209 < RigidBody* MoleculeCreator::createRigidBody(MoleculeStamp *molStamp, Molecule* mol,
210 <                                                                                    RigidBodyStamp* rbStamp,
211 <                                                                                    LocalIndexManager* localIndexMan) {
209 >  RigidBody* MoleculeCreator::createRigidBody(MoleculeStamp *molStamp, Molecule* mol,
210 >                                              RigidBodyStamp* rbStamp,
211 >                                              LocalIndexManager* localIndexMan) {
212      Atom* atom;
213      int nAtoms;
214      Vector3d refCoor;
# Line 234 | Line 217 | RigidBody* MoleculeCreator::createRigidBody(MoleculeSt
217      RigidBody* rb = new RigidBody();
218      nAtoms = rbStamp->getNMembers();    
219      for (int i = 0; i < nAtoms; ++i) {
220 <        //rbStamp->getMember(i) return the local index of current atom inside the molecule.
221 <        //It is not the same as local index of atom which is the index of atom at DataStorage class
222 <        atom = mol->getAtomAt(rbStamp->getMember(i));
223 <        atomStamp= molStamp->getAtom(rbStamp->getMember(i));    
224 <        rb->addAtom(atom, atomStamp);
220 >      //rbStamp->getMember(i) return the local index of current atom inside the molecule.
221 >      //It is not the same as local index of atom which is the index of atom at DataStorage class
222 >      atom = mol->getAtomAt(rbStamp->getMemberAt(i));
223 >      atomStamp= molStamp->getAtomStamp(rbStamp->getMemberAt(i));    
224 >      rb->addAtom(atom, atomStamp);
225      }
226  
227      //after all of the atoms are added, we need to calculate the reference coordinates
# Line 253 | Line 236 | RigidBody* MoleculeCreator::createRigidBody(MoleculeSt
236      //The third part is the index of the rigidbody defined in meta-data file
237      //For example, Butane_RB_0 is a valid rigid body name of butane molecule
238      /**@todo replace itoa by lexi_cast */
239 <    rb->setType(mol->getType() + "_RB_" + toString(mol->getNRigidBodies()));
240 <    
239 >    std::string s = OOPSE_itoa(mol->getNRigidBodies(), 10);
240 >    rb->setType(mol->getType() + "_RB_" + s.c_str());
241 >
242      return rb;
243 < }    
243 >  }    
244  
245 < Bond* MoleculeCreator::createBond(ForceField* ff, Molecule* mol, BondStamp* stamp) {
245 >  Bond* MoleculeCreator::createBond(ForceField* ff, Molecule* mol, BondStamp* stamp) {
246      BondType* bondType;
247      Atom* atomA;
248      Atom* atomB;
# Line 271 | Line 255 | Bond* MoleculeCreator::createBond(ForceField* ff, Mole
255      bondType = ff->getBondType(atomA->getType(), atomB->getType());
256  
257      if (bondType == NULL) {
258 <        sprintf(painCave.errMsg, "Can not find Matching Bond Type for[%s, %s]",
259 <                   atomA->getType().c_str(),
260 <                   atomB->getType().c_str());
258 >      sprintf(painCave.errMsg, "Can not find Matching Bond Type for[%s, %s]",
259 >              atomA->getType().c_str(),
260 >              atomB->getType().c_str());
261  
262 <        painCave.isFatal = 1;
263 <        simError();
262 >      painCave.isFatal = 1;
263 >      simError();
264      }
265      return new Bond(atomA, atomB, bondType);    
266 < }    
266 >  }    
267  
268 < Bend* MoleculeCreator::createBend(ForceField* ff, Molecule* mol, BendStamp* stamp) {
269 <    bool isGhostBend = false;
270 <    int ghostIndex;
268 >  Bend* MoleculeCreator::createBend(ForceField* ff, Molecule* mol, BendStamp* stamp) {
269 >    Bend* bend = NULL;
270 >    std::vector<int> bendAtoms = stamp->getMembers();
271 >    if (bendAtoms.size() == 3) {
272 >      Atom* atomA = mol->getAtomAt(bendAtoms[0]);
273 >      Atom* atomB = mol->getAtomAt(bendAtoms[1]);
274 >      Atom* atomC = mol->getAtomAt(bendAtoms[2]);
275  
276 <    
289 <    //
290 <    if (stamp->haveExtras()){
291 <        LinkedAssign* extras = stamp->getExtras();
292 <        LinkedAssign* currentExtra = extras;
276 >      assert( atomA && atomB && atomC);
277  
278 <        while (currentExtra != NULL){
295 <            if (!strcmp(currentExtra->getlhs(), "ghostVectorSource")){
296 <                switch (currentExtra->getType()){
297 <                case 0:
298 <                    ghostIndex = currentExtra->getInt();
299 <                    isGhostBend = true;
300 <                    break;
278 >      BendType* bendType = ff->getBendType(atomA->getType().c_str(), atomB->getType().c_str(), atomC->getType().c_str());
279  
280 <                default:
281 <                sprintf(painCave.errMsg,
282 <                "SimSetup Error: ghostVectorSource must be an int.\n");
283 <                painCave.isFatal = 1;
284 <                simError();
307 <                }
308 <            } else{
309 <                sprintf(painCave.errMsg,
310 <                "SimSetup Error: unhandled bend assignment:\n");
311 <                painCave.isFatal = 1;
312 <                simError();
313 <            }
314 <            currentExtra = currentExtra->getNext();
315 <        }
316 <        
317 <    }
280 >      if (bendType == NULL) {
281 >        sprintf(painCave.errMsg, "Can not find Matching Bend Type for[%s, %s, %s]",
282 >                atomA->getType().c_str(),
283 >                atomB->getType().c_str(),
284 >                atomC->getType().c_str());
285  
286 <    if (isGhostBend) {
286 >        painCave.isFatal = 1;
287 >        simError();
288 >      }
289  
290 <        int indexA = stamp->getA();
291 <        int indexB= stamp->getB();
290 >      bend = new Bend(atomA, atomB, atomC, bendType);
291 >    } else if ( bendAtoms.size() == 2 && stamp->haveGhostVectorSource()) {
292 >      int ghostIndex = stamp->getGhostVectorSource();
293 >      int normalIndex = ghostIndex != bendAtoms[0] ? bendAtoms[0] : bendAtoms[1];
294 >      Atom* normalAtom = mol->getAtomAt(normalIndex) ;        
295 >      DirectionalAtom* ghostAtom = dynamic_cast<DirectionalAtom*>(mol->getAtomAt(ghostIndex));
296 >      if (ghostAtom == NULL) {
297 >        sprintf(painCave.errMsg, "Can not cast Atom to DirectionalAtom");
298 >        painCave.isFatal = 1;
299 >        simError();
300 >      }
301 >                
302 >      BendType* bendType = ff->getBendType(normalAtom->getType(), ghostAtom->getType(), "GHOST");
303  
304 <        assert(indexA != indexB);
305 <
306 <        int normalIndex;
307 <        if (indexA == ghostIndex) {
308 <            normalIndex = indexB;
329 <        } else if (indexB == ghostIndex) {
330 <            normalIndex = indexA;
331 <        }
332 <        
333 <        Atom* normalAtom = mol->getAtomAt(normalIndex) ;        
334 <        DirectionalAtom* ghostAtom = dynamic_cast<DirectionalAtom*>(mol->getAtomAt(ghostIndex));
335 <        if (ghostAtom == NULL) {
336 <            sprintf(painCave.errMsg, "Can not cast Atom to DirectionalAtom");
337 <            painCave.isFatal = 1;
338 <            simError();
339 <        }
340 <                
341 <        BendType* bendType = ff->getBendType(normalAtom->getType(), ghostAtom->getType(), "GHOST");
304 >      if (bendType == NULL) {
305 >        sprintf(painCave.errMsg, "Can not find Matching Bend Type for[%s, %s, %s]",
306 >                normalAtom->getType().c_str(),
307 >                ghostAtom->getType().c_str(),
308 >                "GHOST");
309  
310 <        if (bendType == NULL) {
311 <            sprintf(painCave.errMsg, "Can not find Matching Bend Type for[%s, %s, %s]",
312 <                       normalAtom->getType().c_str(),
346 <                       ghostAtom->getType().c_str(),
347 <                       "GHOST");
348 <
349 <            painCave.isFatal = 1;
350 <            simError();
351 <        }
310 >        painCave.isFatal = 1;
311 >        simError();
312 >      }
313          
314 <        return new GhostBend(normalAtom, ghostAtom, bendType);      
314 >      bend = new GhostBend(normalAtom, ghostAtom, bendType);      
315  
316 <    } else {
317 <            
318 <        Atom* atomA = mol->getAtomAt(stamp->getA());
319 <        Atom* atomB = mol->getAtomAt(stamp->getB());
359 <        Atom* atomC = mol->getAtomAt(stamp->getC());
316 >    }
317 >    
318 >    return bend;
319 >  }    
320  
321 <        assert( atomA && atomB && atomC);
362 <        
363 <        BendType* bendType = ff->getBendType(atomA->getType(), atomB->getType(), atomC->getType());
321 >  Torsion* MoleculeCreator::createTorsion(ForceField* ff, Molecule* mol, TorsionStamp* stamp) {
322  
323 <        if (bendType == NULL) {
324 <            sprintf(painCave.errMsg, "Can not find Matching Bend Type for[%s, %s, %s]",
325 <                       atomA->getType().c_str(),
326 <                       atomB->getType().c_str(),
369 <                       atomC->getType().c_str());
370 <
371 <            painCave.isFatal = 1;
372 <            simError();
373 <        }
374 <
375 <        return new Bend(atomA, atomB, atomC, bendType);      
323 >    Torsion* torsion = NULL;
324 >    std::vector<int> torsionAtoms = stamp->getMembers();
325 >    if (torsionAtoms.size() < 3) {
326 >        return torsion;
327      }
377 }    
328  
329 < Torsion* MoleculeCreator::createTorsion(ForceField* ff, Molecule* mol, TorsionStamp* stamp) {
329 >    Atom* atomA = mol->getAtomAt(torsionAtoms[0]);
330 >    Atom* atomB = mol->getAtomAt(torsionAtoms[1]);
331 >    Atom* atomC = mol->getAtomAt(torsionAtoms[2]);
332  
333 <    Atom* atomA = mol->getAtomAt(stamp->getA());
334 <    Atom* atomB = mol->getAtomAt(stamp->getB());
383 <    Atom* atomC = mol->getAtomAt(stamp->getC());
384 <    Torsion* torsion;
333 >    if (torsionAtoms.size() == 4) {
334 >      Atom* atomD = mol->getAtomAt(torsionAtoms[3]);
335  
336 <    if (stamp->getD() != -1) {
387 <        Atom* atomD = mol->getAtomAt(stamp->getD());
388 <
389 <        assert(atomA && atomB && atomC && atomD);
336 >      assert(atomA && atomB && atomC && atomD);
337          
338 <        TorsionType* torsionType = ff->getTorsionType(atomA->getType(), atomB->getType(),
339 <                                                           atomC->getType(), atomD->getType());
338 >      TorsionType* torsionType = ff->getTorsionType(atomA->getType(), atomB->getType(),
339 >                                                    atomC->getType(), atomD->getType());
340  
341 <        if (torsionType == NULL) {
342 <            sprintf(painCave.errMsg, "Can not find Matching Torsion Type for[%s, %s, %s, %s]",
343 <                       atomA->getType().c_str(),
344 <                       atomB->getType().c_str(),
345 <                       atomC->getType().c_str(),
346 <                       atomD->getType().c_str());
341 >      if (torsionType == NULL) {
342 >        sprintf(painCave.errMsg, "Can not find Matching Torsion Type for[%s, %s, %s, %s]",
343 >                atomA->getType().c_str(),
344 >                atomB->getType().c_str(),
345 >                atomC->getType().c_str(),
346 >                atomD->getType().c_str());
347  
348 <            painCave.isFatal = 1;
349 <            simError();
350 <        }
348 >        painCave.isFatal = 1;
349 >        simError();
350 >      }
351          
352 <        torsion = new Torsion(atomA, atomB, atomC, atomD, torsionType);      
352 >      torsion = new Torsion(atomA, atomB, atomC, atomD, torsionType);      
353      }
354      else {
355  
356 <        DirectionalAtom* dAtom = dynamic_cast<DirectionalAtom*>(atomC);
357 <        if (dAtom == NULL) {
358 <            sprintf(painCave.errMsg, "Can not cast Atom to DirectionalAtom");
359 <            painCave.isFatal = 1;
360 <            simError();
361 <        }        
356 >      DirectionalAtom* dAtom = dynamic_cast<DirectionalAtom*>(mol->getAtomAt(stamp->getGhostVectorSource()));
357 >      if (dAtom == NULL) {
358 >        sprintf(painCave.errMsg, "Can not cast Atom to DirectionalAtom");
359 >        painCave.isFatal = 1;
360 >        simError();
361 >      }        
362  
363 <        TorsionType* torsionType = ff->getTorsionType(atomA->getType(), atomB->getType(),
364 <                                                           atomC->getType(), "GHOST");
363 >      TorsionType* torsionType = ff->getTorsionType(atomA->getType(), atomB->getType(),
364 >                                                    atomC->getType(), "GHOST");
365  
366 <        if (torsionType == NULL) {
367 <            sprintf(painCave.errMsg, "Can not find Matching Torsion Type for[%s, %s, %s, %s]",
368 <                       atomA->getType().c_str(),
369 <                       atomB->getType().c_str(),
370 <                       atomC->getType().c_str(),
371 <                       "GHOST");
366 >      if (torsionType == NULL) {
367 >        sprintf(painCave.errMsg, "Can not find Matching Torsion Type for[%s, %s, %s, %s]",
368 >                atomA->getType().c_str(),
369 >                atomB->getType().c_str(),
370 >                atomC->getType().c_str(),
371 >                "GHOST");
372  
373 <            painCave.isFatal = 1;
374 <            simError();
375 <        }
373 >        painCave.isFatal = 1;
374 >        simError();
375 >      }
376          
377 <        torsion = new GhostTorsion(atomA, atomB, dAtom, torsionType);              
377 >      torsion = new GhostTorsion(atomA, atomB, dAtom, torsionType);              
378      }
379  
380      return torsion;
381 < }    
381 >  }    
382  
383 < CutoffGroup* MoleculeCreator::createCutoffGroup(Molecule* mol, CutoffGroupStamp* stamp) {
383 >  CutoffGroup* MoleculeCreator::createCutoffGroup(Molecule* mol, CutoffGroupStamp* stamp) {
384      int nAtoms;
385      CutoffGroup* cg;
386      Atom* atom;
# Line 441 | Line 388 | CutoffGroup* MoleculeCreator::createCutoffGroup(Molecu
388      
389      nAtoms = stamp->getNMembers();
390      for (int i =0; i < nAtoms; ++i) {
391 <        atom = mol->getAtomAt(stamp->getMember(i));
392 <        assert(atom);
393 <        cg->addAtom(atom);
391 >      atom = mol->getAtomAt(stamp->getMemberAt(i));
392 >      assert(atom);
393 >      cg->addAtom(atom);
394      }
395  
396      return cg;
397 < }    
397 >  }    
398  
399 < CutoffGroup* MoleculeCreator::createCutoffGroup(Molecule * mol, Atom* atom) {
399 >  CutoffGroup* MoleculeCreator::createCutoffGroup(Molecule * mol, Atom* atom) {
400      CutoffGroup* cg;
401      cg  = new CutoffGroup();
402      cg->addAtom(atom);
403      return cg;
404 < }
404 >  }
405  
406 < void MoleculeCreator::createConstraintPair(Molecule* mol) {
406 >  void MoleculeCreator::createConstraintPair(Molecule* mol) {
407  
408      //add bond constraints
409      Molecule::BondIterator bi;
410      Bond* bond;
411      for (bond = mol->beginBond(bi); bond != NULL; bond = mol->nextBond(bi)) {
412          
413 <        BondType* bt = bond->getBondType();
413 >      BondType* bt = bond->getBondType();
414  
415 <        //class Parent1 {};
416 <        //class Child1 : public Parent {};
417 <        //class Child2 : public Parent {};
418 <        //Child1* ch1 = new Child1();
419 <        //Child2* ch2 = dynamic_cast<Child2*>(ch1);
420 <        //the dynamic_cast is succeed in above line. A compiler bug?        
415 >      //class Parent1 {};
416 >      //class Child1 : public Parent {};
417 >      //class Child2 : public Parent {};
418 >      //Child1* ch1 = new Child1();
419 >      //Child2* ch2 = dynamic_cast<Child2*>(ch1);
420 >      //the dynamic_cast is succeed in above line. A compiler bug?        
421  
422 <        if (typeid(FixedBondType) == typeid(*bt)) {
423 <            FixedBondType* fbt = dynamic_cast<FixedBondType*>(bt);
422 >      if (typeid(FixedBondType) == typeid(*bt)) {
423 >        FixedBondType* fbt = dynamic_cast<FixedBondType*>(bt);
424  
425 <            ConstraintElem* consElemA = new ConstraintElem(bond->getAtomA());
426 <            ConstraintElem* consElemB = new ConstraintElem(bond->getAtomB());            
427 <            ConstraintPair* consPair = new ConstraintPair(consElemA, consElemB, fbt->getEquilibriumBondLength());
428 <            mol->addConstraintPair(consPair);
429 <        }
425 >        ConstraintElem* consElemA = new ConstraintElem(bond->getAtomA());
426 >        ConstraintElem* consElemB = new ConstraintElem(bond->getAtomB());            
427 >        ConstraintPair* consPair = new ConstraintPair(consElemA, consElemB, fbt->getEquilibriumBondLength());
428 >        mol->addConstraintPair(consPair);
429 >      }
430      }
431  
432      //rigidbody -- rigidbody constraint is not support yet
433 < }
433 >  }
434  
435 < void MoleculeCreator::createConstraintElem(Molecule* mol) {
435 >  void MoleculeCreator::createConstraintElem(Molecule* mol) {
436  
437      ConstraintPair* consPair;
438      Molecule::ConstraintPairIterator cpi;
439      std::set<StuntDouble*> sdSet;
440      for (consPair = mol->beginConstraintPair(cpi); consPair != NULL; consPair = mol->nextConstraintPair(cpi)) {
441  
442 <        StuntDouble* sdA = consPair->getConsElem1()->getStuntDouble();            
443 <        if (sdSet.find(sdA) == sdSet.end()){
444 <            sdSet.insert(sdA);
445 <            mol->addConstraintElem(new ConstraintElem(sdA));
446 <        }
442 >      StuntDouble* sdA = consPair->getConsElem1()->getStuntDouble();            
443 >      if (sdSet.find(sdA) == sdSet.end()){
444 >        sdSet.insert(sdA);
445 >        mol->addConstraintElem(new ConstraintElem(sdA));
446 >      }
447  
448 <        StuntDouble* sdB = consPair->getConsElem2()->getStuntDouble();            
449 <        if (sdSet.find(sdB) == sdSet.end()){
450 <            sdSet.insert(sdB);
451 <            mol->addConstraintElem(new ConstraintElem(sdB));
452 <        }
448 >      StuntDouble* sdB = consPair->getConsElem2()->getStuntDouble();            
449 >      if (sdSet.find(sdB) == sdSet.end()){
450 >        sdSet.insert(sdB);
451 >        mol->addConstraintElem(new ConstraintElem(sdB));
452 >      }
453          
454      }
455  
456 < }
456 >  }
457      
458   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines