LCOV - code coverage report
Current view: top level - reference - MultiReferenceBase.h (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 12 14 85.7 %
Date: 2018-12-19 07:49:13 Functions: 6 8 75.0 %

          Line data    Source code
       1             : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       2             :    Copyright (c) 2013-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             : #ifndef __PLUMED_reference_MultiReferenceBase_h
      23             : #define __PLUMED_reference_MultiReferenceBase_h
      24             : 
      25             : #include "ReferenceConfiguration.h"
      26             : #include "tools/Matrix.h"
      27             : 
      28             : namespace PLMD {
      29             : 
      30             : class MultiReferenceBase {
      31             : private:
      32             : /// Everything has been set
      33             :   bool wasSet;
      34             : /// Skip all checking allows users to do really dodgy stuff :-)
      35             :   bool skipchecks;
      36             : /// The type of metric we are using
      37             :   std::string mtype;
      38             : protected:
      39             : /// These are the configurations that serve as references
      40             :   std::vector<ReferenceConfiguration*> frames;
      41             : /// Read something from the last frame
      42             :   template <class T>
      43             :   void parse(const std::string& key, T& val );
      44             : public:
      45             :   MultiReferenceBase( const std::string& type, const bool& checksoff );
      46             : /// Destructor deletes all polymorphic pointers
      47             :   virtual ~MultiReferenceBase();
      48             : /// Delete all the data in the reference object
      49             :   void clearFrames();
      50           0 :   virtual void clearRestOfData() {};
      51             : /// Read a frame from the input
      52             :   void readFrame( PDB& pdb );
      53             : /// Find what is required of us from the reference frames
      54             :   void getAtomAndArgumentRequirements( std::vector<AtomNumber>& atoms, std::vector<std::string>& args );
      55             : /// Finish setup of frames
      56             : //  void setNumberOfAtomsAndArguments( const unsigned& natoms, const unsigned& nargs );
      57             : /// Do additional reading required by derived class
      58          12 :   virtual void readRestOfFrame() {}
      59             : /// Do additional resizing required by derived class
      60           0 :   virtual void resizeRestOfFrame() {}
      61             : /// Return the size of the frames vector
      62             :   unsigned getNumberOfReferenceFrames() const ;
      63             : /// Calculate the distance from one of the reference points
      64             :   double calcDistanceFromConfiguration( const unsigned& ifunc, const std::vector<Vector>& pos, const Pbc& pbc,
      65             :                                         const std::vector<Value*>& arg, ReferenceValuePack& myder, const bool& squared ) const ;
      66             : /// Return the ith reference frame
      67             :   ReferenceConfiguration* getFrame( const unsigned& iframe );
      68             : /// Copy a reference configuration into the multi reference object
      69             :   void copyFrame( ReferenceConfiguration* frameToCopy );
      70             : /// Set the weight of the ith frame
      71             :   void setWeights( const std::vector<double>& ww );
      72             : /// Retrieve the weight of one of the frames
      73             :   double getWeight( const unsigned& ifram ) const ;
      74             : /// Calculate the distances between all the frames and store in a matrix
      75             :   void calculateAllDistances( const Pbc& pbc, const std::vector<Value*> & vals, Communicator& comm, Matrix<double>& distances, const bool& squared );
      76             : };
      77             : 
      78             : template <class T>
      79         252 : void MultiReferenceBase::parse(const std::string& key, T& val ) {
      80         252 :   frames[frames.size()-1]->parse(key,val);
      81         252 : }
      82             : 
      83             : inline
      84      113677 : double MultiReferenceBase::calcDistanceFromConfiguration( const unsigned& ifunc, const std::vector<Vector>& pos, const Pbc& pbc,
      85             :     const std::vector<Value*>& arg, ReferenceValuePack& myder, const bool& squared ) const {
      86      113677 :   return frames[ifunc]->calculate( pos, pbc, arg, myder, squared );
      87             : }
      88             : 
      89             : inline
      90         698 : unsigned MultiReferenceBase::getNumberOfReferenceFrames() const {
      91         698 :   return frames.size();
      92             : }
      93             : 
      94             : inline
      95         294 : double MultiReferenceBase::getWeight( const unsigned& ifram ) const {
      96             :   plumed_dbg_assert( ifram<frames.size() );
      97         294 :   return frames[ifram]->getWeight();
      98             : }
      99             : 
     100             : inline
     101      112876 : ReferenceConfiguration* MultiReferenceBase::getFrame( const unsigned& iframe ) {
     102             :   plumed_dbg_assert( iframe<frames.size() );
     103      112876 :   return frames[iframe];
     104             : }
     105             : 
     106             : }
     107             : #endif

Generated by: LCOV version 1.13