SSAGES  0.1
A MetaDynamics Package
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Groups Pages
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 38 of file Method.cpp.

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

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

42  {
43  ObjectRequirement validator;
44  Value schema;
45  Reader reader;
46 
47  reader.parse(JsonSchema::Method, schema);
48  validator.Parse(schema, path);
49  validator.Validate(json, path);
50  if(validator.HasErrors())
51  throw BuildException(validator.GetErrors());
52 
53  Method* method = nullptr;
54 
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);
67  else
68  throw std::invalid_argument(path + ": Unknown method type specified.");
69 
70  // Load cv mask.
71  std::vector<uint> cvmask;
72  for(auto& v : json["cvs"])
73  {
74  if(v.isString())
75  {
76  auto id = CVManager::LookupCV(v.asString());
77  if(id == -1)
78  throw std::invalid_argument(path + ": CV mask name \"" + v.asString() + "\" does not exist.");
79 
80  cvmask.push_back(CVManager::LookupCV(v.asString()));
81  }
82  else if(v.isIntegral() && v.asInt() >= 0)
83  cvmask.push_back(v.asUInt());
84  else
85  throw std::invalid_argument(path + ": CV mask must contain strings or unsigned integers.");
86 
87  }
88 
89  method->SetCVMask(cvmask);
90  return method;
91  }
static ABF * Build(const Json::Value &json, const MPI_Comm &world, const MPI_Comm &comm, const std::string &path)
Definition: ABF.cpp:311
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 Basis * Build(const Json::Value &json, const MPI_Comm &world, const MPI_Comm &comm, const std::string &path)
Definition: BasisFunc.cpp:521
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::Basis, SSAGES::ABF, SSAGES::StringMethod, SSAGES::Meta, SSAGES::Umbrella, SSAGES::Swarm, SSAGES::FiniteTempString, SSAGES::ElasticBand, 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::Basis, SSAGES::ABF, SSAGES::StringMethod, SSAGES::Meta, and SSAGES::Umbrella.

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::Basis, SSAGES::ABF, SSAGES::StringMethod, SSAGES::Meta, and SSAGES::Umbrella.


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