OpenMD 3.0
Molecular Dynamics in the Open
Loading...
Searching...
No Matches
TokenMap.cpp
1/*
2 * Copyright (c) 2004-present, The University of Notre Dame. All rights
3 * reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 *
15 * 3. Neither the name of the copyright holder nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 *
31 * SUPPORT OPEN SCIENCE! If you use OpenMD or its source code in your
32 * research, please cite the appropriate papers when you publish your
33 * work. Good starting points are:
34 *
35 * [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005).
36 * [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006).
37 * [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008).
38 * [4] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011).
39 * [5] Kuang & Gezelter, Mol. Phys., 110, 691-701 (2012).
40 * [6] Lamichhane, Gezelter & Newman, J. Chem. Phys. 141, 134109 (2014).
41 * [7] Lamichhane, Newman & Gezelter, J. Chem. Phys. 141, 134110 (2014).
42 * [8] Bhattarai, Newman & Gezelter, Phys. Rev. B 99, 094106 (2019).
43 */
44
45#include "selection/TokenMap.hpp"
46
47namespace OpenMD {
48
49 TokenMap::TokenMap() {
50 tokenMap_.insert(TokenMapType::value_type(
51 "define", Token(Token::define, std::string("define"))));
52 tokenMap_.insert(TokenMapType::value_type(
53 "select", Token(Token::select, std::string("select"))));
54 // tokenMap_.insert(TokenMapType::value_type("selected",
55 // Token(Token::selected, std::string("selected"))));
56
57 // expressions
58 tokenMap_.insert(TokenMapType::value_type(
59 "(", Token(Token::leftparen, std::string("("))));
60 tokenMap_.insert(TokenMapType::value_type(
61 ")", Token(Token::rightparen, std::string(")"))));
62
63 tokenMap_.insert(TokenMapType::value_type(
64 "and", Token(Token::opAnd, std::string("and"))));
65 tokenMap_.insert(
66 TokenMapType::value_type("&", Token(Token::opAnd, std::string("and"))));
67 tokenMap_.insert(TokenMapType::value_type(
68 "&&", Token(Token::opAnd, std::string("and"))));
69
70 tokenMap_.insert(
71 TokenMapType::value_type("or", Token(Token::opOr, std::string("or"))));
72 tokenMap_.insert(
73 TokenMapType::value_type(",", Token(Token::opOr, std::string("or"))));
74 tokenMap_.insert(
75 TokenMapType::value_type("|", Token(Token::opOr, std::string("or"))));
76 tokenMap_.insert(
77 TokenMapType::value_type("||", Token(Token::opOr, std::string("or"))));
78
79 tokenMap_.insert(TokenMapType::value_type(
80 "not", Token(Token::opNot, std::string("not"))));
81 tokenMap_.insert(
82 TokenMapType::value_type("!", Token(Token::opNot, std::string("not"))));
83
84 tokenMap_.insert(
85 TokenMapType::value_type("<", Token(Token::opLT, std::string("<"))));
86 tokenMap_.insert(
87 TokenMapType::value_type("<=", Token(Token::opLE, std::string("<="))));
88 tokenMap_.insert(
89 TokenMapType::value_type(">=", Token(Token::opGE, std::string(">="))));
90 tokenMap_.insert(
91 TokenMapType::value_type(">", Token(Token::opGT, std::string(">"))));
92 tokenMap_.insert(
93 TokenMapType::value_type("==", Token(Token::opEQ, std::string("=="))));
94 tokenMap_.insert(
95 TokenMapType::value_type("!=", Token(Token::opNE, std::string("!="))));
96 tokenMap_.insert(TokenMapType::value_type(
97 "within", Token(Token::within, std::string("within"))));
98 tokenMap_.insert(
99 TokenMapType::value_type(".", Token(Token::dot, std::string("."))));
100 tokenMap_.insert(TokenMapType::value_type(
101 "mass", Token(Token::mass, std::string("mass"))));
102 tokenMap_.insert(TokenMapType::value_type(
103 "charge", Token(Token::charge, std::string("charge"))));
104 tokenMap_.insert(TokenMapType::value_type(
105 "hull", Token(Token::hull, std::string("hull"))));
106 tokenMap_.insert(TokenMapType::value_type(
107 "alphahull", Token(Token::alphahull, std::string("alphahull"))));
108 tokenMap_.insert(
109 TokenMapType::value_type("x", Token(Token::x, std::string("x"))));
110 tokenMap_.insert(
111 TokenMapType::value_type("y", Token(Token::y, std::string("y"))));
112 tokenMap_.insert(
113 TokenMapType::value_type("z", Token(Token::z, std::string("z"))));
114 tokenMap_.insert(TokenMapType::value_type(
115 "wrappedx", Token(Token::wrappedX, std::string("wrappedx"))));
116 tokenMap_.insert(TokenMapType::value_type(
117 "wrappedy", Token(Token::wrappedY, std::string("wrappedy"))));
118 tokenMap_.insert(TokenMapType::value_type(
119 "wrappedz", Token(Token::wrappedZ, std::string("wrappedz"))));
120 tokenMap_.insert(TokenMapType::value_type(
121 "atomno", Token(Token::atomno, std::string("atomno"))));
122 tokenMap_.insert(
123 TokenMapType::value_type("r", Token(Token::r, std::string("r"))));
124 tokenMap_.insert(
125 TokenMapType::value_type("to", Token(Token::to, std::string("to"))));
126
127 tokenMap_.insert(
128 TokenMapType::value_type("all", Token(Token::all, std::string("all"))));
129 tokenMap_.insert(TokenMapType::value_type(
130 "none", Token(Token::none, std::string("none"))));
131 }
132
133 Token* TokenMap::getToken(const std::string& ident) {
134 std::map<std::string, Token>::iterator i = tokenMap_.find(ident);
135
136 return i != tokenMap_.end() ? &(i->second) : NULL;
137 }
138} // namespace OpenMD
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.