Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/MapOfActions.cpp

    r112b09 r980dd6  
    66 */
    77
    8 #include "Helpers/MemDebug.hpp"
    9 
    108using namespace std;
    119
     
    1412#include "Helpers/Assert.hpp"
    1513
     14#include <boost/lexical_cast.hpp>
     15#include <boost/optional.hpp>
     16#include <boost/program_options.hpp>
     17
    1618#include "CommandLineParser.hpp"
    1719#include "log.hpp"
    1820#include "verbose.hpp"
     21
     22#include "Actions/Values.hpp"
     23
     24void 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
     37void 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}
    1952
    2053/** Constructor of class MapOfActions.
     
    5184  DescriptionMap["nonconvex-envelope"] = "create the non-convex envelope for a molecule";
    5285  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";
    5687  DescriptionMap["parse-xyz"] = "parse xyz file into World";
    5788  DescriptionMap["principal-axis-system"] = "calculate the principal axis system of the specified molecule";
     
    6596  DescriptionMap["save-temperature"] = "name of the temperature file to write to";
    6697  DescriptionMap["scale-box"] = "scale box and atomic positions inside";
    67   DescriptionMap["subspace-dissect"] = "dissect the molecular system into molecules representing disconnected subgraphs";
     98  DescriptionMap["subgraph-dissect"] = "dissect the molecular system into molecules representing disconnected subgraphs";
    6899  DescriptionMap["suspend-in-water"] = "suspend the given molecule in water such that in the domain the mean density is as specified";
    69100  DescriptionMap["translate-mol"] = "translate molecule by given vector";
     
    72103  DescriptionMap["version"] = "show version";
    73104  // keys for values
     105  DescriptionMap["atom-by-id"] = "index of an atom";
    74106  DescriptionMap["bin-output-file"] = "name of the bin output file";
    75107  DescriptionMap["bin-end"] = "start of the last bin";
    76108  DescriptionMap["bin-start"] = "start of the first bin";
    77109  DescriptionMap["bin-width"] = "width of the bins";
     110  DescriptionMap["convex-file"] = "filename of the non-convex envelope";
    78111  DescriptionMap["distance"] = "distance in space";
    79112  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";
    82118  DescriptionMap["input"] = "name of input file";
    83119  DescriptionMap["length"] = "length in space";
     
    85121  DescriptionMap["MaxDistance"] = "maximum distance in space";
    86122  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, ...";
    87126  DescriptionMap["output-file"] = "name of the output file";
    88127  DescriptionMap["periodic"] = "system is constraint to periodic boundary conditions (y/n)";
    89128  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";
    91131
    92132  // short forms for the actions
     
    110150  ShortFormMap["linear-interpolate"] = "L";
    111151  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";
    115153  ShortFormMap["parse-xyz"] = "p";
    116154  ShortFormMap["remove-atom"] = "r";
     
    123161  ShortFormMap["scale-box"] = "s";
    124162  ShortFormMap["set-basis"] = "M";
    125   ShortFormMap["subspace-dissect"] = "I";
    126   ShortFormMap["suspend-in-water"] = "U";
     163  ShortFormMap["subgraph-dissect"] = "I";
     164  ShortFormMap["suspend-in-water"] = "u";
    127165  ShortFormMap["translate-mol"] = "t";
    128166  ShortFormMap["verbose"] = "v";
     
    131169
    132170  // value types for the actions
    133   TypeMap["add-atom"] = Atom;
     171  TypeMap["add-atom"] = Element;
    134172  TypeMap["bond-file"] = String;
    135173  TypeMap["bond-table"] = String;
    136174  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;
    140178  TypeMap["change-molname"] = String;
    141179  TypeMap["convex-envelope"] = Molecule;
     
    143181  TypeMap["depth-first-search"] = Double;
    144182  TypeMap["element-db"] = String;
    145   TypeMap["end-mol"] = Molecule;
    146183  TypeMap["fastparsing"] = Boolean;
    147184  TypeMap["fill-molecule"] = String;
     
    152189  TypeMap["nonconvex-envelope"] = Molecule;
    153190  TypeMap["parse-xyz"] = String;
    154   TypeMap["principal-axis-system"] = Axis;
     191  TypeMap["pair-correlation"] = String;
     192  TypeMap["principal-axis-system"] = Molecule;
    155193  TypeMap["remove-atom"] = Atom;
    156   TypeMap["remove-sphere"] = Atom;
     194  TypeMap["remove-sphere"] = Double;
    157195  TypeMap["repeat-box"] = Vector;
    158196  TypeMap["rotate-to-pas"] = Molecule;
     
    162200  TypeMap["scale-box"] = Vector;
    163201  TypeMap["set-basis"] = String;
    164   TypeMap["start-mol"] = Molecule;
    165   TypeMap["suspend-in-water"] = Molecule;
     202  TypeMap["subgraph-dissect"] = None;
     203  TypeMap["suspend-in-water"] = Double;
    166204  TypeMap["translate-mol"] = Vector;
    167205  TypeMap["verlet-integrate"] = String;
     
    169207
    170208  // value types for the values
     209  TypeMap["atom-by-id"] = Atom;
    171210  TypeMap["bin-output-file"] = String;
    172211  TypeMap["bin-end"] = Double;
    173212  TypeMap["bin-start"] = Double;
     213  TypeMap["bin-width"] = Double;
     214  TypeMap["convex-file"] = String;
    174215  TypeMap["distance"] = Double;
    175   TypeMap["distances"] = ListOfDoubles;
    176   TypeMap["elements"] = Element;
     216  TypeMap["distances"] = Vector;
     217  TypeMap["DoRotate"] = Boolean;
     218  TypeMap["element"] = Element;
    177219  TypeMap["elements"] = ListOfElements;
     220  TypeMap["end-step"] = Integer;
     221  TypeMap["id-mapping"] = Boolean;
    178222  TypeMap["length"] = Double;
    179   TypeMap["lengths"] = ListOfDoubles;
     223  TypeMap["lengths"] = Vector;
    180224  TypeMap["MaxDistance"] = Double;
    181225  TypeMap["molecule-by-id"] = Molecule;
     226  TypeMap["molecule-by-name"] = Molecule;
     227  TypeMap["nonconvex-file"] = String;
     228  TypeMap["order"] = Integer;
    182229  TypeMap["output-file"] = String;
    183230  TypeMap["periodic"] = Boolean;
    184231  TypeMap["position"] = Vector;
     232  TypeMap["sphere-radius"] = Double;
     233  TypeMap["start-step"] = Integer;
    185234
    186235  // 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";
    187239  DefaultValue["molecule-by-id"] = "-1";
     240  DefaultValue["periodic"] = "0";
    188241
    189242
    190243  // 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");
    194247  generic.insert("boundary");
    195248//  generic.insert("bound-in-box");
     
    198251        generic.insert("change-box");
    199252//  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");
    208261  generic.insert("help");
    209 //      generic.insert("linear-interpolate");
     262        generic.insert("linear-interpolate");
    210263//  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");
    215266//      generic.insert("parse-xyz");
    216267//  generic.insert("principal-axis-system");
    217 //  generic.insert("remove-atom");
    218 //  generic.insert("remove-sphere");
    219     generic.insert("repeat-box");
    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");
    224275  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");
    229280        generic.insert("verbose");
    230 //  generic.insert("verlet-integrate");
     281  generic.insert("verlet-integrate");
    231282        generic.insert("version");
    232 //      // list of generic values
    233 //      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");
    249283
    250284    // 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");
    252313}
    253314
     
    286347              ;
    287348            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;
    288356          case Integer:
    289357            ListRunner->second->add_options()
     
    339407            ListRunner->second->add_options()
    340408              (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(),
    349410                  getDescription(*OptionRunner).c_str())
    350411              ;
     
    385446            ListRunner->second->add_options()
    386447              (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> >(),
    390449                  getDescription(*OptionRunner).c_str())
    391450              ;
     
    497556}
    498557
     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 */
     561map <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}
    499570
    500571
Note: See TracChangeset for help on using the changeset viewer.