SSAGES  0.1
A MetaDynamics Package
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Groups Pages
Logger.h
1 
20 #pragma once
21 
22 #include <mxx/comm.hpp>
23 #include <fstream>
24 #include "EventListener.h"
25 
26 // Forward declare.
27 namespace Json {
28  class Value;
29 }
30 
31 namespace SSAGES
32 {
34 
41  class Logger : public EventListener
42  {
43  protected:
44  mxx::comm world_;
45  mxx::comm comm_;
46 
48  std::vector<uint> cvmask_;
49 
51  std::string filename_;
52 
54  std::ofstream log_;
55 
57  bool append_;
58 
59  public:
61 
68  Logger(uint frequency, const std::string& filename, const MPI_Comm& world, const MPI_Comm& comm) :
69  EventListener(frequency), world_(world), comm_(comm), cvmask_(), filename_(filename),
70  append_(false)
71  {}
72 
74 
80  virtual void PreSimulation(Snapshot* snapshot, const class CVManager& cvmanager) override;
81 
83 
89  virtual void PostIntegration(Snapshot* snapshot, const class CVManager& cvmanager) override;
90 
92 
98  virtual void PostSimulation(Snapshot* snapshot, const class CVManager& cvmanager) override;
99 
101  void SetCVMask(const std::vector<uint>& mask)
102  {
103  cvmask_ = mask;
104  }
105 
107 
110  void SetAppend(bool append)
111  {
112  append_ = append;
113  }
114 
116 
125  static Logger* Build(const Json::Value& json,
126  const MPI_Comm& world,
127  const MPI_Comm& comm,
128  const std::string& path);
129 
131  virtual ~Logger()
132  {
133  }
134  };
135 }
mxx::comm comm_
Local MPI communicator.
Definition: Logger.h:45
Base abstract class for listening in to events fired by "Hook".
Definition: EventListener.h:34
Collective variable manager.
Definition: CVManager.h:40
virtual ~Logger()
Destructor.
Definition: Logger.h:131
void SetCVMask(const std::vector< uint > &mask)
Sets the collective variable mask.
Definition: Logger.h:101
mxx::comm world_
Global MPI communicator.
Definition: Logger.h:44
Class containing a snapshot of the current simulation in time.
Definition: Snapshot.h:43
void SetAppend(bool append)
Set append mode.
Definition: Logger.h:110
std::string filename_
Name of logfile.
Definition: Logger.h:51
bool append_
Append mode?
Definition: Logger.h:57
virtual void PostSimulation(Snapshot *snapshot, const class CVManager &cvmanager) override
Logger call post simulation.
Definition: Logger.cpp:71
std::vector< uint > cvmask_
Mask which identifies which CVs to log.
Definition: Logger.h:48
Logger(uint frequency, const std::string &filename, const MPI_Comm &world, const MPI_Comm &comm)
Constructor.
Definition: Logger.h:68
virtual void PreSimulation(Snapshot *snapshot, const class CVManager &cvmanager) override
Logger call prior to simulation initiation.
Definition: Logger.cpp:34
virtual void PostIntegration(Snapshot *snapshot, const class CVManager &cvmanager) override
Logger call post integration.
Definition: Logger.cpp:55
Base class for logging SSAGES data.
Definition: Logger.h:41
std::ofstream log_
Log file stream.
Definition: Logger.h:54
static Logger * Build(const Json::Value &json, const MPI_Comm &world, const MPI_Comm &comm, const std::string &path)
Build a Logger from JSON node.
Definition: Logger.cpp:75