22 #ifndef __PLUMED_vesselbase_Vessel_h
23 #define __PLUMED_vesselbase_Vessel_h
29 #include "tools/Exception.h"
30 #include "tools/Keywords.h"
71 VesselOptions(
const std::string& thisname,
const std::string& thislab,
const unsigned& nlab,
const std::string& params,
ActionWithVessel* aa );
95 std::vector<std::string>
line;
106 void error(
const std::string& errmsg);
109 void parse(
const std::string&key, T&t);
112 void parseVector(
const std::string&key,std::vector<T>&t);
114 void parseFlag(
const std::string&key,
bool&t);
163 virtual bool applyForce( std::vector<double>& forces )=0;
170 plumed_massert(
keywords.
exists(key),
"keyword " + key +
" has not been registered");
176 plumed_massert( def.length()!=0 &&
Tools::convert(def,t),
"default value is dubious");
178 error(
"keyword " + key +
" is comulsory for this vessel");
186 plumed_massert(
keywords.
exists(key),
"keyword " + key +
" has not been registered");
187 unsigned size=t.size();
bool skipcheck=
false;
188 if(size==0) skipcheck=
true;
191 bool found; std::string def; T val;
196 if( !skipcheck && t.size()!=size )
error(
"vector read in for keyword " + key +
" has the wrong size");
203 plumed_merror(
"weird default value for keyword " + key );
205 for(
unsigned i=0;i<t.size();++i) t[i]=val;
208 error(
"keyword " + key +
" is compulsory");
210 }
else if ( !found ){
247 plumed_dbg_assert( i<
bufsize );
253 plumed_dbg_assert( i<
bufsize );
259 plumed_dbg_assert( i<
bufsize );
virtual void resize()=0
Reset the size of the buffers.
void setBufferFromStash()
Add the contents of the stash to the buffer.
void stashBuffers()
Store everything that is the buffers.
void zero()
Set all the buffer elements to zero.
std::string parameters
The parameters that are read into the function.
virtual ~Vessel()
Virtual destructor needed for proper inheritance.
double getTolerance() const
Return the value of the tolerance.
std::vector< double > buffer
void addToBufferElement(const unsigned &i, const double &val)
Add something to the ith element in the buffer.
int numlab
The numerical label for this vessel.
virtual std::string description()=0
Return a description of the vessel contents.
static void registerKeywords(Keywords &keys)
Reserve any keywords for this particular vessel.
Communicator & comm
A copy of the communicator.
double getBufferElement(const unsigned &i) const
Get the value in the ith element of the buffer.
Class containing wrappers to MPI.
static Keywords emptyKeys
double nl_tolerance
Tolerance for quantities being put in neighbor lists.
virtual unsigned getNumberOfTerms()=0
Retrieve the number of terms we need to accumulate.
Class containing the log stream.
bool getDefaultValue(std::string key, std::string &def) const
Get the value of the default for the keyword named key.
std::string getLabel() const
Return the label.
bool finished_read
This just checks we have done checkRead.
std::vector< double > stash
Something to store the buffer if this is required.
This class holds the keywords and their documentation.
virtual void finish()=0
Complete the calculation once the loop is finished.
void parseFlag(const std::string &key, bool &t)
Parse one keyword as boolean flag.
std::string mylabel
The label for the vessel for referencing.
virtual bool calculate()=0
Calculate the part of the vessel that is done in the loop.
void resizeBuffer(const unsigned &n)
Set the size of the data buffer.
const Keywords & keywords
The keywords.
VesselOptions(const std::string &thisname, const std::string &thislab, const unsigned &nlab, const std::string ¶ms, ActionWithVessel *aa)
The constructor.
int getNumericalLabel() const
Return the numerical label.
virtual bool applyForce(std::vector< double > &forces)=0
Retrieve the forces on the quantities in the vessel.
std::string getName() const
Return the name.
void setBufferElement(const unsigned &i, const double &val)
Set the value of the ith element in the buffer.
unsigned bufsize
The number of elements in this vessel's buffered data.
ActionWithVessel * action
The action that this vessel is created within.
Vessel(const VesselOptions &da)
The constructor.
bool style(const std::string &k, const std::string &t) const
Check if the keyword with name k has style t.
void error(const std::string &errmsg)
Report an error.
std::string myname
The name of the particular vessel.
void parseVector(const std::string &key, std::vector< T > &t)
Parse one keyword as std::vector.
std::string mylabel
The label for this particular vessel;.
This class is used to pass the input to Vessels.
std::vector< std::string > line
Directive line.
const PLMD::Keywords & keywords
The keywords.
ActionWithVessel * action
Pointer to ActionWithVessel that this if from.
bool exists(const std::string &k) const
Check if there is a keyword with name k.
virtual void prepare()
Do something before the loop.
unsigned bufstart
The start of this Vessel's buffer in buffer in the underlying ActionWithVessel.
std::string myname
The keyword for the vessel in the input file.
void parse(const std::string &key, T &t)
Parse something from the input.
void checkRead()
Check that readin was fine.
Log & log
Reference to the log on which to output details.
double tolerance
The tolerance on the accumulators.
double getNLTolerance() const
Return the value of the neighbor list tolerance.
std::string getAllInput()
This returns the whole input line (it is used for less_than/more_than/between)
const int numlab
The numerical label for this object.
ActionWithVessel * getAction()
Return a pointer to the action we are working in.
This is used to create PLMD::Action objects that are computed by calculating the same function multip...