LCOV - code coverage report
Current view: top level - reference - Direction.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 29 31 93.5 %
Date: 2020-11-18 11:20:57 Functions: 12 14 85.7 %

          Line data    Source code
       1             : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       2             :    Copyright (c) 2014-2019 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 "Direction.h"
      23             : #include "MetricRegister.h"
      24             : 
      25             : namespace PLMD {
      26             : 
      27        6462 : PLUMED_REGISTER_METRIC(Direction,"DIRECTION")
      28             : 
      29         211 : Direction::Direction( const ReferenceConfigurationOptions& ro ):
      30             :   ReferenceConfiguration(ro),
      31             :   ReferenceAtoms(ro),
      32             :   ReferenceArguments(ro),
      33         211 :   normalized(false)
      34             : {
      35         211 : }
      36             : 
      37           8 : void Direction::read( const PDB& pdb ) {
      38           8 :   readAtomsFromPDB( pdb );
      39           8 :   readArgumentsFromPDB( pdb );
      40           8 : }
      41             : 
      42         498 : void Direction::setDirection( const std::vector<Vector>& conf, const std::vector<double>& args ) {
      43         996 :   std::vector<double> sigma( args.size(), 1.0 ); setReferenceArguments( args, sigma );
      44             : 
      45        1494 :   reference_atoms.resize( conf.size() ); align.resize( conf.size() );
      46        1494 :   displace.resize( conf.size() ); atom_der_index.resize( conf.size() );
      47        2586 :   for(unsigned i=0; i<conf.size(); ++i) { align[i]=1.0; displace[i]=1.0; atom_der_index[i]=i; reference_atoms[i]=conf[i]; }
      48         498 : }
      49             : 
      50         303 : void Direction::addDirection( const double& weight, const Direction& dir ) {
      51             :   plumed_dbg_assert( dir.getNumberOfReferenceArguments()==getNumberOfReferenceArguments() && dir.reference_atoms.size()==reference_atoms.size() );
      52        3030 :   for(unsigned i=0; i<reference_args.size(); ++i) reference_args[i] += weight*dir.reference_args[i];
      53         606 :   for(unsigned i=0; i<reference_atoms.size(); ++i) reference_atoms[i] += weight*reference_atoms.size()*dir.reference_atoms[i];
      54         303 : }
      55             : 
      56          12 : void Direction::zeroDirection() {
      57          84 :   for(unsigned i=0; i<reference_args.size(); ++i) reference_args[i] = 0.;
      58         102 :   for(unsigned i=0; i<reference_atoms.size(); ++i) reference_atoms[i].zero();
      59          12 : }
      60             : 
      61           0 : double Direction::calc( const std::vector<Vector>& pos, const Pbc& pbc, const std::vector<Value*>& vals, const std::vector<double>& args,
      62             :                         ReferenceValuePack& myder, const bool& squared ) const {
      63           0 :   plumed_merror("You should never be calling calc for a direction"); return 1.0;
      64             : }
      65             : 
      66           8 : void Direction::extractArgumentDisplacement( const std::vector<Value*>& vals, const std::vector<double>& arg, std::vector<double>& dirout ) const {
      67           8 :   for(unsigned i=0; i<getNumberOfReferenceArguments(); ++i) dirout[i]=getReferenceArgument(i);
      68           8 : }
      69             : 
      70           8 : void Direction::extractAtomicDisplacement( const std::vector<Vector>& pos, std::vector<Vector>& dirout ) const {
      71         120 :   for(unsigned i=0; i<getNumberOfAtoms(); ++i) dirout[i]=getReferencePosition(i);
      72           8 : }
      73             : 
      74        4839 : }

Generated by: LCOV version 1.13