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, 234107 (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 |
|
#include "selection/NameFinder.hpp" |
43 |
|
#include "utils/wildcards.hpp" |
44 |
|
#include "utils/StringTokenizer.hpp" |
45 |
|
#include "primitives/Molecule.hpp" |
46 |
|
#include "utils/StringUtils.hpp" |
47 |
< |
namespace oopse { |
47 |
> |
namespace OpenMD { |
48 |
|
|
49 |
|
TreeNode::~TreeNode(){ |
50 |
|
std::map<std::string, TreeNode*>::iterator i; |
54 |
|
children.clear(); |
55 |
|
} |
56 |
|
|
56 |
– |
|
57 |
|
NameFinder::NameFinder(SimInfo* info) : info_(info), root_(NULL){ |
58 |
|
nStuntDouble_ = info_->getNGlobalAtoms() + info_->getNGlobalRigidBodies(); |
59 |
|
loadNames(); |
60 |
|
} |
61 |
|
|
62 |
– |
|
62 |
|
NameFinder::~NameFinder(){ |
63 |
|
delete root_; |
64 |
|
} |
65 |
|
|
66 |
|
void NameFinder::loadNames() { |
67 |
|
|
69 |
– |
std::map<std::string, TreeNode*>::iterator foundIter; |
68 |
|
SimInfo::MoleculeIterator mi; |
69 |
|
Molecule* mol; |
70 |
|
Molecule::AtomIterator ai; |
76 |
|
root_->bs.resize(nStuntDouble_); |
77 |
|
root_->bs.setAll(); // |
78 |
|
|
79 |
< |
for (mol = info_->beginMolecule(mi); mol != NULL; mol = info_->nextMolecule(mi)) { |
79 |
> |
for (mol = info_->beginMolecule(mi); mol != NULL; |
80 |
> |
mol = info_->nextMolecule(mi)) { |
81 |
|
|
82 |
|
std::string molName = mol->getMoleculeName(); |
83 |
|
TreeNode* currentMolNode = createNode(root_, molName); |
90 |
|
currentAtomNode->bs.setBitOn(atom->getGlobalIndex()); |
91 |
|
} |
92 |
|
|
93 |
< |
for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) { |
93 |
> |
for (rb = mol->beginRigidBody(rbIter); rb != NULL; |
94 |
> |
rb = mol->nextRigidBody(rbIter)) { |
95 |
|
std::string rbName = rb->getType(); |
96 |
|
TreeNode* currentRbNode = createNode(currentMolNode, rbName); |
97 |
|
|
105 |
|
|
106 |
|
currentRbAtomNode->bs.setBitOn(atom->getGlobalIndex()); |
107 |
|
} |
108 |
– |
|
108 |
|
} |
109 |
< |
|
111 |
< |
} |
112 |
< |
|
109 |
> |
} |
110 |
|
} |
111 |
|
|
112 |
|
TreeNode* NameFinder::createNode(TreeNode* parent, const std::string& name) { |
124 |
|
return node; |
125 |
|
} |
126 |
|
|
127 |
< |
BitSet NameFinder::match(const std::string& name){ |
128 |
< |
BitSet bs(nStuntDouble_); |
127 |
> |
OpenMDBitSet NameFinder::match(const std::string& name){ |
128 |
> |
OpenMDBitSet bs(nStuntDouble_); |
129 |
|
|
130 |
|
StringTokenizer tokenizer(name, "."); |
131 |
|
|
170 |
|
return bs; |
171 |
|
} |
172 |
|
|
173 |
< |
void NameFinder::matchMolecule(const std::string& molName, BitSet& bs) { |
173 |
> |
void NameFinder::matchMolecule(const std::string& molName, OpenMDBitSet& bs) { |
174 |
|
std::vector<TreeNode*> molNodes = getMatchedChildren(root_, molName); |
175 |
|
std::vector<TreeNode*>::iterator i; |
176 |
|
for( i = molNodes.begin(); i != molNodes.end(); ++i ) { |
178 |
|
} |
179 |
|
} |
180 |
|
|
181 |
< |
void NameFinder::matchStuntDouble(const std::string& molName, const std::string& sdName, BitSet& bs){ |
181 |
> |
void NameFinder::matchStuntDouble(const std::string& molName, const std::string& sdName, OpenMDBitSet& bs){ |
182 |
|
std::vector<TreeNode*> molNodes = getMatchedChildren(root_, molName); |
183 |
|
std::vector<TreeNode*>::iterator i; |
184 |
|
for( i = molNodes.begin(); i != molNodes.end(); ++i ) { |
191 |
|
|
192 |
|
} |
193 |
|
|
194 |
< |
void NameFinder::matchRigidAtoms(const std::string& molName, const std::string& rbName, const std::string& rbAtomName, BitSet& bs){ |
194 |
> |
void NameFinder::matchRigidAtoms(const std::string& molName, const std::string& rbName, const std::string& rbAtomName, OpenMDBitSet& bs){ |
195 |
|
std::vector<TreeNode*> molNodes = getMatchedChildren(root_, molName); |
196 |
|
std::vector<TreeNode*>::iterator i; |
197 |
|
for( i = molNodes.begin(); i != molNodes.end(); ++i ) { |
222 |
|
} |
223 |
|
|
224 |
|
bool NameFinder::isMatched(const std::string& str, const std::string& wildcard) { |
225 |
< |
return Wildcard::wildcardfit (wildcard.c_str(), str.c_str()); |
225 |
> |
return Wildcard::wildcardfit(wildcard.c_str(), str.c_str()) > 0 ? true : false; |
226 |
|
} |
227 |
|
|
228 |
|
|
229 |
< |
void NameFinder::matchInternalIndex(const std::string& name, int internalIndex, BitSet& bs){ |
229 |
> |
void NameFinder::matchInternalIndex(const std::string& name, int internalIndex, OpenMDBitSet& bs){ |
230 |
|
|
234 |
– |
std::map<std::string, TreeNode*>::iterator foundIter; |
231 |
|
SimInfo::MoleculeIterator mi; |
232 |
|
Molecule* mol; |
233 |
|
|
234 |
< |
for (mol = info_->beginMolecule(mi); mol != NULL; mol = info_->nextMolecule(mi)) { |
234 |
> |
for (mol = info_->beginMolecule(mi); mol != NULL; |
235 |
> |
mol = info_->nextMolecule(mi)) { |
236 |
|
|
237 |
|
if (isMatched(mol->getMoleculeName(), name) ) { |
238 |
|
int natoms = mol->getNAtoms(); |
246 |
|
bs.setBitOn(mol->getRigidBodyAt(internalIndex - natoms)->getGlobalIndex()); |
247 |
|
} |
248 |
|
} |
249 |
< |
|
253 |
< |
} |
254 |
< |
|
249 |
> |
} |
250 |
|
} |
251 |
|
|
252 |
< |
bool NameFinder::isInteger(const std::string str) { |
253 |
< |
for(int i =0; i < str.size(); ++i){ |
252 |
> |
bool NameFinder::isInteger(const std::string &str) { |
253 |
> |
for(unsigned int i = 0; i < str.size(); ++i){ |
254 |
|
if (!std::isdigit(str[i])) { |
255 |
|
return false; |
256 |
|
} |
257 |
|
} |
263 |
– |
|
258 |
|
return true; |
259 |
|
} |
266 |
– |
|
260 |
|
} |