LCOV - code coverage report
Current view: top level - multicolvar - AtomValuePack.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 46 46 100.0 %
Date: 2018-12-19 07:49:13 Functions: 6 6 100.0 %

          Line data    Source code
       1             : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       2             :    Copyright (c) 2014-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 "AtomValuePack.h"
      23             : #include "CatomPack.h"
      24             : #include "tools/LinkCells.h"
      25             : 
      26             : namespace PLMD {
      27             : namespace multicolvar {
      28             : 
      29      420459 : AtomValuePack::AtomValuePack( MultiValue& vals, MultiColvarBase const * mcolv ):
      30             :   myvals(vals),
      31             :   mycolv(mcolv),
      32             :   natoms(0),
      33      420459 :   indices( vals.getIndices() ),
      34      420484 :   sort_vector( vals.getSortIndices() ),
      35     1261465 :   myatoms( vals.getAtomVector() )
      36             : {
      37      420549 :   if( indices.size()!=mcolv->getNumberOfAtoms() ) {
      38       33642 :     indices.resize( mcolv->getNumberOfAtoms() );
      39       33654 :     sort_vector.resize( mcolv->getNumberOfAtoms() );
      40       33654 :     myatoms.resize( mcolv->getNumberOfAtoms() );
      41             :   }
      42      420480 : }
      43             : 
      44      191418 : unsigned AtomValuePack::setupAtomsFromLinkCells( const std::vector<unsigned>& cind, const Vector& cpos, const LinkCells& linkcells ) {
      45      191418 :   natoms=cind.size(); for(unsigned i=0; i<natoms; ++i) indices[i]=cind[i];
      46      191447 :   linkcells.retrieveNeighboringAtoms( cpos, natoms, indices );
      47      197729 :   for(unsigned i=0; i<natoms; ++i) myatoms[i]=mycolv->getPositionOfAtomForLinkCells( indices[i] ) - cpos;
      48      191432 :   if( mycolv->usesPbc() ) mycolv->applyPbc( myatoms, natoms );
      49      191451 :   return natoms;
      50             : }
      51             : 
      52      382726 : void AtomValuePack::updateUsingIndices() {
      53      765552 :   if( myvals.updateComplete() ) return;
      54             : 
      55      297047 :   unsigned jactive=0;
      56    12507576 :   for(unsigned i=0; i<natoms; ++i) {
      57    12217314 :     unsigned base=3*indices[i];
      58    12214260 :     if( myvals.isActive( base ) ) { sort_vector[jactive]=indices[i]; jactive++; }
      59             :   }
      60      290262 :   std::sort( sort_vector.begin(), sort_vector.begin()+jactive );
      61             : 
      62      290247 :   myvals.emptyActiveMembers();
      63     4588566 :   for(unsigned i=0; i<jactive; ++i) {
      64     4298453 :     unsigned base=3*sort_vector[i]; // indices[i];
      65     4298368 :     myvals.putIndexInActiveArray( base );
      66     4295538 :     myvals.putIndexInActiveArray( base + 1 );
      67     4295273 :     myvals.putIndexInActiveArray( base + 2 );
      68             :   }
      69      290113 :   unsigned nvir=3*mycolv->getNumberOfAtoms();
      70      290210 :   if( myvals.isActive( nvir ) ) {
      71      220574 :     for(unsigned i=0; i<9; ++i) myvals.putIndexInActiveArray( nvir + i );
      72             :   }
      73      289988 :   myvals.completeUpdate();
      74             : }
      75             : 
      76      548071 : void AtomValuePack::addComDerivatives( const int& ind, const Vector& der, CatomPack& catom_der ) {
      77      548071 :   if( ind<0 ) {
      78       73164 :     for(unsigned ider=0; ider<catom_der.getNumberOfAtomsWithDerivatives(); ++ider) {
      79       37814 :       unsigned jder=3*catom_der.getIndex(ider);
      80       37814 :       myvals.addTemporyDerivative( jder+0, catom_der.getDerivative(ider,0,der) );
      81       37814 :       myvals.addTemporyDerivative( jder+1, catom_der.getDerivative(ider,1,der) );
      82       37814 :       myvals.addTemporyDerivative( jder+2, catom_der.getDerivative(ider,2,der) );
      83             :     }
      84             :   } else {
      85     1027906 :     for(unsigned ider=0; ider<catom_der.getNumberOfAtomsWithDerivatives(); ++ider) {
      86      515185 :       unsigned jder=3*catom_der.getIndex(ider);
      87      515185 :       myvals.addDerivative( ind, jder+0, catom_der.getDerivative(ider,0,der) );
      88      515185 :       myvals.addDerivative( ind, jder+1, catom_der.getDerivative(ider,1,der) );
      89      515185 :       myvals.addDerivative( ind, jder+2, catom_der.getDerivative(ider,2,der) );
      90             :     }
      91             :   }
      92      548071 : }
      93             : 
      94             : }
      95        2523 : }

Generated by: LCOV version 1.13