ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/src/selection/SelectionManager.cpp
(Generate patch)

Comparing trunk/src/selection/SelectionManager.cpp (file contents):
Revision 317 by tim, Sat Feb 12 20:09:28 2005 UTC vs.
Revision 2052 by gezelter, Fri Jan 9 19:06:35 2015 UTC

# Line 6 | Line 6
6   * redistribute this software in source and binary code form, provided
7   * that the following conditions are met:
8   *
9 < * 1. Acknowledgement of the program authors must be made in any
10 < *    publication of scientific results based in part on use of the
11 < *    program.  An acceptable form of acknowledgement is citation of
12 < *    the article in which the program was described (Matthew
13 < *    A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher
14 < *    J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented
15 < *    Parallel Simulation Engine for Molecular Dynamics,"
16 < *    J. Comput. Chem. 26, pp. 252-271 (2005))
17 < *
18 < * 2. Redistributions of source code must retain the above copyright
9 > * 1. Redistributions of source code must retain the above copyright
10   *    notice, this list of conditions and the following disclaimer.
11   *
12 < * 3. Redistributions in binary form must reproduce the above copyright
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.
# Line 37 | Line 28
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"
43 #include "primitives/Molecule.hpp"
44   #include "brains/SimInfo.hpp"
45 < namespace oopse {
46 < SelectionManager::SelectionManager(SimInfo* info) : info_(info){
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 <    int nStuntDoubles = info_->getNGlobalAtoms() + info_->getNGlobalRigidBodies();
55 <
56 <    bsSelection_.resize(nStuntDoubles);
57 <    stuntdoubles_.resize(nStuntDoubles);
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;
54    Molecule* mol;
62      Molecule::AtomIterator ai;
56    Atom* atom;
63      Molecule::RigidBodyIterator rbIter;
64 <    RigidBody* rb;
64 >    Molecule::BondIterator bondIter;
65 >    Molecule::BendIterator bendIter;
66 >    Molecule::TorsionIterator torsionIter;
67 >    Molecule::InversionIterator inversionIter;
68  
69 <    
70 <    for (mol = info_->beginMolecule(mi); mol != NULL; mol = info_->nextMolecule(mi)) {
69 >    Molecule* mol;
70 >    Atom* atom;
71 >    RigidBody* rb;
72 >    Bond* bond;
73 >    Bend* bend;
74 >    Torsion* torsion;
75 >    Inversion* inversion;    
76          
77 <        for(atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) {
78 <            stuntdoubles_[atom->getGlobalIndex()] = atom;
79 <        }
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 <        for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) {
109 <            stuntdoubles_[rb->getGlobalIndex()] = rb;
110 <        }
111 <        
71 <    }    
72 <    
73 < }
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::beginSelected(int& i) {
119 <    i = bsSelection_.firstOnBit();
118 >  StuntDouble* SelectionManager::beginUnselected(int& i){
119 >    i = ss_.bitsets_[STUNTDOUBLE].firstOffBit();
120      return i == -1 ? NULL : stuntdoubles_[i];
121 < }
80 < StuntDouble* SelectionManager::nextSelected(int& i) {
81 <    i = bsSelection_.nextOnBit(i);
82 <    return i == -1 ? NULL : stuntdoubles_[i];
83 < }
121 >  }
122  
123 < StuntDouble* SelectionManager::beginUnselected(int& i) {
124 <    i = bsSelection_.firstOffBit();
123 >  StuntDouble* SelectionManager::nextUnSelected(int& i) {
124 >    i = ss_.bitsets_[STUNTDOUBLE].nextOffBit(i);
125      return i == -1 ? NULL : stuntdoubles_[i];
126 < }
89 < StuntDouble* SelectionManager::nextUnSelected(int& i) {
90 <    i = bsSelection_.nextOffBit(i);
91 <    return i == -1 ? NULL : stuntdoubles_[i];
92 < }
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   }

Comparing trunk/src/selection/SelectionManager.cpp (property svn:keywords):
Revision 317 by tim, Sat Feb 12 20:09:28 2005 UTC vs.
Revision 2052 by gezelter, Fri Jan 9 19:06:35 2015 UTC

# Line 0 | Line 1
1 + Author Id Revision Date

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines