LCOV - code coverage report
Current view: top level - multicolvar - BridgedMultiColvarFunction.h (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 12 23 52.2 %
Date: 2024-10-11 08:09:47 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() { plumed_error(); }
      85           0 :   double compute( const unsigned& tindex, AtomValuePack& myvals ) const override { plumed_error(); }
      86             :   Vector getPositionOfAtomForLinkCells( const unsigned& iatom ) const override;
      87             :   void getIndexList( const unsigned& ntotal, const unsigned& jstore, const unsigned& maxder, std::vector<unsigned>& indices );
      88             :   void applyBridgeForces( const std::vector<double>& bb ) override;
      89             :   Vector getCentralAtomPos( const unsigned& curr ) override;
      90             :   void normalizeVector( std::vector<double>& vals ) const override;
      91             :   void normalizeVectorDerivatives( MultiValue& myvals ) const override;
      92             :   void getCentralAtomPack( const unsigned& basn, const unsigned& curr, CatomPack& mypack ) override;
      93             : };
      94             : 
      95             : inline
      96           5 : const std::vector<AtomNumber> & BridgedMultiColvarFunction::getAbsoluteIndexes() const {
      97           5 :   return mycolv->getAbsoluteIndexes();
      98             : }
      99             : 
     100             : inline
     101             : MultiColvarBase* BridgedMultiColvarFunction::getPntrToMultiColvar() const {
     102      889857 :   return mycolv;
     103             : }
     104             : 
     105             : inline
     106      128406 : unsigned BridgedMultiColvarFunction::getNumberOfDerivatives() {
     107      128406 :   return mycolv->getNumberOfDerivatives() + 3*getNumberOfAtoms();
     108             : }
     109             : 
     110             : inline
     111           0 : bool BridgedMultiColvarFunction::isCurrentlyActive( const unsigned& code ) {
     112           0 :   return mycolv->isCurrentlyActive( code );
     113             : }
     114             : 
     115             : inline
     116             : unsigned BridgedMultiColvarFunction::getSizeOfAtomsWithDerivatives() {
     117             :   return mycolv->getNumberOfAtoms();
     118             : }
     119             : 
     120             : inline
     121           0 : Vector BridgedMultiColvarFunction::getPositionOfAtomForLinkCells( const unsigned& iatom ) const {
     122           0 :   return mycolv->getPositionOfAtomForLinkCells(iatom);
     123             : }
     124             : 
     125             : inline
     126       78336 : Vector BridgedMultiColvarFunction::getCentralAtomPos( const unsigned& curr ) {
     127       78336 :   return mycolv->getCentralAtomPos( curr );
     128             : }
     129             : 
     130             : inline
     131         156 : AtomNumber BridgedMultiColvarFunction::getAbsoluteIndexOfCentralAtom(const unsigned& i) const {
     132         156 :   return mycolv->getAbsoluteIndexOfCentralAtom(i);
     133             : }
     134             : 
     135             : inline
     136           0 : void BridgedMultiColvarFunction::normalizeVector( std::vector<double>& vals ) const {
     137           0 :   mycolv->normalizeVector( vals );
     138           0 : }
     139             : 
     140             : inline
     141           0 : void BridgedMultiColvarFunction::normalizeVectorDerivatives( MultiValue& myvals ) const {
     142           0 :   mycolv->normalizeVectorDerivatives( myvals );
     143           0 : }
     144             : 
     145             : }
     146             : }
     147             : #endif

Generated by: LCOV version 1.15