--- trunk/src/selection/SelectionEvaluator.cpp 2009/11/25 20:02:06 1390 +++ trunk/src/selection/SelectionEvaluator.cpp 2012/10/01 18:21:15 1801 @@ -36,7 +36,8 @@ * [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005). * [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006). * [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008). - * [4] Vardeman & Gezelter, in progress (2009). + * [4] Kuang & Gezelter, J. Chem. Phys. 133, 164101 (2010). + * [5] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011). */ #include @@ -45,13 +46,14 @@ #include "primitives/DirectionalAtom.hpp" #include "primitives/RigidBody.hpp" #include "primitives/Molecule.hpp" -#include "io/basic_ifstrstream.hpp" +#include "io/ifstrstream.hpp" namespace OpenMD { SelectionEvaluator::SelectionEvaluator(SimInfo* si) - : info(si), nameFinder(info), distanceFinder(info), indexFinder(info), + : info(si), nameFinder(info), distanceFinder(info), hullFinder(info), + indexFinder(info), isLoaded_(false){ nStuntDouble = info->getNGlobalAtoms() + info->getNGlobalRigidBodies(); } @@ -148,7 +150,7 @@ namespace OpenMD { OpenMDBitSet bs; std::stack stack; - for (int pc = pcStart; pc < code.size(); ++pc) { + for (unsigned int pc = pcStart; pc < code.size(); ++pc) { Token instruction = code[pc]; switch (instruction.tok) { @@ -157,8 +159,7 @@ namespace OpenMD { case Token::expressionEnd: break; case Token::all: - bs = OpenMDBitSet(nStuntDouble); - bs.setAll(); + bs = allInstruction(); stack.push(bs); break; case Token::none: @@ -181,6 +182,9 @@ namespace OpenMD { case Token::within: withinInstruction(instruction, stack.top()); break; + case Token::hull: + stack.push(hull()); + break; //case Token::selected: // stack.push(getSelectionSet()); // break; @@ -217,7 +221,6 @@ namespace OpenMD { int comparator = instruction.tok; int property = instruction.intValue; float comparisonValue = boost::any_cast(instruction.value); - float propertyValue; OpenMDBitSet bs(nStuntDouble); bs.clearAll(); @@ -274,6 +277,9 @@ namespace OpenMD { case Token::z: propertyValue = sd->getPos().z(); break; + case Token::r: + propertyValue = sd->getPos().length(); + break; default: unrecognizedAtomProperty(property); } @@ -440,7 +446,42 @@ namespace OpenMD { return bs; } + OpenMDBitSet SelectionEvaluator::allInstruction() { + OpenMDBitSet bs(nStuntDouble); + SimInfo::MoleculeIterator mi; + Molecule* mol; + Molecule::AtomIterator ai; + Atom* atom; + Molecule::RigidBodyIterator rbIter; + RigidBody* rb; + + // Doing the loop insures that we're actually on this processor. + + for (mol = info->beginMolecule(mi); mol != NULL; + mol = info->nextMolecule(mi)) { + + for(atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) { + bs.setBitOn(atom->getGlobalIndex()); + } + + for (rb = mol->beginRigidBody(rbIter); rb != NULL; + rb = mol->nextRigidBody(rbIter)) { + bs.setBitOn(rb->getGlobalIndex()); + } + } + + return bs; + } + + OpenMDBitSet SelectionEvaluator::hull() { + OpenMDBitSet bs(nStuntDouble); + + bs = hullFinder.findHull(); + + return bs; + } + RealType SelectionEvaluator::getCharge(Atom* atom) { RealType charge =0.0; AtomType* atomType = atom->getAtomType();