Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
PLMD::Action Class Referenceabstract

Base class for all the input Actions. More...

#include <Action.h>

Inheritance diagram for PLMD::Action:
Inheritance graph
[legend]

Public Types

typedef std::vector< Action * > Dependencies
 
typedef std::set< FILE * >::iterator files_iterator
 

Public Member Functions

bool checkUpdate () const
 Check if action should be updated. More...
 
void addDependency (Action *)
 Specify that this Action depends on another one. More...
 
void clearDependencies ()
 Clear the dependence list for this Action. More...
 
long int getStep () const
 Return the present timestep. More...
 
double getTime () const
 Return the present time. More...
 
double getTimeStep () const
 Return the timestep. More...
 
bool getRestart () const
 Return true if we are doing a restart. More...
 
bool getCPT () const
 Return true if we are doing at a checkpoint step. More...
 
std::string getKeyword (const std::string &key)
 Just read one of the keywords and return the whole thing as a string. More...
 
template<class T >
void parse (const std::string &key, T &t)
 Parse one keyword as generic type. More...
 
template<class T >
bool parseNumbered (const std::string &key, const int no, T &t)
 Parse one numbered keyword as generic type. More...
 
template<class T >
void parseVector (const std::string &key, std::vector< T > &t)
 Parse one keyword as std::vector. More...
 
template<class T >
bool parseNumberedVector (const std::string &key, const int no, std::vector< T > &t)
 Parse a vector with a number. More...
 
void parseFlag (const std::string &key, bool &t)
 Parse one keyword as boolean flag. More...
 
void error (const std::string &msg) const
 Crash calculation and print documentation. More...
 
void warning (const std::string &msg)
 Issue a warning. More...
 
void exit (int c=0)
 Exit with error code c. More...
 
 Action (const ActionOptions &)
 Standard constructor from ActionOptions. More...
 
virtual ~Action ()
 Destructor. More...
 
void checkRead ()
 Check if Action was properly read. More...
 
virtual void prepare ()
 Prepare an Action for calculation This can be used by Action if they need some special preparation before calculation. More...
 
virtual void lockRequests ()
 
virtual void unlockRequests ()
 
virtual void calculate ()=0
 Calculate an Action. More...
 
virtual void apply ()=0
 Apply an Action. More...
 
virtual void beforeUpdate ()
 Before Update. More...
 
virtual void update ()
 Update. More...
 
virtual void runFinalJobs ()
 RunFinalJobs This method is called once at the very end of the calculation. More...
 
void fflush ()
 Tell to the Action to flush open files. More...
 
virtual std::string getDocumentation () const
 
const std::string & getLabel () const
 Returns the label. More...
 
const std::string & getName () const
 Returns the name. More...
 
virtual void activate ()
 Set action to active. More...
 
virtual void setOption (const std::string &s)
 
virtual void clearOptions ()
 
virtual void deactivate ()
 Set action to inactive. More...
 
bool isActive () const
 Check if action is active. More...
 
bool isOptionOn (const std::string &s) const
 Check if an option is on. More...
 
const DependenciesgetDependencies () const
 Return dependencies. More...
 
virtual bool checkNumericalDerivatives () const
 Check if numerical derivatives should be performed. More...
 
virtual bool checkNeedsGradients () const
 Check if the action needs gradient. More...
 
virtual void calculateNumericalDerivatives (ActionWithValue *a=NULL)
 Perform calculation using numerical derivatives N.B. More...
 
FILE * fopen (const char *path, const char *mode)
 Opens a file. More...
 
int fclose (FILE *fp)
 Closes a file opened with Action::fclose(). More...
 
void calculateFromPDB (const PDB &)
 Calculate the action given a pdb file as input. More...
 
virtual void readAtomsFromPDB (const PDB &)
 This is overwritten in ActionAtomistic so that we can read the atoms from the pdb input file rather than taking them from the MD code. More...
 
bool getExchangeStep () const
 Check if we are on an exchange step. More...
 
std::string cite (const std::string &s)
 Cite a paper see PlumedMain::cite. More...
 

Static Public Member Functions

static void registerKeywords (Keywords &keys)
 Register all the relevant keywords for the action. More...
 

Public Attributes

PlumedMainplumed
 Reference to main plumed object. More...
 
Loglog
 Reference to the log stream. More...
 
std::set< FILE * > files
 
Communicatorcomm
 
Communicatormulti_sim_comm
 
const Keywordskeywords
 

Private Member Functions

 Action (const Action &a)
 Copy constructor is disabled (private and unimplemented) More...
 
