/* * MapOfActions.cpp * * Created on: 10.05.2010 * Author: heber */ using namespace std; #include "Patterns/Singleton_impl.hpp" #include "Actions/MapOfActions.hpp" #include "Helpers/Assert.hpp" #include #include #include #include "CommandLineParser.hpp" #include "log.hpp" #include "verbose.hpp" #include "Actions/Values.hpp" void validate(boost::any& v, const std::vector& values, VectorValue *, int) { VectorValue VV; if (values.size() != 3) { cerr << "Specified vector does not have three components but " << values.size() << endl; throw boost::program_options::validation_error("Specified vector does not have three components"); } VV.x = boost::lexical_cast(values.at(0)); VV.y = boost::lexical_cast(values.at(1)); VV.z = boost::lexical_cast(values.at(2)); v = boost::any(VectorValue(VV)); } void validate(boost::any& v, const std::vector& values, BoxValue *, int) { BoxValue BV; if (values.size() != 6) { cerr << "Specified vector does not have three components but " << values.size() << endl; throw boost::program_options::validation_error("Specified symmetric box matrix does not have six components"); } BV.xx = boost::lexical_cast(values.at(0)); BV.xy = boost::lexical_cast(values.at(1)); BV.xz = boost::lexical_cast(values.at(2)); BV.yy = boost::lexical_cast(values.at(3)); BV.yz = boost::lexical_cast(values.at(4)); BV.zz = boost::lexical_cast(values.at(5)); v = boost::any(BoxValue(BV)); } /** Constructor of class MapOfActions. * */ MapOfActions::MapOfActions() { // initialise lookup map CmdParserLookup[&generic] = &(CommandLineParser::getInstance().generic); CmdParserLookup[&config] = &(CommandLineParser::getInstance().config); CmdParserLookup[&hidden] = &(CommandLineParser::getInstance().hidden); CmdParserLookup[&visible] = &(CommandLineParser::getInstance().visible); // keys for actions DescriptionMap["add-atom"] = "add atom of specified element"; DescriptionMap["bond-table"] = "setting name of the bond length table file"; DescriptionMap["bond-file"] = "name of the bond file"; DescriptionMap["boundary"] = "change box to add an empty boundary around all atoms"; DescriptionMap["bound-in-box"] = "bound all atoms in the domain"; DescriptionMap["center-edge"] = "center edge of all atoms on (0,0,0)"; DescriptionMap["center-in-box"] = "center all atoms in the domain"; DescriptionMap["change-box"] = "change the symmetrc matrix of the simulation domain"; DescriptionMap["change-element"] = "change the element of an atom"; DescriptionMap["change-molname"] = "change the name of a molecule"; DescriptionMap["convex-envelope"] = "create the convex envelope for a molecule"; DescriptionMap["default-molname"] = "set the default name of new molecules"; DescriptionMap["depth-first-search"] = "Depth-First Search analysis of the molecular system"; DescriptionMap["element-db"] = "setting the path where the element databases can be found"; DescriptionMap["fastparsing"] = "setting whether trajectories shall be parsed completely (n) or just first step (y)"; DescriptionMap["fill-molecule"] = "fill empty space of box with a filler molecule"; DescriptionMap["fragment-mol"] = "create for a given molecule into fragments up to given order"; DescriptionMap["help"] = "Give this help screen"; DescriptionMap["linear-interpolate"] = "linear interpolation in discrete steps between start and end position of a molecule"; DescriptionMap["nonconvex-envelope"] = "create the non-convex envelope for a molecule"; DescriptionMap["molecular-volume"] = "calculate the volume of a given molecule"; DescriptionMap["pair-correlation"] = "pair correlation analysis between two elements, element and point or element and surface"; DescriptionMap["parse-xyz"] = "parse xyz file into World"; DescriptionMap["principal-axis-system"] = "calculate the principal axis system of the specified molecule"; DescriptionMap["remove-atom"] = "remove a specified atom"; DescriptionMap["remove-sphere"] = "remove sphere of atoms of around a specified atom"; DescriptionMap["repeat-box"] = "create periodic copies of the simulation box per axis"; DescriptionMap["rotate-to-pas"] = "calculate the principal axis system of the specified molecule and rotate specified axis to align with main axis"; DescriptionMap["set-basis"] = "set the name of the gaussian basis set for MPQC"; DescriptionMap["save-adjacency"] = "name of the adjacency file to write to"; DescriptionMap["save-bonds"] = "name of the bonds file to write to"; DescriptionMap["save-temperature"] = "name of the temperature file to write to"; DescriptionMap["scale-box"] = "scale box and atomic positions inside"; DescriptionMap["subspace-dissect"] = "dissect the molecular system into molecules representing disconnected subgraphs"; DescriptionMap["suspend-in-water"] = "suspend the given molecule in water such that in the domain the mean density is as specified"; DescriptionMap["translate-mol"] = "translate molecule by given vector"; DescriptionMap["verbose"] = "set verbosity level"; DescriptionMap["verlet-integrate"] = "perform verlet integration of a given force file"; DescriptionMap["version"] = "show version"; // keys for values DescriptionMap["bin-output-file"] = "name of the bin output file"; DescriptionMap["bin-end"] = "start of the last bin"; DescriptionMap["bin-start"] = "start of the first bin"; DescriptionMap["bin-width"] = "width of the bins"; DescriptionMap["distance"] = "distance in space"; DescriptionMap["distances"] = "list of three of distances in space, one for each axis direction"; DescriptionMap["DoRotate"] = "whether to rotate or just report angles"; DescriptionMap["element"] = "single element"; DescriptionMap["elements"] = "set of elements"; DescriptionMap["end-mol"] = "last or end step"; DescriptionMap["input"] = "name of input file"; DescriptionMap["length"] = "length in space"; DescriptionMap["lengths"] = "list of three of lengths in space, one for each axis direction"; DescriptionMap["MaxDistance"] = "maximum distance in space"; DescriptionMap["molecule-by-id"] = "index of a molecule"; DescriptionMap["molecule-by-name"] = "name of a molecule"; DescriptionMap["order"] = "order of a discretization, dissection, ..."; DescriptionMap["output-file"] = "name of the output file"; DescriptionMap["periodic"] = "system is constraint to periodic boundary conditions (y/n)"; DescriptionMap["position"] = "position in R^3 space"; DescriptionMap["start-mol"] = "first or start step"; // short forms for the actions ShortFormMap["add-atom"] = "a"; ShortFormMap["bond-table"] = "g"; ShortFormMap["bond-file"] = "A"; ShortFormMap["boundary"] = "c"; ShortFormMap["change-box"] = "B"; ShortFormMap["center-edge"] = "O"; ShortFormMap["center-in-box"] = "b"; ShortFormMap["change-element"] = "E"; ShortFormMap["convex-envelope"] = "o"; ShortFormMap["default-molname"] = "X"; ShortFormMap["depth-first-search"] = "D"; ShortFormMap["element-db"] = "e"; ShortFormMap["fastparsing"] = "n"; ShortFormMap["fill-molecule"] = "F"; ShortFormMap["fragment-mol"] = "f"; ShortFormMap["help"] = "h"; ShortFormMap["input"] = "i"; ShortFormMap["linear-interpolate"] = "L"; ShortFormMap["nonconvex-envelope"] = "N"; ShortFormMap["pair-correlation"] = "C"; ShortFormMap["parse-xyz"] = "p"; ShortFormMap["remove-atom"] = "r"; ShortFormMap["remove-sphere"] = "R"; ShortFormMap["repeat-box"] = "d"; ShortFormMap["rotate-to-pas"] = "m"; ShortFormMap["save-adjacency"] = "J"; ShortFormMap["save-bonds"] = "j"; ShortFormMap["save-temperature"] = "S"; ShortFormMap["scale-box"] = "s"; ShortFormMap["set-basis"] = "M"; ShortFormMap["subspace-dissect"] = "I"; ShortFormMap["suspend-in-water"] = "u"; ShortFormMap["translate-mol"] = "t"; ShortFormMap["verbose"] = "v"; ShortFormMap["verlet-integrate"] = "P"; ShortFormMap["version"] = "V"; // value types for the actions TypeMap["add-atom"] = Atom; TypeMap["bond-file"] = String; TypeMap["bond-table"] = String; TypeMap["boundary"] = Vector; TypeMap["center-in-box"] = Box; TypeMap["change-box"] = Box; TypeMap["change-element"] = Element; TypeMap["change-molname"] = String; TypeMap["convex-envelope"] = Molecule; TypeMap["default-molname"] = String; TypeMap["depth-first-search"] = Double; TypeMap["element-db"] = String; TypeMap["end-mol"] = Molecule; TypeMap["fastparsing"] = Boolean; TypeMap["fill-molecule"] = String; TypeMap["fragment-mol"] = Molecule; TypeMap["input"] = String; TypeMap["linear-interpolate"] = String; TypeMap["molecular-volume"] = Molecule; TypeMap["nonconvex-envelope"] = Molecule; TypeMap["parse-xyz"] = String; TypeMap["pair-correlation"] = String; TypeMap["principal-axis-system"] = Molecule; TypeMap["remove-atom"] = Atom; TypeMap["remove-sphere"] = Atom; TypeMap["repeat-box"] = Vector; TypeMap["rotate-to-pas"] = Molecule; TypeMap["save-adjacency"] = String; TypeMap["save-bonds"] = String; TypeMap["save-temperature"] = String; TypeMap["scale-box"] = Vector; TypeMap["set-basis"] = String; TypeMap["start-mol"] = Molecule; TypeMap["suspend-in-water"] = Double; TypeMap["translate-mol"] = Vector; TypeMap["verlet-integrate"] = String; TypeMap["verbose"] = Integer; // value types for the values TypeMap["bin-output-file"] = String; TypeMap["bin-end"] = Double; TypeMap["bin-start"] = Double; TypeMap["bin-width"] = Double; TypeMap["distance"] = Double; TypeMap["distances"] = Vector; TypeMap["DoRotate"] = Boolean; TypeMap["elements"] = Element; TypeMap["elements"] = ListOfElements; TypeMap["length"] = Double; TypeMap["lengths"] = Vector; TypeMap["MaxDistance"] = Double; TypeMap["molecule-by-id"] = Molecule; TypeMap["molecule-by-name"] = Molecule; TypeMap["order"] = Integer; TypeMap["output-file"] = String; TypeMap["periodic"] = Boolean; TypeMap["position"] = Vector; // default values for any action that needs one (always string!) DefaultValue["molecule-by-id"] = "-1"; DefaultValue["bin-width"] = "0.5"; DefaultValue["periodic"] = "0"; // list of generic actions // generic.insert("add-atom"); // generic.insert("bond-file"); // generic.insert("bond-table"); generic.insert("boundary"); // generic.insert("bound-in-box"); generic.insert("center-edge"); generic.insert("center-in-box"); generic.insert("change-box"); // generic.insert("change-molname"); // generic.insert("change-element"); // generic.insert("convex-envelope"); // generic.insert("default-molname"); generic.insert("depth-first-search"); // generic.insert("element-d