LCOV - code coverage report
Current view: top level - function - Function.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 22 22 100.0 %
Date: 2024-10-18 14:00:25 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.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");
      34        3007 : }
      35             : 
      36        1525 : Function::Function(const ActionOptions&ao):
      37             :   Action(ao),
      38             :   ActionWithValue(ao),
      39        1525 :   ActionWithArguments(ao)
      40             : {
      41        1525 : }
      42             : 
      43        1425 : void Function::addValueWithDerivatives() {
      44        1425 :   plumed_massert( getNumberOfArguments()!=0, "for functions you must requestArguments before adding values");
      45        2850 :   ActionWithValue::addValueWithDerivatives();
      46        1425 :   getPntrToValue()->resizeDerivatives(getNumberOfArguments());
      47        1425 : }
      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      270311 : void Function::apply()
      56             : {
      57      270311 :   if( !checkForForces() ) return;
      58       63829 :   unsigned ind=0; addForcesOnArguments( 0, getForcesToApply(), ind, getLabel() );
      59             : }
      60             : 
      61             : }
      62             : }

Generated by: LCOV version 1.16