--- trunk/src/selection/SelectionManager.hpp 2005/12/02 15:38:03 770 +++ trunk/src/selection/SelectionManager.hpp 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,101 +28,296 @@ * 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). */ #ifndef SELECTION_SELECTIONMANAGER_HPP #define SELECTION_SELECTIONMANAGER_HPP -#include "utils/OOPSEBitSet.hpp" +#include "selection/SelectionSet.hpp" #include "primitives/StuntDouble.hpp" -namespace oopse { +#include "primitives/Bond.hpp" +#include "primitives/Bend.hpp" +#include "primitives/Torsion.hpp" +#include "primitives/Inversion.hpp" +#include "primitives/Molecule.hpp" +namespace OpenMD { + class SimInfo; - /** - * @class SelectionManager SelectionManager.hpp "selection/SelectionManager.hpp" - * @brief - */ class SelectionManager { public: SelectionManager(SimInfo* info); - void addSelection(StuntDouble* sd) { - bsSelection_.setBitOn(sd->getGlobalIndex()); + void addSelection(StuntDouble* sd) { + ss_.bitsets_[STUNTDOUBLE].setBitOn(sd->getGlobalIndex()); } + void addSelection(Bond* b) { + ss_.bitsets_[BOND].setBitOn(b->getGlobalIndex()); + } + void addSelection(Bend* b) { + ss_.bitsets_[BEND].setBitOn(b->getGlobalIndex()); + } + void addSelection(Torsion* t) { + ss_.bitsets_[TORSION].setBitOn(t->getGlobalIndex()); + } + void addSelection(Inversion* i) { + ss_.bitsets_[INVERSION].setBitOn(i->getGlobalIndex()); + } + void addSelection(Molecule* m) { + ss_.bitsets_[MOLECULE].setBitOn(m->getGlobalIndex()); + } - void addSelectionSet(const OOPSEBitSet& bs) { - bsSelection_ |= bs; + void addSelectionSet(const SelectionSet& bs) { + ss_.bitsets_[STUNTDOUBLE] |= bs.bitsets_[STUNTDOUBLE]; } + void addBondSelectionSet(const SelectionSet& bs) { + ss_.bitsets_[BOND] |= bs.bitsets_[BOND]; + } + void addBendSelectionSet(const SelectionSet& bs) { + ss_.bitsets_[BEND] |= bs.bitsets_[BEND]; + } + void addTorsionSelectionSet(const SelectionSet& bs) { + ss_.bitsets_[TORSION] |= bs.bitsets_[TORSION]; + } + void addInversionSelectionSet(const SelectionSet& bs) { + ss_.bitsets_[INVERSION] |= bs.bitsets_[INVERSION]; + } + void addMoleculeSelectionSet(const SelectionSet& bs) { + ss_.bitsets_[MOLECULE] |= bs.bitsets_[MOLECULE]; + } + bool isEmpty() { + return ss_.bitsets_[STUNTDOUBLE].none() && ss_.bitsets_[BOND].none() + && ss_.bitsets_[BEND].none() && ss_.bitsets_[TORSION].none() + && ss_.bitsets_[INVERSION].none() && ss_.bitsets_[MOLECULE].none(); + } + + void setSelectionSet(const SelectionSet& bs) { + for (int i = 0; i < N_SELECTIONTYPES; i++) + ss_.bitsets_[i] = bs.bitsets_[i]; + } + + //void setSelectionSet(const SelectionSet& bs) { + // ss_.bitsets_[STUNTDOUBLE] = bs.bitsets_[]; + //} + void setBondSelectionSet(const SelectionSet& bs) { + ss_.bitsets_[BOND] = bs.bitsets_[BOND]; + } + void setBendSelectionSet(const SelectionSet& bs) { + ss_.bitsets_[BEND] = bs.bitsets_[BEND]; + } + void setTorsionSelectionSet(const SelectionSet& bs) { + ss_.bitsets_[TORSION] = bs.bitsets_[TORSION]; + } + void setInversionSelectionSet(const SelectionSet& bs) { + ss_.bitsets_[INVERSION] = bs.bitsets_[INVERSION]; + } + void setMoleculeSelectionSet(const SelectionSet& bs) { + ss_.bitsets_[MOLECULE] = bs.bitsets_[MOLECULE]; + } + + std::vector getSelectionCounts() { + std::vector counts(N_SELECTIONTYPES,0); + for (int i = 0; i < N_SELECTIONTYPES; i++) { + counts[i] = ss_.bitsets_[i].countBits(); + } + return counts; + } + + int getSelectionCount() { + return ss_.bitsets_[STUNTDOUBLE].countBits(); + } + int getBondSelectionCount() { + return ss_.bitsets_[BOND].countBits(); + } + int getBendSelectionCount() { + return ss_.bitsets_[BEND].countBits(); + } + int getTorsionSelectionCount() { + return ss_.bitsets_[TORSION].countBits(); + } + int getInversionSelectionCount() { + return ss_.bitsets_[INVERSION].countBits(); + } + int getMoleculeSelectionCount() { + return ss_.bitsets_[MOLECULE].countBits(); + } + + SelectionSet getSelectionSet() { + return ss_; + } + /* SelectionSet getBondSelectionSet() { + return ss_.bitsets_[BOND]; + } + SelectionSet getBendSelectionSet() { + return ss_.bitsets_[BEND]; + } + SelectionSet getTorsionSelectionSet() { + return ss_.bitsets_[TORSION]; + } + SelectionSet getInversionSelectionSet() { + return ss_.bitsets_[INVERSION]; + } + */ + void setSelection(StuntDouble* sd) { - bsSelection_.clearAll(); - bsSelection_.setBitOn(sd->getGlobalIndex()); + ss_.bitsets_[STUNTDOUBLE].clearAll(); + ss_.bitsets_[STUNTDOUBLE].setBitOn(sd->getGlobalIndex()); } - - void setSelectionSet(const OOPSEBitSet& bs) { - bsSelection_ = bs; + void setSelection(Bond* b) { + ss_.bitsets_[BOND].clearAll(); + ss_.bitsets_[BOND].setBitOn(b->getGlobalIndex()); } + void setSelection(Bend* b) { + ss_.bitsets_[BEND].clearAll(); + ss_.bitsets_[BEND].setBitOn(b->getGlobalIndex()); + } + void setSelection(Torsion* t) { + ss_.bitsets_[TORSION].clearAll(); + ss_.bitsets_[TORSION].setBitOn(t->getGlobalIndex()); + } + void setSelection(Inversion* i) { + ss_.bitsets_[INVERSION].clearAll(); + ss_.bitsets_[INVERSION].setBitOn(i->getGlobalIndex()); + } + void setSelection(Molecule* m) { + ss_.bitsets_[MOLECULE].clearAll(); + ss_.bitsets_[MOLECULE].setBitOn(m->getGlobalIndex()); + } void toggleSelection(StuntDouble* sd) { - bsSelection_.flip(sd->getGlobalIndex()); + ss_.bitsets_[STUNTDOUBLE].flip(sd->getGlobalIndex()); } + void toggleSelection(Bond* b) { + ss_.bitsets_[BOND].flip(b->getGlobalIndex()); + } + void toggleSelection(Bend* b) { + ss_.bitsets_[BEND].flip(b->getGlobalIndex()); + } + void toggleSelection(Torsion* t) { + ss_.bitsets_[TORSION].flip(t->getGlobalIndex()); + } + void toggleSelection(Inversion* i) { + ss_.bitsets_[INVERSION].flip(i->getGlobalIndex()); + } + void toggleSelection(Molecule* m) { + ss_.bitsets_[MOLECULE].flip(m->getGlobalIndex()); + } void toggleSelection() { - bsSelection_.flip(); + for (int i = 0; i < N_SELECTIONTYPES; i++) + ss_.bitsets_[i].flip(); } void selectAll() { - bsSelection_.setAll(); + for (int i = 0; i < N_SELECTIONTYPES; i++) + ss_.bitsets_[i].setAll(); } void clearSelection() { - bsSelection_.clearAll(); + for (int i = 0; i < N_SELECTIONTYPES; i++) + ss_.bitsets_[i].clearAll(); } void clearSelection(StuntDouble* sd) { - bsSelection_.setBitOff(sd->getGlobalIndex()); + ss_.bitsets_[STUNTDOUBLE].setBitOff(sd->getGlobalIndex()); } + void clearSelection(Bond* b) { + ss_.bitsets_[BOND].setBitOff(b->getGlobalIndex()); + } + void clearSelection(Bend* b) { + ss_.bitsets_[BEND].setBitOff(b->getGlobalIndex()); + } + void clearSelection(Torsion* t) { + ss_.bitsets_[TORSION].setBitOff(t->getGlobalIndex()); + } + void clearSelection(Inversion* i) { + ss_.bitsets_[INVERSION].setBitOff(i->getGlobalIndex()); + } + void clearSelection(Molecule* m) { + ss_.bitsets_[MOLECULE].setBitOff(m->getGlobalIndex()); + } bool isSelected(StuntDouble* sd) { - return bsSelection_[sd->getGlobalIndex()]; + return ss_.bitsets_[STUNTDOUBLE][sd->getGlobalIndex()]; } - - bool isEmpty() { - return bsSelection_.none(); + bool isSelected(Bond* b) { + return ss_.bitsets_[BOND][b->getGlobalIndex()]; } - - int getSelectionCount() { - return bsSelection_.countBits(); + bool isSelected(Bend* b) { + return ss_.bitsets_[BEND][b->getGlobalIndex()]; } - - OOPSEBitSet getSelectionSet() { - return bsSelection_; + bool isSelected(Torsion* t) { + return ss_.bitsets_[TORSION][t->getGlobalIndex()]; } + bool isSelected(Inversion* i) { + return ss_.bitsets_[INVERSION][i->getGlobalIndex()]; + } + bool isSelected(Molecule* m) { + return ss_.bitsets_[MOLECULE][m->getGlobalIndex()]; + } - StuntDouble* beginSelected(int& i); StuntDouble* nextSelected(int& i); - StuntDouble* beginUnselected(int& i); StuntDouble* nextUnSelected(int& i); + Bond* beginSelectedBond(int& i); + Bond* nextSelectedBond(int& i); + Bond* beginUnselectedBond(int& i); + Bond* nextUnSelectedBond(int& i); + + Bend* beginSelectedBend(int& i); + Bend* nextSelectedBend(int& i); + Bend* beginUnselectedBend(int& i); + Bend* nextUnSelectedBend(int& i); + + Torsion* beginSelectedTorsion(int& i); + Torsion* nextSelectedTorsion(int& i); + Torsion* beginUnselectedTorsion(int& i); + Torsion* nextUnSelectedTorsion(int& i); + + Inversion* beginSelectedInversion(int& i); + Inversion* nextSelectedInversion(int& i); + Inversion* beginUnselectedInversion(int& i); + Inversion* nextUnSelectedInversion(int& i); + + Molecule* beginSelectedMolecule(int& i); + Molecule* nextSelectedMolecule(int& i); + Molecule* beginUnselectedMolecule(int& i); + Molecule* nextUnSelectedMolecule(int& i); + SelectionManager& operator&= (const SelectionManager &sman) { - bsSelection_ &= sman.bsSelection_; + for (int i = 0; i < N_SELECTIONTYPES; i++) + ss_.bitsets_[i] &= sman.ss_.bitsets_[i]; return *this; } SelectionManager& operator|= (const SelectionManager &sman) { - bsSelection_ |= sman.bsSelection_; + for (int i = 0; i < N_SELECTIONTYPES; i++) + ss_.bitsets_[i] |= sman.ss_.bitsets_[i]; return *this; } SelectionManager& operator^= (const SelectionManager &sman) { - bsSelection_ ^= sman.bsSelection_; + for (int i = 0; i < N_SELECTIONTYPES; i++) + ss_.bitsets_[i] ^= sman.ss_.bitsets_[i]; return *this; } SelectionManager& operator-= (const SelectionManager &sman) { - bsSelection_ -= sman.bsSelection_; + for (int i = 0; i < N_SELECTIONTYPES; i++) + ss_.bitsets_[i] -= sman.ss_.bitsets_[i]; return *this; } @@ -142,8 +328,14 @@ namespace oopse { private: SimInfo* info_; - OOPSEBitSet bsSelection_; + SelectionSet ss_; + std::vector nObjects_; std::vector stuntdoubles_; + std::vector bonds_; + std::vector bends_; + std::vector torsions_; + std::vector inversions_; + std::vector molecules_; }; }