ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/src/selection/SelectionManager.cpp
Revision: 1953
Committed: Thu Dec 5 18:19:26 2013 UTC (11 years, 4 months ago) by gezelter
File size: 8204 byte(s)
Log Message:
Rewrote much of selection module, added a bond correlation function

File Contents

# User Rev Content
1 tim 317 /*
2     * Copyright (c) 2005 The University of Notre Dame. All Rights Reserved.
3     *
4     * The University of Notre Dame grants you ("Licensee") a
5     * non-exclusive, royalty free, license to use, modify and
6     * redistribute this software in source and binary code form, provided
7     * that the following conditions are met:
8     *
9 gezelter 1390 * 1. Redistributions of source code must retain the above copyright
10 tim 317 * notice, this list of conditions and the following disclaimer.
11     *
12 gezelter 1390 * 2. Redistributions in binary form must reproduce the above copyright
13 tim 317 * notice, this list of conditions and the following disclaimer in the
14     * documentation and/or other materials provided with the
15     * distribution.
16     *
17     * This software is provided "AS IS," without a warranty of any
18     * kind. All express or implied conditions, representations and
19     * warranties, including any implied warranty of merchantability,
20     * fitness for a particular purpose or non-infringement, are hereby
21     * excluded. The University of Notre Dame and its licensors shall not
22     * be liable for any damages suffered by licensee as a result of
23     * using, modifying or distributing the software or its
24     * derivatives. In no event will the University of Notre Dame or its
25     * licensors be liable for any lost revenue, profit or data, or for
26     * direct, indirect, special, consequential, incidental or punitive
27     * damages, however caused and regardless of the theory of liability,
28     * arising out of the use of or inability to use software, even if the
29     * University of Notre Dame has been advised of the possibility of
30     * such damages.
31 gezelter 1390 *
32     * SUPPORT OPEN SCIENCE! If you use OpenMD or its source code in your
33     * research, please cite the appropriate papers when you publish your
34     * work. Good starting points are:
35     *
36 gezelter 1801 * [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005).
37     * [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006).
38 gezelter 1879 * [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008).
39 gezelter 1782 * [4] Kuang & Gezelter, J. Chem. Phys. 133, 164101 (2010).
40     * [5] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011).
41 tim 317 */
42    
43     #include "selection/SelectionManager.hpp"
44     #include "primitives/Molecule.hpp"
45     #include "brains/SimInfo.hpp"
46 gezelter 1390 namespace OpenMD {
47 gezelter 507 SelectionManager::SelectionManager(SimInfo* info) : info_(info){
48 gezelter 1953 nObjects_.push_back(info_->getNGlobalAtoms()+info_->getNGlobalRigidBodies());
49     nObjects_.push_back(info_->getNGlobalBonds());
50     nObjects_.push_back(info_->getNGlobalBends());
51     nObjects_.push_back(info_->getNGlobalTorsions());
52     nObjects_.push_back(info_->getNGlobalInversions());
53 tim 317
54 gezelter 1953 stuntdoubles_.resize(nObjects_[STUNTDOUBLE]);
55     bonds_.resize(nObjects_[BOND]);
56     bends_.resize(nObjects_[BEND]);
57     torsions_.resize(nObjects_[TORSION]);
58     inversions_.resize(nObjects_[INVERSION]);
59 tim 317
60     SimInfo::MoleculeIterator mi;
61 gezelter 1953 Molecule::AtomIterator ai;
62     Molecule::RigidBodyIterator rbIter;
63     Molecule::BondIterator bondIter;
64     Molecule::BendIterator bendIter;
65     Molecule::TorsionIterator torsionIter;
66     Molecule::InversionIterator inversionIter;
67    
68 tim 317 Molecule* mol;
69     Atom* atom;
70     RigidBody* rb;
71 gezelter 1953 Bond* bond;
72     Bend* bend;
73     Torsion* torsion;
74     Inversion* inversion;
75    
76 gezelter 1801 for (mol = info_->beginMolecule(mi); mol != NULL;
77     mol = info_->nextMolecule(mi)) {
78 gezelter 1953
79 gezelter 1801 for(atom = mol->beginAtom(ai); atom != NULL;
80     atom = mol->nextAtom(ai)) {
81 gezelter 507 stuntdoubles_[atom->getGlobalIndex()] = atom;
82 gezelter 1953 }
83 gezelter 1801 for (rb = mol->beginRigidBody(rbIter); rb != NULL;
84     rb = mol->nextRigidBody(rbIter)) {
85 gezelter 507 stuntdoubles_[rb->getGlobalIndex()] = rb;
86 gezelter 1801 }
87 gezelter 1953 for (bond = mol->beginBond(bondIter); bond != NULL;
88     bond = mol->nextBond(bondIter)) {
89     bonds_[bond->getGlobalIndex()] = bond;
90     }
91     for (bend = mol->beginBend(bendIter); bend != NULL;
92     bend = mol->nextBend(bendIter)) {
93     bends_[bend->getGlobalIndex()] = bend;
94     }
95     for (torsion = mol->beginTorsion(torsionIter); torsion != NULL;
96     torsion = mol->nextTorsion(torsionIter)) {
97     torsions_[torsion->getGlobalIndex()] = torsion;
98     }
99     for (inversion = mol->beginInversion(inversionIter); inversion != NULL;
100     inversion = mol->nextInversion(inversionIter)) {
101     inversions_[inversion->getGlobalIndex()] = inversion;
102     }
103 gezelter 1801 }
104 gezelter 507 }
105 tim 317
106 gezelter 507 StuntDouble* SelectionManager::beginSelected(int& i) {
107 gezelter 1953 i = ss_.bitsets_[STUNTDOUBLE].firstOnBit();
108 tim 317 return i == -1 ? NULL : stuntdoubles_[i];
109 gezelter 507 }
110 gezelter 1801
111 gezelter 507 StuntDouble* SelectionManager::nextSelected(int& i) {
112 gezelter 1953 i = ss_.bitsets_[STUNTDOUBLE].nextOnBit(i);
113 tim 317 return i == -1 ? NULL : stuntdoubles_[i];
114 gezelter 507 }
115 tim 317
116 gezelter 507 StuntDouble* SelectionManager::beginUnselected(int& i){
117 gezelter 1953 i = ss_.bitsets_[STUNTDOUBLE].firstOffBit();
118 tim 317 return i == -1 ? NULL : stuntdoubles_[i];
119 gezelter 507 }
120 gezelter 1801
121 gezelter 507 StuntDouble* SelectionManager::nextUnSelected(int& i) {
122 gezelter 1953 i = ss_.bitsets_[STUNTDOUBLE].nextOffBit(i);
123 tim 317 return i == -1 ? NULL : stuntdoubles_[i];
124 gezelter 507 }
125 tim 317
126 gezelter 1953 Bond* SelectionManager::beginSelectedBond(int& i) {
127     i = ss_.bitsets_[BOND].firstOnBit();
128     return i == -1 ? NULL : bonds_[i];
129     }
130    
131     Bond* SelectionManager::nextSelectedBond(int& i) {
132     i = ss_.bitsets_[BOND].nextOnBit(i);
133     return i == -1 ? NULL : bonds_[i];
134     }
135    
136     Bond* SelectionManager::beginUnselectedBond(int& i){
137     i = ss_.bitsets_[BOND].firstOffBit();
138     return i == -1 ? NULL : bonds_[i];
139     }
140    
141     Bond* SelectionManager::nextUnSelectedBond(int& i) {
142     i = ss_.bitsets_[BOND].nextOffBit(i);
143     return i == -1 ? NULL : bonds_[i];
144     }
145    
146     Bend* SelectionManager::beginSelectedBend(int& i) {
147     i = ss_.bitsets_[BEND].firstOnBit();
148     return i == -1 ? NULL : bends_[i];
149     }
150    
151     Bend* SelectionManager::nextSelectedBend(int& i) {
152     i = ss_.bitsets_[BEND].nextOnBit(i);
153     return i == -1 ? NULL : bends_[i];
154     }
155    
156     Bend* SelectionManager::beginUnselectedBend(int& i){
157     i = ss_.bitsets_[BEND].firstOffBit();
158     return i == -1 ? NULL : bends_[i];
159     }
160    
161     Bend* SelectionManager::nextUnSelectedBend(int& i) {
162     i = ss_.bitsets_[BEND].nextOffBit(i);
163     return i == -1 ? NULL : bends_[i];
164     }
165    
166     Torsion* SelectionManager::beginSelectedTorsion(int& i) {
167     i = ss_.bitsets_[TORSION].firstOnBit();
168     return i == -1 ? NULL : torsions_[i];
169     }
170    
171     Torsion* SelectionManager::nextSelectedTorsion(int& i) {
172     i = ss_.bitsets_[TORSION].nextOnBit(i);
173     return i == -1 ? NULL : torsions_[i];
174     }
175    
176     Torsion* SelectionManager::beginUnselectedTorsion(int& i){
177     i = ss_.bitsets_[TORSION].firstOffBit();
178     return i == -1 ? NULL : torsions_[i];
179     }
180    
181     Torsion* SelectionManager::nextUnSelectedTorsion(int& i) {
182     i = ss_.bitsets_[TORSION].nextOffBit(i);
183     return i == -1 ? NULL : torsions_[i];
184     }
185    
186     Inversion* SelectionManager::beginSelectedInversion(int& i) {
187     i = ss_.bitsets_[INVERSION].firstOnBit();
188     return i == -1 ? NULL : inversions_[i];
189     }
190    
191     Inversion* SelectionManager::nextSelectedInversion(int& i) {
192     i = ss_.bitsets_[INVERSION].nextOnBit(i);
193     return i == -1 ? NULL : inversions_[i];
194     }
195    
196     Inversion* SelectionManager::beginUnselectedInversion(int& i){
197     i = ss_.bitsets_[INVERSION].firstOffBit();
198     return i == -1 ? NULL : inversions_[i];
199     }
200    
201     Inversion* SelectionManager::nextUnSelectedInversion(int& i) {
202     i = ss_.bitsets_[INVERSION].nextOffBit(i);
203     return i == -1 ? NULL : inversions_[i];
204     }
205    
206 gezelter 1801 SelectionManager operator| (const SelectionManager& sman1,
207     const SelectionManager& sman2) {
208 tim 353 SelectionManager result(sman1);
209     result |= sman2;
210     return result;
211 gezelter 507 }
212 gezelter 1801
213     SelectionManager operator& (const SelectionManager& sman1,
214     const SelectionManager& sman2) {
215 tim 353 SelectionManager result(sman1);
216     result &= sman2;
217     return result;
218 gezelter 1801 }
219 tim 353
220 gezelter 1801 SelectionManager operator^ (const SelectionManager& sman1,
221     const SelectionManager& sman2) {
222 tim 353 SelectionManager result(sman1);
223     result ^= sman2;
224     return result;
225 gezelter 1801 }
226 tim 353
227 gezelter 1801 SelectionManager operator-(const SelectionManager& sman1,
228     const SelectionManager& sman2){
229 tim 353 SelectionManager result(sman1);
230     result -= sman2;
231     return result;
232 gezelter 507 }
233 tim 353
234     }

Properties

Name Value
svn:executable *
svn:keywords Author Id Revision Date