LCOV - code coverage report
Current view: top level - adjmat - AdjacencyMatrixBase.h (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 8 8 100.0 %
Date: 2020-11-18 11:20:57 Functions: 3 3 100.0 %

          Line data    Source code
       1             : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       2             :    Copyright (c) 2015-2019 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_adjmat_AdjacencyMatrixBase_h
      23             : #define __PLUMED_adjmat_AdjacencyMatrixBase_h
      24             : 
      25             : #include "multicolvar/MultiColvarBase.h"
      26             : #include "AdjacencyMatrixVessel.h"
      27             : 
      28             : namespace PLMD {
      29             : namespace adjmat {
      30             : 
      31          21 : class AdjacencyMatrixBase : public multicolvar::MultiColvarBase {
      32             :   friend class AdjacencyMatrixVessel;
      33             :   friend class ActionWithInputMatrix;
      34             :   friend class MatrixColumnSums;
      35             :   friend class MatrixRowSums;
      36             : private:
      37             : /// Used for read in of multiple connection descriptors
      38             :   unsigned connect_id;
      39             : /// Do we need to separate out the tasks for the third atoms
      40             :   bool no_third_dim_accum;
      41             : /// This is the vessel that stores the adjacency matrix
      42             :   AdjacencyMatrixVessel* mat;
      43             : /// This is used within AdjacencyMatrixVessel to recalculate matrix elements
      44             : /// whcih is useful when we are operating with lowmem
      45             :   void recalculateMatrixElement( const unsigned& myelem, MultiValue& myvals );
      46             : /// Finish the setup of the matrix
      47             :   void finishMatrixSetup( const bool& symmetric, const std::vector<AtomNumber>& all_atoms );
      48             : protected:
      49             : /// Read in a matrix involving a maximum of two species
      50             :   void readMaxTwoSpeciesMatrix( const std::string& key0, const std::string& key1, const std::string& key2, const bool& symmetric );
      51             : /// Read in a matrix involving a maximum of three species
      52             :   void readMaxThreeSpeciesMatrix( const std::string& key0, const std::string& key1, const std::string& key2, const std::string& keym, const bool& symmetric );
      53             : /// Get the dimensions of the matrix of types
      54             :   void retrieveTypeDimensions( unsigned& nrows, unsigned& ncols, unsigned& ntype ) const ;
      55             : /// Retrieve the vessel that holds the adjacency matrix
      56             :   AdjacencyMatrixVessel* getAdjacencyVessel();
      57             : /// Put the indices of the matrix elements in current atoms
      58             :   void setMatrixIndexesForTask( const unsigned& ii );
      59             : /// Add derivatives to a matrix element
      60             :   void addDerivativesOnMatrixElement( const unsigned& ielem, const unsigned& jrow, const double& df, Matrix<double>& der );
      61             : /// Read in the information on the connectors
      62             :   void parseConnectionDescriptions( const std::string& key, const bool& multiple, const unsigned& nrow_t );
      63             : protected:
      64             : /// Get the number of nodes of different types
      65             :   unsigned getNumberOfNodeTypes() const ;
      66             : /// Get the size of the vectors that were stored in the base colvars
      67             :   unsigned getSizeOfInputVectors() const ;
      68             : /// Return the group this atom is a part of
      69             :   unsigned getBaseColvarNumber( const unsigned& ) const ;
      70             : public:
      71             :   static void registerKeywords( Keywords& keys );
      72             :   explicit AdjacencyMatrixBase(const ActionOptions&);
      73             : /// Create the connection object
      74             :   virtual void setupConnector( const unsigned& id, const unsigned& i, const unsigned& j, const std::vector<std::string>& desc ) = 0;
      75             : /// None of these things are allowed
      76          23 :   bool isPeriodic() { return false; }
      77             :   Vector getCentralAtom() { plumed_merror("cannot find central atoms for adjacency matrix actions"); Vector dum; return dum; }
      78             : /// Get the atom number
      79             :   AtomNumber getAbsoluteIndexOfCentralAtom( const unsigned& i ) const ;
      80             : };
      81             : 
      82             : inline
      83             : AdjacencyMatrixVessel* AdjacencyMatrixBase::getAdjacencyVessel() {
      84             :   return mat;
      85             : }
      86             : 
      87             : inline
      88             : unsigned AdjacencyMatrixBase::getBaseColvarNumber( const unsigned& inum ) const {
      89   899652436 :   if( atom_lab[inum].first>0 ) return atom_lab[inum].first-1;
      90             :   return 0;
      91             : }
      92             : 
      93             : inline
      94         504 : AtomNumber AdjacencyMatrixBase::getAbsoluteIndexOfCentralAtom( const unsigned& iatom ) const {
      95        1008 :   if( atom_lab[iatom].first>0 ) {
      96         156 :     unsigned mmc=atom_lab[ iatom ].first - 1;
      97         312 :     return mybasemulticolvars[mmc]->getAbsoluteIndexOfCentralAtom( atom_lab[iatom].second );
      98             :   }
      99         348 :   return ActionAtomistic::getAbsoluteIndex( atom_lab[iatom].second );
     100             : }
     101             : 
     102             : }
     103             : }
     104             : 
     105             : #endif

Generated by: LCOV version 1.13