| 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); | 
| 162 | > | bs = OpenMDBitSet(nStuntDouble); | 
| 163 |  | bs.setAll(); | 
| 164 |  | stack.push(bs); | 
| 165 |  | break; | 
| 166 |  | case Token::none: | 
| 167 | < | bs = OOPSEBitSet(nStuntDouble); | 
| 167 | > | bs = OpenMDBitSet(nStuntDouble); | 
| 168 |  | stack.push(bs); | 
| 169 |  | break; | 
| 170 |  | case Token::opOr: | 
| 183 |  | case Token::within: | 
| 184 |  | withinInstruction(instruction, stack.top()); | 
| 185 |  | break; | 
| 186 | + | case Token::hull: | 
| 187 | + | stack.push(hull()); | 
| 188 | + | break; | 
| 189 |  | //case Token::selected: | 
| 190 |  | //  stack.push(getSelectionSet()); | 
| 191 |  | //  break; | 
| 218 |  |  | 
| 219 |  |  | 
| 220 |  |  | 
| 221 | < | OOPSEBitSet SelectionEvaluator::comparatorInstruction(const Token& instruction) { | 
| 221 | > | OpenMDBitSet SelectionEvaluator::comparatorInstruction(const Token& instruction) { | 
| 222 |  | int comparator = instruction.tok; | 
| 223 |  | int property = instruction.intValue; | 
| 224 |  | float comparisonValue = boost::any_cast<float>(instruction.value); | 
| 225 | < | float propertyValue; | 
| 221 | < | OOPSEBitSet bs(nStuntDouble); | 
| 225 | > | OpenMDBitSet bs(nStuntDouble); | 
| 226 |  | bs.clearAll(); | 
| 227 |  |  | 
| 228 |  | SimInfo::MoleculeIterator mi; | 
| 248 |  | return bs; | 
| 249 |  | } | 
| 250 |  |  | 
| 251 | < | void SelectionEvaluator::compareProperty(StuntDouble* sd, OOPSEBitSet& bs, | 
| 251 | > | void SelectionEvaluator::compareProperty(StuntDouble* sd, OpenMDBitSet& bs, | 
| 252 |  | int property, int comparator, | 
| 253 |  | float comparisonValue) { | 
| 254 |  | RealType propertyValue = 0.0; | 
| 278 |  | case Token::z: | 
| 279 |  | propertyValue = sd->getPos().z(); | 
| 280 |  | break; | 
| 281 | + | case Token::r: | 
| 282 | + | propertyValue = sd->getPos().length(); | 
| 283 | + | break; | 
| 284 |  | default: | 
| 285 |  | unrecognizedAtomProperty(property); | 
| 286 |  | } | 
| 312 |  | } | 
| 313 |  |  | 
| 314 |  | void SelectionEvaluator::withinInstruction(const Token& instruction, | 
| 315 | < | OOPSEBitSet& bs){ | 
| 315 | > | OpenMDBitSet& bs){ | 
| 316 |  |  | 
| 317 |  | boost::any withinSpec = instruction.value; | 
| 318 |  | float distance; | 
| 369 |  | } | 
| 370 |  | } | 
| 371 |  |  | 
| 372 | < | void SelectionEvaluator::select(OOPSEBitSet& bs){ | 
| 372 | > | void SelectionEvaluator::select(OpenMDBitSet& bs){ | 
| 373 |  | bs = expression(statement, 1); | 
| 374 |  | } | 
| 375 |  |  | 
| 376 | < | OOPSEBitSet SelectionEvaluator::lookupValue(const std::string& variable){ | 
| 376 | > | OpenMDBitSet SelectionEvaluator::lookupValue(const std::string& variable){ | 
| 377 |  |  | 
| 378 | < | OOPSEBitSet bs(nStuntDouble); | 
| 378 | > | OpenMDBitSet bs(nStuntDouble); | 
| 379 |  | std::map<std::string, boost::any>::iterator i = variables.find(variable); | 
| 380 |  |  | 
| 381 |  | if (i != variables.end()) { | 
| 382 | < | if (i->second.type() == typeid(OOPSEBitSet)) { | 
| 383 | < | return boost::any_cast<OOPSEBitSet>(i->second); | 
| 382 | > | if (i->second.type() == typeid(OpenMDBitSet)) { | 
| 383 | > | return boost::any_cast<OpenMDBitSet>(i->second); | 
| 384 |  | } else if (i->second.type() ==  typeid(std::vector<Token>)){ | 
| 385 |  | bs = expression(boost::any_cast<std::vector<Token> >(i->second), 2); | 
| 386 |  | i->second =  bs; /**@todo fixme */ | 
| 393 |  | return bs; | 
| 394 |  | } | 
| 395 |  |  | 
| 396 | < | OOPSEBitSet SelectionEvaluator::nameInstruction(const std::string& name){ | 
| 396 | > | OpenMDBitSet SelectionEvaluator::nameInstruction(const std::string& name){ | 
| 397 |  | return nameFinder.match(name); | 
| 398 |  | } | 
| 399 |  |  | 
| 414 |  | //predefine(); | 
| 415 |  | } | 
| 416 |  |  | 
| 417 | < | OOPSEBitSet SelectionEvaluator::evaluate() { | 
| 418 | < | OOPSEBitSet bs(nStuntDouble); | 
| 417 | > | OpenMDBitSet SelectionEvaluator::evaluate() { | 
| 418 | > | OpenMDBitSet bs(nStuntDouble); | 
| 419 |  | if (isLoaded_) { | 
| 420 |  | pc = 0; | 
| 421 |  | instructionDispatchLoop(bs); | 
| 424 |  | return bs; | 
| 425 |  | } | 
| 426 |  |  | 
| 427 | < | OOPSEBitSet SelectionEvaluator::indexInstruction(const boost::any& value) { | 
| 428 | < | OOPSEBitSet bs(nStuntDouble); | 
| 427 | > | OpenMDBitSet SelectionEvaluator::indexInstruction(const boost::any& value) { | 
| 428 | > | OpenMDBitSet bs(nStuntDouble); | 
| 429 |  |  | 
| 430 |  | if (value.type() == typeid(int)) { | 
| 431 |  | int index = boost::any_cast<int>(value); | 
| 448 |  | } | 
| 449 |  |  | 
| 450 |  |  | 
| 451 | + | OpenMDBitSet SelectionEvaluator::hull() { | 
| 452 | + | OpenMDBitSet bs(nStuntDouble); | 
| 453 | + |  | 
| 454 | + | bs = hullFinder.findHull(); | 
| 455 | + |  | 
| 456 | + | return bs; | 
| 457 | + | } | 
| 458 | + |  | 
| 459 | + |  | 
| 460 | + |  | 
| 461 |  | RealType SelectionEvaluator::getCharge(Atom* atom) { | 
| 462 |  | RealType charge =0.0; | 
| 463 |  | AtomType* atomType = atom->getAtomType(); | 
| 472 |  | } else { | 
| 473 |  | sprintf( painCave.errMsg, | 
| 474 |  | "Can not cast GenericData to DoubleGenericData\n"); | 
| 475 | < | painCave.severity = OOPSE_ERROR; | 
| 475 | > | painCave.severity = OPENMD_ERROR; | 
| 476 |  | painCave.isFatal = 1; | 
| 477 |  | simError(); | 
| 478 |  | } |