Changes in src/Actions/MapOfActions.cpp [112b09:980dd6]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/MapOfActions.cpp
r112b09 r980dd6 6 6 */ 7 7 8 #include "Helpers/MemDebug.hpp"9 10 8 using namespace std; 11 9 … … 14 12 #include "Helpers/Assert.hpp" 15 13 14 #include <boost/lexical_cast.hpp> 15 #include <boost/optional.hpp> 16 #include <boost/program_options.hpp> 17 16 18 #include "CommandLineParser.hpp" 17 19 #include "log.hpp" 18 20 #include "verbose.hpp" 21 22 #include "Actions/Values.hpp" 23 24 void validate(boost::any& v, const std::vector<std::string>& values, VectorValue *, int) 25 { 26 VectorValue VV; 27 if (values.size() != 3) { 28 cerr << "Specified vector does not have three components but " << values.size() << endl; 29 throw boost::program_options::validation_error("Specified vector does not have three components"); 30 } 31 VV.x = boost::lexical_cast<double>(values.at(0)); 32 VV.y = boost::lexical_cast<double>(values.at(1)); 33 VV.z = boost::lexical_cast<double>(values.at(2)); 34 v = boost::any(VectorValue(VV)); 35 } 36 37 void validate(boost::any& v, const std::vector<std::string>& values, BoxValue *, int) 38 { 39 BoxValue BV; 40 if (values.size() != 6) { 41 cerr << "Specified vector does not have three components but " << values.size() << endl; 42 throw boost::program_options::validation_error("Specified symmetric box matrix does not have six components"); 43 } 44 BV.xx = boost::lexical_cast<double>(values.at(0)); 45 BV.xy = boost::lexical_cast<double>(values.at(1)); 46 BV.xz = boost::lexical_cast<double>(values.at(2)); 47 BV.yy = boost::lexical_cast<double>(values.at(3)); 48 BV.yz = boost::lexical_cast<double>(values.at(4)); 49 BV.zz = boost::lexical_cast<double>(values.at(5)); 50 v = boost::any(BoxValue(BV)); 51 } 19 52 20 53 /** Constructor of class MapOfActions. … … 51 84 DescriptionMap["nonconvex-envelope"] = "create the non-convex envelope for a molecule"; 52 85 DescriptionMap["molecular-volume"] = "calculate the volume of a given molecule"; 53 DescriptionMap["pair-correlation"] = "pair correlation analysis between two elements"; 54 DescriptionMap["pair-correlation-point"] = "pair correlation analysis between atoms of a element to a given point"; 55 DescriptionMap["pair-correlation-surface"] = "pair correlation analysis between atoms of a given element and a surface"; 86 DescriptionMap["pair-correlation"] = "pair correlation analysis between two elements, element and point or element and surface"; 56 87 DescriptionMap["parse-xyz"] = "parse xyz file into World"; 57 88 DescriptionMap["principal-axis-system"] = "calculate the principal axis system of the specified molecule"; … … 65 96 DescriptionMap["save-temperature"] = "name of the temperature file to write to"; 66 97 DescriptionMap["scale-box"] = "scale box and atomic positions inside"; 67 DescriptionMap["sub space-dissect"] = "dissect the molecular system into molecules representing disconnected subgraphs";98 DescriptionMap["subgraph-dissect"] = "dissect the molecular system into molecules representing disconnected subgraphs"; 68 99 DescriptionMap["suspend-in-water"] = "suspend the given molecule in water such that in the domain the mean density is as specified"; 69 100 DescriptionMap["translate-mol"] = "translate molecule by given vector"; … … 72 103 DescriptionMap["version"] = "show version"; 73 104 // keys for values 105 DescriptionMap["atom-by-id"] = "index of an atom"; 74 106 DescriptionMap["bin-output-file"] = "name of the bin output file"; 75 107 DescriptionMap["bin-end"] = "start of the last bin"; 76 108 DescriptionMap["bin-start"] = "start of the first bin"; 77 109 DescriptionMap["bin-width"] = "width of the bins"; 110 DescriptionMap["convex-file"] = "filename of the non-convex envelope"; 78 111 DescriptionMap["distance"] = "distance in space"; 79 112 DescriptionMap["distances"] = "list of three of distances in space, one for each axis direction"; 80 DescriptionMap["element"] = "set of elements"; 81 DescriptionMap["end-mol"] = "last or end step"; 113 DescriptionMap["DoRotate"] = "whether to rotate or just report angles"; 114 DescriptionMap["element"] = "single element"; 115 DescriptionMap["elements"] = "set of elements"; 116 DescriptionMap["end-step"] = "last or end step"; 117 DescriptionMap["id-mapping"] = "whether the identity shall be used in mapping atoms onto atoms or some closest distance measure shall be used"; 82 118 DescriptionMap["input"] = "name of input file"; 83 119 DescriptionMap["length"] = "length in space"; … … 85 121 DescriptionMap["MaxDistance"] = "maximum distance in space"; 86 122 DescriptionMap["molecule-by-id"] = "index of a molecule"; 123 DescriptionMap["molecule-by-name"] = "name of a molecule"; 124 DescriptionMap["nonconvex-file"] = "filename of the non-convex envelope"; 125 DescriptionMap["order"] = "order of a discretization, dissection, ..."; 87 126 DescriptionMap["output-file"] = "name of the output file"; 88 127 DescriptionMap["periodic"] = "system is constraint to periodic boundary conditions (y/n)"; 89 128 DescriptionMap["position"] = "position in R^3 space"; 90 DescriptionMap["start-mol"] = "first or start step"; 129 DescriptionMap["sphere-radius"] = "radius of tesselation sphere"; 130 DescriptionMap["start-step"] = "first or start step"; 91 131 92 132 // short forms for the actions … … 110 150 ShortFormMap["linear-interpolate"] = "L"; 111 151 ShortFormMap["nonconvex-envelope"] = "N"; 112 ShortFormMap["pair-correlation"] = "CE"; 113 ShortFormMap["pair-correlation-point"] = "CP"; 114 ShortFormMap["pair-correlation-surface"] = "CS"; 152 ShortFormMap["pair-correlation"] = "C"; 115 153 ShortFormMap["parse-xyz"] = "p"; 116 154 ShortFormMap["remove-atom"] = "r"; … … 123 161 ShortFormMap["scale-box"] = "s"; 124 162 ShortFormMap["set-basis"] = "M"; 125 ShortFormMap["sub space-dissect"] = "I";126 ShortFormMap["suspend-in-water"] = " U";163 ShortFormMap["subgraph-dissect"] = "I"; 164 ShortFormMap["suspend-in-water"] = "u"; 127 165 ShortFormMap["translate-mol"] = "t"; 128 166 ShortFormMap["verbose"] = "v"; … … 131 169 132 170 // value types for the actions 133 TypeMap["add-atom"] = Atom;171 TypeMap["add-atom"] = Element; 134 172 TypeMap["bond-file"] = String; 135 173 TypeMap["bond-table"] = String; 136 174 TypeMap["boundary"] = Vector; 137 TypeMap["center-in-box"] = ListOfDoubles;138 TypeMap["change-box"] = ListOfDoubles;139 TypeMap["change-element"] = Element;175 TypeMap["center-in-box"] = Box; 176 TypeMap["change-box"] = Box; 177 TypeMap["change-element"] = Atom; 140 178 TypeMap["change-molname"] = String; 141 179 TypeMap["convex-envelope"] = Molecule; … … 143 181 TypeMap["depth-first-search"] = Double; 144 182 TypeMap["element-db"] = String; 145 TypeMap["end-mol"] = Molecule;146 183 TypeMap["fastparsing"] = Boolean; 147 184 TypeMap["fill-molecule"] = String; … … 152 189 TypeMap["nonconvex-envelope"] = Molecule; 153 190 TypeMap["parse-xyz"] = String; 154 TypeMap["principal-axis-system"] = Axis; 191 TypeMap["pair-correlation"] = String; 192 TypeMap["principal-axis-system"] = Molecule; 155 193 TypeMap["remove-atom"] = Atom; 156 TypeMap["remove-sphere"] = Atom;194 TypeMap["remove-sphere"] = Double; 157 195 TypeMap["repeat-box"] = Vector; 158 196 TypeMap["rotate-to-pas"] = Molecule; … … 162 200 TypeMap["scale-box"] = Vector; 163 201 TypeMap["set-basis"] = String; 164 TypeMap["s tart-mol"] = Molecule;165 TypeMap["suspend-in-water"] = Molecule;202 TypeMap["subgraph-dissect"] = None; 203 TypeMap["suspend-in-water"] = Double; 166 204 TypeMap["translate-mol"] = Vector; 167 205 TypeMap["verlet-integrate"] = String; … … 169 207 170 208 // value types for the values 209 TypeMap["atom-by-id"] = Atom; 171 210 TypeMap["bin-output-file"] = String; 172 211 TypeMap["bin-end"] = Double; 173 212 TypeMap["bin-start"] = Double; 213 TypeMap["bin-width"] = Double; 214 TypeMap["convex-file"] = String; 174 215 TypeMap["distance"] = Double; 175 TypeMap["distances"] = ListOfDoubles; 176 TypeMap["elements"] = Element; 216 TypeMap["distances"] = Vector; 217 TypeMap["DoRotate"] = Boolean; 218 TypeMap["element"] = Element; 177 219 TypeMap["elements"] = ListOfElements; 220 TypeMap["end-step"] = Integer; 221 TypeMap["id-mapping"] = Boolean; 178 222 TypeMap["length"] = Double; 179 TypeMap["lengths"] = ListOfDoubles;223 TypeMap["lengths"] = Vector; 180 224 TypeMap["MaxDistance"] = Double; 181 225 TypeMap["molecule-by-id"] = Molecule; 226 TypeMap["molecule-by-name"] = Molecule; 227 TypeMap["nonconvex-file"] = String; 228 TypeMap["order"] = Integer; 182 229 TypeMap["output-file"] = String; 183 230 TypeMap["periodic"] = Boolean; 184 231 TypeMap["position"] = Vector; 232 TypeMap["sphere-radius"] = Double; 233 TypeMap["start-step"] = Integer; 185 234 186 235 // default values for any action that needs one (always string!) 236 DefaultValue["bin-width"] = "0.5"; 237 DefaultValue["fastparsing"] = "0"; 238 DefaultValue["atom-by-id"] = "-1"; 187 239 DefaultValue["molecule-by-id"] = "-1"; 240 DefaultValue["periodic"] = "0"; 188 241 189 242 190 243 // list of generic actions 191 //generic.insert("add-atom");192 //generic.insert("bond-file");193 //generic.insert("bond-table");244 generic.insert("add-atom"); 245 generic.insert("bond-file"); 246 generic.insert("bond-table"); 194 247 generic.insert("boundary"); 195 248 // generic.insert("bound-in-box"); … … 198 251 generic.insert("change-box"); 199 252 // generic.insert("change-molname"); 200 //generic.insert("change-element");201 //generic.insert("convex-envelope");202 //generic.insert("default-molname");203 //generic.insert("depth-first-search");204 //generic.insert("element-db");205 //generic.insert("fastparsing");206 //generic.insert("fill-molecule");207 //generic.insert("fragment-mol");253 generic.insert("change-element"); 254 generic.insert("convex-envelope"); 255 generic.insert("default-molname"); 256 generic.insert("depth-first-search"); 257 generic.insert("element-db"); 258 generic.insert("fastparsing"); 259 generic.insert("fill-molecule"); 260 generic.insert("fragment-mol"); 208 261 generic.insert("help"); 209 //generic.insert("linear-interpolate");262 generic.insert("linear-interpolate"); 210 263 // generic.insert("molecular-volume"); 211 // generic.insert("nonconvex-envelope"); 212 // generic.insert("pair-correlation"); 213 // generic.insert("pair-correlation-point"); 214 // generic.insert("pair-correlation-surface"); 264 generic.insert("nonconvex-envelope"); 265 generic.insert("pair-correlation"); 215 266 // generic.insert("parse-xyz"); 216 267 // generic.insert("principal-axis-system"); 217 //generic.insert("remove-atom");218 //generic.insert("remove-sphere");219 220 //generic.insert("rotate-to-pas");221 //generic.insert("save-adjacency");222 //generic.insert("save-bonds");223 //generic.insert("save-temperature");268 generic.insert("remove-atom"); 269 generic.insert("remove-sphere"); 270 generic.insert("repeat-box"); 271 generic.insert("rotate-to-pas"); 272 generic.insert("save-adjacency"); 273 generic.insert("save-bonds"); 274 generic.insert("save-temperature"); 224 275 generic.insert("scale-box"); 225 //generic.insert("set-basis");226 // generic.insert("subspace-dissect");227 //generic.insert("suspend-in-water");228 //generic.insert("translate-mol");276 generic.insert("set-basis"); 277 generic.insert("subgraph-dissect"); 278 generic.insert("suspend-in-water"); 279 generic.insert("translate-mol"); 229 280 generic.insert("verbose"); 230 //generic.insert("verlet-integrate");281 generic.insert("verlet-integrate"); 231 282 generic.insert("version"); 232 // // list of generic values233 // generic.insert("bin-output-file");234 // generic.insert("bin-end");235 // generic.insert("bin-start");236 // generic.insert("distance");237 // generic.insert("distances");238 // generic.insert("element");239 // generic.insert("end-mol");240 generic.insert("input");241 // generic.insert("length");242 // generic.insert("lengths");243 // generic.insert("MaxDistance");244 // generic.insert("molecule-by-id");245 // generic.insert("output-file");246 // generic.insert("periodic");247 // generic.insert("position");248 // generic.insert("start-mol");249 283 250 284 // positional arguments 251 inputfile.insert("input"); 285 generic.insert("input"); 286 inputfile.insert("input"); 287 288 // hidden arguments 289 generic.insert("atom-by-id"); 290 generic.insert("bin-end"); 291 generic.insert("bin-output-file"); 292 generic.insert("bin-start"); 293 generic.insert("bin-width"); 294 generic.insert("convex-file"); 295 generic.insert("distance"); 296 generic.insert("DoRotate"); 297 generic.insert("distances"); 298 generic.insert("element"); 299 generic.insert("elements"); 300 generic.insert("end-step"); 301 generic.insert("id-mapping"); 302 generic.insert("lengths"); 303 generic.insert("MaxDistance"); 304 generic.insert("molecule-by-id"); 305 generic.insert("molecule-by-name"); 306 generic.insert("nonconvex-file"); 307 generic.insert("order"); 308 generic.insert("output-file"); 309 generic.insert("periodic"); 310 generic.insert("position"); 311 generic.insert("sphere-radius"); 312 generic.insert("start-step"); 252 313 } 253 314 … … 286 347 ; 287 348 break; 349 case Box: 350 ListRunner->second->add_options() 351 (getKeyAndShortForm(*OptionRunner).c_str(), 352 po::value<BoxValue>()->multitoken(), 353 getDescription(*OptionRunner).c_str()) 354 ; 355 break; 288 356 case Integer: 289 357 ListRunner->second->add_options() … … 339 407 ListRunner->second->add_options() 340 408 (getKeyAndShortForm(*OptionRunner).c_str(), 341 po::value< vector<double> >()->multitoken(), 342 getDescription(*OptionRunner).c_str()) 343 ; 344 break; 345 case Box: 346 ListRunner->second->add_options() 347 (getKeyAndShortForm(*OptionRunner).c_str(), 348 po::value< vector<double> >(), 409 po::value<VectorValue>()->multitoken(), 349 410 getDescription(*OptionRunner).c_str()) 350 411 ; … … 385 446 ListRunner->second->add_options() 386 447 (getKeyAndShortForm(*OptionRunner).c_str(), 387 DefaultValue.find(*OptionRunner) != DefaultValue.end() ? 388 po::value< int >()->default_value(atoi(DefaultValue[*OptionRunner].c_str())) : 389 po::value< int >(), 448 po::value< vector<int> >(), 390 449 getDescription(*OptionRunner).c_str()) 391 450 ; … … 497 556 } 498 557 558 /** Returns the inverse to MapOfActions::ShortFormMap, i.e. lookup actionname for its short form. 559 * \return map from short form of action to name of action 560 */ 561 map <std::string, std::string> MapOfActions::getShortFormToActionMap() 562 { 563 map <std::string, std::string> result; 564 565 for (map<std::string, std::string>::iterator iter = ShortFormMap.begin(); iter != ShortFormMap.end(); ++iter) 566 result[iter->second] = iter->first; 567 568 return result; 569 } 499 570 500 571
Note:
See TracChangeset
for help on using the changeset viewer.