--- branches/development/src/UseTheForce/ForceField.cpp 2010/12/28 21:47:55 1530 +++ branches/development/src/UseTheForce/ForceField.cpp 2010/12/31 18:31:56 1535 @@ -51,7 +51,6 @@ #include "UseTheForce/ForceField.hpp" #include "utils/simError.h" #include "utils/Tuple.hpp" -#include "UseTheForce/DarkSide/atype_interface.h" namespace OpenMD { ForceField::ForceField() { @@ -67,17 +66,29 @@ namespace OpenMD { } } - - ForceField::~ForceField() { - deleteAtypes(); - } - + /** + * getAtomType by string + * + * finds the requested atom type in this force field using the string + * name of the atom type. + */ AtomType* ForceField::getAtomType(const std::string &at) { std::vector keys; keys.push_back(at); return atomTypeCont_.find(keys); } + /** + * getAtomType by ident + * + * finds the requested atom type in this force field using the + * integer ident instead of the string name of the atom type. + */ + AtomType* ForceField::getAtomType(int ident) { + std::string at = atypeIdentToName.find(ident)->second; + return getAtomType(at); + } + BondType* ForceField::getBondType(const std::string &at1, const std::string &at2) { std::vector keys; @@ -440,14 +451,14 @@ namespace OpenMD { std::vector keys; keys.push_back(at1); keys.push_back(at2); - + //try exact match first NonBondedInteractionType* nbiType = nonBondedInteractionTypeCont_.find(keys); if (nbiType) { return nbiType; } else { //if no exact match found, try wild card match - return nonBondedInteractionTypeCont_.find(keys, wildCardAtomTypeName_); + return nonBondedInteractionTypeCont_.find(keys, wildCardAtomTypeName_); } } @@ -504,12 +515,14 @@ namespace OpenMD { bool ForceField::addAtomType(const std::string &at, AtomType* atomType) { std::vector keys; keys.push_back(at); + atypeIdentToName[atomType->getIdent()] = at; return atomTypeCont_.add(keys, atomType); } bool ForceField::replaceAtomType(const std::string &at, AtomType* atomType) { std::vector keys; keys.push_back(at); + atypeIdentToName[atomType->getIdent()] = at; return atomTypeCont_.replace(keys, atomType); }