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, 24107 (2008). |
39 |
< |
* [4] Vardeman & Gezelter, in progress (2009). |
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 <stack> |
46 |
|
#include "primitives/DirectionalAtom.hpp" |
47 |
|
#include "primitives/RigidBody.hpp" |
48 |
|
#include "primitives/Molecule.hpp" |
49 |
< |
#include "io/basic_ifstrstream.hpp" |
49 |
> |
#include "io/ifstrstream.hpp" |
50 |
|
|
51 |
|
namespace OpenMD { |
52 |
|
|
53 |
|
|
54 |
|
SelectionEvaluator::SelectionEvaluator(SimInfo* si) |
55 |
< |
: info(si), nameFinder(info), distanceFinder(info), indexFinder(info), |
55 |
> |
: info(si), nameFinder(info), distanceFinder(info), hullFinder(info), |
56 |
> |
indexFinder(info), |
57 |
|
isLoaded_(false){ |
58 |
|
nStuntDouble = info->getNGlobalAtoms() + info->getNGlobalRigidBodies(); |
59 |
|
} |
150 |
|
OpenMDBitSet bs; |
151 |
|
std::stack<OpenMDBitSet> stack; |
152 |
|
|
153 |
< |
for (int pc = pcStart; pc < code.size(); ++pc) { |
153 |
> |
for (unsigned int pc = pcStart; pc < code.size(); ++pc) { |
154 |
|
Token instruction = code[pc]; |
155 |
|
|
156 |
|
switch (instruction.tok) { |
159 |
|
case Token::expressionEnd: |
160 |
|
break; |
161 |
|
case Token::all: |
162 |
< |
bs = OpenMDBitSet(nStuntDouble); |
161 |
< |
bs.setAll(); |
162 |
> |
bs = allInstruction(); |
163 |
|
stack.push(bs); |
164 |
|
break; |
165 |
|
case Token::none: |
182 |
|
case Token::within: |
183 |
|
withinInstruction(instruction, stack.top()); |
184 |
|
break; |
185 |
+ |
case Token::hull: |
186 |
+ |
stack.push(hull()); |
187 |
+ |
break; |
188 |
|
//case Token::selected: |
189 |
|
// stack.push(getSelectionSet()); |
190 |
|
// break; |
221 |
|
int comparator = instruction.tok; |
222 |
|
int property = instruction.intValue; |
223 |
|
float comparisonValue = boost::any_cast<float>(instruction.value); |
220 |
– |
float propertyValue; |
224 |
|
OpenMDBitSet bs(nStuntDouble); |
225 |
|
bs.clearAll(); |
226 |
|
|
277 |
|
case Token::z: |
278 |
|
propertyValue = sd->getPos().z(); |
279 |
|
break; |
280 |
+ |
case Token::r: |
281 |
+ |
propertyValue = sd->getPos().length(); |
282 |
+ |
break; |
283 |
|
default: |
284 |
|
unrecognizedAtomProperty(property); |
285 |
|
} |
446 |
|
return bs; |
447 |
|
} |
448 |
|
|
449 |
+ |
OpenMDBitSet SelectionEvaluator::allInstruction() { |
450 |
+ |
OpenMDBitSet bs(nStuntDouble); |
451 |
|
|
452 |
+ |
SimInfo::MoleculeIterator mi; |
453 |
+ |
Molecule* mol; |
454 |
+ |
Molecule::AtomIterator ai; |
455 |
+ |
Atom* atom; |
456 |
+ |
Molecule::RigidBodyIterator rbIter; |
457 |
+ |
RigidBody* rb; |
458 |
+ |
|
459 |
+ |
// Doing the loop insures that we're actually on this processor. |
460 |
+ |
|
461 |
+ |
for (mol = info->beginMolecule(mi); mol != NULL; |
462 |
+ |
mol = info->nextMolecule(mi)) { |
463 |
+ |
|
464 |
+ |
for(atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) { |
465 |
+ |
bs.setBitOn(atom->getGlobalIndex()); |
466 |
+ |
} |
467 |
+ |
|
468 |
+ |
for (rb = mol->beginRigidBody(rbIter); rb != NULL; |
469 |
+ |
rb = mol->nextRigidBody(rbIter)) { |
470 |
+ |
bs.setBitOn(rb->getGlobalIndex()); |
471 |
+ |
} |
472 |
+ |
} |
473 |
+ |
|
474 |
+ |
return bs; |
475 |
+ |
} |
476 |
+ |
|
477 |
+ |
OpenMDBitSet SelectionEvaluator::hull() { |
478 |
+ |
OpenMDBitSet bs(nStuntDouble); |
479 |
+ |
|
480 |
+ |
bs = hullFinder.findHull(); |
481 |
+ |
|
482 |
+ |
return bs; |
483 |
+ |
} |
484 |
+ |
|
485 |
|
RealType SelectionEvaluator::getCharge(Atom* atom) { |
486 |
|
RealType charge =0.0; |
487 |
|
AtomType* atomType = atom->getAtomType(); |