--- trunk/src/selection/NameFinder.cpp 2009/11/25 20:02:06 1390 +++ trunk/src/selection/NameFinder.cpp 2012/10/01 18:21:15 1801 @@ -36,7 +36,8 @@ * [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005). * [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006). * [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008). - * [4] Vardeman & Gezelter, in progress (2009). + * [4] Kuang & Gezelter, J. Chem. Phys. 133, 164101 (2010). + * [5] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011). */ #include "selection/NameFinder.hpp" #include "utils/wildcards.hpp" @@ -53,13 +54,11 @@ namespace OpenMD { children.clear(); } - NameFinder::NameFinder(SimInfo* info) : info_(info), root_(NULL){ nStuntDouble_ = info_->getNGlobalAtoms() + info_->getNGlobalRigidBodies(); loadNames(); } - NameFinder::~NameFinder(){ delete root_; } @@ -78,7 +77,8 @@ namespace OpenMD { root_->bs.resize(nStuntDouble_); root_->bs.setAll(); // - for (mol = info_->beginMolecule(mi); mol != NULL; mol = info_->nextMolecule(mi)) { + for (mol = info_->beginMolecule(mi); mol != NULL; + mol = info_->nextMolecule(mi)) { std::string molName = mol->getMoleculeName(); TreeNode* currentMolNode = createNode(root_, molName); @@ -91,7 +91,8 @@ namespace OpenMD { currentAtomNode->bs.setBitOn(atom->getGlobalIndex()); } - for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) { + for (rb = mol->beginRigidBody(rbIter); rb != NULL; + rb = mol->nextRigidBody(rbIter)) { std::string rbName = rb->getType(); TreeNode* currentRbNode = createNode(currentMolNode, rbName); @@ -105,11 +106,8 @@ namespace OpenMD { currentRbAtomNode->bs.setBitOn(atom->getGlobalIndex()); } - } - - } - + } } TreeNode* NameFinder::createNode(TreeNode* parent, const std::string& name) { @@ -225,7 +223,7 @@ namespace OpenMD { } bool NameFinder::isMatched(const std::string& str, const std::string& wildcard) { - return Wildcard::wildcardfit (wildcard.c_str(), str.c_str()); + return Wildcard::wildcardfit(wildcard.c_str(), str.c_str()) > 0 ? true : false; } @@ -235,7 +233,8 @@ namespace OpenMD { SimInfo::MoleculeIterator mi; Molecule* mol; - for (mol = info_->beginMolecule(mi); mol != NULL; mol = info_->nextMolecule(mi)) { + for (mol = info_->beginMolecule(mi); mol != NULL; + mol = info_->nextMolecule(mi)) { if (isMatched(mol->getMoleculeName(), name) ) { int natoms = mol->getNAtoms(); @@ -249,19 +248,15 @@ namespace OpenMD { bs.setBitOn(mol->getRigidBodyAt(internalIndex - natoms)->getGlobalIndex()); } } - - } - + } } bool NameFinder::isInteger(const std::string str) { - for(int i =0; i < str.size(); ++i){ + for(unsigned int i = 0; i < str.size(); ++i){ if (!std::isdigit(str[i])) { return false; } } - return true; } - }