Version: SMASH-1.5
smash::BinaryOutputParticles Class Reference

#include <binaryoutput.h>

Writes the particle list at specific times to the binary file.

This class writes the current particle list at a specific time t to the binary output file. This specific time can be: event start, event end or every next time interval \(\Delta t \). Writing (or not writing) the output at these moments is controlled by different options. The time interval \(\Delta t \) is also regulated by an option. The output file is binary and has a block structure.

Details of the output format can be found on the wiki in the User Guide section, look for binary output.

Definition at line 188 of file binaryoutput.h.

Inheritance diagram for smash::BinaryOutputParticles:
[legend]
Collaboration diagram for smash::BinaryOutputParticles:
[legend]

Public Member Functions

 BinaryOutputParticles (const bf::path &path, std::string name, const OutputParameters &out_par)
 Create binary particle output. More...
 
void at_eventstart (const Particles &particles, const int event_number) override
 Writes the initial particle information of an event to the binary output. More...
 
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. More...
 
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. More...
 
- Public Member Functions inherited from smash::OutputInterface
 OutputInterface (std::string name)
 Construct output interface. More...
 
virtual ~OutputInterface ()=default
 
virtual void at_interaction (const Action &action, const double density)
 Called whenever an action modified one or more particles. More...
 
virtual void thermodynamics_output (const ThermodynamicQuantity tq, const DensityType dt, RectangularLattice< DensityOnLattice > &lattice)
 Output to write thermodynamics from the lattice. More...
 
virtual void thermodynamics_output (const ThermodynamicQuantity tq, const DensityType dt, RectangularLattice< EnergyMomentumTensor > &lattice)
 Output to write energy-momentum tensor and related quantities from the lattice. More...
 
virtual void thermodynamics_output (const GrandCanThermalizer &gct)
 Output to write energy-momentum tensor and related quantities from the thermalizer class. More...
 
bool is_dilepton_output () const
 Get, whether this is the dilepton output? More...
 
bool is_photon_output () const
 Get, whether this is the photon output? More...
 
const char * to_string (const ThermodynamicQuantity tq)
 Convert thermodynamic quantities to strings. More...
 
const char * to_string (const DensityType dens_type)
 Convert density types to strings. More...
 

Private Attributes

bool only_final_
 Write only final particles (True) or both, inital and final (False). More...
 

Additional Inherited Members

- Protected Member Functions inherited from smash::BinaryOutputBase
 BinaryOutputBase (const bf::path &path, const std::string &mode, const std::string &name, bool extended_format)
 Create binary output base. More...
 
void write (const std::string &s)
 Write string to binary output. More...
 
void write (const double x)
 Write double to binary output. More...
 
void write (const FourVector &v)
 Write four-vector to binary output. More...
 
void write (const std::int32_t x)
 Write integer (32 bit) to binary output. More...
 
void write (const std::uint32_t x)
 Write unsigned integer (32 bit) to binary output. More...
 
void write (const std::uint16_t x)
 Write unsigned integer (16 bit) to binary output. More...
 
void write (const size_t x)
 Write a std::size_t to binary output. More...
 
void write (const Particles &particles)
 Write particle data of each particle in particles to binary output. More...
 
void write (const ParticleList &particles)
 Write each particle data entry to binary output. More...
 
void write_particledata (const ParticleData &p)
 Write particle data to binary output. More...
 
- Protected Attributes inherited from smash::BinaryOutputBase
RenamingFilePtr file_
 Binary particles output file path. More...
 
- Protected Attributes inherited from smash::OutputInterface
const bool is_dilepton_output_
 Is this the dilepton output? More...
 
const bool is_photon_output_
 Is this the photon output? More...
 

Constructor & Destructor Documentation

◆ BinaryOutputParticles()

smash::BinaryOutputParticles::BinaryOutputParticles ( const bf::path &  path,
std::string  name,
const OutputParameters out_par 
)

Create binary particle output.

