| 97 | 
  | 
 | 
| 98 | 
  | 
    for (int i = 0; i < nBonds; ++i) { | 
| 99 | 
  | 
      currentBondStamp = molStamp->getBondStamp(i); | 
| 100 | 
< | 
      bond = createBond(ff, mol, currentBondStamp); | 
| 100 | 
> | 
      bond = createBond(ff, mol, currentBondStamp, localIndexMan); | 
| 101 | 
  | 
      mol->addBond(bond); | 
| 102 | 
  | 
    } | 
| 103 | 
  | 
 | 
| 107 | 
  | 
    int nBends = molStamp->getNBends(); | 
| 108 | 
  | 
    for (int i = 0; i < nBends; ++i) { | 
| 109 | 
  | 
      currentBendStamp = molStamp->getBendStamp(i); | 
| 110 | 
< | 
      bend = createBend(ff, mol, currentBendStamp); | 
| 110 | 
> | 
      bend = createBend(ff, mol, currentBendStamp, localIndexMan); | 
| 111 | 
  | 
      mol->addBend(bend); | 
| 112 | 
  | 
    } | 
| 113 | 
  | 
 | 
| 117 | 
  | 
    int nTorsions = molStamp->getNTorsions(); | 
| 118 | 
  | 
    for (int i = 0; i < nTorsions; ++i) { | 
| 119 | 
  | 
      currentTorsionStamp = molStamp->getTorsionStamp(i); | 
| 120 | 
< | 
      torsion = createTorsion(ff, mol, currentTorsionStamp); | 
| 120 | 
> | 
      torsion = createTorsion(ff, mol, currentTorsionStamp, localIndexMan); | 
| 121 | 
  | 
      mol->addTorsion(torsion); | 
| 122 | 
  | 
    } | 
| 123 | 
  | 
 | 
| 127 | 
  | 
    int nInversions = molStamp->getNInversions(); | 
