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