Parameters
[in]pathOutput path.
[in]nameName of the ouput.
[in]out_parA structure containing the parameters of the output.

Definition at line 231 of file binaryoutput.cc.

234  : BinaryOutputBase(path / "particles_binary.bin", "wb", name,
235  out_par.part_extended),
236  only_final_(out_par.part_only_final) {}
BinaryOutputBase(const bf::path &path, const std::string &mode, const std::string &name, bool extended_format)
Create binary output base.
bool only_final_
Write only final particles (True) or both, inital and final (False).
Definition: binaryoutput.h:228

Member Function Documentation

◆ at_eventstart()

void smash::BinaryOutputParticles::at_eventstart ( const Particles particles,
const int  event_number 
)
overridevirtual

Writes the initial particle information of an event to the binary output.

Parameters
[in]particlesCurrent list of all particles.
[in]event_numberUnused, needed since inherited.

Implements smash::OutputInterface.

Definition at line 238 of file binaryoutput.cc.

239  {
240  char pchar = 'p';
241  if (!only_final_) {
242  std::fwrite(&pchar, sizeof(char), 1, file_.get());
243  write(particles.size());
244  write(particles);
245  }
246 }
FILE * get()
Get the underlying FILE* pointer.
Definition: file.cc:27
RenamingFilePtr file_
Binary particles output file path.
Definition: binaryoutput.h:108
void write(const std::string &s)
Write string to binary output.
bool only_final_
Write only final particles (True) or both, inital and final (False).
Definition: binaryoutput.h:228
Here is the call graph for this function:

◆ at_eventend()

void smash::BinaryOutputParticles::at_eventend ( const Particles particles,
const int  event_number,
double  impact_parameter 
)
overridevirtual

Writes the final particle information of an event to the binary output.

Parameters
[in]particlesCurrent list of particles.
[in]event_numberNumber of event.
[in]impact_parameterImpact parameter of this event.

Implements smash::OutputInterface.

Definition at line 248 of file binaryoutput.cc.

250  {
251  char pchar = 'p';
252  std::fwrite(&pchar, sizeof(char), 1, file_.get());
253  write(particles.size());
254  write(particles);
255 
256  // Event end line
257  char fchar = 'f';
258  std::fwrite(&fchar, sizeof(char), 1, file_.get());
259  write(event_number);
260  write(impact_parameter);
261 
262  // Flush to disk
263  std::fflush(file_.get());
264 }
FILE * get()
Get the underlying FILE* pointer.
Definition: file.cc:27
RenamingFilePtr file_
Binary particles output file path.
Definition: binaryoutput.h:108
void write(const std::string &s)
Write string to binary output.
Here is the call graph for this function:

◆ at_intermediate_time()

void smash::BinaryOutputParticles::at_intermediate_time ( const Particles particles,
const Clock clock,
const DensityParameters dens_param 
)
overridevirtual

Writes particles at each time interval; fixed by option OUTPUT_INTERVAL.

Parameters
[in]particlesCurrent list of particles.
[in]clockUnused, needed since inherited.
[in]dens_paramUnused, needed since inherited.

Reimplemented from smash::OutputInterface.

Definition at line 266 of file binaryoutput.cc.

268  {
269  char pchar = 'p';
270  if (!only_final_) {
271  std::fwrite(&pchar, sizeof(char), 1, file_.get());
272  write(particles.size());
273  write(particles);
274  }
275 }
FILE * get()
Get the underlying FILE* pointer.
Definition: file.cc:27
RenamingFilePtr file_
Binary particles output file path.
Definition: binaryoutput.h:108
void write(const std::string &s)
Write string to binary output.
bool only_final_
Write only final particles (True) or both, inital and final (False).
Definition: binaryoutput.h:228
Here is the call graph for this function:

Member Data Documentation

◆ only_final_

bool smash::BinaryOutputParticles::only_final_
private

Write only final particles (True) or both, inital and final (False).

Definition at line 228 of file binaryoutput.h.


The documentation for this class was generated from the following files: