LCOV - code coverage report
Current view: top level - core - ActionForInterface.h (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 7 8 87.5 %
Date: 2024-10-18 14:00:25 Functions: 6 7 85.7 %

          Line data    Source code
       1             : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       2             :    Copyright (c) 2017-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_core_ActionForInterface_h
      23             : #define __PLUMED_core_ActionForInterface_h
      24             : 
      25             : #include "tools/TypesafePtr.h"
      26             : #include "ActionWithValue.h"
      27             : 
      28             : namespace PLMD {
      29             : 
      30             : class ActionForInterface : public ActionWithValue {
      31             :   friend class Atoms;
      32             :   friend class PlumedMain;
      33             : protected:
      34             : // Is this the first step
      35             :   bool firststep;
      36             : /// Have the forces in this action been scaled by another action
      37             :   bool wasscaled;
      38             : /// Action has been set
      39             :   bool wasset;
      40             : /// The role this plays
      41             :   std::string role;
      42             : public:
      43             :   static void registerKeywords(Keywords& keys);
      44             :   explicit ActionForInterface(const ActionOptions&ao);
      45             : /// Override clear the input data
      46      520510 :   void clearDerivatives(const bool& force=false) override {}
      47             : /// Override the need to deal with gradients
      48      520510 :   void setGradientsIfNeeded() override {}
      49             : /// Check if the value has been set
      50             :   bool hasBeenSet() const ;
      51             : /// The number of derivatives
      52      808971 :   unsigned getNumberOfDerivatives() override { return 0; }
      53             : ///
      54             :   virtual void resetForStepStart() = 0;
      55             : /// Set the start point for the memory if needed
      56             :   virtual void setStart( const std::string& name, const unsigned& sss) = 0;
      57             : /// Set the stride for the memory if needed
      58             :   virtual void setStride( const std::string& name, const unsigned& sss) = 0;
      59             : /// Set the pointer to the value that contains this data
      60             :   virtual bool setValuePointer( const std::string& name, const TypesafePtr & ) = 0;
      61             : /// Set the force to the value that contains this data
      62             :   virtual bool setForcePointer( const std::string& name, const TypesafePtr & ) = 0;
      63             : /// This get the number of forces that need to be rescaled in rescale forces
      64           0 :   virtual unsigned getNumberOfForcesToRescale() const { plumed_merror("no method for rescaling forces for this type of input"); }
      65             : /// Overriding this method from ActionWithValue ensures that taskLists that are set during share are not updated during calculate loop
      66             : //  void setupForCalculation( const bool& force=false ) override {}
      67             : /// Get the data
      68             :   virtual void share() = 0;
      69             :   virtual void shareAll() = 0;
      70             : /// Get the data to share
      71             :   virtual void wait() = 0;
      72             : /// Actually set the values for the output
      73      520510 :   void calculate() override { firststep=false; wasscaled=false; }
      74       93856 :   virtual void reset() {}
      75             :   virtual void Set_comm(Communicator& comm) = 0;
      76             : /// For replica exchange
      77             :   virtual void writeBinary(std::ostream&o) = 0;
      78             :   virtual void readBinary(std::istream&i) = 0;
      79             :   virtual bool onStep() const = 0;
      80             :   std::string getRole() const ;
      81         843 :   ActionForInterface* castToActionForInterface() noexcept final { return this; }
      82             : };
      83             : 
      84             : inline
      85             : bool ActionForInterface::hasBeenSet() const {
      86      786646 :   return wasset;
      87             : }
      88             : 
      89             : }
      90             : #endif

Generated by: LCOV version 1.16