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. |
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, 24107 (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 <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 oopse { |
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 |
|
} |
69 |
|
|
70 |
|
sprintf( painCave.errMsg, |
71 |
|
"SelectionCompiler Error: %s\n", errorMessage.c_str()); |
72 |
< |
painCave.severity = OOPSE_ERROR; |
72 |
> |
painCave.severity = OPENMD_ERROR; |
73 |
|
painCave.isFatal = 1; |
74 |
|
simError(); |
75 |
|
return false; |
124 |
|
return loadScript(filename, script); |
125 |
|
} |
126 |
|
|
127 |
< |
void SelectionEvaluator::instructionDispatchLoop(OOPSEBitSet& bs){ |
127 |
> |
void SelectionEvaluator::instructionDispatchLoop(OpenMDBitSet& bs){ |
128 |
|
|
129 |
|
while ( pc < aatoken.size()) { |
130 |
|
statement = aatoken[pc++]; |
145 |
|
|
146 |
|
} |
147 |
|
|
148 |
< |
OOPSEBitSet SelectionEvaluator::expression(const std::vector<Token>& code, |
148 |
> |
OpenMDBitSet SelectionEvaluator::expression(const std::vector<Token>& code, |
149 |
|
int pcStart) { |
150 |
< |
OOPSEBitSet bs; |
151 |
< |
std::stack<OOPSEBitSet> stack; |
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 = OOPSEBitSet(nStuntDouble); |
161 |
< |
bs.setAll(); |
162 |
> |
bs = allInstruction(); |
163 |
|
stack.push(bs); |
164 |
|
break; |
165 |
|
case Token::none: |
166 |
< |
bs = OOPSEBitSet(nStuntDouble); |
166 |
> |
bs = OpenMDBitSet(nStuntDouble); |
167 |
|
stack.push(bs); |
168 |
|
break; |
169 |
|
case Token::opOr: |
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; |
217 |
|
|
218 |
|
|
219 |
|
|
220 |
< |
OOPSEBitSet SelectionEvaluator::comparatorInstruction(const Token& instruction) { |
220 |
> |
OpenMDBitSet SelectionEvaluator::comparatorInstruction(const Token& instruction) { |
221 |
|
int comparator = instruction.tok; |
222 |
|
int property = instruction.intValue; |
223 |
|
float comparisonValue = boost::any_cast<float>(instruction.value); |
224 |
< |
float propertyValue; |
221 |
< |
OOPSEBitSet bs(nStuntDouble); |
224 |
> |
OpenMDBitSet bs(nStuntDouble); |
225 |
|
bs.clearAll(); |
226 |
|
|
227 |
|
SimInfo::MoleculeIterator mi; |
247 |
|
return bs; |
248 |
|
} |
249 |
|
|
250 |
< |
void SelectionEvaluator::compareProperty(StuntDouble* sd, OOPSEBitSet& bs, |
250 |
> |
void SelectionEvaluator::compareProperty(StuntDouble* sd, OpenMDBitSet& bs, |
251 |
|
int property, int comparator, |
252 |
|
float comparisonValue) { |
253 |
|
RealType propertyValue = 0.0; |
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 |
|
} |
311 |
|
} |
312 |
|
|
313 |
|
void SelectionEvaluator::withinInstruction(const Token& instruction, |
314 |
< |
OOPSEBitSet& bs){ |
314 |
> |
OpenMDBitSet& bs){ |
315 |
|
|
316 |
|
boost::any withinSpec = instruction.value; |
317 |
|
float distance; |
368 |
|
} |
369 |
|
} |
370 |
|
|
371 |
< |
void SelectionEvaluator::select(OOPSEBitSet& bs){ |
371 |
> |
void SelectionEvaluator::select(OpenMDBitSet& bs){ |
372 |
|
bs = expression(statement, 1); |
373 |
|
} |
374 |
|
|
375 |
< |
OOPSEBitSet SelectionEvaluator::lookupValue(const std::string& variable){ |
375 |
> |
OpenMDBitSet SelectionEvaluator::lookupValue(const std::string& variable){ |
376 |
|
|
377 |
< |
OOPSEBitSet bs(nStuntDouble); |
377 |
> |
OpenMDBitSet bs(nStuntDouble); |
378 |
|
std::map<std::string, boost::any>::iterator i = variables.find(variable); |
379 |
|
|
380 |
|
if (i != variables.end()) { |
381 |
< |
if (i->second.type() == typeid(OOPSEBitSet)) { |
382 |
< |
return boost::any_cast<OOPSEBitSet>(i->second); |
381 |
> |
if (i->second.type() == typeid(OpenMDBitSet)) { |
382 |
> |
return boost::any_cast<OpenMDBitSet>(i->second); |
383 |
|
} else if (i->second.type() == typeid(std::vector<Token>)){ |
384 |
|
bs = expression(boost::any_cast<std::vector<Token> >(i->second), 2); |
385 |
|
i->second = bs; /**@todo fixme */ |
392 |
|
return bs; |
393 |
|
} |
394 |
|
|
395 |
< |
OOPSEBitSet SelectionEvaluator::nameInstruction(const std::string& name){ |
395 |
> |
OpenMDBitSet SelectionEvaluator::nameInstruction(const std::string& name){ |
396 |
|
return nameFinder.match(name); |
397 |
|
} |
398 |
|
|
413 |
|
//predefine(); |
414 |
|
} |
415 |
|
|
416 |
< |
OOPSEBitSet SelectionEvaluator::evaluate() { |
417 |
< |
OOPSEBitSet bs(nStuntDouble); |
416 |
> |
OpenMDBitSet SelectionEvaluator::evaluate() { |
417 |
> |
OpenMDBitSet bs(nStuntDouble); |
418 |
|
if (isLoaded_) { |
419 |
|
pc = 0; |
420 |
|
instructionDispatchLoop(bs); |
423 |
|
return bs; |
424 |
|
} |
425 |
|
|
426 |
< |
OOPSEBitSet SelectionEvaluator::indexInstruction(const boost::any& value) { |
427 |
< |
OOPSEBitSet bs(nStuntDouble); |
426 |
> |
OpenMDBitSet SelectionEvaluator::indexInstruction(const boost::any& value) { |
427 |
> |
OpenMDBitSet bs(nStuntDouble); |
428 |
|
|
429 |
|
if (value.type() == typeid(int)) { |
430 |
|
int index = boost::any_cast<int>(value); |
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(); |
496 |
|
} else { |
497 |
|
sprintf( painCave.errMsg, |
498 |
|
"Can not cast GenericData to DoubleGenericData\n"); |
499 |
< |
painCave.severity = OOPSE_ERROR; |
499 |
> |
painCave.severity = OPENMD_ERROR; |
500 |
|
painCave.isFatal = 1; |
501 |
|
simError(); |
502 |
|
} |