LCOV - code coverage report
Current view: top level - reference - Direction.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 28 30 93.3 %
Date: 2024-10-11 08:09:47 Functions: 10 12 83.3 %

          Line data    Source code
       1             : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       2             :    Copyright (c) 2014-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 "Direction.h"
      23             : #include "MetricRegister.h"
      24             : 
      25             : namespace PLMD {
      26             : 
      27       10439 : PLUMED_REGISTER_METRIC(Direction,"DIRECTION")
      28             : 
      29         219 : Direction::Direction( const ReferenceConfigurationOptions& ro ):
      30             :   ReferenceConfiguration(ro),
      31             :   ReferenceAtoms(ro),
      32             :   ReferenceArguments(ro),
      33         219 :   normalized(false)
      34             : {
      35         219 : }
      36             : 
      37         219 : void Direction::read( const PDB& pdb ) {
      38         219 :   readAtomsFromPDB( pdb, true );
      39         219 :   readArgumentsFromPDB( pdb );
      40         219 : }
      41             : 
      42         494 : void Direction::setDirection( const std::vector<Vector>& conf, const std::vector<double>& args ) {
      43         494 :   std::vector<double> sigma( args.size(), 1.0 ); setReferenceArguments( args, sigma );
      44             : 
      45         494 :   reference_atoms.resize( conf.size() ); align.resize( conf.size() );
      46         494 :   displace.resize( conf.size() ); atom_der_index.resize( conf.size() );
      47         715 :   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         494 : }
      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         909 :   for(unsigned i=0; i<reference_args.size(); ++i) reference_args[i] += weight*dir.reference_args[i];
      53         303 :   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          32 :   for(unsigned i=0; i<reference_args.size(); ++i) reference_args[i] = 0.;
      58          38 :   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");
      64             : }
      65             : 
      66          10 : void Direction::extractArgumentDisplacement( const std::vector<Value*>& vals, const std::vector<double>& arg, std::vector<double>& dirout ) const {
      67          10 :   for(unsigned i=0; i<getNumberOfReferenceArguments(); ++i) dirout[i]=getReferenceArgument(i);
      68          10 : }
      69             : 
      70          10 : void Direction::extractAtomicDisplacement( const std::vector<Vector>& pos, std::vector<Vector>& dirout ) const {
      71          80 :   for(unsigned i=0; i<getNumberOfAtoms(); ++i) dirout[i]=getReferencePosition(i);
      72          10 : }
      73             : 
      74             : }

Generated by: LCOV version 1.15