23 #include "BasisFunc.h"
24 #include "ForwardFlux.h"
26 #include "StringMethod.h"
28 #include "json/json.h"
29 #include "Drivers/DriverException.h"
30 #include "Validator/ObjectRequirement.h"
31 #include "CVs/CVManager.h"
38 Method* Method::BuildMethod(
const Value& json,
39 const MPI_Comm& world,
41 const std::string& path)
47 reader.parse(JsonSchema::Method, schema);
48 validator.
Parse(schema, path);
55 if(json[
"type"] ==
"ABF")
56 method = ABF::Build(json, world, comm, path);
57 else if(json[
"type"] ==
"Basis")
58 method = Basis::Build(json, world, comm, path);
59 else if(json[
"type"] ==
"ForwardFlux")
60 method = ForwardFlux::Build(json, world, comm, path);
61 else if(json[
"type"] ==
"Metadynamics")
62 method = Meta::Build(json, world, comm, path);
63 else if(json[
"type"] ==
"Umbrella")
64 method = Umbrella::Build(json, world, comm, path);
65 else if(json[
"type"] ==
"String")
66 method = StringMethod::Build(json, world, comm, path);
68 throw std::invalid_argument(path +
": Unknown method type specified.");
71 std::vector<uint> cvmask;
72 for(
auto& v : json[
"cvs"])
76 auto id = CVManager::LookupCV(v.asString());
78 throw std::invalid_argument(path +
": CV mask name \"" + v.asString() +
"\" does not exist.");
80 cvmask.push_back(CVManager::LookupCV(v.asString()));
82 else if(v.isIntegral() && v.asInt() >= 0)
83 cvmask.push_back(v.asUInt());
85 throw std::invalid_argument(path +
": CV mask must contain strings or unsigned integers.");
bool HasErrors()
Check if errors have occured.
Interface for Method implementations.
virtual void Parse(Value json, const std::string &path) override
Parse JSON value to generate Requirement(s).
Exception to be thrown when building the Driver fails.
std::vector< std::string > GetErrors()
Get list of error messages.
Requirements on an object.
void SetCVMask(const std::vector< uint > &mask)
Sets the collective variable mask.
virtual void Validate(const Value &json, const std::string &path) override
Validate JSON value.