Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/MapOfActions.cpp

    r986ed3 rb540f3  
    1717#include <boost/optional.hpp>
    1818#include <boost/program_options.hpp>
    19 
    20 #include <iostream>
    2119
    2220#include "CommandLineParser.hpp"
     
    6765#include "Actions/WorldAction/SetDefaultNameAction.hpp"
    6866#include "Actions/WorldAction/SetGaussianBasisAction.hpp"
     67#include "Actions/WorldAction/SetOutputFormatsAction.hpp"
    6968#include "Actions/Values.hpp"
    7069
     
    7271{
    7372  VectorValue VV;
    74   if (values.size() != 3) {
    75     cerr <<  "Specified vector does not have three components but " << values.size() << endl;
     73  std::vector<std::string> components;
     74
     75  // split comma-separated values
     76  if (values.size() != 1) {
     77    cerr <<  "Not one vector but " << components.size() << " given " << endl;
     78    throw boost::program_options::validation_error("Unequal to one vector given");
     79  }
     80  std::string argument(values.at(0));
     81  std::string::iterator Aiter = argument.begin();
     82  std::string::iterator Biter = argument.begin();
     83  for (; Aiter != argument.end(); ++Aiter) {
     84    if (*Aiter == ',') {
     85      components.push_back(string(Biter,Aiter));
     86      do {
     87        Aiter++;
     88      } while (*Aiter == ' ' || *Aiter == '\t');
     89      Biter = Aiter;
     90    }
     91  }
     92  components.push_back(string(Biter,argument.end()));
     93
     94  if (components.size() != 3) {
     95    cerr <<  "Specified vector does not have three components but " << components.size() << endl;
    7696    throw boost::program_options::validation_error("Specified vector does not have three components");
    7797  }
    78   VV.x = boost::lexical_cast<double>(values.at(0));
    79   VV.y = boost::lexical_cast<double>(values.at(1));
    80   VV.z = boost::lexical_cast<double>(values.at(2));
     98  VV.x = boost::lexical_cast<double>(components.at(0));
     99  VV.y = boost::lexical_cast<double>(components.at(1));
     100  VV.z = boost::lexical_cast<double>(components.at(2));
    81101  v = boost::any(VectorValue(VV));
    82102}
     
    85105{
    86106  BoxValue BV;
    87   if (values.size() != 6) {
    88     cerr <<  "Specified vector does not have three components but " << values.size() << endl;
     107  std::vector<std::string> components;
     108
     109  // split comma-separated values
     110  if (values.size() != 1) {
     111    cerr <<  "Not one vector but " << components.size() << " given " << endl;
     112    throw boost::program_options::validation_error("Unequal to one vector given");
     113  }
     114  std::string argument(values.at(0));
     115  std::string::iterator Aiter = argument.begin();
     116  std::string::iterator Biter = argument.begin();
     117  for (; Aiter != argument.end(); ++Aiter) {
     118    if (*Aiter == ',') {
     119      components.push_back(string(Biter,Aiter));
     120      do {
     121        Aiter++;
     122      } while (*Aiter == ' ' || *Aiter == '\t');
     123      Biter = Aiter;
     124    }
     125  }
     126  components.push_back(string(Biter,argument.end()));
     127
     128  if (components.size() != 6) {
     129    cerr <<  "Specified vector does not have three components but " << components.size() << endl;
    89130    throw boost::program_options::validation_error("Specified symmetric box matrix does not have six components");
    90131  }
    91   BV.xx = boost::lexical_cast<double>(values.at(0));
    92   BV.xy = boost::lexical_cast<double>(values.at(1));
    93   BV.xz = boost::lexical_cast<double>(values.at(2));
    94   BV.yy = boost::lexical_cast<double>(values.at(3));
    95   BV.yz = boost::lexical_cast<double>(values.at(4));
    96   BV.zz = boost::lexical_cast<double>(values.at(5));
     132  BV.xx = boost::lexical_cast<double>(components.at(0));
     133  BV.xy = boost::lexical_cast<double>(components.at(1));
     134  BV.xz = boost::lexical_cast<double>(components.at(2));
     135  BV.yy = boost::lexical_cast<double>(components.at(3));
     136  BV.yz = boost::lexical_cast<double>(components.at(4));
     137  BV.zz = boost::lexical_cast<double>(components.at(5));
    97138  v = boost::any(BoxValue(BV));
    98139}
     
    130171  DescriptionMap["input"] = "specify input files";
    131172  DescriptionMap["linear-interpolate"] = "linear interpolation in discrete steps between start and end position of a molecule";
     173  DescriptionMap["molecular-volume"] = "calculate the volume of a given molecule";
    132174  DescriptionMap["nonconvex-envelope"] = "create the non-convex envelope for a molecule";
    133   DescriptionMap["molecular-volume"] = "calculate the volume of a given molecule";
    134   DescriptionMap["output"] = "specify output formats";
     175  DescriptionMap["output"] = "write output files";
     176  DescriptionMap["set-output"] = "specify output formats";
    135177  DescriptionMap["pair-correlation"] = "pair correlation analysis between two elements, element and point or element and surface";
    136178  DescriptionMap["parse-xyz"] = "parse xyz file into World";
     
    140182  DescriptionMap["repeat-box"] = "create periodic copies of the simulation box per axis";
    141183  DescriptionMap["rotate-to-pas"] = "calculate the principal axis system of the specified molecule and rotate specified axis to align with main axis";
    142   DescriptionMap["set-basis"] = "set the name of the gaussian basis set for MPQC";
    143184  DescriptionMap["save-adjacency"] = "name of the adjacency file to write to";
    144185  DescriptionMap["save-bonds"] = "name of the bonds file to write to";
     
    146187  DescriptionMap["SaveXyz"] = "save world as xyz file";
    147188  DescriptionMap["scale-box"] = "scale box and atomic positions inside";
     189  DescriptionMap["set-basis"] = "set the name of the gaussian basis set for MPQC";
     190  DescriptionMap["set-output"] = "specify output formats";
    148191  DescriptionMap["subgraph-dissect"] = "dissect the molecular system into molecules representing disconnected subgraphs";
    149192  DescriptionMap["suspend-in-water"] = "suspend the given molecule in water such that in the domain the mean density is as specified";
     
    189232  ShortFormMap["center-in-box"] = "b";
    190233  ShortFormMap["change-element"] = "E";
    191   ShortFormMap["convex-envelope"] = "o";
     234//  ShortFormMap["convex-envelope"] = "x";
    192235  ShortFormMap["default-molname"] = "X";
    193236  ShortFormMap["depth-first-search"] = "D";
     
    200243  ShortFormMap["linear-interpolate"] = "L";
    201244  ShortFormMap["nonconvex-envelope"] = "N";
     245//  ShortFormMap["output"] = "o";
    202246  ShortFormMap["pair-correlation"] = "C";
    203247  ShortFormMap["parse-xyz"] = "p";
     
    211255  ShortFormMap["scale-box"] = "s";
    212256  ShortFormMap["set-basis"] = "M";
     257  ShortFormMap["set-output"] = "o";
    213258  ShortFormMap["subgraph-dissect"] = "I";
    214259  ShortFormMap["suspend-in-water"] = "u";
     
    238283  TypeMap["molecular-volume"] = Molecule;
    239284  TypeMap["nonconvex-envelope"] = Molecule;
    240   TypeMap["output"] = String;
     285  TypeMap["output"] = None;
    241286  TypeMap["parse-xyz"] = String;
    242287  TypeMap["pair-correlation"] = String;
     
    251296  TypeMap["scale-box"] = Vector;
    252297  TypeMap["set-basis"] = String;
     298  TypeMap["set-output"] = ListOfString;
    253299  TypeMap["subgraph-dissect"] = None;
    254300  TypeMap["suspend-in-water"] = Double;
     
    349395  MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "default-molname") );
    350396  MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "set-basis") );
     397  MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "set-output") );
    351398
    352399  // put actions into command line category
     
    386433  generic.insert("scale-box");
    387434  generic.insert("set-basis");
     435  generic.insert("set-output");
    388436        generic.insert("subgraph-dissect");
    389437  generic.insert("suspend-in-water");
     
    484532  new WorldSetDefaultNameAction();
    485533  new WorldSetGaussianBasisAction();
     534  new WorldSetOutputFormatsAction();
    486535}
    487536
     
    561610              ;
    562611            break;
     612          case ListOfString:
     613            ListRunner->second->add_options()
     614              (getKeyAndShortForm(*OptionRunner).c_str(),
     615                  po::value< vector<std::string> >()->multitoken(),
     616                  getDescription(*OptionRunner).c_str())
     617              ;
     618            break;
    563619          case Axis:
    564620            ListRunner->second->add_options()
     
    573629            ListRunner->second->add_options()
    574630              (getKeyAndShortForm(*OptionRunner).c_str(),
    575                   po::value<VectorValue>()->multitoken(),
     631                  po::value<VectorValue>(),
    576632                  getDescription(*OptionRunner).c_str())
    577633              ;
Note: See TracChangeset for help on using the changeset viewer.