Line data Source code
1 : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 : Copyright (c) 2011-2023 The plumed team 3 : (see the PEOPLE file at the root of the distribution for a list of names) 4 : 5 : See http://www.plumed.org for more information. 6 : 7 : This file is part of plumed, version 2. 8 : 9 : plumed is free software: you can redistribute it and/or modify 10 : it under the terms of the GNU Lesser General Public License as published by 11 : the Free Software Foundation, either version 3 of the License, or 12 : (at your option) any later version. 13 : 14 : plumed is distributed in the hope that it will be useful, 15 : but WITHOUT ANY WARRANTY; without even the implied warranty of 16 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 : GNU Lesser General Public License for more details. 18 : 19 : You should have received a copy of the GNU Lesser General Public License 20 : along with plumed. If not, see <http://www.gnu.org/licenses/>. 21 : +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ 22 : #ifndef __PLUMED_colvar_ColvarShortcut_h 23 : #define __PLUMED_colvar_ColvarShortcut_h 24 : 25 : #include "core/ActionShortcut.h" 26 : 27 : namespace PLMD { 28 : namespace colvar { 29 : 30 : template <class T> 31 : class ColvarShortcut : public ActionShortcut { 32 : public: 33 : static void registerKeywords(Keywords&); 34 : explicit ColvarShortcut(const ActionOptions&); 35 : }; 36 : 37 : template <class T> 38 2016 : void ColvarShortcut<T>::registerKeywords(Keywords& keys ) { 39 2016 : T::registerKeywords( keys ); 40 4032 : keys.remove("NO_ACTION_LOG"); 41 18901 : for (auto& key : keys.getKeys()) { 42 33770 : if( keys.style( key, "atoms" ) ) { 43 11662 : keys.reset_style( key, "numbered" ); 44 : } 45 : } 46 2016 : keys.addActionNameSuffix("_SCALAR"); 47 2016 : keys.addActionNameSuffix("_VECTOR"); 48 2016 : } 49 : 50 : template <class T> 51 1695 : ColvarShortcut<T>::ColvarShortcut(const ActionOptions&ao): 52 : Action(ao), 53 1695 : ActionShortcut(ao) { 54 : bool scalar=true; 55 5058 : if( getName()=="MASS" || getName()=="CHARGE" || getName()=="POSITION" ) { 56 : std::string inpt; 57 306 : parse("ATOMS",inpt); 58 153 : if( inpt.length()>0 ) { 59 114 : readInputLine( getShortcutLabel() + ": " + getName() + "_VECTOR ATOMS=" + inpt + " " + convertInputLineToString() ); 60 : scalar=false; 61 : } 62 : } 63 15896 : for (auto& key : keywords.getKeys()) { 64 28690 : if( keywords.style( key, "atoms" ) ) { 65 : std::string inpt; 66 5304 : parseNumbered( key, 1, inpt ); 67 5304 : if( inpt.length()>0 ) { 68 288 : readInputLine( getShortcutLabel() + ": " + getName() + "_VECTOR " + key + "1=" + inpt + " " + convertInputLineToString() ); 69 : scalar=false; 70 : break; 71 : } 72 : } 73 : } 74 1551 : if( scalar ) { 75 3006 : readInputLine( getShortcutLabel() + ": " + getName() + "_SCALAR " + convertInputLineToString() ); 76 : } 77 1701 : } 78 : 79 : } 80 : } 81 : #endif