LCOV - code coverage report
Current view: top level - analysis - AnalysisBase.h (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 24 33 72.7 %
Date: 2024-10-11 08:09:47 Functions: 13 19 68.4 %

          Line data    Source code
       1             : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       2             :    Copyright (c) 2015-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             : #ifndef __PLUMED_analysis_AnalysisBase_h
      23             : #define __PLUMED_analysis_AnalysisBase_h
      24             : 
      25             : #include "core/ActionPilot.h"
      26             : #include "core/ActionAtomistic.h"
      27             : #include "core/ActionWithArguments.h"
      28             : #include "core/ActionWithValue.h"
      29             : #include "vesselbase/ActionWithVessel.h"
      30             : #include "DataCollectionObject.h"
      31             : 
      32             : namespace PLMD {
      33             : 
      34             : class ReferenceConfiguration;
      35             : 
      36             : namespace analysis {
      37             : 
      38             : /**
      39             : \ingroup INHERIT
      40             : This is the abstract base class to use for implementing new methods for analyzing the trajectory. You can find
      41             : \ref AddingAnAnalysis "information" on how to use it to implement new analysis methods here.
      42             : 
      43             : */
      44             : 
      45             : class AnalysisBase :
      46             :   public ActionPilot,
      47             :   public ActionWithValue,
      48             :   public ActionAtomistic,
      49             :   public ActionWithArguments,
      50             :   public vesselbase::ActionWithVessel
      51             : {
      52             :   friend class ReselectLandmarks;
      53             :   friend class ReadDissimilarityMatrix;
      54             : protected:
      55             : /// The Analysis action that we are reusing data from
      56             :   AnalysisBase* my_input_data;
      57             : public:
      58             :   static void registerKeywords( Keywords& keys );
      59             :   explicit AnalysisBase(const ActionOptions&);
      60             : /// These are required because we inherit from both ActionAtomistic and ActionWithArguments
      61             :   void lockRequests() override;
      62             :   void unlockRequests() override;
      63             : /// Return the number of data points
      64             :   virtual unsigned getNumberOfDataPoints() const ;
      65             : /// Return the index of the data point in the base class
      66             :   virtual unsigned getDataPointIndexInBase( const unsigned& idata ) const ;
      67             : /// Return the weight of the ith point
      68             :   virtual double getWeight( const unsigned& idata );
      69             : /// Get the name of the metric that is being used
      70             :   virtual std::string getMetricName() const ;
      71             : /// Are we using memory in this calculation this affects the weights of points
      72             :   virtual bool usingMemory() const ;
      73             : /// Return the normalisation constant for the calculation
      74             :   virtual double getNormalization() const ;
      75             : /// Ensures that dissimilarities were set somewhere
      76             :   virtual bool dissimilaritiesWereSet() const ;
      77             : /// Get the information on how dissimilarities were calculated for output PDB
      78             :   virtual std::string getDissimilarityInstruction() const ;
      79             : /// Get the squared dissimilarity between two reference configurations
      80             :   virtual double getDissimilarity( const unsigned& i, const unsigned& j );
      81             : /// Get the indices of the atoms that have been stored
      82             :   virtual const std::vector<AtomNumber>& getAtomIndexes() const ;
      83             : /// Overwrite getArguments so we get arguments from underlying class
      84             :   virtual std::vector<Value*> getArgumentList();
      85             : /// Get the list of argument names in the base
      86             :   std::vector<std::string> getArgumentNames();
      87             : /// Get a reference configuration (in dimensionality reduction this returns the projection)
      88             :   virtual DataCollectionObject& getStoredData( const unsigned& idata, const bool& calcdist );
      89             : /// This actually performs the analysis
      90             :   virtual void performAnalysis()=0;
      91             : /// These overwrite things from inherited classes (this is a bit of a fudge)
      92           0 :   bool isPeriodic() override { plumed_error(); }
      93           0 :   unsigned getNumberOfDerivatives() override { plumed_error(); }
      94           0 :   void calculateNumericalDerivatives( ActionWithValue* a=NULL ) override { plumed_error(); }
      95             : /// Calculate and apply do nothing all analysis is done during update step
      96        7546 :   void calculate() override {}
      97        7546 :   void apply() override {}
      98             : /// This will call the analysis to be performed
      99             :   void update() override;
     100             : /// This calls the analysis to be performed in the final step of the calculation
     101             : /// i.e. when use_all_data is true
     102             :   void runFinalJobs() override;
     103             : };
     104             : 
     105             : inline
     106        7546 : void AnalysisBase::lockRequests() {
     107             :   ActionAtomistic::lockRequests();
     108             :   ActionWithArguments::lockRequests();
     109        7546 : }
     110             : 
     111             : inline
     112        7546 : void AnalysisBase::unlockRequests() {
     113             :   ActionAtomistic::unlockRequests();
     114             :   ActionWithArguments::unlockRequests();
     115        7546 : }
     116             : 
     117             : inline
     118      360092 : unsigned AnalysisBase::getNumberOfDataPoints() const {
     119      360137 :   return my_input_data->getNumberOfDataPoints();
     120             : }
     121             : 
     122             : inline
     123      375002 : unsigned AnalysisBase::getDataPointIndexInBase( const unsigned& idata ) const {
     124      500004 :   return my_input_data->getDataPointIndexInBase( idata );
     125             : }
     126             : 
     127             : inline
     128           0 : std::string AnalysisBase::getMetricName() const {
     129           0 :   return my_input_data->getMetricName();
     130             : }
     131             : 
     132             : inline
     133    40113999 : double AnalysisBase::getWeight( const unsigned& idata ) {
     134    40113999 :   return my_input_data->getWeight( idata );
     135             : }
     136             : 
     137             : inline
     138           0 : bool AnalysisBase::usingMemory() const {
     139           0 :   return my_input_data->usingMemory();
     140             : }
     141             : 
     142             : inline
     143           0 : double AnalysisBase::getNormalization() const {
     144           0 :   return my_input_data->getNormalization();
     145             : }
     146             : 
     147             : inline
     148         848 : bool AnalysisBase::dissimilaritiesWereSet() const {
     149         877 :   return my_input_data->dissimilaritiesWereSet();
     150             : }
     151             : 
     152             : inline
     153      659376 : double AnalysisBase::getDissimilarity( const unsigned& i, const unsigned& j ) {
     154      721705 :   return my_input_data->getDissimilarity( i, j );
     155             : }
     156             : 
     157             : inline
     158          22 : std::vector<Value*> AnalysisBase::getArgumentList() {
     159          24 :   return my_input_data->getArgumentList();
     160             : }
     161             : 
     162             : inline
     163      522156 : DataCollectionObject& AnalysisBase::getStoredData( const unsigned& idata, const bool& calcdist ) {
     164      526340 :   return my_input_data->getStoredData( idata, calcdist );
     165             : }
     166             : 
     167             : inline
     168          14 : const std::vector<AtomNumber>& AnalysisBase::getAtomIndexes() const {
     169          14 :   return my_input_data->getAtomIndexes();
     170             : }
     171             : 
     172             : inline
     173         841 : std::string AnalysisBase::getDissimilarityInstruction() const {
     174         841 :   return my_input_data->getDissimilarityInstruction();
     175             : }
     176             : 
     177             : }
     178             : }
     179             : 
     180             : #endif

Generated by: LCOV version 1.15