SSAGES  0.8.3
Software Suite for Advanced General Ensemble Simulations
COPSS.h
1 
21 #pragma once
22 
23 #include "Constraint.h"
24 #include <iostream>
25 #include <iomanip>
26 #include <boost/mpi.hpp>
27 #include <fstream>
28 
29 namespace SSAGES
30 {
32  class COPSS : public Constraint
33  {
34  private:
36  std::ofstream myout_;
37 
38  public:
40 
44  COPSS(boost::mpi::communicator& comm,
45  unsigned int frequency) :
46  Constraint(frequency, comm)
47  {
48  myout_.open("test.out");
49  }
50 
52  void PreSimulation(Snapshot*, const CVList&) override
53  {
54  myout_<<"In PreSimulation"<<std::endl;
55  }
56 
58  void PostIntegration(Snapshot* snapshot, const CVList&) override
59  {
60 
61  using std::setw;
62  using std::right;
63  using std::setprecision;
64 
65 
66  myout_ << snapshot->GetWalkerID()
67  << " " << snapshot->GetCommunicator().rank() << std::endl;
68  auto& f = snapshot->GetForces();
69  f[0][0] = 1.000000*f[0][0];
70  }
71 
73  void PostSimulation(Snapshot*, const CVList&) override
74  {
75  myout_ <<" Post simulation"<<std::endl;
76  }
77 
79 
82  void Serialize(Json::Value& /* json */) const override
83  {
84 
85  }
86 
88  ~COPSS() { myout_.close(); }
89  };
90 }
std::vector< CollectiveVariable * > CVList
List of Collective Variables.
Definition: types.h:51
const mxx::comm & GetCommunicator() const
Get communicator for walker.
Definition: Snapshot.h:184
Wrapper class for COPSS simulations.
Definition: COPSS.h:32
const std::vector< Vector3 > & GetForces() const
Access the per-particle forces.
Definition: Snapshot.h:362
Class containing a snapshot of the current simulation in time.
Definition: Snapshot.h:43
void Serialize(Json::Value &) const override
Serialize the class.
Definition: COPSS.h:82
~COPSS()
Destructor.
Definition: COPSS.h:88
std::ofstream myout_
Output stream for debug output.
Definition: COPSS.h:36
Interface for Constraint implementations.
Definition: Constraint.h:41
unsigned GetWalkerID() const
Get walker ID.
Definition: Snapshot.h:193
void PreSimulation(Snapshot *, const CVList &) override
Pre-Simulation Hook.
Definition: COPSS.h:52
void PostSimulation(Snapshot *, const CVList &) override
Post-Simulation Hook.
Definition: COPSS.h:73
COPSS(boost::mpi::communicator &comm, unsigned int frequency)
Constructor.
Definition: COPSS.h:44
void PostIntegration(Snapshot *snapshot, const CVList &) override
Post-Integration Hook.
Definition: COPSS.h:58