--- trunk/src/selection/IndexFinder.cpp 2009/11/25 20:02:06 1390 +++ trunk/src/selection/IndexFinder.cpp 2015/01/09 19:06:35 2052 @@ -35,61 +35,89 @@ * * [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). + * [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008). + * [4] Kuang & Gezelter, J. Chem. Phys. 133, 164101 (2010). + * [5] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011). */ #include "selection/IndexFinder.hpp" #include "primitives/Molecule.hpp" namespace OpenMD { - - IndexFinder::IndexFinder(SimInfo* info) : info_(info){ - nStuntDoubles_ = info_->getNGlobalAtoms() + info_->getNGlobalRigidBodies(); - bitSets_.resize(info_->getNGlobalMolecules()); + nObjects_.push_back(info_->getNGlobalAtoms()+info_->getNGlobalRigidBodies()); + nObjects_.push_back(info_->getNGlobalBonds()); + nObjects_.push_back(info_->getNGlobalBends()); + nObjects_.push_back(info_->getNGlobalTorsions()); + nObjects_.push_back(info_->getNGlobalInversions()); + nObjects_.push_back(info_->getNGlobalMolecules()); + + selectionSets_.resize(info_->getNGlobalMolecules()); init(); } - void IndexFinder::init() { SimInfo::MoleculeIterator mi; - Molecule* mol; Molecule::AtomIterator ai; - Atom* atom; Molecule::RigidBodyIterator rbIter; + Molecule::BondIterator bondIter; + Molecule::BendIterator bendIter; + Molecule::TorsionIterator torsionIter; + Molecule::InversionIterator inversionIter; + + Molecule* mol; + Atom* atom; RigidBody* rb; + Bond* bond; + Bend* bend; + Torsion* torsion; + Inversion* inversion; - for (mol = info_->beginMolecule(mi); mol != NULL; mol = info_->nextMolecule(mi)) { + for (mol = info_->beginMolecule(mi); mol != NULL; + mol = info_->nextMolecule(mi)) { - OpenMDBitSet bs(nStuntDoubles_); + SelectionSet ss(nObjects_); + ss.bitsets_[MOLECULE].setBitOn(mol->getGlobalIndex()); + for(atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) { - bs.setBitOn(atom->getGlobalIndex()); + ss.bitsets_[STUNTDOUBLE].setBitOn(atom->getGlobalIndex()); } - - for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) { - bs.setBitOn(rb->getGlobalIndex()); + for (rb = mol->beginRigidBody(rbIter); rb != NULL; + rb = mol->nextRigidBody(rbIter)) { + ss.bitsets_[STUNTDOUBLE].setBitOn(rb->getGlobalIndex()); } + for (bond = mol->beginBond(bondIter); bond != NULL; + bond = mol->nextBond(bondIter)) { + ss.bitsets_[BOND].setBitOn(bond->getGlobalIndex()); + } + for (bend = mol->beginBend(bendIter); bend != NULL; + bend = mol->nextBend(bendIter)) { + ss.bitsets_[BEND].setBitOn(bend->getGlobalIndex()); + } + for (torsion = mol->beginTorsion(torsionIter); torsion != NULL; + torsion = mol->nextTorsion(torsionIter)) { + ss.bitsets_[TORSION].setBitOn(torsion->getGlobalIndex()); + } + for (inversion = mol->beginInversion(inversionIter); inversion != NULL; + inversion = mol->nextInversion(inversionIter)) { + ss.bitsets_[INVERSION].setBitOn(inversion->getGlobalIndex()); + } - bitSets_[mol->getGlobalIndex()] = bs; - } - + selectionSets_[mol->getGlobalIndex()] = ss; + } } - OpenMDBitSet IndexFinder::find(int molIndex){ - return bitSets_[molIndex]; + SelectionSet IndexFinder::find(int molIndex){ + return selectionSets_[molIndex]; } - OpenMDBitSet IndexFinder::find(int begMolIndex, int endMolIndex){ - OpenMDBitSet bs(nStuntDoubles_); + SelectionSet IndexFinder::find(int begMolIndex, int endMolIndex){ + SelectionSet ss(nObjects_); for (int i = begMolIndex; i < endMolIndex; ++i) { - bs |= bitSets_[i]; - } - - return bs; + ss |= selectionSets_[i]; + } + return ss; } - - }