SSAGES  0.9.3
Software Suite for Advanced General Ensemble Simulations
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 (unsigned int 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< unsigned int > &mask)
 Sets the collective variable mask. More...
 
virtual ~Method ()
 Destructor.
 
- Public Member Functions inherited from SSAGES::EventListener
 EventListener (unsigned int frequency)
 Constructor. More...
 
unsigned int 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...
 
- Static Public Member Functions inherited from SSAGES::EventListener
static unsigned int GetWalkerID (const MPI_Comm &world, const MPI_Comm &comm)
 Get walker ID number of specified communicator. More...
 
static unsigned int GetNumWalkers (const MPI_Comm &world, const MPI_Comm &comm)
 Get total number of walkers in the simulation. More...
 
static bool IsMasterRank (const MPI_Comm &comm)
 Check if current processor is master. More...
 

Protected Attributes

mxx::comm world_
 Global MPI communicator.
 
mxx::comm comm_
 Local MPI communicator.
 
std::vector< unsigned int > 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

◆ Method()

SSAGES::Method::Method ( unsigned int  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  {}
EventListener(unsigned int frequency)
Constructor.
Definition: EventListener.h:45
mxx::comm comm_
Local MPI communicator.
Definition: Method.h:47
std::vector< unsigned int > cvmask_
Mask which identifies which CVs to act on.
Definition: Method.h:50
mxx::comm world_
Global MPI communicator.
Definition: Method.h:46

Member Function Documentation

◆ BuildMethod()

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 40 of file Method.cpp.

44  {
45  ObjectRequirement validator;
46  Value schema;
47  CharReaderBuilder rbuilder;
48  CharReader* reader = rbuilder.newCharReader();
49 
50  reader->parse(JsonSchema::Method.c_str(),
51  JsonSchema::Method.c_str() + JsonSchema::Method.size(),
52  &schema, nullptr);
53  validator.Parse(schema, path);
54  validator.Validate(json, path);
55  if(validator.HasErrors())
56  throw BuildException(validator.GetErrors());
57 
58  Method* method = nullptr;
59 
60  if(json["type"] == "ABF")
61  method = ABF::Build(json, world, comm, path);
62  else if(json["type"] == "ANN")
63  method = ANN::Build(json, world, comm, path);
64  else if(json["type"] == "BFSMethod")
65  method = BFS::Build(json, world, comm, path);
66  else if(json["type"] == "CFF")
67  method = CFF::Build(json, world, comm, path);
68  else if(json["type"] == "ForwardFlux")
69  method = ForwardFlux::Build(json, world, comm, path);
70  else if(json["type"] == "Metadynamics")
71  method = Meta::Build(json, world, comm, path);
72  else if(json["type"] == "Umbrella")
73  method = Umbrella::Build(json, world, comm, path);
74  else if(json["type"] == "String")
75  method = StringMethod::Build(json, world, comm, path);
76  else
77  throw std::invalid_argument(path + ": Unknown method type specified.");
78 
79  // Load cv mask.
80  std::vector<unsigned int> cvmask;
81  for(auto& cv : json["cvs"])
82  {
83  cvmask.push_back(CVManager::LookupCV(cv, path));
84  }
85 
86  method->SetCVMask(cvmask);
87  return method;
88  }
Requirements on an object.
virtual void Parse(Value json, const std::string &path) override
Parse JSON value to generate Requirement(s).
virtual void Validate(const Value &json, const std::string &path) override
Validate JSON value.
std::vector< std::string > GetErrors()
Get list of error messages.
Definition: Requirement.h:92
bool HasErrors()
Check if errors have occured.
Definition: Requirement.h:86
static ABF * Build(const Json::Value &json, const MPI_Comm &world, const MPI_Comm &comm, const std::string &path)
Build a derived method from JSON node.
Definition: ABF.cpp:297
static ANN * Build(const Json::Value &json, const MPI_Comm &world, const MPI_Comm &comm, const std::string &path)
Build a derived method from JSON node.
Definition: ANN.cpp:287
static BFS * Build(const Json::Value &json, const MPI_Comm &world, const MPI_Comm &comm, const std::string &path)
Build a derived method from JSON node.
Definition: BasisFunc.cpp:308
static CFF * Build(const Json::Value &json, const MPI_Comm &world, const MPI_Comm &comm, const std::string &path)
Build a derived method from JSON node.
Definition: CFF.cpp:407
static int LookupCV(const Json::Value &cv, const std::string &path)
Get CV id from map.
Definition: CVManager.h:112
static ForwardFlux * Build(const Json::Value &json, const MPI_Comm &world, const MPI_Comm &comm, const std::string &path)
Build a derived method from JSON node.
static Meta * Build(const Json::Value &json, const MPI_Comm &world, const MPI_Comm &comm, const std::string &path)
Build a derived method from JSON node.
Definition: Meta.cpp:332
Method(unsigned int frequency, const MPI_Comm &world, const MPI_Comm &comm)
Constructor.
Definition: Method.h:61
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.
static Umbrella * Build(const Json::Value &json, const MPI_Comm &world, const MPI_Comm &comm, const std::string &path)
Build a derived method from JSON node.
Definition: Umbrella.cpp:112

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

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PostIntegration()

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::StringMethod, SSAGES::ForwardFlux, SSAGES::Umbrella, SSAGES::Swarm, SSAGES::Meta, SSAGES::FiniteTempString, SSAGES::ElasticBand, SSAGES::DirectForwardFlux, SSAGES::CFF, SSAGES::BFS, SSAGES::ANN, and SSAGES::ABF.

◆ PostSimulation()

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::Umbrella, SSAGES::StringMethod, SSAGES::Meta, SSAGES::ForwardFlux, SSAGES::CFF, SSAGES::BFS, SSAGES::ANN, and SSAGES::ABF.

◆ PreSimulation()

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::Umbrella, SSAGES::StringMethod, SSAGES::Meta, SSAGES::ForwardFlux, SSAGES::CFF, SSAGES::BFS, SSAGES::ANN, and SSAGES::ABF.

◆ SetCVMask()

void SSAGES::Method::SetCVMask ( const std::vector< unsigned int > &  mask)
inline

Sets the collective variable mask.

Parameters
maskVector mask which contains the indices of which CV to include in the container.

This function sets the Snapshot's CV mask.

Definition at line 99 of file Method.h.

100  {
101  cvmask_ = mask;
102  }

References cvmask_.

Referenced by BuildMethod().

Here is the caller graph for this function:

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