LCOV - code coverage report
Current view: top level - multicolvar - MultiColvar.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 35 37 94.6 %
Date: 2018-12-19 07:49:13 Functions: 6 7 85.7 %

          Line data    Source code
       1             : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       2             :    Copyright (c) 2012-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 "MultiColvar.h"
      23             : #include "core/PlumedMain.h"
      24             : #include "core/ActionSet.h"
      25             : #include "core/SetupMolInfo.h"
      26             : #include "vesselbase/Vessel.h"
      27             : #include "tools/Pbc.h"
      28             : #include <vector>
      29             : #include <string>
      30             : 
      31             : using namespace std;
      32             : namespace PLMD {
      33             : namespace multicolvar {
      34             : 
      35         117 : void MultiColvar::registerKeywords( Keywords& keys ) {
      36         117 :   MultiColvarBase::registerKeywords( keys );
      37             :   keys.reserve("numbered","ATOMS","the atoms involved in each of the collective variables you wish to calculate. "
      38             :                "Keywords like ATOMS1, ATOMS2, ATOMS3,... should be listed and one CV will be "
      39             :                "calculated for each ATOM keyword you specify (all ATOM keywords should "
      40             :                "define the same number of atoms).  The eventual number of quantities calculated by this "
      41         117 :                "action will depend on what functions of the distribution you choose to calculate.");
      42         117 :   keys.reset_style("ATOMS","atoms");
      43         117 : }
      44             : 
      45          98 : MultiColvar::MultiColvar(const ActionOptions&ao):
      46             :   Action(ao),
      47          98 :   MultiColvarBase(ao)
      48             : {
      49          98 : }
      50             : 
      51          57 : void MultiColvar::readAtoms( int& natoms, std::vector<AtomNumber> all_atoms ) {
      52          57 :   if( atom_lab.size()==0 && keywords.exists("ATOMS")  ) readAtomsLikeKeyword( "ATOMS", natoms, all_atoms );
      53             :   // Setup the multicolvar base
      54          57 :   setupMultiColvarBase( all_atoms );
      55          57 : }
      56             : 
      57          45 : void MultiColvar::readAtomsLikeKeyword( const std::string & key, int& natoms, std::vector<AtomNumber>& all_atoms ) {
      58          45 :   plumed_assert( !usespecies );
      59          90 :   if( all_atoms.size()>0 ) return;
      60             : 
      61          45 :   std::vector<AtomNumber> t;
      62         953 :   for(int i=1;; ++i ) {
      63         953 :     parseAtomList(key, i, t );
      64         953 :     if( t.empty() ) break;
      65             : 
      66         908 :     log.printf("  Colvar %d is calculated from atoms : ", i);
      67         908 :     for(unsigned j=0; j<t.size(); ++j) log.printf("%d ",t[j].serial() );
      68         908 :     log.printf("\n");
      69             : 
      70         908 :     if( i==1 && natoms<0 ) { natoms=t.size(); ablocks.resize(natoms); }
      71         902 :     else if( i==1 ) ablocks.resize(natoms);
      72         908 :     if( t.size()!=natoms ) {
      73           0 :       std::string ss; Tools::convert(i,ss);
      74           0 :       error(key + ss + " keyword has the wrong number of atoms");
      75             :     }
      76        3388 :     for(unsigned j=0; j<natoms; ++j) {
      77        2480 :       ablocks[j].push_back( natoms*(i-1)+j ); all_atoms.push_back( t[j] );
      78        2480 :       atom_lab.push_back( std::pair<unsigned,unsigned>( 0, natoms*(i-1)+j ) );
      79             :     }
      80         908 :     t.resize(0);
      81         908 :   }
      82          45 :   if( all_atoms.size()>0 ) {
      83          45 :     nblock=0;
      84          45 :     for(unsigned i=0; i<ablocks[0].size(); ++i) addTaskToList( i );
      85          45 :   }
      86             : }
      87             : 
      88             : }
      89        2523 : }

Generated by: LCOV version 1.13