LCOV - code coverage report
Current view: top level - colvar - ColvarInput.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 11 26 42.3 %
Date: 2025-12-04 11:19:34 Functions: 2 3 66.7 %

          Line data    Source code
       1             : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       2             :    Copyright (c) 2025 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 "ColvarInput.h"
      23             : #include "core/Colvar.h"
      24             : 
      25             : namespace PLMD {
      26             : namespace colvar {
      27             : 
      28      121043 : ColvarInput ColvarInput::createColvarInput( unsigned m,
      29             :     const std::vector<Vector>& p,
      30             :     const Colvar* colv ) {
      31             :   return ColvarInput( m,
      32             :                       p.size(),
      33             :                       &p[0][0],
      34             :                       colv->getMasses().data(),
      35      121043 :                       colv->getCharges(true).data(),
      36      121043 :                       colv->getPbc() );
      37             : }
      38             : 
      39     2184426 : void ColvarInput::setBoxDerivativesNoPbc( const ColvarInput& inpt, ColvarOutput& out ) {
      40             :   //Both version passes the tests, we should discuss wicht onw might be better
      41             : 
      42     2184426 :   unsigned nat=inpt.pos.size();
      43     4610863 :   for(unsigned i=0; i<out.ncomponents; ++i) {
      44             :     Tensor v;
      45             :     v.zero();
      46     7485900 :     for(unsigned j=0; j<nat; j++) {
      47     5059463 :       v-=Tensor(Vector(inpt.pos[j][0],inpt.pos[j][1],inpt.pos[j][2]),
      48    10118926 :                 out.derivs.getAtomDerivatives(i,j));
      49             :     }
      50     2426437 :     out.virial.set( i, v );
      51             :   }
      52     2184426 : }
      53             : 
      54           0 : void ColvarInput::setBoxDerivativesNoPbc_inplace( const ColvarInput& inpt, ColvarOutput& out ) {
      55             :   //now with no extra allocated memory:
      56           0 :   unsigned nat=inpt.pos.size();
      57           0 :   for(unsigned i=0; i<out.ncomponents; ++i) {
      58             :     auto v = out.virial.getView(i);
      59             :     LoopUnroller<9>::_zero(v.data());
      60           0 :     for(unsigned j=0; j<nat; j++) {
      61           0 :       const auto deriv =  out.derivs.getView(i,j);
      62           0 :       v[0] -= inpt.pos[j][0]*deriv[0];
      63           0 :       v[1] -= inpt.pos[j][0]*deriv[1];
      64           0 :       v[2] -= inpt.pos[j][0]*deriv[2];
      65             : 
      66           0 :       v[3] -= inpt.pos[j][1]*deriv[0];
      67           0 :       v[4] -= inpt.pos[j][1]*deriv[1];
      68           0 :       v[5] -= inpt.pos[j][1]*deriv[2];
      69             : 
      70           0 :       v[6] -= inpt.pos[j][2]*deriv[0];
      71           0 :       v[7] -= inpt.pos[j][2]*deriv[1];
      72           0 :       v[8] -= inpt.pos[j][2]*deriv[2];
      73             :     }
      74             :   }
      75           0 : }
      76             : 
      77             : } // namespace colvar
      78             : } // namespace PLMD

Generated by: LCOV version 1.16