ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/src/selection/SelectionManager.cpp
Revision: 2052
Committed: Fri Jan 9 19:06:35 2015 UTC (10 years, 3 months ago) by gezelter
File size: 8940 byte(s)
Log Message:
Updating Hydrogen Bonding structures, and selection syntax to include molecule selections:

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 "brains/SimInfo.hpp"
45 gezelter 1390 namespace OpenMD {
46 gezelter 507 SelectionManager::SelectionManager(SimInfo* info) : info_(info){
47 gezelter 1953 nObjects_.push_back(info_->getNGlobalAtoms()+info_->getNGlobalRigidBodies());
48     nObjects_.push_back(info_->getNGlobalBonds());
49     nObjects_.push_back(info_->getNGlobalBends());
50     nObjects_.push_back(info_->getNGlobalTorsions());
51     nObjects_.push_back(info_->getNGlobalInversions());
52 gezelter 2052 nObjects_.push_back(info_->getNGlobalMolecules());
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 gezelter 2052 molecules_.resize(nObjects_[MOLECULE]);
60 tim 317
61     SimInfo::MoleculeIterator mi;
62 gezelter 1953 Molecule::AtomIterator ai;
63     Molecule::RigidBodyIterator rbIter;
64     Molecule::BondIterator bondIter;
65     Molecule::BendIterator bendIter;
66     Molecule::TorsionIterator torsionIter;
67     Molecule::InversionIterator inversionIter;
68    
69 tim 317 Molecule* mol;
70     Atom* atom;
71     RigidBody* rb;
72 gezelter 1953 Bond* bond;
73     Bend* bend;
74     Torsion* torsion;
75     Inversion* inversion;
76    
77 gezelter 1801 for (mol = info_->beginMolecule(mi); mol != NULL;
78     mol = info_->nextMolecule(mi)) {
79 gezelter 2052 molecules_[mol->getGlobalIndex()] = mol;
80 gezelter 1953
81 gezelter 1801 for(atom = mol->beginAtom(ai); atom != NULL;
82     atom = mol->nextAtom(ai)) {
83 gezelter 507 stuntdoubles_[atom->getGlobalIndex()] = atom;
84 gezelter 1953 }
85 gezelter 1801 for (rb = mol->beginRigidBody(rbIter); rb != NULL;
86     rb = mol->nextRigidBody(rbIter)) {
87 gezelter 507 stuntdoubles_[rb->getGlobalIndex()] = rb;
88 gezelter 1801 }
89 gezelter 1953 for (bond = mol->beginBond(bondIter); bond != NULL;
90     bond = mol->nextBond(bondIter)) {
91     bonds_[bond->getGlobalIndex()] = bond;
92     }
93     for (bend = mol->beginBend(bendIter); bend != NULL;
94     bend = mol->nextBend(bendIter)) {
95     bends_[bend->getGlobalIndex()] = bend;
96     }
97     for (torsion = mol->beginTorsion(torsionIter); torsion != NULL;
98     torsion = mol->nextTorsion(torsionIter)) {
99     torsions_[torsion->getGlobalIndex()] = torsion;
100     }
101     for (inversion = mol->beginInversion(inversionIter); inversion != NULL;
102     inversion = mol->nextInversion(inversionIter)) {
103     inversions_[inversion->getGlobalIndex()] = inversion;
104     }
105 gezelter 1801 }
106 gezelter 507 }
107 tim 317
108 gezelter 507 StuntDouble* SelectionManager::beginSelected(int& i) {
109 gezelter 1953 i = ss_.bitsets_[STUNTDOUBLE].firstOnBit();
110 tim 317 return i == -1 ? NULL : stuntdoubles_[i];
111 gezelter 507 }
112 gezelter 1801
113 gezelter 507 StuntDouble* SelectionManager::nextSelected(int& i) {
114 gezelter 1953 i = ss_.bitsets_[STUNTDOUBLE].nextOnBit(i);
115 tim 317 return i == -1 ? NULL : stuntdoubles_[i];
116 gezelter 507 }
117 tim 317
118 gezelter 507 StuntDouble* SelectionManager::beginUnselected(int& i){
119 gezelter 1953 i = ss_.bitsets_[STUNTDOUBLE].firstOffBit();
120 tim 317 return i == -1 ? NULL : stuntdoubles_[i];
121 gezelter 507 }
122 gezelter 1801
123 gezelter 507 StuntDouble* SelectionManager::nextUnSelected(int& i) {
124 gezelter 1953 i = ss_.bitsets_[STUNTDOUBLE].nextOffBit(i);
125 tim 317 return i == -1 ? NULL : stuntdoubles_[i];
126 gezelter 507 }
127 tim 317
128 gezelter 1953 Bond* SelectionManager::beginSelectedBond(int& i) {
129     i = ss_.bitsets_[BOND].firstOnBit();
130     return i == -1 ? NULL : bonds_[i];
131     }
132    
133     Bond* SelectionManager::nextSelectedBond(int& i) {
134     i = ss_.bitsets_[BOND].nextOnBit(i);
135     return i == -1 ? NULL : bonds_[i];
136     }
137    
138     Bond* SelectionManager::beginUnselectedBond(int& i){
139     i = ss_.bitsets_[BOND].firstOffBit();
140     return i == -1 ? NULL : bonds_[i];
141     }
142    
143     Bond* SelectionManager::nextUnSelectedBond(int& i) {
144     i = ss_.bitsets_[BOND].nextOffBit(i);
145     return i == -1 ? NULL : bonds_[i];
146     }
147    
148     Bend* SelectionManager::beginSelectedBend(int& i) {
149     i = ss_.bitsets_[BEND].firstOnBit();
150     return i == -1 ? NULL : bends_[i];
151     }
152    
153     Bend* SelectionManager::nextSelectedBend(int& i) {
154     i = ss_.bitsets_[BEND].nextOnBit(i);
155     return i == -1 ? NULL : bends_[i];
156     }
157    
158     Bend* SelectionManager::beginUnselectedBend(int& i){
159     i = ss_.bitsets_[BEND].firstOffBit();
160     return i == -1 ? NULL : bends_[i];
161     }
162    
163     Bend* SelectionManager::nextUnSelectedBend(int& i) {
164     i = ss_.bitsets_[BEND].nextOffBit(i);
165     return i == -1 ? NULL : bends_[i];
166     }
167    
168     Torsion* SelectionManager::beginSelectedTorsion(int& i) {
169     i = ss_.bitsets_[TORSION].firstOnBit();
170     return i == -1 ? NULL : torsions_[i];
171     }
172    
173     Torsion* SelectionManager::nextSelectedTorsion(int& i) {
174     i = ss_.bitsets_[TORSION].nextOnBit(i);
175     return i == -1 ? NULL : torsions_[i];
176     }
177    
178     Torsion* SelectionManager::beginUnselectedTorsion(int& i){
179     i = ss_.bitsets_[TORSION].firstOffBit();
180     return i == -1 ? NULL : torsions_[i];
181     }
182    
183     Torsion* SelectionManager::nextUnSelectedTorsion(int& i) {
184     i = ss_.bitsets_[TORSION].nextOffBit(i);
185     return i == -1 ? NULL : torsions_[i];
186     }
187    
188     Inversion* SelectionManager::beginSelectedInversion(int& i) {
189     i = ss_.bitsets_[INVERSION].firstOnBit();
190     return i == -1 ? NULL : inversions_[i];
191     }
192    
193     Inversion* SelectionManager::nextSelectedInversion(int& i) {
194     i = ss_.bitsets_[INVERSION].nextOnBit(i);
195     return i == -1 ? NULL : inversions_[i];
196     }
197    
198     Inversion* SelectionManager::beginUnselectedInversion(int& i){
199     i = ss_.bitsets_[INVERSION].firstOffBit();
200     return i == -1 ? NULL : inversions_[i];
201     }
202    
203     Inversion* SelectionManager::nextUnSelectedInversion(int& i) {
204     i = ss_.bitsets_[INVERSION].nextOffBit(i);
205     return i == -1 ? NULL : inversions_[i];
206     }
207 gezelter 2052
208     Molecule* SelectionManager::beginSelectedMolecule(int& i) {
209     i = ss_.bitsets_[MOLECULE].firstOnBit();
210     return i == -1 ? NULL : molecules_[i];
211     }
212 gezelter 1953
213 gezelter 2052 Molecule* SelectionManager::nextSelectedMolecule(int& i) {
214     i = ss_.bitsets_[MOLECULE].nextOnBit(i);
215     return i == -1 ? NULL : molecules_[i];
216     }
217    
218     Molecule* SelectionManager::beginUnselectedMolecule(int& i){
219     i = ss_.bitsets_[MOLECULE].firstOffBit();
220     return i == -1 ? NULL : molecules_[i];
221     }
222    
223     Molecule* SelectionManager::nextUnSelectedMolecule(int& i) {
224     i = ss_.bitsets_[MOLECULE].nextOffBit(i);
225     return i == -1 ? NULL : molecules_[i];
226     }
227    
228 gezelter 1801 SelectionManager operator| (const SelectionManager& sman1,
229     const SelectionManager& sman2) {
230 tim 353 SelectionManager result(sman1);
231     result |= sman2;
232     return result;
233 gezelter 507 }
234 gezelter 1801
235     SelectionManager operator& (const SelectionManager& sman1,
236     const SelectionManager& sman2) {
237 tim 353 SelectionManager result(sman1);
238     result &= sman2;
239     return result;
240 gezelter 1801 }
241 tim 353
242 gezelter 1801 SelectionManager operator^ (const SelectionManager& sman1,
243     const SelectionManager& sman2) {
244 tim 353 SelectionManager result(sman1);
245     result ^= sman2;
246     return result;
247 gezelter 1801 }
248 tim 353
249 gezelter 1801 SelectionManager operator-(const SelectionManager& sman1,
250     const SelectionManager& sman2){
251 tim 353 SelectionManager result(sman1);
252     result -= sman2;
253     return result;
254 gezelter 507 }
255 tim 353
256     }

Properties

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