Version: SMASH-3.0
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 196 of file binaryoutput.h.

Inheritance diagram for smash::BinaryOutputParticles:
smash::BinaryOutputBase smash::OutputInterface

Public Member Functions

 BinaryOutputParticles (const std::filesystem::path &path, std::string name, const OutputParameters &out_par)
 Create binary particle output. More...
 
void at_eventstart (const Particles &particles, const int event_number, const EventInfo &event) override
 Writes the initial particle information of an event to the binary output. More...
 
void at_eventend (const Particles &particles, const int event_number, const EventInfo &event) override
 Writes the final particle information of an event to the binary output. More...
 
void at_intermediate_time (const Particles &particles, const std::unique_ptr< Clock > &clock, const DensityParameters &dens_param, const EventInfo &event) 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_eventstart (const std::vector< Particles > &ensembles, int event_number)
 Output launched at event start after initialization, when particles are generated but not yet propagated. More...
 
virtual void at_eventstart (const int event_number, const ThermodynamicQuantity tq, const DensityType dens_type, RectangularLattice< DensityOnLattice > lattice)
 Output launched at event start after initialization, when particles are generated but not yet propagated. More...
 
virtual void at_eventstart (const int event_number, const ThermodynamicQuantity tq, const DensityType dens_type, RectangularLattice< EnergyMomentumTensor > lattice)
 Output launched atevent start after initialization, when particles are generated but not yet propagated. More...
 
virtual void at_eventend (const int event_number, const ThermodynamicQuantity tq, const DensityType dens_type)
 Output launched at event end. More...
 
virtual void at_eventend (const ThermodynamicQuantity tq)
 Output launched at event end. More...
 
virtual void at_eventend (const std::vector< Particles > &ensembles, const int event_number)
 Output launched at event end. More...
 
virtual void at_interaction (const Action &action, const double density)
 Called whenever an action modified one or more particles. More...
 
virtual void at_intermediate_time (const std::vector< Particles > &ensembles, const std::unique_ptr< Clock > &clock, const DensityParameters &dens_param)
 Output launched after every N'th timestep. 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_lattice_output (RectangularLattice< DensityOnLattice > &lattice, const double current_time)
 Output to write thermodynamics from the lattice. More...
 
virtual void thermodynamics_lattice_output (RectangularLattice< DensityOnLattice > &lattice, const double current_time, const std::vector< Particles > &ensembles, const DensityParameters &dens_param)
 Output to write thermodynamics from the lattice. More...
 
virtual void thermodynamics_lattice_output (const ThermodynamicQuantity tq, RectangularLattice< EnergyMomentumTensor > &lattice, const double current_time)
 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...
 
virtual void fields_output (const std::string name1, const std::string name2, RectangularLattice< std::pair< ThreeVector, ThreeVector >> &lat)
 Write fields in vtk output. 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...
 
bool is_IC_output () const
 Get, whether this is the IC 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

OutputOnlyFinal only_final_
 Whether final- or initial-state particles should be written. More...
 

Additional Inherited Members

- Protected Member Functions inherited from smash::BinaryOutputBase
 BinaryOutputBase (const std::filesystem::path &path, const std::string &mode, const std::string &name, bool extended_format)
 Create binary output base. More...
 
void write (const char c)
 Write byte to binary output. 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...
 
const bool is_IC_output_
 Is this the IC output? More...
 

Constructor & Destructor Documentation

◆ BinaryOutputParticles()

smash::BinaryOutputParticles::BinaryOutputParticles ( const std::filesystem::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 257 of file binaryoutput.cc.

260  : BinaryOutputBase(path / "particles_binary.bin", "wb", name,
261  out_par.part_extended),
262  only_final_(out_par.part_only_final) {}
BinaryOutputBase(const std::filesystem::path &path, const std::string &mode, const std::string &name, bool extended_format)
Create binary output base.
OutputOnlyFinal only_final_
Whether final- or initial-state particles should be written.
Definition: binaryoutput.h:240

Member Function Documentation

◆ at_eventstart()

void smash::BinaryOutputParticles::at_eventstart ( const Particles particles,
const int  event_number,
const EventInfo event 
)
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.
[in]eventEvent info, see event_info

Reimplemented from smash::OutputInterface.

Definition at line 264 of file binaryoutput.cc.

265  {
266  const char pchar = 'p';
268  std::fwrite(&pchar, sizeof(char), 1, file_.get());
269  write(particles.size());
270  write(particles);
271  }
272 }
void write(const char c)
Write byte to binary output.
RenamingFilePtr file_
Binary particles output file path.
Definition: binaryoutput.h:115
FILE * get()
Get the underlying FILE* pointer.
Definition: file.cc:27
@ No
Print initial, intermediate and final-state particles.

◆ at_eventend()

void smash::BinaryOutputParticles::at_eventend ( const Particles particles,
const int  event_number,
const EventInfo event 
)
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]eventEvent info, see event_info

Reimplemented from smash::OutputInterface.

Definition at line 274 of file binaryoutput.cc.

276  {
277  const char pchar = 'p';
278  if (!(event.empty_event && only_final_ == OutputOnlyFinal::IfNotEmpty)) {
279  std::fwrite(&pchar, sizeof(char), 1, file_.get());
280  write(particles.size());
281  write(particles);
282  }
283 
284  // Event end line
285  const char fchar = 'f';
286  std::fwrite(&fchar, sizeof(char), 1, file_.get());
287  write(event_number);
288  write(event.impact_parameter);
289  const char empty = event.empty_event;
290  write(empty);
291 
292  // Flush to disk
293  std::fflush(file_.get());
294 }
@ IfNotEmpty
Print only final-state particles, and those only if the event is not empty.

◆ at_intermediate_time()

void smash::BinaryOutputParticles::at_intermediate_time ( const Particles particles,
const std::unique_ptr< Clock > &  clock,
const DensityParameters dens_param,
const EventInfo event 
)
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.
[in]eventEvent info, see event_info.

Reimplemented from smash::OutputInterface.

Definition at line 296 of file binaryoutput.cc.

299  {
300  const char pchar = 'p';
302  std::fwrite(&pchar, sizeof(char), 1, file_.get());
303  write(particles.size());
304  write(particles);
305  }
306 }

Member Data Documentation

◆ only_final_

OutputOnlyFinal smash::BinaryOutputParticles::only_final_
private

Whether final- or initial-state particles should be written.

Definition at line 240 of file binaryoutput.h.


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