Skip to content
Snippets Groups Projects
Commit 6881fef8 authored by Giovanni Bussi's avatar Giovanni Bussi
Browse files

Added documentation

parent 9177592a
No related branches found
No related tags found
No related merge requests found
...@@ -13,7 +13,8 @@ namespace PLMD{ ...@@ -13,7 +13,8 @@ namespace PLMD{
class PlumedMain; class PlumedMain;
/// This class is used to bring the relevant information to the Action constructor. /// This class is used to bring the relevant information to the Action constructor.
/// Its content is kept private to other classes, and may change in the future /// Only Action and ActionRegister class can access to its content, which is
/// kept private to other classes, and may change in the future.
class ActionOptions{ class ActionOptions{
friend class Action; friend class Action;
friend class ActionRegister; friend class ActionRegister;
......
...@@ -16,6 +16,7 @@ protected: ...@@ -16,6 +16,7 @@ protected:
int getStride()const; int getStride()const;
public: public:
ActionPilot(const ActionOptions&); ActionPilot(const ActionOptions&);
/// Check if the action is active on this step
bool onStep()const; bool onStep()const;
}; };
......
...@@ -21,8 +21,11 @@ class ActionWithArguments: ...@@ -21,8 +21,11 @@ class ActionWithArguments:
protected: protected:
ActionWithArguments(const ActionOptions&); ActionWithArguments(const ActionOptions&);
virtual ~ActionWithArguments(){}; virtual ~ActionWithArguments(){};
/// Returns an array of pointers to the arguments
std::vector<Value*> & getArguments(); std::vector<Value*> & getArguments();
/// Returns the value of an argument
double getArgument(int)const; double getArgument(int)const;
/// Returns the number of arguments
unsigned getNumberOfArguments()const; unsigned getNumberOfArguments()const;
public: public:
}; };
......
...@@ -11,6 +11,8 @@ namespace PLMD{ ...@@ -11,6 +11,8 @@ namespace PLMD{
/// Action which can take one or more values. /// Action which can take one or more values.
/// This object contains an array of PLMD::Value, one for each component. /// This object contains an array of PLMD::Value, one for each component.
/// It also stores all the derivatives of these values wrt the parameters
/// Parameters are other values (from other Action s) or atomic positions.
class ActionWithValue: class ActionWithValue:
public virtual Action public virtual Action
{ {
...@@ -21,20 +23,44 @@ class ActionWithValue: ...@@ -21,20 +23,44 @@ class ActionWithValue:
public: public:
ActionWithValue(const ActionOptions&ao); ActionWithValue(const ActionOptions&ao);
~ActionWithValue(); ~ActionWithValue();
/// Add a new value without derivatives.
/// This should be used for values which are only evaluated (e.g. for printing)
/// but for which we do not make derivatives available so that forces cannot
/// be applied
void addValue(const std::string&name); void addValue(const std::string&name);
/// Add a new value with derivatives.
/// This should be used for values for which we make derivatives available
/// so that forces can be applied
void addValueWithDerivatives(const std::string&name); void addValueWithDerivatives(const std::string&name);
/// Check if a value with a given name is already used
bool hasNamedValue(const std::string&name)const; bool hasNamedValue(const std::string&name)const;
/// Return a pointer to the value by name
Value* getValue(const std::string&name)const; Value* getValue(const std::string&name)const;
/// Return a pointer to the value by index
/// This should be an indexes growing for new inserted values.
/// E.g., the default value (no name) is number 0, ...
Value* getValue(int i)const; Value* getValue(int i)const;
/// Returns an array of strings with the names of the values
std::vector<std::string> getValueNames()const; std::vector<std::string> getValueNames()const;
/// Returns the number of values defined
int getNumberOfValues(); int getNumberOfValues();
/// Set the number of parameters on which this Action depends.
/// Example: for a Bias, this is the number of arguments, for a Colvar
/// is 3*Natoms+cell variables
void setNumberOfParameters(int n); void setNumberOfParameters(int n);
/// Returns the number of parameters on which this Action depends.
int getNumberOfParameters()const; int getNumberOfParameters()const;
/// Returns the total force applied on i-th value
double getForce(int n); double getForce(int n);
/// Add a force to the i-th value
void addInputForces(int i,double f); void addInputForces(int i,double f);
/// Clear the forces on the values
void clearInputForces(); void clearInputForces();
/// Clear the derivatives of values wrt parameters
void clearDerivatives(); void clearDerivatives();
/// Set the value
void setValue(Value*,double); void setValue(Value*,double);
/// Set the default value (the one without name)
void setValue(double); void setValue(double);
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment