LCOV - code coverage report
Current view: top level - function - Function.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 23 23 100.0 %
Date: 2024-10-18 13:59:31 Functions: 5 6 83.3 %

          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             : #include "Function.h"
      23             : #include "tools/OpenMP.h"
      24             : #include "tools/Communicator.h"
      25             : 
      26             : namespace PLMD {
      27             : namespace function {
      28             : 
      29        3007 : void Function::registerKeywords(Keywords& keys) {
      30        3007 :   Action::registerKeywords(keys);
      31        3007 :   ActionWithValue::registerKeywords(keys);
      32        3007 :   ActionWithArguments::registerKeywords(keys);
      33        6014 :   keys.addInputKeyword("compulsory","ARG","scalar","the labels of the values from which the function is calculated");
      34        6014 :   keys.reserve("compulsory","PERIODIC","if the output of your function is periodic then you should specify the periodicity of the function.  If the output is not periodic you must state this using PERIODIC=NO");
      35        3007 : }
      36             : 
      37        1525 : Function::Function(const ActionOptions&ao):
      38             :   Action(ao),
      39             :   ActionWithValue(ao),
      40        1525 :   ActionWithArguments(ao)
      41             : {
      42        1525 : }
      43             : 
      44        1425 : void Function::addValueWithDerivatives() {
      45        1425 :   plumed_massert( getNumberOfArguments()!=0, "for functions you must requestArguments before adding values");
      46        2850 :   ActionWithValue::addValueWithDerivatives();
      47        1425 :   getPntrToValue()->resizeDerivatives(getNumberOfArguments());
      48        1425 : }
      49             : 
      50        3177 : void Function::addComponentWithDerivatives( const std::string& name ) {
      51        3177 :   plumed_massert( getNumberOfArguments()!=0, "for functions you must requestArguments before adding values");
      52        3177 :   ActionWithValue::addComponentWithDerivatives(name);
      53        3177 :   getPntrToComponent(name)->resizeDerivatives(getNumberOfArguments());
      54        3177 : }
      55             : 
      56      270311 : void Function::apply()
      57             : {
      58      270311 :   if( !checkForForces() ) return;
      59       63829 :   unsigned ind=0; addForcesOnArguments( 0, getForcesToApply(), ind, getLabel() );
      60             : }
      61             : 
      62             : }
      63             : }

Generated by: LCOV version 1.16