SSAGES  0.1
A MetaDynamics Package
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
SSAGES::Method Class Referenceabstract

Interface for Method implementations. More...

#include <Method.h>

Inheritance diagram for SSAGES::Method:
Inheritance graph
[legend]

Public Member Functions

 Method (uint frequency, const MPI_Comm &world, const MPI_Comm &comm)
 Constructor. More...
 
virtual void PreSimulation (Snapshot *snapshot, const class CVManager &cvmanager) override=0
 Method call prior to simulation initiation. More...
 
virtual void PostIntegration (Snapshot *snapshot, const class CVManager &cvmanager) override=0
 Method call post integration. More...
 
virtual void PostSimulation (Snapshot *snapshot, const class CVManager &cvmanager) override=0
 Method call post simulation. More...
 
void SetCVMask (const std::vector< uint > &mask)
 Sets the collective variable mask.
 
virtual ~Method ()
 Destructor.
 
- Public Member Functions inherited from SSAGES::EventListener
 EventListener (uint frequency)
 Constructor. More...
 
uint GetFrequency () const
 Get frequency of event listener. More...
 
virtual ~EventListener ()
 Destructor.
 

Static Public Member Functions

static MethodBuildMethod (const Json::Value &json, const MPI_Comm &world, const MPI_Comm &comm, const std::string &path)
 Build a derived method from JSON node. More...
 

Protected Attributes

mxx::comm world_
 Global MPI communicator.
 
mxx::comm comm_
 Local MPI communicator.
 
std::vector< uint > cvmask_
 Mask which identifies which CVs to act on.
 

Detailed Description

Interface for Method implementations.

The base method class from which advanced sampling routines derive. A method is allowed to manipulate a simulation at three points: before the simulation begins (usually initialization), after each integration step by the simulation engine, and after the integration steps are complete (usually cleanup).

Definition at line 43 of file Method.h.

Constructor & Destructor Documentation

SSAGES::Method::Method ( uint  frequency,
const MPI_Comm &  world,
const MPI_Comm &  comm 
)
inline

Constructor.

Parameters
frequencyFrequency of sampling.
worldGlobal MPI communicator.
commMPI communicator of walker.

Frequency of sampling must be specified by all methods.

Definition at line 61 of file Method.h.

61  :
62  EventListener(frequency), world_(world), comm_(comm), cvmask_()
63  {}
mxx::comm comm_
Local MPI communicator.
Definition: Method.h:47
mxx::comm world_
Global MPI communicator.
Definition: Method.h:46
std::vector< uint > cvmask_
Mask which identifies which CVs to act on.
Definition: Method.h:50
EventListener(uint frequency)
Constructor.
Definition: EventListener.h:44

Member Function Documentation

Method * SSAGES::Method::BuildMethod ( const Json::Value &  json,
const MPI_Comm &  world,
const MPI_Comm &  comm,
const std::string &  path 
)
static

Build a derived method from JSON node.

Parameters
jsonJSON Value containing all input information.
worldMPI global communicator.
commMPI local communicator.
pathPath for JSON path specification.
Returns
Pointer to the Method built. nullptr if an unknown error occurred.

This function builds a registered method from a JSON node. The difference between this function and "Build" is that this automatically determines the appropriate derived type based on the JSON node information.

Note
Object lifetime is the caller's responsibility.

Definition at line 39 of file Method.cpp.

References Json::Requirement::GetErrors(), Json::Requirement::HasErrors(), Json::ObjectRequirement::Parse(), SetCVMask(), and Json::ObjectRequirement::Validate().

Referenced by SSAGES::ResourceHandler::Build().

