Line data Source code
1 : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 : Copyright (c) 2013-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_manyrestraints_ManyRestraintsBase_h 23 : #define __PLUMED_manyrestraints_ManyRestraintsBase_h 24 : 25 : #include "core/ActionAtomistic.h" 26 : #include "core/ActionWithValue.h" 27 : #include "core/ActionPilot.h" 28 : #include "vesselbase/ActionWithVessel.h" 29 : #include "vesselbase/ActionWithInputVessel.h" 30 : 31 : namespace PLMD { 32 : namespace manyrestraints { 33 : 34 : class ManyRestraintsBase : 35 : public ActionWithValue, 36 : public ActionPilot, 37 : public vesselbase::ActionWithVessel, 38 : public vesselbase::ActionWithInputVessel 39 : { 40 : private: 41 : /// Pointer to underlying action with vessel 42 : vesselbase::ActionWithVessel* aves; 43 : public: 44 : static void registerKeywords( Keywords& keys ); 45 : explicit ManyRestraintsBase(const ActionOptions&); 46 0 : bool isPeriodic() override { return false; } 47 : unsigned getNumberOfDerivatives() override; 48 : /// Routines that have to be defined so as not to have problems with virtual methods 49 : void deactivate_task( const unsigned & task_index ) {}; 50 : /// Don't actually clear the derivatives when this is called from plumed main. 51 : /// They are calculated inside another action and clearing them would be bad 52 10 : void clearDerivatives() override {} 53 : /// Do jobs required before tasks are undertaken 54 : void doJobsRequiredBeforeTaskList() override; 55 : /// This actually does the calculation 56 : void transformBridgedDerivatives( const unsigned& current, MultiValue& invals, MultiValue& outvals ) const override; 57 : /// Calculate the potential 58 : virtual double calcPotential( const double& val, double& df ) const=0; 59 : // Calculate does nothing 60 5 : void calculate() override {}; 61 : /// This should never be called 62 0 : void performTask( const unsigned&, const unsigned&, MultiValue& ) const override { plumed_error(); } 63 : /// Deactivate task now does nothing 64 : void apply() override; 65 10 : void applyBridgeForces( const std::vector<double>& bb ) override { plumed_assert( bb.size()==0 ); } 66 : }; 67 : 68 : inline 69 14828 : unsigned ManyRestraintsBase::getNumberOfDerivatives() { 70 14828 : return aves->getNumberOfDerivatives(); 71 : } 72 : 73 : } 74 : } 75 : 76 : #endif