All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
StoreColvarVessel.h
Go to the documentation of this file.
1 /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2  Copyright (c) 2013 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-code.org for more information.
6 
7  This file is part of plumed, version 2.0.
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_multicolvar_StoreColvarVessel_h
23 #define __PLUMED_multicolvar_StoreColvarVessel_h
24 
25 #include <string>
26 #include <cstring>
27 #include <vector>
28 #include "vesselbase/Vessel.h"
29 #include "tools/DynamicList.h"
30 
31 namespace PLMD {
32 namespace multicolvar{
33 
34 class MultiColvarBase;
35 
37 private:
38  unsigned bufsize;
39  std::vector<unsigned> start;
41  std::vector< DynamicList<unsigned> > active_atoms;
42 protected:
43 /// Are the weights differentiable
44  bool diffweight;
45 /// Get the number of stored colvar values
46  unsigned getNumberOfStoredColvars() const ;
47 /// Get the ith value in the vessel
48  double getValue( const unsigned& ) const ;
49 /// Get the weight of the ith quantity in the vessel
50  double getWeight( const unsigned& ) const ;
51 /// Add the derivatives from the value
52  void addDerivatives( const unsigned& ival, double& pref, Value* value_out );
53 /// Add the derivatives from the weight of the value
54  void addWeightDerivatives( const unsigned& ival, double& pref, Value* value_out );
55 public:
56  static void registerKeywords( Keywords& keys );
57 /// Constructor
59 /// Return the number of terms
60  unsigned getNumberOfTerms(){ return 2; }
61 /// This does the resizing of the buffer
62  void resize();
63 /// This makes sure things further down the chain are resized
64  virtual void local_resizing()=0;
65 /// This makes sure all values are stored
66  bool calculate();
67 /// Makes sure the dynamic lists are gathered
68  void finish();
69 /// Do the calculation
70  virtual void performCalculationUsingAllValues()=0;
71 };
72 
73 inline
74 double StoreColvarVessel::getValue( const unsigned& ival ) const {
75  plumed_dbg_assert( ival<start.size()-1 );
76  return getBufferElement( start[ival] );
77 }
78 
79 inline
80 double StoreColvarVessel::getWeight( const unsigned& ival ) const {
81  plumed_dbg_assert( ival<start.size()-1 );
82  return getBufferElement( bufsize + start[ival] );
83 }
84 
85 inline
87  return start.size()-1;
88 }
89 
90 }
91 }
92 #endif
virtual void performCalculationUsingAllValues()=0
Do the calculation.
A class for holding the value of a function together with its derivatives.
Definition: Value.h:46
unsigned getNumberOfStoredColvars() const
Get the number of stored colvar values.
double getBufferElement(const unsigned &i) const
Get the value in the ith element of the buffer.
Definition: Vessel.h:258
bool calculate()
This makes sure all values are stored.
virtual void local_resizing()=0
This makes sure things further down the chain are resized.
void resize()
This does the resizing of the buffer.
std::vector< DynamicList< unsigned > > active_atoms
void addDerivatives(const unsigned &ival, double &pref, Value *value_out)
Add the derivatives from the value.
double getValue(const unsigned &) const
Get the ith value in the vessel.
This class holds the keywords and their documentation.
Definition: Keywords.h:36
static void registerKeywords(Keywords &keys)
void addWeightDerivatives(const unsigned &ival, double &pref, Value *value_out)
Add the derivatives from the weight of the value.
StoreColvarVessel(const vesselbase::VesselOptions &)
Constructor.
This class is used to pass the input to Vessels.
Definition: Vessel.h:53
unsigned getNumberOfTerms()
Return the number of terms.
void finish()
Makes sure the dynamic lists are gathered.
bool diffweight
Are the weights differentiable.
double getWeight(const unsigned &) const
Get the weight of the ith quantity in the vessel.