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

Comparing branches/new_design/OOPSE-2.0/src/brains/MoleculeCreator.cpp (file contents):
Revision 1773 by tim, Fri Nov 12 07:05:43 2004 UTC vs.
Revision 1774 by tim, Tue Nov 23 23:12:23 2004 UTC

# Line 257 | Line 257 | Bend* MoleculeCreator::createBend(ForceField* ff, Mole
257   }    
258  
259   Bend* MoleculeCreator::createBend(ForceField* ff, Molecule* mol, BendStamp* stamp) {
260 <    BendType* bendType;
261 <    Atom* atomA;
262 <    Atom* atomB;
263 <    Atom* atomC;
264 <
265 <    //need to consider the ghost bend
266 <    atomA = mol->getAtomAt(stamp->getA());
267 <    atomB = mol->getAtomAt(stamp->getB());
268 <    atomC = mol->getAtomAt(stamp->getC());
260 >    bool isGhostBend = false;
261 >    int ghostIndex;
262  
270    assert( atomA && atomB && atomC);
263      
264 <    bendType = ff->getBendType(atomA->getType(), atomB->getType(), atomC->getType());
264 >    //
265 >    if (stamp->haveExtras()){
266 >        LinkedAssign* extras = currentBend->getExtras();
267 >        LinkedAssign* currentExtra = extras;
268  
269 <    if (bendType == NULL) {
270 <        sprintf(painCave.errMsg, "Can not find Matching Bend Type for[%s, %s, %s]",
271 <                   atomA->getType().c_str(),
272 <                   atomB->getType().c_str(),
273 <                   atomC->getType().c_str());
269 >        while (currentExtra != NULL){
270 >            if (!strcmp(currentExtra->getlhs(), "ghostVectorSource")){
271 >                switch (currentExtra->getType()){
272 >                case 0:
273 >                    ghostIndex = currentExtra->getInt();
274 >                    isGhostBend = true;
275 >                    break;
276  
277 <        painCave.isFatal = 1;
278 <        simError();
277 >                default:
278 >                sprintf(painCave.errMsg,
279 >                "SimSetup Error: ghostVectorSource must be an int.\n");
280 >                painCave.isFatal = 1;
281 >                simError();
282 >                }
283 >            } else{
284 >                sprintf(painCave.errMsg,
285 >                "SimSetup Error: unhandled bend assignment:\n");
286 >                painCave.isFatal = 1;
287 >                simError();
288 >            }
289 >            currentExtra = currentExtra->getNext();
290 >        }
291 >        
292      }
293  
294 <    return new Bond(atomA, atomB, bendType);      
294 >    if (isGhostBend) {
295  
296 +        int indexA = stamp->getA();
297 +        int indexB= stamp->getB();
298 +
299 +        assert(indexA != indexB);
300 +
301 +        int normalIndex;
302 +        if (indexA == ghostIndex) {
303 +            normalIndex = indexB;
304 +        } else if (indexB == ghostIndex) {
305 +            normalIndex = indexA;
306 +        }
307 +        
308 +        Atom* normalAtom = mol->getAtomAt(normalIndex) ;
309 +        Atom* ghostAtom = mol->getAtomAt(ghostIndex);
310 +        
311 +        BendType* bendType = ff->getBendType(normalAtom->getType(), ghostAtom->getType(), "GHOST");
312 +
313 +        if (bendType == NULL) {
314 +            sprintf(painCave.errMsg, "Can not find Matching Bend Type for[%s, %s, %s]",
315 +                       normalAtom->getType().c_str(),
316 +                       ghostAtom->getType().c_str(),
317 +                       "GHOST");
318 +
319 +            painCave.isFatal = 1;
320 +            simError();
321 +        }
322 +
323 +        return new GhostBend(normalAtom, ghostAtom, bendType);      
324 +
325 +    } else {
326 +            
327 +        Atom* atomA = mol->getAtomAt(stamp->getA());
328 +        Atom* atomB = mol->getAtomAt(stamp->getB());
329 +        Atom* atomC = mol->getAtomAt(stamp->getC());
330 +
331 +        assert( atomA && atomB && atomC);
332 +        
333 +        BendType* bendType = ff->getBendType(atomA->getType(), atomB->getType(), atomC->getType());
334 +
335 +        if (bendType == NULL) {
336 +            sprintf(painCave.errMsg, "Can not find Matching Bend Type for[%s, %s, %s]",
337 +                       atomA->getType().c_str(),
338 +                       atomB->getType().c_str(),
339 +                       atomC->getType().c_str());
340 +
341 +            painCave.isFatal = 1;
342 +            simError();
343 +        }
344 +
345 +        return new Bend(atomA, atomB, atomC, bendType);      
346 +    }
347   }    
348  
349   Torsion* MoleculeCreator::createTorsion(ForceField* ff, Molecule* mol, TorsionStamp* stamp) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines