LCOV - code coverage report
Current view: top level - function - Function.h (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 7 8 87.5 %
Date: 2024-10-11 08:09:47 Functions: 3 3 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_function_Function_h
      23             : #define __PLUMED_function_Function_h
      24             : 
      25             : #include "core/ActionWithValue.h"
      26             : #include "core/ActionWithArguments.h"
      27             : 
      28             : namespace PLMD {
      29             : namespace function {
      30             : 
      31             : /**
      32             : \ingroup INHERIT
      33             : This is the abstract base class to use for implementing new CV function, within it there is
      34             : \ref AddingAFunction "information" as to how to go about implementing a new function.
      35             : */
      36             : 
      37             : class Function:
      38             :   public ActionWithValue,
      39             :   public ActionWithArguments
      40             : {
      41             : protected:
      42             :   void setDerivative(int,double);
      43             :   void setDerivative(Value*,int,double);
      44             :   void addValueWithDerivatives();
      45             :   void addComponentWithDerivatives( const std::string& name );
      46             : public:
      47             :   explicit Function(const ActionOptions&);
      48         664 :   virtual ~Function() {}
      49             :   void apply() override;
      50             :   static void registerKeywords(Keywords&);
      51             :   unsigned getNumberOfDerivatives() override;
      52             : };
      53             : 
      54             : inline
      55             : void Function::setDerivative(Value*v,int i,double d) {
      56       55078 :   v->addDerivative(i,d);
      57           0 : }
      58             : 
      59             : inline
      60       52168 : void Function::setDerivative(int i,double d) {
      61       52168 :   setDerivative(getPntrToValue(),i,d);
      62       52168 : }
      63             : 
      64             : inline
      65     3471287 : unsigned Function::getNumberOfDerivatives() {
      66     3471287 :   return getNumberOfArguments();
      67             : }
      68             : 
      69             : }
      70             : }
      71             : 
      72             : #endif
      73             : 

Generated by: LCOV version 1.15