Actionoperator= (const Action &a)
 Assignment operator is disabled (private and unimplemented) More...
 

Private Attributes

const std::string name
 Name of the directive in the plumed.dat file. More...
 
std::string label
 Label of the Action, as set with LABEL= in the plumed.dat file. More...
 
std::vector< std::string > line
 Directive line. More...
 
double update_from
 Update only after this time. More...
 
double update_until
 Update only until this time. More...
 
Dependencies after
 Actions on which this Action depends. More...
 
bool active
 Switch to activate Action on this step. More...
 
std::set< std::string > options
 Option that you might have enabled. More...
 
bool restart
 
bool doCheckPoint
 

Detailed Description

Base class for all the input Actions.

The input Actions are more or less corresponding to the directives in the plumed.dat file and are applied in order at each time-step.

Member Typedef Documentation

◆ Dependencies

typedef std::vector<Action*> PLMD::Action::Dependencies

◆ files_iterator

typedef std::set<FILE*>::iterator PLMD::Action::files_iterator

Constructor & Destructor Documentation

◆ Action() [1/2]

PLMD::Action::Action ( const ActionOptions ao)
explicit

Standard constructor from ActionOptions.

◆ ~Action()

PLMD::Action::~Action ( )
virtual

Destructor.

◆ Action() [2/2]

PLMD::Action::Action ( const Action a)
explicitprivate

Copy constructor is disabled (private and unimplemented)

Member Function Documentation

◆ activate()

void PLMD::Action::activate ( )
virtual

Set action to active.

◆ addDependency()

void PLMD::Action::addDependency ( Action action)

Specify that this Action depends on another one.

◆ apply()

virtual void PLMD::Action::apply ( )
pure virtual

◆ beforeUpdate()

virtual void PLMD::Action::beforeUpdate ( )
inlinevirtual

Before Update.

This is a special method that is called just before the update() method. It can be used by actions that want to do something irrespectively of the fact that update() is active or not. In other words, this is always called, even when action is not active.

Reimplemented in PLMD::generic::UpdateIf.

◆ calculate()

virtual void PLMD::Action::calculate ( )
pure virtual

Calculate an Action.

This method is called one or more times per step. The set of all Actions is calculated in forward order.

Implemented in PLMD::colvar::CS2Backbone, PLMD::bias::MetaD, PLMD::bias::PBMetaD, PLMD::function::FuncSumHills, PLMD::mapping::PCAVars, PLMD::function::Matheval, PLMD::generic::WrapAround, PLMD::multicolvar::MultiColvarBase, PLMD::bias::Metainference, PLMD::function::FuncPathMSD, PLMD::colvar::RDC, PLMD::bias::ExtendedLagrangian, PLMD::generic::Group, PLMD::generic::FitToTemplate, PLMD::colvar::Distance, PLMD::colvar::ContactMap, PLMD::generic::DumpAtoms, PLMD::generic::EffectiveEnergyDrift, PLMD::bias::MovingRestraint, PLMD::colvar::ERMSD, PLMD::generic::WholeMolecules, PLMD::colvar::DRMSD, PLMD::colvar::JCoupling, PLMD::function::Target, PLMD::generic::DumpMassCharge, PLMD::bias::External, PLMD::adjmat::Sprint, PLMD::generic::ResetCell, PLMD::colvar::Gyration, PLMD::multicolvar::CenterOfMultiColvar, PLMD::bias::ABMD, PLMD::colvar::Angle, PLMD::colvar::FretEfficiency, PLMD::generic::UpdateIf, PLMD::multicolvar::DistanceFromContour, PLMD::function::Combine, PLMD::vatom::FixedAtom, PLMD::bias::BiasValue, PLMD::function::LocalEnsemble, PLMD::vatom::Center, PLMD::adjmat::OutputCluster, PLMD::colvar::PRE, PLMD::generic::Read, PLMD::generic::RandomExchanges, PLMD::colvar::NOE, PLMD::colvar::Puckering, PLMD::function::Piecewise, PLMD::multicolvar::DumpMultiColvar, PLMD::vesselbase::ActionWithAveraging, PLMD::adjmat::ClusterDistribution, PLMD::colvar::PathMSDBase, PLMD::secondarystructure::SecondaryStructureRMSD, PLMD::colvar::Position, PLMD::bias::LWalls, PLMD::bias::UWalls, PLMD::colvar::Torsion, PLMD::vatom::COM, PLMD::adjmat::ClusterDiameter, PLMD::generic::Print, PLMD::adjmat::ClusterSize, PLMD::colvar::Constant, PLMD::generic::Include, PLMD::analysis::Committor, PLMD::bias::Restraint, PLMD::generic::Flush, PLMD::adjmat::ClusterProperties, PLMD::function::Ensemble, PLMD::colvar::Energy, PLMD::multicolvar::BridgedMultiColvarFunction, PLMD::colvar::Dipole, PLMD::function::Sort, PLMD::function::Stats, PLMD::generic::DumpDerivatives, PLMD::generic::DumpForces, PLMD::generic::Debug, PLMD::vatom::Ghost, PLMD::colvar::Template, PLMD::generic::DumpProjections, PLMD::manyrestraints::ManyRestraintsBase, PLMD::colvar::Cell, PLMD::colvar::ColvarFake, PLMD::colvar::Volume, PLMD::generic::Time, PLMD::adjmat::ClusteringBase, PLMD::colvar::MultiRMSD, PLMD::colvar::RMSD, PLMD::colvar::PCARMSD, PLMD::colvar::CoordinationBase, PLMD::bias::ReweightBase, PLMD::ActionSetup, PLMD::gridtools::GridPrintingBase, and PLMD::mapping::PathBase.

