22 #include "CollectiveVariable.h"
23 #include "Drivers/DriverException.h"
24 #include "Validator/Requirement.h"
46 std::vector<CollectiveVariable*>
cvs_;
49 static std::map<std::string, unsigned int>
cvmap_;
60 if(std::find(
cvs_.begin(),
cvs_.end(), cv) ==
cvs_.end())
81 CVList GetCVs(
const std::vector<unsigned int>& mask = std::vector<unsigned int>())
const
87 std::vector<CollectiveVariable*> cvs;
89 cvs.push_back(
cvs_[i]);
101 static void AddCVtoMap(
const std::string& name,
unsigned int id)
112 static int LookupCV(
const Json::Value& cv,
const std::string& path)
117 auto name = cv.asString();
120 throw BuildException({path +
": CV mask name \"" + name +
"\" does not exist."});
124 else if(cv.isIntegral())
127 if(id < 0 || id >=
static_cast<int>(
cvmap_.size()))
129 throw BuildException({path +
": CV mask index of " + std::to_string(
id) +
" does not exist. " +
130 "Index must be nonnegative and less than " + std::to_string(
cvmap_.size()) +
"."});
135 throw BuildException({path +
": CV mask must contain strings or nonnegative integers."});
Exception to be thrown when building the Driver fails.
Collective variable manager.
static void AddCVtoMap(const std::string &name, unsigned int id)
Register CV name with map.
static int LookupCV(const Json::Value &cv, const std::string &path)
Get CV id from map.
std::vector< CollectiveVariable * > cvs_
List of collective variables.
CVList GetCVs(const std::vector< unsigned int > &mask=std::vector< unsigned int >()) const
Get CV iterator.
static std::map< std::string, unsigned int > cvmap_
Map between CV names and ID's.
void AddCV(CollectiveVariable *cv)
Adds a CV to the CV manager.
void ClearCVs()
Clears CVs from CV manager.
Abstract class for a collective variable.
std::vector< CollectiveVariable * > CVList
List of Collective Variables.