| 128 | 
  | 
    for (int i = 0; i < nInversions; ++i) { | 
| 129 | 
  | 
      currentInversionStamp = molStamp->getInversionStamp(i); | 
| 130 | 
< | 
      inversion = createInversion(ff, mol, currentInversionStamp); | 
| 130 | 
> | 
      inversion = createInversion(ff, mol, currentInversionStamp,  | 
| 131 | 
> | 
                                  localIndexMan); | 
| 132 | 
  | 
      if (inversion != NULL ) { | 
| 133 | 
  | 
        mol->addInversion(inversion); | 
| 134 | 
  | 
      } | 
| 140 | 
  | 
    int nCutoffGroups = molStamp->getNCutoffGroups(); | 
| 141 | 
  | 
    for (int i = 0; i < nCutoffGroups; ++i) { | 
| 142 | 
  | 
      currentCutoffGroupStamp = molStamp->getCutoffGroupStamp(i); | 
| 143 | 
< | 
      cutoffGroup = createCutoffGroup(mol, currentCutoffGroupStamp, localIndexMan); | 
| 143 | 
> | 
      cutoffGroup = createCutoffGroup(mol, currentCutoffGroupStamp,  | 
| 144 | 
> | 
                                      localIndexMan); | 
| 145 | 
  | 
      mol->addCutoffGroup(cutoffGroup); | 
| 146 | 
  | 
    } | 
| 147 | 
  | 
 | 
| 228 | 
  | 
  RigidBody* MoleculeCreator::createRigidBody(MoleculeStamp *molStamp,  | 
| 229 | 
  | 
                                              Molecule* mol, | 
| 230 | 
  | 
                                              RigidBodyStamp* rbStamp,  | 
| 231 | 
< | 
                                              LocalIndexManager* localIndexMan) { | 
| 231 | 
> | 
                                              LocalIndexManager* localIndexMan){ | 
| 232 | 
  | 
    Atom* atom; | 
| 233 | 
  | 
    int nAtoms; | 
| 234 | 
  | 
    Vector3d refCoor; | 
| 252 | 
  | 
    //set the local index of this rigid body, global index will be set later | 
| 253 | 
  | 
    rb->setLocalIndex(localIndexMan->getNextRigidBodyIndex()); | 
| 254 | 
  | 
 | 
| 255 | 
< | 
    //the rule for naming rigidbody MoleculeName_RB_Integer | 
| 256 | 
< | 
    //The first part is the name of the molecule | 
| 257 | 
< | 
    //The second part is alway fixed as "RB" | 
| 258 | 
< | 
    //The third part is the index of the rigidbody defined in meta-data file | 
| 259 | 
< | 
    //For example, Butane_RB_0 is a valid rigid body name of butane molecule | 
| 260 | 
< | 
    /**@todo replace itoa by lexi_cast */ | 
| 255 | 
> | 
    // The rule for naming a rigidbody is: MoleculeName_RB_Integer | 
| 256 | 
> | 
    // The first part is the name of the molecule | 
| 257 | 
> | 
    // The second part is always fixed as "RB" | 
| 258 | 
> | 
    // The third part is the index of the rigidbody defined in meta-data file | 
| 259 | 
> | 
    // For example, Butane_RB_0 is a valid rigid body name of butane molecule | 
| 260 | 
> | 
 | 
| 261 | 
  | 
    std::string s = OpenMD_itoa(mol->getNRigidBodies(), 10); | 
| 262 | 
  | 
    rb->setType(mol->getType() + "_RB_" + s.c_str()); | 
| 261 | 
– | 
 | 
| 263 | 
  | 
    return rb; | 
| 264 | 
  | 
  }     | 
| 265 | 
  | 
 | 
| 266 | 
  | 
  Bond* MoleculeCreator::createBond(ForceField* ff, Molecule* mol,  | 
| 267 | 
< | 
                                    BondStamp* stamp) { | 
| 267 | 
> | 
                                    BondStamp* stamp, | 
| 268 | 
> | 
                                    LocalIndexManager* localIndexMan) { | 
| 269 | 
  | 
    BondType* bondType; | 
| 270 | 
  | 
    Atom* atomA; | 
| 271 | 
  | 
    Atom* atomB; | 
| 285 | 
  | 
      painCave.isFatal = 1; | 
| 286 | 
  | 
      simError(); | 
| 287 | 
  | 
    } | 
| 288 | 
< | 
    return new Bond(atomA, atomB, bondType);     | 
| 288 | 
> | 
    Bond* bond = new Bond(atomA, atomB, bondType); | 
| 289 | 
> | 
 | 
| 290 | 
> | 
    //set the local index of this bond, the global index will be set later | 
| 291 | 
> | 
    bond->setLocalIndex(localIndexMan->getNextBondIndex()); | 
| 292 | 
> | 
 | 
| 293 | 
> | 
    // The rule for naming a bond is: MoleculeName_Bond_Integer | 
| 294 | 
> | 
    // The first part is the name of the molecule | 
| 295 | 
> | 
    // The second part is always fixed as "Bond" | 
| 296 | 
> | 
    // The third part is the index of the bond defined in meta-data file | 
| 297 | 
> | 
    // For example, Butane_bond_0 is a valid Bond name in a butane molecule | 
| 298 | 
> | 
 | 
| 299 | 
> | 
    std::string s = OpenMD_itoa(mol->getNBonds(), 10); | 
| 300 | 
> | 
    bond->setName(mol->getType() + "_Bond_" + s.c_str()); | 
| 301 | 
> | 
    return bond;     | 
| 302 | 
  | 
  }     | 
| 303 | 
  | 
   | 
