Version: SMASH-1.5
binaryoutput.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (c) 2014-2018
4  * SMASH Team
5  *
6  * GNU General Public License (GPLv3 or later)
7  *
8  */
9 
10 #ifndef SRC_INCLUDE_BINARYOUTPUT_H_
11 #define SRC_INCLUDE_BINARYOUTPUT_H_
12 
13 #include <string>
14 
15 #include <boost/numeric/conversion/cast.hpp>
16 
17 #include "file.h"
18 #include "forwarddeclarations.h"
19 #include "outputinterface.h"
20 #include "outputparameters.h"
21 
22 namespace smash {
23 
29  protected:
38  explicit BinaryOutputBase(const bf::path &path, const std::string &mode,
39  const std::string &name, bool extended_format);
40 
45  void write(const std::string &s);
46 
51  void write(const double x);
52 
57  void write(const FourVector &v);
58 
63  void write(const std::int32_t x) {
64  std::fwrite(&x, sizeof(x), 1, file_.get());
65  }
66 
71  void write(const std::uint32_t x) {
72  std::fwrite(&x, sizeof(x), 1, file_.get());
73  }
74 
79  void write(const std::uint16_t x) {
80  std::fwrite(&x, sizeof(x), 1, file_.get());
81  }
82 
87  void write(const size_t x) { write(boost::numeric_cast<uint32_t>(x)); }
88 
93  void write(const Particles &particles);
94 
99  void write(const ParticleList &particles);
100 
105  void write_particledata(const ParticleData &p);
106 
109 
110  private:
112  uint16_t format_version_ = 6;
114  bool extended_;
115 };
116 
130  public:
138  BinaryOutputCollisions(const bf::path &path, std::string name,
139  const OutputParameters &out_par);
140 
147  void at_eventstart(const Particles &particles,
148  const int event_number) override;
149 
157  void at_eventend(const Particles &particles, const int event_number,
158  double impact_parameter) override;
159 
166  void at_interaction(const Action &action, const double density) override;
167 
168  private:
171 };
172 
189  public:
197  BinaryOutputParticles(const bf::path &path, std::string name,
198  const OutputParameters &out_par);
199 
205  void at_eventstart(const Particles &particles,
206  const int event_number) override;
207 
214  void at_eventend(const Particles &particles, const int event_number,
215  double impact_parameter) override;
216 
223  void at_intermediate_time(const Particles &particles, const Clock &clock,
224  const DensityParameters &dens_param) override;
225 
226  private:
229 };
230 
231 } // namespace smash
232 
233 #endif // SRC_INCLUDE_BINARYOUTPUT_H_
void at_intermediate_time(const Particles &particles, const Clock &clock, const DensityParameters &dens_param) override
Writes particles at each time interval; fixed by option OUTPUT_INTERVAL.
A class to pre-calculate and store parameters relevant for density calculation.
Definition: density.h:103
void at_eventend(const Particles &particles, const int event_number, double impact_parameter) override
Writes the final particle information of an event to the binary output.
void at_interaction(const Action &action, const double density) override
Writes an interaction block, including information about the incoming and outgoing particles...
BinaryOutputCollisions(const bf::path &path, std::string name, const OutputParameters &out_par)
Create binary particle output.
void write(const std::uint16_t x)
Write unsigned integer (16 bit) to binary output.
Definition: binaryoutput.h:79
void write(const size_t x)
Write a std::size_t to binary output.
Definition: binaryoutput.h:87
FILE * get()
Get the underlying FILE* pointer.
Definition: file.cc:27
RenamingFilePtr file_
Binary particles output file path.
Definition: binaryoutput.h:108
Writes the particle list at specific times to the binary file.
Definition: binaryoutput.h:188
void write_particledata(const ParticleData &p)
Write particle data to binary output.
void write(const std::uint32_t x)
Write unsigned integer (32 bit) to binary output.
Definition: binaryoutput.h:71
void write(const std::int32_t x)
Write integer (32 bit) to binary output.
Definition: binaryoutput.h:63
uint16_t format_version_
Binary file format version number.
Definition: binaryoutput.h:112
A RAII type to replace std::FILE *.
Definition: file.h:73
void at_eventstart(const Particles &particles, const int event_number) override
Writes the initial particle information of an event to the binary output.
void write(const std::string &s)
Write string to binary output.
Helper structure for Experiment to hold output options and parameters.
Saves SMASH collision history to binary file.
Definition: binaryoutput.h:129
Base class for SMASH binary output.
Definition: binaryoutput.h:28
Clock tracks the time in the simulation.
Definition: clock.h:75
Action is the base class for a generic process that takes a number of incoming particles and transfor...
Definition: action.h:34
BinaryOutputBase(const bf::path &path, const std::string &mode, const std::string &name, bool extended_format)
Create binary output base.
void at_eventstart(const Particles &particles, const int event_number) override
Writes the initial particle information list of an event to the binary output.
void at_eventend(const Particles &particles, const int event_number, double impact_parameter) override
Writes the final particle information list of an event to the binary output.
constexpr int p
Proton.
bool print_start_end_
Write initial and final particles additonally to collisions?
Definition: binaryoutput.h:170
bool only_final_
Write only final particles (True) or both, inital and final (False).
Definition: binaryoutput.h:228
The Particles class abstracts the storage and manipulation of particles.
Definition: particles.h:33
The FourVector class holds relevant values in Minkowski spacetime with (+, −, −, −) metric signature.
Definition: fourvector.h:32
BinaryOutputParticles(const bf::path &path, std::string name, const OutputParameters &out_par)
Create binary particle output.
ParticleData contains the dynamic information of a certain particle.
Definition: particledata.h:52
Abstraction of generic output.
Definition: action.h:24
bool extended_
Option for extended output.
Definition: binaryoutput.h:114