43  {
44  ObjectRequirement validator;
45  Value schema;
46  Reader reader;
47 
48  reader.parse(JsonSchema::Method, schema);
49  validator.Parse(schema, path);
50  validator.Validate(json, path);
51  if(validator.HasErrors())
52  throw BuildException(validator.GetErrors());
53 
54  Method* method = nullptr;
55 
56  if(json["type"] == "ABF")
57  method = ABF::Build(json, world, comm, path);
58  else if(json["type"] == "ANN")
59  method = ANN::Build(json, world, comm, path);
60  else if(json["type"] == "BFSMethod")
61  method = BFS::Build(json, world, comm, path);
62  else if(json["type"] == "ForwardFlux")
63  method = ForwardFlux::Build(json, world, comm, path);
64  else if(json["type"] == "Metadynamics")
65  method = Meta::Build(json, world, comm, path);
66  else if(json["type"] == "Umbrella")
67  method = Umbrella::Build(json, world, comm, path);
68  else if(json["type"] == "String")
69  method = StringMethod::Build(json, world, comm, path);
70  else
71  throw std::invalid_argument(path + ": Unknown method type specified.");
72 
73  // Load cv mask.
74  std::vector<uint> cvmask;
75  for(auto& v : json["cvs"])
76  {
77  if(v.isString())
78  {
79  auto id = CVManager::LookupCV(v.asString());
80  if(id == -1)
81  throw std::invalid_argument(path + ": CV mask name \"" + v.asString() + "\" does not exist.");
82 
83  cvmask.push_back(CVManager::LookupCV(v.asString()));
84  }
85  else if(v.isIntegral() && v.asInt() >= 0)
86  cvmask.push_back(v.asUInt());
87  else
88  throw std::invalid_argument(path + ": CV mask must contain strings or unsigned integers.");
89 
90  }
91 
92  method->SetCVMask(cvmask);
93  return method;
94  }
static ABF * Build(const Json::Value &json, const MPI_Comm &world, const MPI_Comm &comm, const std::string &path)
Definition: ABF.cpp:302
static Umbrella * Build(const Json::Value &json, const MPI_Comm &world, const MPI_Comm &comm, const std::string &path)
Definition: Umbrella.cpp:113
bool HasErrors()
Check if errors have occured.
Definition: Requirement.h:86
static Meta * Build(const Json::Value &json, const MPI_Comm &world, const MPI_Comm &comm, const std::string &path)
Definition: Meta.cpp:332
virtual void Parse(Value json, const std::string &path) override
Parse JSON value to generate Requirement(s).
Method(uint frequency, const MPI_Comm &world, const MPI_Comm &comm)
Constructor.
Definition: Method.h:61
std::vector< std::string > GetErrors()
Get list of error messages.
Definition: Requirement.h:92
static StringMethod * Build(const Json::Value &json, const MPI_Comm &world, const MPI_Comm &comm, const std::string &path)
Build a derived method from JSON node.
Requirements on an object.
static BFS * Build(const Json::Value &json, const MPI_Comm &world, const MPI_Comm &comm, const std::string &path)
Definition: BasisFunc.cpp:302
static ANN * Build(const Json::Value &json, const MPI_Comm &world, const MPI_Comm &comm, const std::string &path)
Definition: ANN.cpp:216
static int LookupCV(const std::string &name)
Get CV id from map.
Definition: CVManager.h:110
static ForwardFlux * Build(const Json::Value &json, const MPI_Comm &world, const MPI_Comm &comm, const std::string &path)
virtual void Validate(const Value &json, const std::string &path) override
Validate JSON value.

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void SSAGES::Method::PostIntegration ( Snapshot snapshot,
const class CVManager cvmanager 
)
overridepure virtual

Method call post integration.

Parameters
snapshotPointer to the simulation snapshot.
cvmanagerCollective variable manager.

This function will be called after each integration step.

Implements SSAGES::EventListener.

Implemented in SSAGES::ForwardFlux, SSAGES::ABF, SSAGES::BFS, SSAGES::StringMethod, SSAGES::Meta, SSAGES::Umbrella, SSAGES::Swarm, SSAGES::FiniteTempString, SSAGES::ElasticBand, SSAGES::ANN, and SSAGES::DirectForwardFlux.

virtual void SSAGES::Method::PostSimulation ( Snapshot snapshot,
const class CVManager cvmanager 
)
overridepure virtual

Method call post simulation.

Parameters
snapshotPointer to the simulation snapshot.
cvmanagerCollective variable manager.

This function will be called after the end of the simulation run.

Implements SSAGES::EventListener.

Implemented in SSAGES::ForwardFlux, SSAGES::ABF, SSAGES::BFS, SSAGES::StringMethod, SSAGES::Meta, SSAGES::Umbrella, and SSAGES::ANN.

virtual void SSAGES::Method::PreSimulation ( Snapshot snapshot,
const class CVManager cvmanager 
)
overridepure virtual

Method call prior to simulation initiation.

Parameters
snapshotPointer to the simulation snapshot.
cvmanagerCollective variable manager.

This function will be called before the simulation is started.

Implements SSAGES::EventListener.

Implemented in SSAGES::ForwardFlux, SSAGES::ABF, SSAGES::BFS, SSAGES::StringMethod, SSAGES::Meta, SSAGES::Umbrella, and SSAGES::ANN.


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