LCOV - code coverage report
Current view: top level - multicolvar - BridgedMultiColvarFunction.h (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 12 24 50.0 %
Date: 2026-03-30 13:16:06 Functions: 7 12 58.3 %

          Line data    Source code
       1             : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       2             :    Copyright (c) 2014-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_multicolvar_BridgedMultiColvarFunction_h
      23             : #define __PLUMED_multicolvar_BridgedMultiColvarFunction_h
      24             : 
      25             : #include "vesselbase/BridgeVessel.h"
      26             : #include "MultiColvarBase.h"
      27             : 
      28             : namespace PLMD {
      29             : namespace multicolvar {
      30             : 
      31             : class BridgedMultiColvarFunction : public MultiColvarBase {
      32             :   friend class MultiColvarBase;
      33             :   friend class MultiColvarFunction;
      34             : private:
      35             : /// This is used for storing positions properly
      36             :   Vector tmp_p;
      37             : /// The action that is calculating the colvars of interest
      38             :   MultiColvarBase* mycolv;
      39             : /// The vessel that bridges
      40             :   vesselbase::BridgeVessel* myBridgeVessel;
      41             : /// Everything for controlling the updating of neighbor lists
      42             :   bool firsttime;
      43             :   int updateFreq;
      44             : protected:
      45             : /// Deactivate all the atoms in the list
      46             :   void deactivateAllAtoms();
      47             : /// Activate the nth atom in the list
      48             :   void setAtomActive( const unsigned& n );
      49             : public:
      50             :   static void registerKeywords( Keywords& keys );
      51             :   explicit BridgedMultiColvarFunction(const ActionOptions&);
      52             : /// Get a pointer to the base multicolvar
      53             :   MultiColvarBase* getPntrToMultiColvar() const ;
      54             : /// Don't actually clear the derivatives when this is called from plumed main.
      55             : /// They are calculated inside another action and clearing them would be bad
      56         785 :   void clearDerivatives() override {}
      57             : /// Check nothing impossible being done with derivatives
      58             :   void turnOnDerivatives() override;
      59             : /// Get the number of derivatives for this action
      60             :   unsigned getNumberOfDerivatives() override;
      61             : /// Get the size of the atoms with derivatives array
      62             :   unsigned getSizeOfAtomsWithDerivatives();
      63             : /// Is the output quantity periodic
      64             :   bool isPeriodic() override;
      65             : /// Routines that have to be defined so as not to have problems with virtual methods
      66             :   void deactivate_task( const unsigned& taskno );
      67         725 :   void calculate() override {}
      68             : /// This does the task
      69             :   void transformBridgedDerivatives( const unsigned& current, MultiValue& invals, MultiValue& outvals ) const override;
      70             :   void performTask( const unsigned&, const unsigned&, MultiValue& ) const override;
      71             :   virtual void completeTask( const unsigned& curr, MultiValue& invals, MultiValue& outvals ) const=0;
      72             : /// Get the central atom position
      73             :   Vector retrieveCentralAtomPos();
      74             : /// Get the index of the central atom
      75             :   AtomNumber getAbsoluteIndexOfCentralAtom( const unsigned& i ) const override;
      76             : /// Get indicecs involved in this colvar
      77             :   const std::vector<AtomNumber> & getAbsoluteIndexes()const override;
      78             : /// We need our own calculate numerical derivatives here
      79             :   void calculateNumericalDerivatives( ActionWithValue* a=NULL ) override;
      80         785 :   void apply() override {};
      81             : /// Is this atom currently being copied
      82             :   bool isCurrentlyActive( const unsigned& ) override;
      83             : /// This should not be called
      84             :   Vector calculateCentralAtomPosition() {
      85             :     plumed_error();
      86             :   }
      87           0 :   double compute( const unsigned& tindex, AtomValuePack& myvals ) const override {
      88           0 :     plumed_error();
      89             :   }
      90             :   Vector getPositionOfAtomForLinkCells( const unsigned& iatom ) const override;
      91             :   void getIndexList( const unsigned& ntotal, const unsigned& jstore, const unsigned& maxder, std::vector<unsigned>& indices );
      92             :   void applyBridgeForces( const std::vector<double>& bb ) override;
      93             :   Vector getCentralAtomPos( const unsigned& curr ) override;
      94             :   void normalizeVector( std::vector<double>& vals ) const override;
      95             :   void normalizeVectorDerivatives( MultiValue& myvals ) const override;
      96             :   void getCentralAtomPack( const unsigned& basn, const unsigned& curr, CatomPack& mypack ) override;
      97             : };
      98             : 
      99             : inline
     100           5 : const std::vector<AtomNumber> & BridgedMultiColvarFunction::getAbsoluteIndexes() const {
     101           5 :   return mycolv->getAbsoluteIndexes();
     102             : }
     103             : 
     104             : inline
     105             : MultiColvarBase* BridgedMultiColvarFunction::getPntrToMultiColvar() const {
     106      889857 :   return mycolv;
     107             : }
     108             : 
     109             : inline
     110      128406 : unsigned BridgedMultiColvarFunction::getNumberOfDerivatives() {
     111      128406 :   return mycolv->getNumberOfDerivatives() + 3*getNumberOfAtoms();
     112             : }
     113             : 
     114             : inline
     115           0 : bool BridgedMultiColvarFunction::isCurrentlyActive( const unsigned& code ) {
     116           0 :   return mycolv->isCurrentlyActive( code );
     117             : }
     118             : 
     119             : inline
     120             : unsigned BridgedMultiColvarFunction::getSizeOfAtomsWithDerivatives() {
     121             :   return mycolv->getNumberOfAtoms();
     122             : }
     123             : 
     124             : inline
     125           0 : Vector BridgedMultiColvarFunction::getPositionOfAtomForLinkCells( const unsigned& iatom ) const {
     126           0 :   return mycolv->getPositionOfAtomForLinkCells(iatom);
     127             : }
     128             : 
     129             : inline
     130       78336 : Vector BridgedMultiColvarFunction::getCentralAtomPos( const unsigned& curr ) {
     131       78336 :   return mycolv->getCentralAtomPos( curr );
     132             : }
     133             : 
     134             : inline
     135         156 : AtomNumber BridgedMultiColvarFunction::getAbsoluteIndexOfCentralAtom(const unsigned& i) const {
     136         156 :   return mycolv->getAbsoluteIndexOfCentralAtom(i);
     137             : }
     138             : 
     139             : inline
     140           0 : void BridgedMultiColvarFunction::normalizeVector( std::vector<double>& vals ) const {
     141           0 :   mycolv->normalizeVector( vals );
     142           0 : }
     143             : 
     144             : inline
     145           0 : void BridgedMultiColvarFunction::normalizeVectorDerivatives( MultiValue& myvals ) const {
     146           0 :   mycolv->normalizeVectorDerivatives( myvals );
     147           0 : }
     148             : 
     149             : }
     150             : }
     151             : #endif

Generated by: LCOV version 1.16