LCOV - code coverage report
Current view: top level - core - Colvar.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 30 30 100.0 %
Date: 2024-10-18 13:59:31 Functions: 6 7 85.7 %

          Line data    Source code
       1             : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       2             :    Copyright (c) 2011-2023 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 "Colvar.h"
      23             : #include "tools/OpenMP.h"
      24             : #include <vector>
      25             : #include <string>
      26             : 
      27             : namespace PLMD {
      28             : 
      29        2183 : Colvar::Colvar(const ActionOptions&ao):
      30             :   Action(ao),
      31             :   ActionAtomistic(ao),
      32        2183 :   ActionWithValue(ao)
      33             : {
      34        2183 : }
      35             : 
      36        6373 : void Colvar::registerKeywords( Keywords& keys ) {
      37        6373 :   Action::registerKeywords( keys );
      38        6373 :   ActionWithValue::registerKeywords( keys );
      39        6373 :   ActionAtomistic::registerKeywords( keys );
      40       12746 :   keys.addFlag("NOPBC",false,"ignore the periodic boundary conditions when calculating distances");
      41        6373 : }
      42             : 
      43        2616 : void Colvar::requestAtoms(const std::vector<AtomNumber> & a) {
      44             : // Tell actionAtomistic what atoms we are getting
      45        2616 :   ActionAtomistic::requestAtoms(a);
      46             : // Resize the derivatives of all atoms
      47        6733 :   for(int i=0; i<getNumberOfComponents(); ++i) getPntrToComponent(i)->resizeDerivatives(3*a.size()+9);
      48        2615 : }
      49             : 
      50      143623 : void Colvar::apply() {
      51      143623 :   if( !checkForForces() ) return ;
      52      110080 :   unsigned ind=0;
      53      110080 :   if( getNumberOfAtoms()>0 ) setForcesOnAtoms( getForcesToApply(), ind );
      54          88 :   else setForcesOnCell( getForcesToApply(), ind );
      55             : }
      56             : 
      57      454275 : void Colvar::setBoxDerivativesNoPbc( const std::vector<Vector>& pos, std::vector<std::vector<Vector> >& derivs, std::vector<Tensor>& virial ) {
      58      454275 :   unsigned nat=pos.size();
      59     1120920 :   for(unsigned i=0; i<virial.size(); ++i) {
      60     2190746 :     virial[i].zero(); for(unsigned j=0; j<nat; j++) virial[i]-=Tensor(pos[j],derivs[i][j]);
      61             :   }
      62      454275 : }
      63             : 
      64      112014 : void Colvar::setBoxDerivativesNoPbc(Value* v) {
      65      112014 :   Tensor virial;
      66             :   unsigned nat=getNumberOfAtoms();
      67    32947498 :   for(unsigned i=0; i<nat; i++) virial-=Tensor(getPosition(i),
      68    16417742 :                                           Vector(v->getDerivative(3*i+0),
      69             :                                               v->getDerivative(3*i+1),
      70    32835484 :                                               v->getDerivative(3*i+2)));
      71      112014 :   setBoxDerivatives(v,virial);
      72      112014 : }
      73             : }

Generated by: LCOV version 1.16