LCOV - code coverage report
Current view: top level - colvar - ColvarShortcut.h (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 28 28 100.0 %
Date: 2026-11-05 10:19:04 Functions: 16 16 100.0 %

          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        3221 : void ColvarShortcut<T>::registerKeywords(Keywords& keys ) {
      39        3221 :   T::registerKeywords( keys );
      40        6442 :   keys.remove("NO_ACTION_LOG");
      41       31043 :   for (auto& key : keys.getKeys()) {
      42       55644 :     if( keys.style( key, "atoms" ) ) {
      43       11918 :       keys.reset_style( key, "numbered" );
      44             :     }
      45             :   }
      46        3221 :   keys.addActionNameSuffix("_SCALAR");
      47        6442 :   keys.addActionNameSuffix("_VECTOR");
      48             :   //GPU related settings
      49        3221 :   keys.addFlag("USEGPU",false,"run this calculation on the GPU");
      50        6442 :   keys.addLinkInDocForFlag("USEGPU","plugin_openaccPTM.md");
      51        3221 :   keys.addActionNameSuffix("_VECTORACC");
      52        3221 : }
      53             : 
      54             : template <class T>
      55        2764 : ColvarShortcut<T>::ColvarShortcut(const ActionOptions&ao):
      56             :   Action(ao),
      57        2764 :   ActionShortcut(ao) {
      58             :   bool scalar=true;
      59        2764 :   if( getName()=="MASS" || getName()=="CHARGE" || getName()=="POSITION" ) {
      60             :     std::string inpt;
      61         286 :     parse("ATOMS",inpt);
      62         143 :     if( inpt.length()>0 ) {
      63         184 :       readInputLine( getShortcutLabel() + ": " + getName() + "_VECTOR ATOMS=" + inpt + " " + convertInputLineToString() );
      64             :       scalar=false;
      65             :     }
      66             :   }
      67       28506 :   for (auto& key : keywords.getKeys()) {
      68       52032 :     if( keywords.style( key, "atoms" ) ) {
      69             :       std::string inpt;
      70        5327 :       parseNumbered( key, 1, inpt );
      71        5327 :       bool usegpuFLAG=false;
      72       10654 :       parseFlag("USEGPU",usegpuFLAG);
      73        5327 :       if( inpt.length()>0 ) {
      74        1645 :         readInputLine( getShortcutLabel() + ": "
      75             :                        + getName()  + "_VECTOR" + (usegpuFLAG ? "ACC ":" ")
      76             :                        + key + "1=" + inpt + " " + convertInputLineToString() );
      77             :         scalar=false;
      78             :         break;
      79             :       }
      80             :     }
      81             :   }
      82        2490 :   if( scalar ) {
      83        7332 :     readInputLine( getShortcutLabel() + ": " + getName() + "_SCALAR " + convertInputLineToString() );
      84             :   }
      85        2771 : }
      86             : 
      87             : }
      88             : }
      89             : #endif

Generated by: LCOV version 1.16