◆ calculateFromPDB()

void PLMD::Action::calculateFromPDB ( const PDB pdb)

Calculate the action given a pdb file as input.

This is used to initialize things like distance from a point in CV map space given a pdb as an input file

◆ calculateNumericalDerivatives()

void PLMD::Action::calculateNumericalDerivatives ( ActionWithValue a = NULL)
virtual

◆ checkNeedsGradients()

virtual bool PLMD::Action::checkNeedsGradients ( ) const
inlinevirtual

Check if the action needs gradient.

Reimplemented in PLMD::bias::MetaD, and PLMD::generic::DumpProjections.

◆ checkNumericalDerivatives()

virtual bool PLMD::Action::checkNumericalDerivatives ( ) const
inlinevirtual

Check if numerical derivatives should be performed.

Reimplemented in PLMD::ActionWithValue.

◆ checkRead()

void PLMD::Action::checkRead ( )

Check if Action was properly read.

This checks if Action::line is empty. It must be called after a final Action has been initialized

◆ checkUpdate()

bool PLMD::Action::checkUpdate ( ) const

Check if action should be updated.

◆ cite()

std::string PLMD::Action::cite ( const std::string &  s)

Cite a paper see PlumedMain::cite.

◆ clearDependencies()

void PLMD::Action::clearDependencies ( )

Clear the dependence list for this Action.

◆ clearOptions()

void PLMD::Action::clearOptions ( )
virtual

◆ deactivate()

void PLMD::Action::deactivate ( )
inlinevirtual

Set action to inactive.

◆ error()

void PLMD::Action::error ( const std::string &  msg) const

Crash calculation and print documentation.

◆ exit()

void PLMD::Action::exit ( int  c = 0)

Exit with error code c.

◆ fclose()

int PLMD::Action::fclose ( FILE *  fp)

Closes a file opened with Action::fclose().

◆ fflush()

void PLMD::Action::fflush ( )

Tell to the Action to flush open files.

◆ fopen()

FILE * PLMD::Action::fopen ( const char *  path,
const char *  mode 
)

Opens a file.

This is similar to plain fopen, but with some extra functionality.

  • When opened for writing, processors other than the one with rank 0 just open /dev/null
  • PlumedMain::fopen is used, so that other tricks may appear (see PlumedMain::fopen)

◆ getCPT()

bool PLMD::Action::getCPT ( ) const

Return true if we are doing at a checkpoint step.

◆ getDependencies()

const Dependencies& PLMD::Action::getDependencies ( ) const
inline

Return dependencies.

◆ getDocumentation()

std::string PLMD::Action::getDocumentation ( ) const
virtual

◆ getExchangeStep()

bool PLMD::Action::getExchangeStep ( ) const

Check if we are on an exchange step.

◆ getKeyword()

std::string PLMD::Action::getKeyword ( const std::string &  key)

Just read one of the keywords and return the whole thing as a string.

◆ getLabel()

const std::string & PLMD::Action::getLabel ( ) const
inline

Returns the label.

◆ getName()

const std::string & PLMD::Action::getName ( ) const
inline

Returns the name.

◆ getRestart()

bool PLMD::Action::getRestart ( ) const
inline

Return true if we are doing a restart.

◆ getStep()

long int PLMD::Action::getStep ( ) const

Return the present timestep.

◆ getTime()

double PLMD::Action::getTime ( ) const

Return the present time.

◆ getTimeStep()

