LCOV - code coverage report
Current view: top level - core - Colvar.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 29 29 100.0 %
Date: 2026-11-05 10:19:04 Functions: 5 6 83.3 %

          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             : 
      26             : namespace PLMD {
      27             : 
      28        3280 : Colvar::Colvar(const ActionOptions&ao):
      29             :   Action(ao),
      30             :   ActionAtomistic(ao),
      31        3280 :   ActionWithValue(ao) {
      32        3280 : }
      33             : 
      34       10000 : void Colvar::registerKeywords( Keywords& keys ) {
      35       10000 :   Action::registerKeywords( keys );
      36       10000 :   ActionWithValue::registerKeywords( keys );
      37       10000 :   ActionAtomistic::registerKeywords( keys );
      38       10000 :   keys.addFlag("NOPBC",false,"ignore the periodic boundary conditions when calculating distances");
      39       10000 : }
      40             : 
      41        3748 : void Colvar::requestAtoms(const std::vector<AtomNumber> & a) {
      42             : // Tell actionAtomistic what atoms we are getting
      43        3748 :   ActionAtomistic::requestAtoms(a);
      44             : // Resize the derivatives of all atoms
      45        8915 :   for(unsigned i=0; i<getNumberOfComponents(); ++i) {
      46        5168 :     getPntrToComponent(i)->resizeDerivatives(3*a.size()+9);
      47             :   }
      48        3747 : }
      49             : 
      50      310052 : void Colvar::apply() {
      51      310052 :   if( !checkForForces() ) {
      52       34521 :     return ;
      53             :   }
      54      275531 :   unsigned ind=0;
      55      275531 :   if( getNumberOfAtoms()>0 ) {
      56      275443 :     setForcesOnAtoms( getForcesToApply(), ind );
      57             :   } else {
      58          88 :     setForcesOnCell( getForcesToApply(), ind );
      59             :   }
      60             : }
      61             : 
      62      110799 : void Colvar::setBoxDerivativesNoPbc(Value* v) {
      63      110799 :   Tensor virial;
      64             :   unsigned nat=getNumberOfAtoms();
      65    16519546 :   for(unsigned i=0; i<nat; i++)
      66    16408747 :     virial-=Tensor(getPosition(i),
      67    16408747 :                    Vector(v->getDerivative(3*i+0),
      68             :                           v->getDerivative(3*i+1),
      69    16408747 :                           v->getDerivative(3*i+2)));
      70      110799 :   setBoxDerivatives(v,virial);
      71      110799 : }
      72             : }

Generated by: LCOV version 1.16