SSAGES  0.9.3
Software Suite for Advanced General Ensemble Simulations
EventListener.h
1 
21 #pragma once
22 
23 #include <mxx/comm.hpp>
24 #include "types.h"
25 
26 namespace SSAGES
27 {
28  // Forward declare.
29  class Snapshot;
30 
32 
36  {
37  private:
38  unsigned int frequency_;
39 
40  public:
42 
45  EventListener(unsigned int frequency) :
46  frequency_(frequency)
47  {
48  }
49 
51 
54  unsigned int GetFrequency() const { return frequency_; }
55 
57 
63  virtual void PreSimulation(Snapshot* snapshot, const class CVManager& cvmanager) = 0;
64 
66 
72  virtual void PostIntegration(Snapshot* snapshot, const class CVManager& cvmanager) = 0;
73 
75 
81  virtual void PostSimulation(Snapshot* snapshot, const class CVManager& cvmanager) = 0;
82 
84 
89  static unsigned int GetWalkerID(const MPI_Comm& world, const MPI_Comm& comm)
90  {
91  return mxx::comm(world).rank()/mxx::comm(comm).size();
92  }
93 
95 
100  static unsigned int GetNumWalkers(const MPI_Comm& world, const MPI_Comm& comm)
101  {
102  return mxx::comm(world).size()/mxx::comm(comm).size();
103  }
104 
106 
110  static bool IsMasterRank(const MPI_Comm& comm)
111  {
112  return mxx::comm(comm).rank() == 0;
113  }
114 
116  virtual ~EventListener() {}
117  };
118 }
Collective variable manager.
Definition: CVManager.h:43
Base abstract class for listening in to events fired by "Hook".
Definition: EventListener.h:36
EventListener(unsigned int frequency)
Constructor.
Definition: EventListener.h:45
virtual void PostSimulation(Snapshot *snapshot, const class CVManager &cvmanager)=0
Method call post simulation.
virtual void PostIntegration(Snapshot *snapshot, const class CVManager &cvmanager)=0
Method call post integration.
virtual ~EventListener()
Destructor.
unsigned int GetFrequency() const
Get frequency of event listener.
Definition: EventListener.h:54
static unsigned int GetNumWalkers(const MPI_Comm &world, const MPI_Comm &comm)
Get total number of walkers in the simulation.
unsigned int frequency_
Frequency for listening.
Definition: EventListener.h:38
virtual void PreSimulation(Snapshot *snapshot, const class CVManager &cvmanager)=0
Method call prior to simulation initiation.
static bool IsMasterRank(const MPI_Comm &comm)
Check if current processor is master.
static unsigned int GetWalkerID(const MPI_Comm &world, const MPI_Comm &comm)
Get walker ID number of specified communicator.
Definition: EventListener.h:89
Class containing a snapshot of the current simulation in time.
Definition: Snapshot.h:48