Line data Source code
1 : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 : Copyright (c) 2013-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 : #ifndef __PLUMED_analysis_LandmarkSelectionBase_h
23 : #define __PLUMED_analysis_LandmarkSelectionBase_h
24 :
25 : #include "reference/ReferenceConfiguration.h"
26 : #include "AnalysisWithLandmarks.h"
27 :
28 : namespace PLMD {
29 : namespace analysis {
30 :
31 1 : class LandmarkSelectionOptions {
32 : friend class LandmarkRegister;
33 : friend class LandmarkSelectionBase;
34 : private:
35 : std::vector<std::string> words;
36 : AnalysisWithLandmarks* action;
37 : public:
38 : LandmarkSelectionOptions( const std::vector<std::string>& input, AnalysisWithLandmarks* myanalysis );
39 : };
40 :
41 : class LandmarkSelectionBase {
42 : friend class AnalysisWithLandmarks;
43 : friend class CopyAllFrames;
44 : private:
45 : /// Name of the method we are using for landmark selection
46 : std::string style;
47 : /// The number of landmarks we are selecting
48 : unsigned nlandmarks;
49 : /// The input to the landmark selection object
50 : std::vector<std::string> input;
51 : /// A pointer to the underlying action
52 : AnalysisWithLandmarks* action;
53 : /// How do we treat weights
54 : bool novoronoi, noweights;
55 : protected:
56 : /// Return the numbe of landmarks
57 : unsigned getNumberOfLandmarks() const ;
58 : /// Return the communicator
59 : Communicator& getCommunicator();
60 : /// Read a keywords from the input
61 : template <class T>
62 : void parse(const std::string&,T& );
63 : /// Read a flag from the input
64 : void parseFlag(const std::string& key, bool& t);
65 : /// Get the number of frames in the underlying action
66 : unsigned getNumberOfFrames() const;
67 : /// Get the weight of the ith frame
68 : double getWeightOfFrame( const unsigned& );
69 : /// Calculate the distance between the ith and jth frames
70 : double getDistanceBetweenFrames( const unsigned&, const unsigned& );
71 : /// Transfer frame i in the underlying action to the object we are going to analyze
72 : void selectFrame( const unsigned&, MultiReferenceBase* );
73 : public:
74 : explicit LandmarkSelectionBase( const LandmarkSelectionOptions& lo );
75 : virtual ~LandmarkSelectionBase();
76 : /// Check everything was read in
77 : void checkRead() const ;
78 : /// Return a description of the landmark selection protocol
79 : std::string description();
80 : /// Overwrite this to have a more descriptive output
81 0 : virtual std::string rest_of_description() { return ""; };
82 : /// Actually do landmark selection
83 : void selectLandmarks( MultiReferenceBase* );
84 : virtual void select( MultiReferenceBase* )=0;
85 : };
86 :
87 : inline
88 : unsigned LandmarkSelectionBase::getNumberOfLandmarks() const {
89 0 : return nlandmarks;
90 : }
91 :
92 : inline
93 : Communicator& LandmarkSelectionBase::getCommunicator() {
94 : return action->comm;
95 : }
96 :
97 : inline
98 202 : unsigned LandmarkSelectionBase::getNumberOfFrames() const {
99 404 : return action->getNumberOfDataPoints();
100 : }
101 :
102 : template <class T>
103 0 : void LandmarkSelectionBase::parse( const std::string& key, T& t ) {
104 0 : bool found=Tools::parse(input,key,t);
105 0 : if(!found) plumed_merror("landmark seleciton style " + style + " requires " + key + " keyword");
106 0 : }
107 :
108 : }
109 : }
110 : #endif
|