SSAGES  0.8.3
Software Suite for Advanced General Ensemble Simulations
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<unsigned int> cvmask_;
49 
51  std::string filename_;
52 
54  std::ofstream log_;
55 
57  bool append_;
58 
59  public:
61 
69  Logger(unsigned int frequency, const std::string& filename, const MPI_Comm& world, const MPI_Comm& comm) :
70  EventListener(frequency), world_(world), comm_(comm), cvmask_(), filename_(filename),
71  append_(false)
72  {}
73 
75 
81  virtual void PreSimulation(Snapshot* snapshot, const class CVManager& cvmanager) override;
82 
84 
90  virtual void PostIntegration(Snapshot* snapshot, const class CVManager& cvmanager) override;
91 
93 
99  virtual void PostSimulation(Snapshot* snapshot, const class CVManager& cvmanager) override;
100 
102  void SetCVMask(const std::vector<unsigned int>& mask)
103  {
104  cvmask_ = mask;
105  }
106 
108 
111  void SetAppend(bool append)
112  {
113  append_ = append;
114  }
115 
117 
126  static Logger* Build(const Json::Value& json,
127  const MPI_Comm& world,
128  const MPI_Comm& comm,
129  const std::string& path);
130 
132  virtual ~Logger()
133  {
134  }
135  };
136 }
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:132
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 SetCVMask(const std::vector< unsigned int > &mask)
Sets the collective variable mask.
Definition: Logger.h:102
void SetAppend(bool append)
Set append mode.
Definition: Logger.h:111
std::string filename_
Name of logfile.
Definition: Logger.h:51
bool append_
Append mode?
Definition: Logger.h:57
std::vector< unsigned int > cvmask_
Mask which identifies which CVs to log.
Definition: Logger.h:48
Logger(unsigned int frequency, const std::string &filename, const MPI_Comm &world, const MPI_Comm &comm)
Constructor.
Definition: Logger.h:69
Base class for logging SSAGES data.
Definition: Logger.h:41
std::ofstream log_
Log file stream.
Definition: Logger.h:54