LCOV - code coverage report
Current view: top level - adjmat - AdjacencyMatrixBase.h (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 13 14 92.9 %
Date: 2018-12-19 07:49:13 Functions: 6 8 75.0 %

          Line data    Source code
       1             : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       2             :    Copyright (c) 2015-2018 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          15 : 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          17 :   bool isPeriodic() { return false; }
      77             :   Vector getCentralAtom() { plumed_merror("cannot find central atoms for adjacency matrix actions"); Vector dum; return dum; }
      78             : /// Transforms the stored values in whatever way is required
      79             :   virtual double transformStoredValues( const std::vector<double>& myvals, unsigned& vout, double& df ) const ;
      80             : /// Used to check for connections between atoms
      81             :   virtual bool checkForConnection( const std::vector<double>& myvals ) const;
      82             : /// Get the atom number
      83             :   AtomNumber getAbsoluteIndexOfCentralAtom( const unsigned& i ) const ;
      84             : };
      85             : 
      86             : inline
      87             : AdjacencyMatrixVessel* AdjacencyMatrixBase::getAdjacencyVessel() {
      88             :   return mat;
      89             : }
      90             : 
      91             : inline
      92     2451101 : unsigned AdjacencyMatrixBase::getBaseColvarNumber( const unsigned& inum ) const {
      93     2451101 :   if( atom_lab[inum].first>0 ) return atom_lab[inum].first-1;
      94     2091063 :   return 0;
      95             : }
      96             : 
      97             : inline
      98         156 : AtomNumber AdjacencyMatrixBase::getAbsoluteIndexOfCentralAtom( const unsigned& iatom ) const {
      99         156 :   if( atom_lab[iatom].first>0 ) {
     100         156 :     unsigned mmc=atom_lab[ iatom ].first - 1;
     101         156 :     return mybasemulticolvars[mmc]->getAbsoluteIndexOfCentralAtom( atom_lab[iatom].second );
     102             :   }
     103           0 :   return ActionAtomistic::getAbsoluteIndex( atom_lab[iatom].second );
     104             : }
     105             : 
     106             : inline
     107       12411 : double AdjacencyMatrixBase::transformStoredValues( const std::vector<double>& myvals, unsigned& vout, double& df  ) const {
     108       12411 :   plumed_dbg_assert( myvals.size()==2 ); vout=1; df=1; return myvals[1];
     109             : }
     110             : 
     111             : inline
     112       11169 : bool AdjacencyMatrixBase::checkForConnection( const std::vector<double>& myvals ) const {
     113       11169 :   return (myvals[0]*myvals[1]>epsilon);
     114             : }
     115             : 
     116             : }
     117             : }
     118             : 
     119             : #endif

Generated by: LCOV version 1.13