--- trunk/src/selection/IndexFinder.cpp 2005/12/02 15:38:03 770 +++ trunk/src/selection/IndexFinder.cpp 2015/01/09 19:06:35 2052 @@ -6,19 +6,10 @@ * redistribute this software in source and binary code form, provided * that the following conditions are met: * - * 1. Acknowledgement of the program authors must be made in any - * publication of scientific results based in part on use of the - * program. An acceptable form of acknowledgement is citation of - * the article in which the program was described (Matthew - * A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher - * J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented - * Parallel Simulation Engine for Molecular Dynamics," - * J. Comput. Chem. 26, pp. 252-271 (2005)) - * - * 2. Redistributions of source code must retain the above copyright + * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - * 3. Redistributions in binary form must reproduce the above copyright + * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the * distribution. @@ -37,59 +28,96 @@ * arising out of the use of or inability to use software, even if the * University of Notre Dame has been advised of the possibility of * such damages. + * + * SUPPORT OPEN SCIENCE! If you use OpenMD or its source code in your + * research, please cite the appropriate papers when you publish your + * work. Good starting points are: + * + * [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, 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 oopse { +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)) { - OOPSEBitSet 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; + } } - OOPSEBitSet IndexFinder::find(int molIndex){ - return bitSets_[molIndex]; + SelectionSet IndexFinder::find(int molIndex){ + return selectionSets_[molIndex]; } - OOPSEBitSet IndexFinder::find(int begMolIndex, int endMolIndex){ - OOPSEBitSet 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; } - - }