LCOV - code coverage report
Current view: top level - core - Colvar.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 28 28 100.0 %
Date: 2025-12-04 11:19:34 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        2197 : Colvar::Colvar(const ActionOptions&ao):
      29             :   Action(ao),
      30             :   ActionAtomistic(ao),
      31        2197 :   ActionWithValue(ao) {
      32        2197 : }
      33             : 
      34        6492 : void Colvar::registerKeywords( Keywords& keys ) {
      35        6492 :   Action::registerKeywords( keys );
      36        6492 :   ActionWithValue::registerKeywords( keys );
      37        6492 :   ActionAtomistic::registerKeywords( keys );
      38        6492 :   keys.addFlag("NOPBC",false,"ignore the periodic boundary conditions when calculating distances");
      39        6492 : }
      40             : 
      41        2792 : void Colvar::requestAtoms(const std::vector<AtomNumber> & a) {
      42             : // Tell actionAtomistic what atoms we are getting
      43        2792 :   ActionAtomistic::requestAtoms(a);
      44             : // Resize the derivatives of all atoms
      45        7089 :   for(unsigned i=0; i<getNumberOfComponents(); ++i) {
      46        4298 :     getPntrToComponent(i)->resizeDerivatives(3*a.size()+9);
      47             :   }
      48        2791 : }
      49             : 
      50      145806 : void Colvar::apply() {
      51      145806 :   if( !checkForForces() ) {
      52       33560 :     return ;
      53             :   }
      54      112246 :   unsigned ind=0;
      55      112246 :   if( getNumberOfAtoms()>0 ) {
      56      112158 :     setForcesOnAtoms( getForcesToApply(), ind );
      57             :   } else {
      58          88 :     setForcesOnCell( getForcesToApply(), ind );
      59             :   }
      60             : }
      61             : 
      62      112016 : void Colvar::setBoxDerivativesNoPbc(Value* v) {
      63             :   Tensor virial;
      64             :   unsigned nat=getNumberOfAtoms();
      65    16530004 :   for(unsigned i=0; i<nat; i++)
      66    16417988 :     virial-=Tensor(getPosition(i),
      67    16417988 :                    Vector(v->getDerivative(3*i+0),
      68             :                           v->getDerivative(3*i+1),
      69    16417988 :                           v->getDerivative(3*i+2)));
      70      112016 :   setBoxDerivatives(v,virial);
      71      112016 : }
      72             : }

Generated by: LCOV version 1.16