| 304 | 
  | 
  Bend* MoleculeCreator::createBend(ForceField* ff, Molecule* mol,  | 
| 305 | 
< | 
                                    BendStamp* stamp) { | 
| 305 | 
> | 
                                    BendStamp* stamp, | 
| 306 | 
> | 
                                    LocalIndexManager* localIndexMan) { | 
| 307 | 
  | 
    Bend* bend = NULL;  | 
| 308 | 
  | 
    std::vector<int> bendAtoms = stamp->getMembers();  | 
| 309 | 
  | 
    if (bendAtoms.size() == 3) { | 
| 318 | 
  | 
                                           atomC->getType().c_str()); | 
| 319 | 
  | 
       | 
| 320 | 
  | 
      if (bendType == NULL) { | 
| 321 | 
< | 
        sprintf(painCave.errMsg, "Can not find Matching Bend Type for[%s, %s, %s]", | 
| 321 | 
> | 
        sprintf(painCave.errMsg,  | 
| 322 | 
> | 
                "Can not find Matching Bend Type for[%s, %s, %s]", | 
| 323 | 
  | 
                atomA->getType().c_str(), | 
| 324 | 
  | 
                atomB->getType().c_str(), | 
| 325 | 
  | 
                atomC->getType().c_str()); | 
| 343 | 
  | 
      BendType* bendType = ff->getBendType(normalAtom->getType(), ghostAtom->getType(), "GHOST"); | 
| 344 | 
  | 
 | 
| 345 | 
  | 
      if (bendType == NULL) { | 
| 346 | 
< | 
        sprintf(painCave.errMsg, "Can not find Matching Bend Type for[%s, %s, %s]", | 
| 346 | 
> | 
        sprintf(painCave.errMsg,  | 
| 347 | 
> | 
                "Can not find Matching Bend Type for[%s, %s, %s]", | 
| 348 | 
  | 
                normalAtom->getType().c_str(), | 
| 349 | 
  | 
                ghostAtom->getType().c_str(), | 
| 350 | 
  | 
                "GHOST"); | 
| 356 | 
  | 
      bend = new GhostBend(normalAtom, ghostAtom, bendType);        | 
| 357 | 
  | 
       | 
| 358 | 
  | 
    }  | 
| 359 | 
< | 
     | 
| 359 | 
> | 
 | 
| 360 | 
> | 
    //set the local index of this bend, the global index will be set later | 
| 361 | 
> | 
    bend->setLocalIndex(localIndexMan->getNextBendIndex()); | 
| 362 | 
> | 
 | 
| 363 | 
> | 
    // The rule for naming a bend is: MoleculeName_Bend_Integer | 
| 364 | 
> | 
    // The first part is the name of the molecule | 
| 365 | 
> | 
    // The second part is always fixed as "Bend" | 
| 366 | 
> | 
    // The third part is the index of the bend defined in meta-data file | 
| 367 | 
> | 
    // For example, Butane_Bend_0 is a valid Bend name in a butane molecule | 
| 368 | 
> | 
 | 
| 369 | 
> | 
    std::string s = OpenMD_itoa(mol->getNBends(), 10); | 
| 370 | 
> | 
    bend->setName(mol->getType() + "_Bend_" + s.c_str());     | 
| 371 | 
  | 
    return bend; | 
| 372 | 
  | 
  }     | 
| 373 | 
  | 
 | 
| 374 | 
  | 
  Torsion* MoleculeCreator::createTorsion(ForceField* ff, Molecule* mol,  | 
| 375 | 
< | 
                                          TorsionStamp* stamp) { | 
| 375 | 
> | 
                                          TorsionStamp* stamp, | 
| 376 | 
> | 
                                          LocalIndexManager* localIndexMan) { | 
| 377 | 
  | 
 | 
| 378 | 
  | 
    Torsion* torsion = NULL; | 
| 379 | 
  | 
    std::vector<int> torsionAtoms = stamp->getMembers(); | 
| 395 | 
  | 
                                                    atomC->getType(),  | 
| 396 | 
  | 
                                                    atomD->getType()); | 
| 397 | 
  | 
      if (torsionType == NULL) { | 
| 398 | 
< | 
        sprintf(painCave.errMsg, "Can not find Matching Torsion Type for[%s, %s, %s, %s]", | 
| 398 | 
> | 
        sprintf(painCave.errMsg,  | 
| 399 | 
> | 
                "Can not find Matching Torsion Type for[%s, %s, %s, %s]", | 
| 400 | 
  | 
                atomA->getType().c_str(), | 
| 401 | 
  | 
                atomB->getType().c_str(), | 
| 402 | 
  | 
                atomC->getType().c_str(), | 
| 433 | 
  | 
       | 
| 434 | 
  | 
      torsion = new GhostTorsion(atomA, atomB, dAtom, torsionType);                | 
| 435 | 
  | 
    } | 
| 436 | 
+ | 
 | 
| 437 | 
+ | 
    //set the local index of this torsion, the global index will be set later | 
| 438 | 
+ | 
    torsion->setLocalIndex(localIndexMan->getNextTorsionIndex()); | 
| 439 | 
  | 
     | 
| 440 | 
+ | 
    // The rule for naming a torsion is: MoleculeName_Torsion_Integer | 
| 441 | 
+ | 
    // The first part is the name of the molecule | 
| 442 | 
+ | 
    // The second part is always fixed as "Torsion" | 
| 443 | 
+ | 
    // The third part is the index of the torsion defined in meta-data file | 
| 444 | 
+ | 
    // For example, Butane_Torsion_0 is a valid Torsion name in a | 
| 445 | 
+ | 
    // butane molecule | 
| 446 | 
+ | 
 | 
| 447 | 
+ | 
    std::string s = OpenMD_itoa(mol->getNTorsions(), 10); | 
| 448 | 
+ | 
    torsion->setName(mol->getType() + "_Torsion_" + s.c_str()); | 
| 449 | 
  | 
    return torsion; | 
| 450 | 
  | 
  }     | 
| 451 | 
  | 
 | 
| 452 | 
  | 
  Inversion* MoleculeCreator::createInversion(ForceField* ff, Molecule* mol,  | 
| 453 | 
< | 
                                              InversionStamp* stamp) { | 
| 453 | 
> | 
                                              InversionStamp* stamp, | 
| 454 | 
> | 
                                              LocalIndexManager* localIndexMan) { | 
| 455 | 
  | 
     | 
| 456 | 
  | 
    Inversion* inversion = NULL; | 
| 457 | 
  | 
    int center = stamp->getCenter(); | 
| 487 | 
  | 
    } else { | 
| 488 | 
  | 
       | 
| 489 | 
  | 
      inversion = new Inversion(atomA, atomB, atomC, atomD, inversionType); | 
| 490 | 
+ | 
 | 
| 491 | 
+ | 
      // set the local index of this inversion, the global index will | 
| 492 | 
+ | 
      // be set later | 
| 493 | 
+ | 
      inversion->setLocalIndex(localIndexMan->getNextInversionIndex()); | 
| 494 | 
+ | 
 | 
| 495 | 
+ | 
      // The rule for naming an inversion is: MoleculeName_Inversion_Integer | 
| 496 | 
+ | 
      // The first part is the name of the molecule | 
| 497 | 
+ | 
      // The second part is always fixed as "Inversion" | 
| 498 | 
+ | 
      // The third part is the index of the inversion defined in meta-data file | 
| 499 | 
+ | 
      // For example, Benzene_Inversion_0 is a valid Inversion name in a | 
| 500 | 
+ | 
      // Benzene molecule | 
| 501 | 
+ | 
 | 
| 502 | 
+ | 
      std::string s = OpenMD_itoa(mol->getNInversions(), 10); | 
| 503 | 
+ | 
      inversion->setName(mol->getType() + "_Inversion_" + s.c_str()); | 
| 504 | 
  | 
      return inversion; | 
| 505 | 
  | 
    } | 
| 506 | 
  | 
  } | 
| 548 | 
  | 
         | 
| 549 | 
  | 
      BondType* bt = bond->getBondType(); | 
| 550 | 
  | 
 | 
| 493 | 
– | 
      //class Parent1 {}; | 
| 494 | 
– | 
      //class Child1 : public Parent {}; | 
| 495 | 
– | 
      //class Child2 : public Parent {}; | 
| 496 | 
– | 
      //Child1* ch1 = new Child1(); | 
| 497 | 
– | 
      //Child2* ch2 = dynamic_cast<Child2*>(ch1);  | 
| 498 | 
– | 
      //the dynamic_cast is succeed in above line. A compiler bug?         | 
| 499 | 
– | 
 | 
| 551 | 
  | 
      if (typeid(FixedBondType) == typeid(*bt)) { | 
| 552 | 
  | 
        FixedBondType* fbt = dynamic_cast<FixedBondType*>(bt); | 
| 553 | 
  | 
 |