double PLMD::Action::getTimeStep ( ) const

Return the timestep.

◆ isActive()

bool PLMD::Action::isActive ( ) const
inline

Check if action is active.

◆ isOptionOn()

bool PLMD::Action::isOptionOn ( const std::string &  s) const
inline

Check if an option is on.

◆ lockRequests()

virtual void PLMD::Action::lockRequests ( )
inlinevirtual

◆ operator=()

Action& PLMD::Action::operator= ( const Action a)
private

Assignment operator is disabled (private and unimplemented)

◆ parse()

template<class T >
void PLMD::Action::parse ( const std::string &  key,
T &  t 
)

Parse one keyword as generic type.

◆ parseFlag()

void PLMD::Action::parseFlag ( const std::string &  key,
bool &  t 
)

Parse one keyword as boolean flag.

◆ parseNumbered()

template<class T >
bool PLMD::Action::parseNumbered ( const std::string &  key,
const int  no,
T &  t 
)

Parse one numbered keyword as generic type.

◆ parseNumberedVector()

template<class T >
bool PLMD::Action::parseNumberedVector ( const std::string &  key,
const int  no,
std::vector< T > &  t 
)

Parse a vector with a number.

◆ parseVector()

template<class T >
void PLMD::Action::parseVector ( const std::string &  key,
std::vector< T > &  t 
)

Parse one keyword as std::vector.

◆ prepare()

void PLMD::Action::prepare ( )
virtual

Prepare an Action for calculation This can be used by Action if they need some special preparation before calculation.

Typical case is for collective variables which would like to change their list of requested atoms. By default (if not overridden) does nothing.

Reimplemented in PLMD::multicolvar::MultiColvarBase, PLMD::function::FuncPathMSD, PLMD::generic::DumpMassCharge, PLMD::generic::UpdateIf, PLMD::generic::Read, PLMD::generic::Print, PLMD::bias::ReweightTemperature, PLMD::gridtools::ConvertToFES, PLMD::colvar::Energy, and PLMD::colvar::CoordinationBase.

◆ readAtomsFromPDB()

virtual void PLMD::Action::readAtomsFromPDB ( const PDB )
inlinevirtual

This is overwritten in ActionAtomistic so that we can read the atoms from the pdb input file rather than taking them from the MD code.

Reimplemented in PLMD::ActionAtomistic.

◆ registerKeywords()

void PLMD::Action::registerKeywords ( Keywords keys)
static

Register all the relevant keywords for the action.

◆ runFinalJobs()

virtual void PLMD::Action::runFinalJobs ( )
inlinevirtual

RunFinalJobs This method is called once at the very end of the calculation.

The set of all Actions in run for the final time in forward order.

Reimplemented in PLMD::analysis::Analysis, PLMD::gridtools::ConvertToFES, and PLMD::gridtools::GridPrintingBase.

◆ setOption()

void PLMD::Action::setOption ( const std::string &  s)
virtual

◆ unlockRequests()

virtual void PLMD::Action::unlockRequests ( )
inlinevirtual

◆ update()

virtual void PLMD::Action::update ( )
inlinevirtual

◆ warning()

void PLMD::Action::warning ( const std::string &  msg)

Issue a warning.

Member Data Documentation

◆ active

bool PLMD::Action::active
private

Switch to activate Action on this step.

◆ after

Dependencies PLMD::Action::after
private

Actions on which this Action depends.

◆ comm

Communicator& PLMD::Action::comm

◆ doCheckPoint

bool PLMD::Action::doCheckPoint
private

◆ files

std::set<FILE*> PLMD::Action::files

◆ keywords

const Keywords& PLMD::Action::keywords

◆ label

std::string PLMD::Action::label
private

Label of the Action, as set with LABEL= in the plumed.dat file.

◆ line

std::vector<std::string> PLMD::Action::line
private

Directive line.

This line is progressively erased during Action construction so as to check if all the present keywords are correct.

◆ log

Log& PLMD::Action::log

Reference to the log stream.

◆ multi_sim_comm

Communicator& PLMD::Action::multi_sim_comm

◆ name

const std::string PLMD::Action::name
private

Name of the directive in the plumed.dat file.

◆ options

std::set<std::string> PLMD::Action::options
private

Option that you might have enabled.

◆ plumed

PlumedMain& PLMD::Action::plumed

Reference to main plumed object.

◆ restart

bool PLMD::Action::restart
private

◆ update_from

double PLMD::Action::update_from
private

Update only after this time.

◆ update_until

double PLMD::Action::update_until
private

Update only until this time.


The documentation for this class was generated from the following files: