LCOV - code coverage report
Current view: top level - adjmat - ClusterAnalysisBase.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 43 47 91.5 %
Date: 2018-12-19 07:49:13 Functions: 14 17 82.4 %

          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             : #include "ClusterAnalysisBase.h"
      23             : 
      24             : namespace PLMD {
      25             : namespace adjmat {
      26             : 
      27          33 : void ClusterAnalysisBase::registerKeywords( Keywords& keys ) {
      28          33 :   MultiColvarBase::registerKeywords( keys );
      29          33 :   keys.add("compulsory","CLUSTERS","the label of the action that does the clustering");
      30          33 : }
      31             : 
      32          29 : ClusterAnalysisBase::ClusterAnalysisBase(const ActionOptions& ao):
      33             :   Action(ao),
      34             :   MultiColvarBase(ao),
      35             :   myfvals(0,0),
      36             :   myfatoms( myfvals, this ),
      37          29 :   myclusters(NULL)
      38             : {
      39             :   // This makes these colvars behave appropriately with dump and analysis
      40          29 :   matsums=usespecies=true; std::vector<AtomNumber> fake_atoms;
      41             :   // Find what action we are taking the clusters from
      42          29 :   if( !parseMultiColvarAtomList("CLUSTERS",-1,fake_atoms ) ) error("unable to interpret input CLUSTERS" );
      43          29 :   if( mybasemulticolvars.size()!=1 ) error("should be exactly one multicolvar input");
      44          29 :   atom_lab.resize(0); myclusters = dynamic_cast<ClusteringBase*>( mybasemulticolvars[0] );
      45          29 :   if( !myclusters ) error("input label is not that of a DFS object");
      46             :   // Setup the atom pack
      47          29 :   myfatoms.setNumberOfAtoms( myclusters->getNumberOfNodes() );
      48          29 :   myfvals.getIndices().resize( myclusters->getNumberOfNodes() );
      49          29 :   for(unsigned i=0; i<myclusters->getNumberOfNodes(); ++i) myfatoms.setAtomIndex( i, i );
      50          29 : }
      51             : 
      52           7 : void ClusterAnalysisBase::turnOnDerivatives() {
      53             :   // Check for dubious vessels
      54          16 :   for(unsigned i=0; i<getNumberOfVessels(); ++i) {
      55           9 :     if( getPntrToVessel(i)->getName()=="MEAN" ) error("MEAN of cluster is not differentiable");
      56           9 :     if( getPntrToVessel(i)->getName()=="VMEAN" ) error("VMEAN of cluster is not differentiable");
      57             :   }
      58           7 :   MultiColvarBase::turnOnDerivatives();
      59           7 : }
      60             : 
      61        2054 : unsigned ClusterAnalysisBase::getNumberOfQuantities() const {
      62        2054 :   return myclusters->getNumberOfQuantities();
      63             : }
      64             : 
      65    15973831 : unsigned ClusterAnalysisBase::getNumberOfNodes() const {
      66    15973831 :   return myclusters->getNumberOfNodes();
      67             : }
      68             : 
      69           4 : unsigned ClusterAnalysisBase::getNumberOfClusters() const {
      70           4 :   return myclusters->getNumberOfClusters();
      71             : }
      72             : 
      73          11 : bool ClusterAnalysisBase::isPeriodic() {
      74          11 :   return mybasemulticolvars[0]->isPeriodic();
      75             : }
      76             : 
      77          37 : void ClusterAnalysisBase::retrieveAtomsInCluster( const unsigned& clust, std::vector<unsigned>& myatoms ) const {
      78          37 :   myclusters->retrieveAtomsInCluster( clust, myatoms );
      79          37 : }
      80             : 
      81           1 : bool ClusterAnalysisBase::nodeIsActive( const unsigned& ind ) const {
      82           1 :   return myclusters->isCurrentlyActive( ind );
      83             : }
      84             : 
      85        1699 : void ClusterAnalysisBase::getPropertiesOfNode( const unsigned& ind, std::vector<double>& vals ) const {
      86        1699 :   myclusters->getInputData( ind, false, myfatoms, vals );
      87        1699 : }
      88             : 
      89        1589 : void ClusterAnalysisBase::getNodePropertyDerivatives( const unsigned& ind, MultiValue& myvals ) const {
      90        1589 :   myvals=myclusters->getInputDerivatives( ind, false, myfatoms );
      91        1589 : }
      92             : 
      93        1975 : Vector ClusterAnalysisBase::getPositionOfAtomForLinkCells( const unsigned& iatom ) const {
      94        1975 :   return myclusters->getPositionOfAtomForLinkCells( iatom );
      95             : }
      96             : 
      97           0 : double ClusterAnalysisBase::getCutoffForConnection() const {
      98           0 :   return myclusters->getCutoffForConnection();
      99             : }
     100             : 
     101           0 : bool ClusterAnalysisBase::areConnected( const unsigned& ind1, const unsigned& ind2 ) const {
     102           0 :   return myclusters->areConnected( ind1, ind2 );
     103             : }
     104             : 
     105             : }
     106        2523 : }

Generated by: LCOV version 1.13