LCOV - code coverage report
Current view: top level - function - Function.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 25 25 100.0 %
Date: 2025-04-08 21:11:17 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        2997 : void Function::registerKeywords(Keywords& keys) {
      30        2997 :   Action::registerKeywords(keys);
      31        2997 :   ActionWithValue::registerKeywords(keys);
      32        2997 :   ActionWithArguments::registerKeywords(keys);
      33        5994 :   keys.addInputKeyword("compulsory","ARG","scalar","the labels of the values from which the function is calculated");
      34        2997 :   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        2997 : }
      36             : 
      37        1517 : Function::Function(const ActionOptions&ao):
      38             :   Action(ao),
      39             :   ActionWithValue(ao),
      40        1517 :   ActionWithArguments(ao) {
      41        1517 : }
      42             : 
      43        1417 : void Function::addValueWithDerivatives() {
      44        1417 :   plumed_massert( getNumberOfArguments()!=0, "for functions you must requestArguments before adding values");
      45        2834 :   ActionWithValue::addValueWithDerivatives();
      46        1417 :   getPntrToValue()->resizeDerivatives(getNumberOfArguments());
      47        1417 : }
      48             : 
      49        3177 : void Function::addComponentWithDerivatives( const std::string& name ) {
      50        3177 :   plumed_massert( getNumberOfArguments()!=0, "for functions you must requestArguments before adding values");
      51        3177 :   ActionWithValue::addComponentWithDerivatives(name);
      52        3177 :   getPntrToComponent(name)->resizeDerivatives(getNumberOfArguments());
      53        3177 : }
      54             : 
      55      270317 : void Function::apply() {
      56      270317 :   if( !checkForForces() ) {
      57      206482 :     return;
      58             :   }
      59       63835 :   unsigned ind=0;
      60       63835 :   addForcesOnArguments( 0, getForcesToApply(), ind, getLabel() );
      61             : }
      62             : 
      63             : }
      64             : }

Generated by: LCOV version 1.16