Line data Source code
1 : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 : Copyright (c) 2013-2020 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_AdjacencyMatrixVessel_h 23 : #define __PLUMED_adjmat_AdjacencyMatrixVessel_h 24 : 25 : #include "vesselbase/StoreDataVessel.h" 26 : #include "multicolvar/MultiColvarBase.h" 27 : 28 : namespace PLMD { 29 : namespace adjmat { 30 : 31 : class AdjacencyMatrixBase; 32 : 33 : // One school of thought would have it that it makes more sense to 34 : // have the functionality contained within this class in AdjacencyMatrixBase 35 : // I have not done this as I can inherit many useful things from StoreDataVessel 36 : // If I put this functionality within AdjacencyMatrixBase I would have to reimplement 37 : // these features. 38 : 39 23 : class AdjacencyMatrixVessel : public vesselbase::StoreDataVessel { 40 : friend class AdjacencyMatrixBase; 41 : friend class ActionWithInputMatrix; 42 : private: 43 : /// Pointer to underlying action 44 : AdjacencyMatrixBase* function; 45 : /// Is the matrix symmetric and are we calculating hbonds 46 : bool symmetric, hbonds; 47 : public: 48 : static void registerKeywords( Keywords& keys ); 49 : /// Constructor 50 : explicit AdjacencyMatrixVessel( const vesselbase::VesselOptions& ); 51 : /// Get the underlying adjacency matrix action object 52 : AdjacencyMatrixBase* getMatrixAction(); 53 : /// Is an element of the matrix currently active 54 : bool matrixElementIsActive( const unsigned& ielem, const unsigned& jelem ) const ; 55 : /// Get the index that a particular element is stored in from the matrix indices 56 : unsigned getStoreIndexFromMatrixIndices( const unsigned& ielem, const unsigned& jelem ) const ; 57 : /// Get the adjacency matrix 58 : void retrieveMatrix( DynamicList<unsigned>& myactive_elements, Matrix<double>& mymatrix ); 59 : /// Get the neighbour list based on the adjacency matrix 60 : void retrieveAdjacencyLists( std::vector<unsigned>& nneigh, Matrix<unsigned>& adj_list ); 61 : /// Retrieve the list of edges in the adjacency matrix/graph 62 : void retrieveEdgeList( unsigned& nedge, std::vector<std::pair<unsigned,unsigned> >& edge_list ); 63 : /// 64 : void getMatrixIndices( const unsigned& code, unsigned& i, unsigned& j ) const ; 65 : /// Can we think of the matrix as an undirected graph 66 : bool undirectedGraph() const ; 67 : /// Is the matrix symmetric 68 : bool isSymmetric() const ; 69 : /// Get the number of rows 70 : unsigned getNumberOfRows() const ; 71 : /// Get the number of columns 72 : unsigned getNumberOfColumns() const ; 73 : /// Are these two nodes connected 74 : bool nodesAreConnected( const unsigned& iatom, const unsigned& jatom ) const ; 75 : /// Get the cutoff that we are using for connections 76 : double getCutoffForConnection() const ; 77 : /// 78 : Vector getNodePosition( const unsigned& taskIndex ) const ; 79 : }; 80 : 81 : } 82 : } 83 : #endif 84 :