1 |
tim |
277 |
/* |
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 |
277 |
* 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 |
277 |
* 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 |
|
|
* [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 |
277 |
*/ |
42 |
|
|
|
43 |
tim |
283 |
#include <stack> |
44 |
tim |
277 |
#include "selection/SelectionEvaluator.hpp" |
45 |
tim |
283 |
#include "primitives/Atom.hpp" |
46 |
|
|
#include "primitives/DirectionalAtom.hpp" |
47 |
|
|
#include "primitives/RigidBody.hpp" |
48 |
|
|
#include "primitives/Molecule.hpp" |
49 |
gezelter |
1782 |
#include "io/ifstrstream.hpp" |
50 |
gezelter |
1816 |
#include "types/FixedChargeAdapter.hpp" |
51 |
|
|
#include "types/FluctuatingChargeAdapter.hpp" |
52 |
tim |
283 |
|
53 |
gezelter |
1816 |
|
54 |
gezelter |
1390 |
namespace OpenMD { |
55 |
tim |
277 |
|
56 |
|
|
|
57 |
gezelter |
507 |
SelectionEvaluator::SelectionEvaluator(SimInfo* si) |
58 |
gezelter |
1412 |
: info(si), nameFinder(info), distanceFinder(info), hullFinder(info), |
59 |
gezelter |
1903 |
indexFinder(info), hasSurfaceArea_(false), |
60 |
cli2 |
1364 |
isLoaded_(false){ |
61 |
gezelter |
1953 |
nObjects.push_back(info->getNGlobalAtoms() + info->getNGlobalRigidBodies()); |
62 |
|
|
nObjects.push_back(info->getNGlobalBonds()); |
63 |
|
|
nObjects.push_back(info->getNGlobalBends()); |
64 |
|
|
nObjects.push_back(info->getNGlobalTorsions()); |
65 |
|
|
nObjects.push_back(info->getNGlobalInversions()); |
66 |
gezelter |
2052 |
nObjects.push_back(info->getNGlobalMolecules()); |
67 |
gezelter |
1953 |
} |
68 |
|
|
|
69 |
cli2 |
1364 |
bool SelectionEvaluator::loadScript(const std::string& filename, |
70 |
|
|
const std::string& script) { |
71 |
tim |
288 |
clearDefinitionsAndLoadPredefined(); |
72 |
tim |
278 |
this->filename = filename; |
73 |
|
|
this->script = script; |
74 |
|
|
if (! compiler.compile(filename, script)) { |
75 |
gezelter |
507 |
error = true; |
76 |
|
|
errorMessage = compiler.getErrorMessage(); |
77 |
cli2 |
1364 |
|
78 |
|
|
sprintf( painCave.errMsg, |
79 |
|
|
"SelectionCompiler Error: %s\n", errorMessage.c_str()); |
80 |
gezelter |
1390 |
painCave.severity = OPENMD_ERROR; |
81 |
cli2 |
1364 |
painCave.isFatal = 1; |
82 |
|
|
simError(); |
83 |
gezelter |
507 |
return false; |
84 |
tim |
278 |
} |
85 |
|
|
|
86 |
|
|
pc = 0; |
87 |
|
|
aatoken = compiler.getAatokenCompiled(); |
88 |
|
|
linenumbers = compiler.getLineNumbers(); |
89 |
|
|
lineIndices = compiler.getLineIndices(); |
90 |
tim |
288 |
|
91 |
|
|
std::vector<std::vector<Token> >::const_iterator i; |
92 |
|
|
|
93 |
|
|
isDynamic_ = false; |
94 |
|
|
for (i = aatoken.begin(); i != aatoken.end(); ++i) { |
95 |
gezelter |
507 |
if (containDynamicToken(*i)) { |
96 |
|
|
isDynamic_ = true; |
97 |
|
|
break; |
98 |
|
|
} |
99 |
tim |
288 |
} |
100 |
|
|
|
101 |
|
|
isLoaded_ = true; |
102 |
tim |
278 |
return true; |
103 |
gezelter |
507 |
} |
104 |
tim |
278 |
|
105 |
gezelter |
507 |
void SelectionEvaluator::clearState() { |
106 |
tim |
278 |
error = false; |
107 |
tim |
281 |
errorMessage = ""; |
108 |
gezelter |
507 |
} |
109 |
tim |
278 |
|
110 |
gezelter |
507 |
bool SelectionEvaluator::loadScriptString(const std::string& script) { |
111 |
tim |
278 |
clearState(); |
112 |
tim |
281 |
return loadScript("", script); |
113 |
gezelter |
507 |
} |
114 |
tim |
278 |
|
115 |
gezelter |
507 |
bool SelectionEvaluator::loadScriptFile(const std::string& filename) { |
116 |
tim |
278 |
clearState(); |
117 |
|
|
return loadScriptFileInternal(filename); |
118 |
gezelter |
507 |
} |
119 |
tim |
278 |
|
120 |
cli2 |
1364 |
bool SelectionEvaluator::loadScriptFileInternal(const std::string & filename) { |
121 |
|
|
ifstrstream ifs(filename.c_str()); |
122 |
tim |
288 |
if (!ifs.is_open()) { |
123 |
gezelter |
507 |
return false; |
124 |
tim |
288 |
} |
125 |
cli2 |
1364 |
|
126 |
tim |
288 |
const int bufferSize = 65535; |
127 |
|
|
char buffer[bufferSize]; |
128 |
|
|
std::string script; |
129 |
|
|
while(ifs.getline(buffer, bufferSize)) { |
130 |
gezelter |
507 |
script += buffer; |
131 |
tim |
288 |
} |
132 |
|
|
return loadScript(filename, script); |
133 |
gezelter |
507 |
} |
134 |
cli2 |
1364 |
|
135 |
gezelter |
1953 |
void SelectionEvaluator::instructionDispatchLoop(SelectionSet& bs){ |
136 |
tim |
288 |
|
137 |
tim |
281 |
while ( pc < aatoken.size()) { |
138 |
gezelter |
507 |
statement = aatoken[pc++]; |
139 |
|
|
statementLength = statement.size(); |
140 |
|
|
Token token = statement[0]; |
141 |
|
|
switch (token.tok) { |
142 |
|
|
case Token::define: |
143 |
|
|
define(); |
144 |
|
|
break; |
145 |
|
|
case Token::select: |
146 |
|
|
select(bs); |
147 |
|
|
break; |
148 |
|
|
default: |
149 |
|
|
unrecognizedCommand(token); |
150 |
|
|
return; |
151 |
|
|
} |
152 |
tim |
278 |
} |
153 |
tim |
288 |
|
154 |
gezelter |
507 |
} |
155 |
tim |
278 |
|
156 |
gezelter |
1953 |
void SelectionEvaluator::instructionDispatchLoop(SelectionSet& bs, int frame){ |
157 |
gezelter |
1816 |
|
158 |
|
|
while ( pc < aatoken.size()) { |
159 |
|
|
statement = aatoken[pc++]; |
160 |
|
|
statementLength = statement.size(); |
161 |
|
|
Token token = statement[0]; |
162 |
|
|
switch (token.tok) { |
163 |
|
|
case Token::define: |
164 |
|
|
define(); |
165 |
|
|
break; |
166 |
|
|
case Token::select: |
167 |
|
|
select(bs, frame); |
168 |
|
|
break; |
169 |
|
|
default: |
170 |
|
|
unrecognizedCommand(token); |
171 |
|
|
return; |
172 |
|
|
} |
173 |
|
|
} |
174 |
|
|
|
175 |
|
|
} |
176 |
|
|
|
177 |
gezelter |
1953 |
SelectionSet SelectionEvaluator::expression(const std::vector<Token>& code, |
178 |
cli2 |
1364 |
int pcStart) { |
179 |
gezelter |
1953 |
SelectionSet bs = createSelectionSets(); |
180 |
|
|
std::stack<SelectionSet> stack; |
181 |
|
|
vector<int> bsSize = bs.size(); |
182 |
cli2 |
1364 |
|
183 |
gezelter |
1782 |
for (unsigned int pc = pcStart; pc < code.size(); ++pc) { |
184 |
tim |
278 |
Token instruction = code[pc]; |
185 |
tim |
282 |
|
186 |
tim |
278 |
switch (instruction.tok) { |
187 |
tim |
281 |
case Token::expressionBegin: |
188 |
tim |
278 |
break; |
189 |
tim |
281 |
case Token::expressionEnd: |
190 |
tim |
282 |
break; |
191 |
tim |
281 |
case Token::all: |
192 |
gezelter |
1801 |
bs = allInstruction(); |
193 |
gezelter |
1953 |
stack.push(bs); |
194 |
tim |
278 |
break; |
195 |
tim |
281 |
case Token::none: |
196 |
gezelter |
1953 |
bs = createSelectionSets(); |
197 |
|
|
stack.push(bs); |
198 |
tim |
278 |
break; |
199 |
tim |
281 |
case Token::opOr: |
200 |
gezelter |
1953 |
bs= stack.top(); |
201 |
|
|
stack.pop(); |
202 |
|
|
stack.top() |= bs; |
203 |
tim |
278 |
break; |
204 |
tim |
281 |
case Token::opAnd: |
205 |
gezelter |
1953 |
bs = stack.top(); |
206 |
|
|
stack.pop(); |
207 |
|
|
stack.top() &= bs; |
208 |
tim |
278 |
break; |
209 |
tim |
281 |
case Token::opNot: |
210 |
gezelter |
1953 |
stack.top().flip(); |
211 |
tim |
278 |
break; |
212 |
tim |
281 |
case Token::within: |
213 |
tim |
283 |
withinInstruction(instruction, stack.top()); |
214 |
tim |
278 |
break; |
215 |
gezelter |
1412 |
case Token::hull: |
216 |
gezelter |
1953 |
stack.push(hull()); |
217 |
gezelter |
1412 |
break; |
218 |
gezelter |
507 |
//case Token::selected: |
219 |
|
|
// stack.push(getSelectionSet()); |
220 |
|
|
// break; |
221 |
tim |
281 |
case Token::name: |
222 |
gezelter |
1953 |
stack.push(nameInstruction(boost::any_cast<std::string>(instruction.value))); |
223 |
tim |
278 |
break; |
224 |
tim |
295 |
case Token::index: |
225 |
gezelter |
1953 |
stack.push(indexInstruction(instruction.value)); |
226 |
tim |
281 |
break; |
227 |
|
|
case Token::identifier: |
228 |
gezelter |
1953 |
stack.push(lookupValue(boost::any_cast<std::string>(instruction.value))); |
229 |
tim |
281 |
break; |
230 |
|
|
case Token::opLT: |
231 |
|
|
case Token::opLE: |
232 |
|
|
case Token::opGE: |
233 |
|
|
case Token::opGT: |
234 |
|
|
case Token::opEQ: |
235 |
|
|
case Token::opNE: |
236 |
tim |
283 |
stack.push(comparatorInstruction(instruction)); |
237 |
tim |
278 |
break; |
238 |
|
|
default: |
239 |
|
|
unrecognizedExpression(); |
240 |
|
|
} |
241 |
|
|
} |
242 |
tim |
283 |
if (stack.size() != 1) |
243 |
tim |
278 |
evalError("atom expression compiler error - stack over/underflow"); |
244 |
tim |
283 |
|
245 |
|
|
return stack.top(); |
246 |
tim |
278 |
} |
247 |
|
|
|
248 |
|
|
|
249 |
gezelter |
1953 |
SelectionSet SelectionEvaluator::expression(const std::vector<Token>& code, |
250 |
gezelter |
1816 |
int pcStart, int frame) { |
251 |
gezelter |
1953 |
SelectionSet bs = createSelectionSets(); |
252 |
|
|
std::stack<SelectionSet> stack; |
253 |
gezelter |
1816 |
|
254 |
|
|
for (unsigned int pc = pcStart; pc < code.size(); ++pc) { |
255 |
|
|
Token instruction = code[pc]; |
256 |
tim |
278 |
|
257 |
gezelter |
1816 |
switch (instruction.tok) { |
258 |
|
|
case Token::expressionBegin: |
259 |
|
|
break; |
260 |
|
|
case Token::expressionEnd: |
261 |
|
|
break; |
262 |
|
|
case Token::all: |
263 |
|
|
bs = allInstruction(); |
264 |
|
|
stack.push(bs); |
265 |
|
|
break; |
266 |
|
|
case Token::none: |
267 |
gezelter |
1953 |
bs = SelectionSet(nObjects); |
268 |
gezelter |
1816 |
stack.push(bs); |
269 |
|
|
break; |
270 |
|
|
case Token::opOr: |
271 |
|
|
bs = stack.top(); |
272 |
|
|
stack.pop(); |
273 |
|
|
stack.top() |= bs; |
274 |
|
|
break; |
275 |
|
|
case Token::opAnd: |
276 |
|
|
bs = stack.top(); |
277 |
|
|
stack.pop(); |
278 |
|
|
stack.top() &= bs; |
279 |
|
|
break; |
280 |
|
|
case Token::opNot: |
281 |
|
|
stack.top().flip(); |
282 |
|
|
break; |
283 |
|
|
case Token::within: |
284 |
|
|
withinInstruction(instruction, stack.top(), frame); |
285 |
|
|
break; |
286 |
|
|
case Token::hull: |
287 |
|
|
stack.push(hull(frame)); |
288 |
|
|
break; |
289 |
|
|
//case Token::selected: |
290 |
|
|
// stack.push(getSelectionSet()); |
291 |
|
|
// break; |
292 |
|
|
case Token::name: |
293 |
|
|
stack.push(nameInstruction(boost::any_cast<std::string>(instruction.value))); |
294 |
|
|
break; |
295 |
|
|
case Token::index: |
296 |
|
|
stack.push(indexInstruction(instruction.value)); |
297 |
|
|
break; |
298 |
|
|
case Token::identifier: |
299 |
|
|
stack.push(lookupValue(boost::any_cast<std::string>(instruction.value))); |
300 |
|
|
break; |
301 |
|
|
case Token::opLT: |
302 |
|
|
case Token::opLE: |
303 |
|
|
case Token::opGE: |
304 |
|
|
case Token::opGT: |
305 |
|
|
case Token::opEQ: |
306 |
|
|
case Token::opNE: |
307 |
|
|
stack.push(comparatorInstruction(instruction, frame)); |
308 |
|
|
break; |
309 |
|
|
default: |
310 |
|
|
unrecognizedExpression(); |
311 |
|
|
} |
312 |
|
|
} |
313 |
|
|
if (stack.size() != 1) |
314 |
|
|
evalError("atom expression compiler error - stack over/underflow"); |
315 |
|
|
|
316 |
|
|
return stack.top(); |
317 |
|
|
} |
318 |
|
|
|
319 |
|
|
|
320 |
|
|
|
321 |
gezelter |
1953 |
SelectionSet SelectionEvaluator::comparatorInstruction(const Token& instruction) { |
322 |
tim |
278 |
int comparator = instruction.tok; |
323 |
|
|
int property = instruction.intValue; |
324 |
tim |
283 |
float comparisonValue = boost::any_cast<float>(instruction.value); |
325 |
gezelter |
1953 |
SelectionSet bs = createSelectionSets(); |
326 |
tim |
295 |
bs.clearAll(); |
327 |
tim |
283 |
|
328 |
|
|
SimInfo::MoleculeIterator mi; |
329 |
|
|
Molecule* mol; |
330 |
|
|
Molecule::AtomIterator ai; |
331 |
|
|
Atom* atom; |
332 |
|
|
Molecule::RigidBodyIterator rbIter; |
333 |
|
|
RigidBody* rb; |
334 |
tim |
281 |
|
335 |
cli2 |
1364 |
for (mol = info->beginMolecule(mi); mol != NULL; |
336 |
|
|
mol = info->nextMolecule(mi)) { |
337 |
|
|
|
338 |
gezelter |
2055 |
compareProperty(mol, bs, property, comparator, comparisonValue); |
339 |
|
|
|
340 |
gezelter |
507 |
for(atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) { |
341 |
|
|
compareProperty(atom, bs, property, comparator, comparisonValue); |
342 |
|
|
} |
343 |
cli2 |
1364 |
|
344 |
|
|
for (rb = mol->beginRigidBody(rbIter); rb != NULL; |
345 |
|
|
rb = mol->nextRigidBody(rbIter)) { |
346 |
|
|
compareProperty(rb, bs, property, comparator, comparisonValue); |
347 |
|
|
} |
348 |
tim |
278 |
} |
349 |
|
|
|
350 |
tim |
283 |
return bs; |
351 |
gezelter |
507 |
} |
352 |
tim |
278 |
|
353 |
gezelter |
1953 |
SelectionSet SelectionEvaluator::comparatorInstruction(const Token& instruction, int frame) { |
354 |
gezelter |
1816 |
int comparator = instruction.tok; |
355 |
|
|
int property = instruction.intValue; |
356 |
|
|
float comparisonValue = boost::any_cast<float>(instruction.value); |
357 |
gezelter |
1953 |
SelectionSet bs = createSelectionSets(); |
358 |
gezelter |
1816 |
bs.clearAll(); |
359 |
|
|
|
360 |
|
|
SimInfo::MoleculeIterator mi; |
361 |
|
|
Molecule* mol; |
362 |
|
|
Molecule::AtomIterator ai; |
363 |
|
|
Atom* atom; |
364 |
|
|
Molecule::RigidBodyIterator rbIter; |
365 |
|
|
RigidBody* rb; |
366 |
|
|
|
367 |
|
|
for (mol = info->beginMolecule(mi); mol != NULL; |
368 |
|
|
mol = info->nextMolecule(mi)) { |
369 |
|
|
|
370 |
gezelter |
2055 |
compareProperty(mol, bs, property, comparator, comparisonValue, frame); |
371 |
|
|
|
372 |
gezelter |
1816 |
for(atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) { |
373 |
|
|
compareProperty(atom, bs, property, comparator, comparisonValue, frame); |
374 |
|
|
} |
375 |
|
|
|
376 |
|
|
for (rb = mol->beginRigidBody(rbIter); rb != NULL; |
377 |
|
|
rb = mol->nextRigidBody(rbIter)) { |
378 |
|
|
compareProperty(rb, bs, property, comparator, comparisonValue, frame); |
379 |
|
|
} |
380 |
|
|
} |
381 |
|
|
|
382 |
|
|
return bs; |
383 |
|
|
} |
384 |
|
|
|
385 |
gezelter |
1953 |
void SelectionEvaluator::compareProperty(StuntDouble* sd, SelectionSet& bs, |
386 |
cli2 |
1364 |
int property, int comparator, |
387 |
|
|
float comparisonValue) { |
388 |
tim |
963 |
RealType propertyValue = 0.0; |
389 |
gezelter |
1879 |
Vector3d pos; |
390 |
gezelter |
1931 |
|
391 |
gezelter |
507 |
switch (property) { |
392 |
|
|
case Token::mass: |
393 |
|
|
propertyValue = sd->getMass(); |
394 |
|
|
break; |
395 |
|
|
case Token::charge: |
396 |
|
|
if (sd->isAtom()){ |
397 |
|
|
Atom* atom = static_cast<Atom*>(sd); |
398 |
|
|
propertyValue = getCharge(atom); |
399 |
|
|
} else if (sd->isRigidBody()) { |
400 |
|
|
RigidBody* rb = static_cast<RigidBody*>(sd); |
401 |
|
|
RigidBody::AtomIterator ai; |
402 |
|
|
Atom* atom; |
403 |
|
|
for (atom = rb->beginAtom(ai); atom != NULL; atom = rb->nextAtom(ai)) { |
404 |
|
|
propertyValue+= getCharge(atom); |
405 |
|
|
} |
406 |
|
|
} |
407 |
|
|
break; |
408 |
cli2 |
1360 |
case Token::x: |
409 |
|
|
propertyValue = sd->getPos().x(); |
410 |
|
|
break; |
411 |
|
|
case Token::y: |
412 |
|
|
propertyValue = sd->getPos().y(); |
413 |
|
|
break; |
414 |
|
|
case Token::z: |
415 |
|
|
propertyValue = sd->getPos().z(); |
416 |
|
|
break; |
417 |
gezelter |
1879 |
case Token::wrappedX: |
418 |
|
|
pos = sd->getPos(); |
419 |
|
|
info->getSnapshotManager()->getCurrentSnapshot()->wrapVector(pos); |
420 |
|
|
propertyValue = pos.x(); |
421 |
|
|
break; |
422 |
|
|
case Token::wrappedY: |
423 |
|
|
pos = sd->getPos(); |
424 |
|
|
info->getSnapshotManager()->getCurrentSnapshot()->wrapVector(pos); |
425 |
|
|
propertyValue = pos.y(); |
426 |
|
|
break; |
427 |
|
|
case Token::wrappedZ: |
428 |
|
|
pos = sd->getPos(); |
429 |
|
|
info->getSnapshotManager()->getCurrentSnapshot()->wrapVector(pos); |
430 |
|
|
propertyValue = pos.z(); |
431 |
|
|
break; |
432 |
gezelter |
1513 |
case Token::r: |
433 |
|
|
propertyValue = sd->getPos().length(); |
434 |
|
|
break; |
435 |
gezelter |
507 |
default: |
436 |
|
|
unrecognizedAtomProperty(property); |
437 |
|
|
} |
438 |
tim |
283 |
|
439 |
gezelter |
507 |
bool match = false; |
440 |
|
|
switch (comparator) { |
441 |
|
|
case Token::opLT: |
442 |
|
|
match = propertyValue < comparisonValue; |
443 |
|
|
break; |
444 |
|
|
case Token::opLE: |
445 |
|
|
match = propertyValue <= comparisonValue; |
446 |
|
|
break; |
447 |
|
|
case Token::opGE: |
448 |
|
|
match = propertyValue >= comparisonValue; |
449 |
|
|
break; |
450 |
|
|
case Token::opGT: |
451 |
|
|
match = propertyValue > comparisonValue; |
452 |
|
|
break; |
453 |
|
|
case Token::opEQ: |
454 |
|
|
match = propertyValue == comparisonValue; |
455 |
|
|
break; |
456 |
|
|
case Token::opNE: |
457 |
|
|
match = propertyValue != comparisonValue; |
458 |
|
|
break; |
459 |
|
|
} |
460 |
gezelter |
1931 |
|
461 |
gezelter |
1816 |
if (match) |
462 |
gezelter |
1953 |
bs.bitsets_[STUNTDOUBLE].setBitOn(sd->getGlobalIndex()); |
463 |
gezelter |
1816 |
|
464 |
cli2 |
1364 |
|
465 |
gezelter |
507 |
} |
466 |
tim |
283 |
|
467 |
gezelter |
2055 |
void SelectionEvaluator::compareProperty(Molecule* mol, SelectionSet& bs, |
468 |
|
|
int property, int comparator, |
469 |
|
|
float comparisonValue) { |
470 |
|
|
RealType propertyValue = 0.0; |
471 |
|
|
Vector3d pos; |
472 |
|
|
|
473 |
|
|
switch (property) { |
474 |
|
|
case Token::mass: |
475 |
|
|
propertyValue = mol->getMass(); |
476 |
|
|
break; |
477 |
|
|
case Token::charge: |
478 |
|
|
{ |
479 |
|
|
Molecule::AtomIterator ai; |
480 |
|
|
Atom* atom; |
481 |
|
|
for (atom = mol->beginAtom(ai); atom != NULL; |
482 |
|
|
atom = mol->nextAtom(ai)) { |
483 |
|
|
propertyValue+= getCharge(atom); |
484 |
|
|
} |
485 |
|
|
} |
486 |
|
|
break; |
487 |
|
|
case Token::x: |
488 |
|
|
propertyValue = mol->getCom().x(); |
489 |
|
|
break; |
490 |
|
|
case Token::y: |
491 |
|
|
propertyValue = mol->getCom().y(); |
492 |
|
|
break; |
493 |
|
|
case Token::z: |
494 |
|
|
propertyValue = mol->getCom().z(); |
495 |
|
|
break; |
496 |
|
|
case Token::wrappedX: |
497 |
|
|
pos = mol->getCom(); |
498 |
|
|
info->getSnapshotManager()->getCurrentSnapshot()->wrapVector(pos); |
499 |
|
|
propertyValue = pos.x(); |
500 |
|
|
break; |
501 |
|
|
case Token::wrappedY: |
502 |
|
|
pos = mol->getCom(); |
503 |
|
|
info->getSnapshotManager()->getCurrentSnapshot()->wrapVector(pos); |
504 |
|
|
propertyValue = pos.y(); |
505 |
|
|
break; |
506 |
|
|
case Token::wrappedZ: |
507 |
|
|
pos = mol->getCom(); |
508 |
|
|
info->getSnapshotManager()->getCurrentSnapshot()->wrapVector(pos); |
509 |
|
|
propertyValue = pos.z(); |
510 |
|
|
break; |
511 |
|
|
case Token::r: |
512 |
|
|
propertyValue = mol->getCom().length(); |
513 |
|
|
break; |
514 |
|
|
default: |
515 |
|
|
unrecognizedMoleculeProperty(property); |
516 |
|
|
} |
517 |
|
|
|
518 |
|
|
bool match = false; |
519 |
|
|
switch (comparator) { |
520 |
|
|
case Token::opLT: |
521 |
|
|
match = propertyValue < comparisonValue; |
522 |
|
|
break; |
523 |
|
|
case Token::opLE: |
524 |
|
|
match = propertyValue <= comparisonValue; |
525 |
|
|
break; |
526 |
|
|
case Token::opGE: |
527 |
|
|
match = propertyValue >= comparisonValue; |
528 |
|
|
break; |
529 |
|
|
case Token::opGT: |
530 |
|
|
match = propertyValue > comparisonValue; |
531 |
|
|
break; |
532 |
|
|
case Token::opEQ: |
533 |
|
|
match = propertyValue == comparisonValue; |
534 |
|
|
break; |
535 |
|
|
case Token::opNE: |
536 |
|
|
match = propertyValue != comparisonValue; |
537 |
|
|
break; |
538 |
|
|
} |
539 |
|
|
|
540 |
|
|
if (match) |
541 |
|
|
bs.bitsets_[MOLECULE].setBitOn(mol->getGlobalIndex()); |
542 |
|
|
} |
543 |
|
|
|
544 |
|
|
void SelectionEvaluator::compareProperty(Molecule* mol, SelectionSet& bs, |
545 |
|
|
int property, int comparator, |
546 |
|
|
float comparisonValue, int frame) { |
547 |
|
|
RealType propertyValue = 0.0; |
548 |
|
|
Vector3d pos; |
549 |
|
|
switch (property) { |
550 |
|
|
case Token::mass: |
551 |
|
|
propertyValue = mol->getMass(); |
552 |
|
|
break; |
553 |
|
|
case Token::charge: |
554 |
|
|
{ |
555 |
|
|
Molecule::AtomIterator ai; |
556 |
|
|
Atom* atom; |
557 |
|
|
for (atom = mol->beginAtom(ai); atom != NULL; |
558 |
|
|
atom = mol->nextAtom(ai)) { |
559 |
|
|
propertyValue+= getCharge(atom,frame); |
560 |
|
|
} |
561 |
|
|
} |
562 |
|
|
break; |
563 |
|
|
case Token::x: |
564 |
|
|
propertyValue = mol->getCom(frame).x(); |
565 |
|
|
break; |
566 |
|
|
case Token::y: |
567 |
|
|
propertyValue = mol->getCom(frame).y(); |
568 |
|
|
break; |
569 |
|
|
case Token::z: |
570 |
|
|
propertyValue = mol->getCom(frame).z(); |
571 |
|
|
break; |
572 |
|
|
case Token::wrappedX: |
573 |
|
|
pos = mol->getCom(frame); |
574 |
|
|
info->getSnapshotManager()->getSnapshot(frame)->wrapVector(pos); |
575 |
|
|
propertyValue = pos.x(); |
576 |
|
|
break; |
577 |
|
|
case Token::wrappedY: |
578 |
|
|
pos = mol->getCom(frame); |
579 |
|
|
info->getSnapshotManager()->getSnapshot(frame)->wrapVector(pos); |
580 |
|
|
propertyValue = pos.y(); |
581 |
|
|
break; |
582 |
|
|
case Token::wrappedZ: |
583 |
|
|
pos = mol->getCom(frame); |
584 |
|
|
info->getSnapshotManager()->getSnapshot(frame)->wrapVector(pos); |
585 |
|
|
propertyValue = pos.z(); |
586 |
|
|
break; |
587 |
|
|
|
588 |
|
|
case Token::r: |
589 |
|
|
propertyValue = mol->getCom(frame).length(); |
590 |
|
|
break; |
591 |
|
|
default: |
592 |
|
|
unrecognizedMoleculeProperty(property); |
593 |
|
|
} |
594 |
|
|
|
595 |
|
|
bool match = false; |
596 |
|
|
switch (comparator) { |
597 |
|
|
case Token::opLT: |
598 |
|
|
match = propertyValue < comparisonValue; |
599 |
|
|
break; |
600 |
|
|
case Token::opLE: |
601 |
|
|
match = propertyValue <= comparisonValue; |
602 |
|
|
break; |
603 |
|
|
case Token::opGE: |
604 |
|
|
match = propertyValue >= comparisonValue; |
605 |
|
|
break; |
606 |
|
|
case Token::opGT: |
607 |
|
|
match = propertyValue > comparisonValue; |
608 |
|
|
break; |
609 |
|
|
case Token::opEQ: |
610 |
|
|
match = propertyValue == comparisonValue; |
611 |
|
|
break; |
612 |
|
|
case Token::opNE: |
613 |
|
|
match = propertyValue != comparisonValue; |
614 |
|
|
break; |
615 |
|
|
} |
616 |
|
|
if (match) |
617 |
|
|
bs.bitsets_[MOLECULE].setBitOn(mol->getGlobalIndex()); |
618 |
|
|
|
619 |
|
|
|
620 |
|
|
} |
621 |
gezelter |
1953 |
void SelectionEvaluator::compareProperty(StuntDouble* sd, SelectionSet& bs, |
622 |
gezelter |
1816 |
int property, int comparator, |
623 |
|
|
float comparisonValue, int frame) { |
624 |
|
|
RealType propertyValue = 0.0; |
625 |
gezelter |
1879 |
Vector3d pos; |
626 |
gezelter |
1816 |
switch (property) { |
627 |
|
|
case Token::mass: |
628 |
|
|
propertyValue = sd->getMass(); |
629 |
|
|
break; |
630 |
|
|
case Token::charge: |
631 |
|
|
if (sd->isAtom()){ |
632 |
|
|
Atom* atom = static_cast<Atom*>(sd); |
633 |
|
|
propertyValue = getCharge(atom,frame); |
634 |
|
|
} else if (sd->isRigidBody()) { |
635 |
|
|
RigidBody* rb = static_cast<RigidBody*>(sd); |
636 |
|
|
RigidBody::AtomIterator ai; |
637 |
|
|
Atom* atom; |
638 |
|
|
for (atom = rb->beginAtom(ai); atom != NULL; atom = rb->nextAtom(ai)) { |
639 |
|
|
propertyValue+= getCharge(atom,frame); |
640 |
|
|
} |
641 |
|
|
} |
642 |
|
|
break; |
643 |
|
|
case Token::x: |
644 |
|
|
propertyValue = sd->getPos(frame).x(); |
645 |
|
|
break; |
646 |
|
|
case Token::y: |
647 |
|
|
propertyValue = sd->getPos(frame).y(); |
648 |
|
|
break; |
649 |
|
|
case Token::z: |
650 |
|
|
propertyValue = sd->getPos(frame).z(); |
651 |
|
|
break; |
652 |
gezelter |
1879 |
case Token::wrappedX: |
653 |
|
|
pos = sd->getPos(frame); |
654 |
|
|
info->getSnapshotManager()->getSnapshot(frame)->wrapVector(pos); |
655 |
|
|
propertyValue = pos.x(); |
656 |
|
|
break; |
657 |
|
|
case Token::wrappedY: |
658 |
|
|
pos = sd->getPos(frame); |
659 |
|
|
info->getSnapshotManager()->getSnapshot(frame)->wrapVector(pos); |
660 |
|
|
propertyValue = pos.y(); |
661 |
|
|
break; |
662 |
|
|
case Token::wrappedZ: |
663 |
|
|
pos = sd->getPos(frame); |
664 |
|
|
info->getSnapshotManager()->getSnapshot(frame)->wrapVector(pos); |
665 |
|
|
propertyValue = pos.z(); |
666 |
|
|
break; |
667 |
|
|
|
668 |
gezelter |
1816 |
case Token::r: |
669 |
|
|
propertyValue = sd->getPos(frame).length(); |
670 |
|
|
break; |
671 |
|
|
default: |
672 |
|
|
unrecognizedAtomProperty(property); |
673 |
|
|
} |
674 |
|
|
|
675 |
|
|
bool match = false; |
676 |
|
|
switch (comparator) { |
677 |
|
|
case Token::opLT: |
678 |
|
|
match = propertyValue < comparisonValue; |
679 |
|
|
break; |
680 |
|
|
case Token::opLE: |
681 |
|
|
match = propertyValue <= comparisonValue; |
682 |
|
|
break; |
683 |
|
|
case Token::opGE: |
684 |
|
|
match = propertyValue >= comparisonValue; |
685 |
|
|
break; |
686 |
|
|
case Token::opGT: |
687 |
|
|
match = propertyValue > comparisonValue; |
688 |
|
|
break; |
689 |
|
|
case Token::opEQ: |
690 |
|
|
match = propertyValue == comparisonValue; |
691 |
|
|
break; |
692 |
|
|
case Token::opNE: |
693 |
|
|
match = propertyValue != comparisonValue; |
694 |
|
|
break; |
695 |
|
|
} |
696 |
|
|
if (match) |
697 |
gezelter |
1953 |
bs.bitsets_[STUNTDOUBLE].setBitOn(sd->getGlobalIndex()); |
698 |
gezelter |
1816 |
|
699 |
|
|
|
700 |
|
|
} |
701 |
|
|
|
702 |
gezelter |
2055 |
|
703 |
cli2 |
1364 |
void SelectionEvaluator::withinInstruction(const Token& instruction, |
704 |
gezelter |
1953 |
SelectionSet& bs){ |
705 |
tim |
295 |
|
706 |
tim |
281 |
boost::any withinSpec = instruction.value; |
707 |
tim |
295 |
float distance; |
708 |
tim |
282 |
if (withinSpec.type() == typeid(float)){ |
709 |
gezelter |
507 |
distance = boost::any_cast<float>(withinSpec); |
710 |
tim |
295 |
} else if (withinSpec.type() == typeid(int)) { |
711 |
gezelter |
507 |
distance = boost::any_cast<int>(withinSpec); |
712 |
tim |
295 |
} else { |
713 |
gezelter |
507 |
evalError("casting error in withinInstruction"); |
714 |
|
|
bs.clearAll(); |
715 |
tim |
278 |
} |
716 |
tim |
282 |
|
717 |
tim |
295 |
bs = distanceFinder.find(bs, distance); |
718 |
gezelter |
507 |
} |
719 |
gezelter |
1816 |
|
720 |
|
|
void SelectionEvaluator::withinInstruction(const Token& instruction, |
721 |
gezelter |
1953 |
SelectionSet& bs, int frame){ |
722 |
gezelter |
1816 |
|
723 |
|
|
boost::any withinSpec = instruction.value; |
724 |
|
|
float distance; |
725 |
|
|
if (withinSpec.type() == typeid(float)){ |
726 |
|
|
distance = boost::any_cast<float>(withinSpec); |
727 |
|
|
} else if (withinSpec.type() == typeid(int)) { |
728 |
|
|
distance = boost::any_cast<int>(withinSpec); |
729 |
|
|
} else { |
730 |
|
|
evalError("casting error in withinInstruction"); |
731 |
|
|
bs.clearAll(); |
732 |
|
|
} |
733 |
|
|
|
734 |
|
|
bs = distanceFinder.find(bs, distance, frame); |
735 |
|
|
} |
736 |
cli2 |
1364 |
|
737 |
gezelter |
507 |
void SelectionEvaluator::define() { |
738 |
tim |
282 |
assert(statement.size() >= 3); |
739 |
cli2 |
1364 |
|
740 |
tim |
282 |
std::string variable = boost::any_cast<std::string>(statement[1].value); |
741 |
cli2 |
1364 |
|
742 |
|
|
variables.insert(VariablesType::value_type(variable, |
743 |
|
|
expression(statement, 2))); |
744 |
gezelter |
507 |
} |
745 |
cli2 |
1364 |
|
746 |
tim |
278 |
|
747 |
gezelter |
507 |
/** @todo */ |
748 |
|
|
void SelectionEvaluator::predefine(const std::string& script) { |
749 |
cli2 |
1364 |
|
750 |
tim |
282 |
if (compiler.compile("#predefine", script)) { |
751 |
gezelter |
507 |
std::vector<std::vector<Token> > aatoken = compiler.getAatokenCompiled(); |
752 |
|
|
if (aatoken.size() != 1) { |
753 |
|
|
evalError("predefinition does not have exactly 1 command:" |
754 |
|
|
+ script); |
755 |
|
|
return; |
756 |
|
|
} |
757 |
|
|
std::vector<Token> statement = aatoken[0]; |
758 |
|
|
if (statement.size() > 2) { |
759 |
|
|
int tok = statement[1].tok; |
760 |
cli2 |
1364 |
if (tok == Token::identifier || |
761 |
|
|
(tok & Token::predefinedset) == Token::predefinedset) { |
762 |
gezelter |
507 |
std::string variable = boost::any_cast<std::string>(statement[1].value); |
763 |
|
|
variables.insert(VariablesType::value_type(variable, statement)); |
764 |
cli2 |
1364 |
|
765 |
gezelter |
507 |
} else { |
766 |
|
|
evalError("invalid variable name:" + script); |
767 |
|
|
} |
768 |
|
|
}else { |
769 |
|
|
evalError("bad predefinition length:" + script); |
770 |
cli2 |
1364 |
} |
771 |
tim |
282 |
|
772 |
|
|
} else { |
773 |
gezelter |
507 |
evalError("predefined set compile error:" + script + |
774 |
|
|
"\ncompile error:" + compiler.getErrorMessage()); |
775 |
tim |
282 |
} |
776 |
gezelter |
507 |
} |
777 |
tim |
282 |
|
778 |
gezelter |
1953 |
void SelectionEvaluator::select(SelectionSet& bs){ |
779 |
tim |
288 |
bs = expression(statement, 1); |
780 |
gezelter |
507 |
} |
781 |
gezelter |
1816 |
|
782 |
gezelter |
1953 |
void SelectionEvaluator::select(SelectionSet& bs, int frame){ |
783 |
gezelter |
1816 |
bs = expression(statement, 1, frame); |
784 |
|
|
} |
785 |
cli2 |
1364 |
|
786 |
gezelter |
1953 |
SelectionSet SelectionEvaluator::lookupValue(const std::string& variable){ |
787 |
cli2 |
1364 |
|
788 |
gezelter |
1953 |
SelectionSet bs = createSelectionSets(); |
789 |
tim |
282 |
std::map<std::string, boost::any>::iterator i = variables.find(variable); |
790 |
tim |
295 |
|
791 |
tim |
282 |
if (i != variables.end()) { |
792 |
gezelter |
1953 |
if (i->second.type() == typeid(SelectionSet)) { |
793 |
|
|
return boost::any_cast<SelectionSet>(i->second); |
794 |
gezelter |
507 |
} else if (i->second.type() == typeid(std::vector<Token>)){ |
795 |
|
|
bs = expression(boost::any_cast<std::vector<Token> >(i->second), 2); |
796 |
|
|
i->second = bs; /**@todo fixme */ |
797 |
|
|
return bs; |
798 |
|
|
} |
799 |
tim |
283 |
} else { |
800 |
gezelter |
507 |
unrecognizedIdentifier(variable); |
801 |
tim |
282 |
} |
802 |
cli2 |
1364 |
|
803 |
tim |
295 |
return bs; |
804 |
gezelter |
507 |
} |
805 |
cli2 |
1364 |
|
806 |
gezelter |
1953 |
SelectionSet SelectionEvaluator::nameInstruction(const std::string& name){ |
807 |
cli2 |
1364 |
return nameFinder.match(name); |
808 |
gezelter |
507 |
} |
809 |
tim |
283 |
|
810 |
gezelter |
507 |
bool SelectionEvaluator::containDynamicToken(const std::vector<Token>& tokens){ |
811 |
tim |
288 |
std::vector<Token>::const_iterator i; |
812 |
|
|
for (i = tokens.begin(); i != tokens.end(); ++i) { |
813 |
gezelter |
507 |
if (i->tok & Token::dynamic) { |
814 |
|
|
return true; |
815 |
|
|
} |
816 |
tim |
288 |
} |
817 |
cli2 |
1364 |
|
818 |
tim |
288 |
return false; |
819 |
gezelter |
507 |
} |
820 |
tim |
288 |
|
821 |
gezelter |
507 |
void SelectionEvaluator::clearDefinitionsAndLoadPredefined() { |
822 |
tim |
288 |
variables.clear(); |
823 |
|
|
//load predefine |
824 |
|
|
//predefine(); |
825 |
gezelter |
507 |
} |
826 |
tim |
288 |
|
827 |
gezelter |
1953 |
SelectionSet SelectionEvaluator::createSelectionSets() { |
828 |
|
|
SelectionSet ss(nObjects); |
829 |
|
|
return ss; |
830 |
|
|
} |
831 |
|
|
|
832 |
|
|
SelectionSet SelectionEvaluator::evaluate() { |
833 |
|
|
SelectionSet bs = createSelectionSets(); |
834 |
tim |
288 |
if (isLoaded_) { |
835 |
gezelter |
507 |
pc = 0; |
836 |
|
|
instructionDispatchLoop(bs); |
837 |
tim |
288 |
} |
838 |
gezelter |
1816 |
return bs; |
839 |
|
|
} |
840 |
tim |
288 |
|
841 |
gezelter |
1953 |
SelectionSet SelectionEvaluator::evaluate(int frame) { |
842 |
|
|
SelectionSet bs = createSelectionSets(); |
843 |
gezelter |
1816 |
if (isLoaded_) { |
844 |
|
|
pc = 0; |
845 |
|
|
instructionDispatchLoop(bs, frame); |
846 |
|
|
} |
847 |
tim |
288 |
return bs; |
848 |
gezelter |
507 |
} |
849 |
tim |
295 |
|
850 |
gezelter |
1953 |
SelectionSet SelectionEvaluator::indexInstruction(const boost::any& value) { |
851 |
|
|
SelectionSet bs = createSelectionSets(); |
852 |
tim |
295 |
|
853 |
|
|
if (value.type() == typeid(int)) { |
854 |
gezelter |
507 |
int index = boost::any_cast<int>(value); |
855 |
gezelter |
1953 |
if (index < 0 || index >= bs.bitsets_[STUNTDOUBLE].size()) { |
856 |
gezelter |
507 |
invalidIndex(index); |
857 |
|
|
} else { |
858 |
|
|
bs = indexFinder.find(index); |
859 |
|
|
} |
860 |
tim |
295 |
} else if (value.type() == typeid(std::pair<int, int>)) { |
861 |
gezelter |
507 |
std::pair<int, int> indexRange= boost::any_cast<std::pair<int, int> >(value); |
862 |
|
|
assert(indexRange.first <= indexRange.second); |
863 |
gezelter |
1953 |
if (indexRange.first < 0 || |
864 |
|
|
indexRange.second >= bs.bitsets_[STUNTDOUBLE].size()) { |
865 |
gezelter |
507 |
invalidIndexRange(indexRange); |
866 |
|
|
}else { |
867 |
|
|
bs = indexFinder.find(indexRange.first, indexRange.second); |
868 |
|
|
} |
869 |
tim |
295 |
} |
870 |
|
|
|
871 |
|
|
return bs; |
872 |
gezelter |
507 |
} |
873 |
tim |
295 |
|
874 |
gezelter |
1953 |
SelectionSet SelectionEvaluator::allInstruction() { |
875 |
|
|
SelectionSet ss = createSelectionSets(); |
876 |
tim |
432 |
|
877 |
gezelter |
1801 |
SimInfo::MoleculeIterator mi; |
878 |
gezelter |
1953 |
Molecule::AtomIterator ai; |
879 |
|
|
Molecule::RigidBodyIterator rbIter; |
880 |
|
|
Molecule::BondIterator bondIter; |
881 |
|
|
Molecule::BendIterator bendIter; |
882 |
|
|
Molecule::TorsionIterator torsionIter; |
883 |
|
|
Molecule::InversionIterator inversionIter; |
884 |
|
|
|
885 |
gezelter |
1801 |
Molecule* mol; |
886 |
|
|
Atom* atom; |
887 |
|
|
RigidBody* rb; |
888 |
gezelter |
1953 |
Bond* bond; |
889 |
|
|
Bend* bend; |
890 |
|
|
Torsion* torsion; |
891 |
|
|
Inversion* inversion; |
892 |
gezelter |
1801 |
|
893 |
|
|
// Doing the loop insures that we're actually on this processor. |
894 |
|
|
|
895 |
|
|
for (mol = info->beginMolecule(mi); mol != NULL; |
896 |
|
|
mol = info->nextMolecule(mi)) { |
897 |
|
|
for(atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) { |
898 |
gezelter |
1953 |
ss.bitsets_[STUNTDOUBLE].setBitOn(atom->getGlobalIndex()); |
899 |
|
|
} |
900 |
gezelter |
1801 |
for (rb = mol->beginRigidBody(rbIter); rb != NULL; |
901 |
|
|
rb = mol->nextRigidBody(rbIter)) { |
902 |
gezelter |
1953 |
ss.bitsets_[STUNTDOUBLE].setBitOn(rb->getGlobalIndex()); |
903 |
gezelter |
1801 |
} |
904 |
gezelter |
1953 |
for (bond = mol->beginBond(bondIter); bond != NULL; |
905 |
|
|
bond = mol->nextBond(bondIter)) { |
906 |
|
|
ss.bitsets_[BOND].setBitOn(bond->getGlobalIndex()); |
907 |
|
|
} |
908 |
|
|
for (bend = mol->beginBend(bendIter); bend != NULL; |
909 |
|
|
bend = mol->nextBend(bendIter)) { |
910 |
|
|
ss.bitsets_[BEND].setBitOn(bend->getGlobalIndex()); |
911 |
|
|
} |
912 |
|
|
for (torsion = mol->beginTorsion(torsionIter); torsion != NULL; |
913 |
|
|
torsion = mol->nextTorsion(torsionIter)) { |
914 |
|
|
ss.bitsets_[TORSION].setBitOn(torsion->getGlobalIndex()); |
915 |
|
|
} |
916 |
|
|
for (inversion = mol->beginInversion(inversionIter); inversion != NULL; |
917 |
|
|
inversion = mol->nextInversion(inversionIter)) { |
918 |
|
|
ss.bitsets_[INVERSION].setBitOn(inversion->getGlobalIndex()); |
919 |
gezelter |
2052 |
} |
920 |
|
|
ss.bitsets_[MOLECULE].setBitOn(mol->getGlobalIndex()); |
921 |
gezelter |
1801 |
} |
922 |
|
|
|
923 |
gezelter |
1953 |
return ss; |
924 |
gezelter |
1801 |
} |
925 |
|
|
|
926 |
gezelter |
1953 |
SelectionSet SelectionEvaluator::hull() { |
927 |
|
|
SelectionSet bs = createSelectionSets(); |
928 |
gezelter |
1412 |
|
929 |
|
|
bs = hullFinder.findHull(); |
930 |
gezelter |
1903 |
surfaceArea_ = hullFinder.getSurfaceArea(); |
931 |
|
|
hasSurfaceArea_ = true; |
932 |
gezelter |
1412 |
return bs; |
933 |
|
|
} |
934 |
|
|
|
935 |
gezelter |
1816 |
|
936 |
gezelter |
1953 |
SelectionSet SelectionEvaluator::hull(int frame) { |
937 |
|
|
SelectionSet bs = createSelectionSets(); |
938 |
gezelter |
1816 |
|
939 |
|
|
bs = hullFinder.findHull(frame); |
940 |
gezelter |
1903 |
|
941 |
gezelter |
1816 |
return bs; |
942 |
|
|
} |
943 |
|
|
|
944 |
tim |
963 |
RealType SelectionEvaluator::getCharge(Atom* atom) { |
945 |
gezelter |
1816 |
RealType charge = 0.0; |
946 |
tim |
432 |
AtomType* atomType = atom->getAtomType(); |
947 |
|
|
|
948 |
gezelter |
1816 |
FixedChargeAdapter fca = FixedChargeAdapter(atomType); |
949 |
|
|
if ( fca.isFixedCharge() ) { |
950 |
|
|
charge = fca.getCharge(); |
951 |
|
|
} |
952 |
|
|
|
953 |
|
|
FluctuatingChargeAdapter fqa = FluctuatingChargeAdapter(atomType); |
954 |
|
|
if ( fqa.isFluctuatingCharge() ) { |
955 |
|
|
charge += atom->getFlucQPos(); |
956 |
|
|
} |
957 |
|
|
return charge; |
958 |
|
|
} |
959 |
tim |
432 |
|
960 |
gezelter |
1816 |
RealType SelectionEvaluator::getCharge(Atom* atom, int frame) { |
961 |
|
|
RealType charge = 0.0; |
962 |
|
|
AtomType* atomType = atom->getAtomType(); |
963 |
|
|
|
964 |
|
|
FixedChargeAdapter fca = FixedChargeAdapter(atomType); |
965 |
|
|
if ( fca.isFixedCharge() ) { |
966 |
|
|
charge = fca.getCharge(); |
967 |
tim |
432 |
} |
968 |
gezelter |
1816 |
|
969 |
|
|
FluctuatingChargeAdapter fqa = FluctuatingChargeAdapter(atomType); |
970 |
|
|
if ( fqa.isFluctuatingCharge() ) { |
971 |
|
|
charge += atom->getFlucQPos(frame); |
972 |
|
|
} |
973 |
tim |
432 |
return charge; |
974 |
gezelter |
507 |
} |
975 |
tim |
432 |
|
976 |
|
|
} |