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

          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_ActionToPutData_h
      23             : #define __PLUMED_core_ActionToPutData_h
      24             : 
      25             : #include "ActionForInterface.h"
      26             : #include "DataPassingObject.h"
      27             : #include "tools/Units.h"
      28             : #include "DataPassingTools.h"
      29             : 
      30             : namespace PLMD {
      31             : 
      32             : class ActionToPutData :
      33             :   public ActionForInterface
      34             : {
      35             :   friend class PlumedMain;
      36             :   friend class TimeStep;
      37             :   friend class DomainDecomposition;
      38             : private:
      39             : /// Are we not applying forces on this values
      40             :   bool noforce;
      41             : /// Is this quantity fixed
      42             :   bool fixed;
      43             : /// Is this quantity passed from the domains
      44             :   bool from_domains;
      45             : /// Is PLUMED allowed to change the value of this pointer
      46             :   bool resetable;
      47             : /// Are we allowed to set data at this time
      48             :   bool dataCanBeSet;
      49             : /// The unit of the value that has been passed to plumed
      50             :   enum {n,e,l,m,q,t} unit;
      51             : /// The unit to to use for the force
      52             :   enum {d,eng} funit;
      53             : /// This holds the pointer that we getting data from
      54             :   std::unique_ptr<DataPassingObject> mydata;
      55             : /// Convert the enum contaning the unit into the name of the unit
      56             :   std::string getUnitName() const ;
      57             : protected:
      58             : /// Setup the units of the input value
      59             :   void setUnit( const std::string& unitstr, const std::string& funitstr );
      60             : public:
      61             :   static void registerKeywords(Keywords& keys);
      62             :   explicit ActionToPutData(const ActionOptions&ao);
      63             : /// Set the start point for the memory if needed
      64             :   void setStart( const std::string& name, const unsigned& sss) override;
      65             : /// This resets the stride in the collection object
      66             :   void setStride( const std::string& name, const unsigned& sss ) override;
      67             : /// Update the units on the input data
      68             :   void updateUnits( DataPassingTools* passtools );
      69             : /// This is called at the start of the step
      70      755863 :   void resetForStepStart() override { dataCanBeSet = true; }
      71             : /// These are the actions that set the pointers to the approrpiate values
      72             :   virtual bool setValuePointer( const std::string& name, const TypesafePtr & val ) override ;
      73             :   bool setForcePointer( const std::string& name, const TypesafePtr & val ) override ;
      74             : ///
      75           1 :   void Set_comm(Communicator& comm) override {}
      76             : /// And this gets the number of forces that need to be rescaled
      77             :   unsigned getNumberOfForcesToRescale() const override ;
      78             : /// Share the data
      79      744562 :   void share() override {}
      80         228 :   void shareAll() override {}
      81             : ///
      82             :   void getLocalValues( std::vector<double>& vals ) const ;
      83             : /// Get the data to share
      84             :   virtual void wait() override ;
      85             : /// Actually set the values for the output
      86             :   virtual void apply() override ;
      87             :   void rescaleForces( const double& alpha );
      88             : /// For replica exchange
      89             :   void writeBinary(std::ostream&o) override;
      90             :   virtual void readBinary(std::istream&i) override;
      91        3415 :   bool onStep() const override { return false; }
      92      576796 :   ActionToPutData* castToActionToPutData() noexcept final { return this; }
      93             : };
      94             : 
      95             : }
      96             : #endif

Generated by: LCOV version 1.16