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

# Content
1 /*
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 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * 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 *
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 * [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005).
37 * [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006).
38 * [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008).
39 * [4] Kuang & Gezelter, J. Chem. Phys. 133, 164101 (2010).
40 * [5] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011).
41 */
42
43 #include "selection/SelectionManager.hpp"
44 #include "brains/SimInfo.hpp"
45 namespace OpenMD {
46 SelectionManager::SelectionManager(SimInfo* info) : info_(info){
47 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 nObjects_.push_back(info_->getNGlobalMolecules());
53
54 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 molecules_.resize(nObjects_[MOLECULE]);
60
61 SimInfo::MoleculeIterator mi;
62 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 Molecule* mol;
70 Atom* atom;
71 RigidBody* rb;
72 Bond* bond;
73 Bend* bend;
74 Torsion* torsion;
75 Inversion* inversion;
76
77 for (mol = info_->beginMolecule(mi); mol != NULL;
78 mol = info_->nextMolecule(mi)) {
79 molecules_[mol->getGlobalIndex()] = mol;
80
81 for(atom = mol->beginAtom(ai); atom != NULL;
82 atom = mol->nextAtom(ai)) {
83 stuntdoubles_[atom->getGlobalIndex()] = atom;
84 }
85 for (rb = mol->beginRigidBody(rbIter); rb != NULL;
86 rb = mol->nextRigidBody(rbIter)) {
87 stuntdoubles_[rb->getGlobalIndex()] = rb;
88 }
89 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 }
106 }
107
108 StuntDouble* SelectionManager::beginSelected(int& i) {
109 i = ss_.bitsets_[STUNTDOUBLE].firstOnBit();
110 return i == -1 ? NULL : stuntdoubles_[i];
111 }
112
113 StuntDouble* SelectionManager::nextSelected(int& i) {
114 i = ss_.bitsets_[STUNTDOUBLE].nextOnBit(i);
115 return i == -1 ? NULL : stuntdoubles_[i];
116 }
117
118 StuntDouble* SelectionManager::beginUnselected(int& i){
119 i = ss_.bitsets_[STUNTDOUBLE].firstOffBit();
120 return i == -1 ? NULL : stuntdoubles_[i];
121 }
122
123 StuntDouble* SelectionManager::nextUnSelected(int& i) {
124 i = ss_.bitsets_[STUNTDOUBLE].nextOffBit(i);
125 return i == -1 ? NULL : stuntdoubles_[i];
126 }
127
128 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
208 Molecule* SelectionManager::beginSelectedMolecule(int& i) {
209 i = ss_.bitsets_[MOLECULE].firstOnBit();
210 return i == -1 ? NULL : molecules_[i];
211 }
212
213 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 SelectionManager operator| (const SelectionManager& sman1,
229 const SelectionManager& sman2) {
230 SelectionManager result(sman1);
231 result |= sman2;
232 return result;
233 }
234
235 SelectionManager operator& (const SelectionManager& sman1,
236 const SelectionManager& sman2) {
237 SelectionManager result(sman1);
238 result &= sman2;
239 return result;
240 }
241
242 SelectionManager operator^ (const SelectionManager& sman1,
243 const SelectionManager& sman2) {
244 SelectionManager result(sman1);
245 result ^= sman2;
246 return result;
247 }
248
249 SelectionManager operator-(const SelectionManager& sman1,
250 const SelectionManager& sman2){
251 SelectionManager result(sman1);
252 result -= sman2;
253 return result;
254 }
255
256 }

Properties

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