Version: SMASH-3.0
outputinterface.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (c) 2014-2022
4  * SMASH Team
5  *
6  * GNU General Public License (GPLv3 or later)
7  *
8  */
9 
10 #ifndef SRC_INCLUDE_SMASH_OUTPUTINTERFACE_H_
11 #define SRC_INCLUDE_SMASH_OUTPUTINTERFACE_H_
12 
13 #include <memory>
14 #include <string>
15 #include <utility>
16 #include <vector>
17 
18 #include "density.h"
19 #include "energymomentumtensor.h"
20 #include "forwarddeclarations.h"
21 #include "grandcan_thermalizer.h"
22 #include "lattice.h"
23 #include "macros.h"
24 
25 namespace smash {
26 static constexpr int LOutput = LogArea::Output::id;
27 
38 struct EventInfo {
42  double modus_length;
44  double current_time;
50  double total_energy;
59 };
60 
73  public:
78  explicit OutputInterface(std::string name)
79  : is_dilepton_output_(name == "Dileptons"),
80  is_photon_output_(name == "Photons"),
81  is_IC_output_(name == "SMASH_IC") {}
82  virtual ~OutputInterface() = default;
83 
91  virtual void at_eventstart(const Particles &particles, const int event_number,
92  const EventInfo &info) {
93  SMASH_UNUSED(particles);
94  SMASH_UNUSED(event_number);
95  SMASH_UNUSED(info);
96  }
103  virtual void at_eventstart(const std::vector<Particles> &ensembles,
104  int event_number) {
105  SMASH_UNUSED(ensembles);
106  SMASH_UNUSED(event_number);
107  }
108 
117  virtual void at_eventstart(const int event_number,
118  const ThermodynamicQuantity tq,
119  const DensityType dens_type,
121  SMASH_UNUSED(event_number);
122  SMASH_UNUSED(tq);
123  SMASH_UNUSED(dens_type);
124  SMASH_UNUSED(lattice);
125  }
126 
135  virtual void at_eventstart(const int event_number,
136  const ThermodynamicQuantity tq,
137  const DensityType dens_type,
139  SMASH_UNUSED(event_number);
140  SMASH_UNUSED(tq);
141  SMASH_UNUSED(dens_type);
142  SMASH_UNUSED(lattice);
143  }
144 
153  virtual void at_eventend(const int event_number,
154  const ThermodynamicQuantity tq,
155  const DensityType dens_type) {
156  SMASH_UNUSED(event_number);
157  SMASH_UNUSED(tq);
158  SMASH_UNUSED(dens_type);
159  }
160 
166  virtual void at_eventend(const ThermodynamicQuantity tq) { SMASH_UNUSED(tq); }
167 
175  virtual void at_eventend(const Particles &particles, const int event_number,
176  const EventInfo &info) {
177  SMASH_UNUSED(particles);
178  SMASH_UNUSED(event_number);
179  SMASH_UNUSED(info);
180  }
187  virtual void at_eventend(const std::vector<Particles> &ensembles,
188  const int event_number) {
189  SMASH_UNUSED(ensembles);
190  SMASH_UNUSED(event_number);
191  }
192 
200  virtual void at_interaction(const Action &action, const double density) {
201  SMASH_UNUSED(action);
202  SMASH_UNUSED(density);
203  }
204 
212  virtual void at_intermediate_time(const Particles &particles,
213  const std::unique_ptr<Clock> &clock,
214  const DensityParameters &dens_param,
215  const EventInfo &info) {
216  SMASH_UNUSED(particles);
217  SMASH_UNUSED(clock);
218  SMASH_UNUSED(dens_param);
219  SMASH_UNUSED(info);
220  }
227  virtual void at_intermediate_time(const std::vector<Particles> &ensembles,
228  const std::unique_ptr<Clock> &clock,
229  const DensityParameters &dens_param) {
230  SMASH_UNUSED(ensembles);
231  SMASH_UNUSED(clock);
232  SMASH_UNUSED(dens_param);
233  }
234 
243  virtual void thermodynamics_output(
244  const ThermodynamicQuantity tq, const DensityType dt,
246  SMASH_UNUSED(tq);
247  SMASH_UNUSED(dt);
248  SMASH_UNUSED(lattice);
249  }
250 
260  virtual void thermodynamics_output(
261  const ThermodynamicQuantity tq, const DensityType dt,
263  SMASH_UNUSED(tq);
264  SMASH_UNUSED(dt);
265  SMASH_UNUSED(lattice);
266  }
267 
277  const double current_time) {
278  SMASH_UNUSED(lattice);
279  SMASH_UNUSED(current_time);
280  }
281 
295  RectangularLattice<DensityOnLattice> &lattice, const double current_time,
296  const std::vector<Particles> &ensembles,
297  const DensityParameters &dens_param) {
298  SMASH_UNUSED(lattice);
299  SMASH_UNUSED(current_time);
300  SMASH_UNUSED(ensembles);
301  SMASH_UNUSED(dens_param);
302  }
303 
314  const ThermodynamicQuantity tq,
316  const double current_time) {
317  SMASH_UNUSED(tq);
318  SMASH_UNUSED(lattice);
319  SMASH_UNUSED(current_time);
320  }
321 
329  virtual void thermodynamics_output(const GrandCanThermalizer &gct) {
330  SMASH_UNUSED(gct);
331  }
332 
342  virtual void fields_output(
343  const std::string name1, const std::string name2,
344  RectangularLattice<std::pair<ThreeVector, ThreeVector>> &lat) {
345  SMASH_UNUSED(name1);
346  SMASH_UNUSED(name2);
347  SMASH_UNUSED(lat);
348  }
349 
351  bool is_dilepton_output() const { return is_dilepton_output_; }
352 
354  bool is_photon_output() const { return is_photon_output_; }
355 
357  bool is_IC_output() const { return is_IC_output_; }
358 
364  const char *to_string(const ThermodynamicQuantity tq) {
365  switch (tq) {
367  return "rho_eckart";
369  return "tmn";
371  return "tmn_landau";
373  return "v_landau";
375  return "j_QBS";
376  }
377  throw std::invalid_argument("Unknown thermodynamic quantity.");
378  }
379 
385  const char *to_string(const DensityType dens_type) {
386  switch (dens_type) {
387  case DensityType::Hadron:
388  return "hadron";
389  case DensityType::Baryon:
390  return "net_baryon";
392  return "net_baryonI3";
393  case DensityType::Pion:
394  return "pion";
396  return "tot_isospin3";
397  case DensityType::Charge:
398  return "charge";
400  return "strangeness";
401  case DensityType::None:
402  return "none";
403  }
404  throw std::invalid_argument("Unknown density type.");
405  }
406 
407  protected:
410 
412  const bool is_photon_output_;
413 
415  const bool is_IC_output_;
416 };
417 
418 } // namespace smash
419 
420 #endif // SRC_INCLUDE_SMASH_OUTPUTINTERFACE_H_
Action is the base class for a generic process that takes a number of incoming particles and transfor...
Definition: action.h:35
A class to pre-calculate and store parameters relevant for density calculation.
Definition: density.h:108
The GrandCanThermalizer class implements the following functionality:
Abstraction of generic output.
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.
const bool is_photon_output_
Is this the photon output?
bool is_photon_output() const
Get, whether this is the photon output?
const bool is_dilepton_output_
Is this the dilepton output?
virtual void at_eventend(const std::vector< Particles > &ensembles, const int event_number)
Output launched at event end.
const bool is_IC_output_
Is this the IC output?
OutputInterface(std::string name)
Construct output interface.
virtual ~OutputInterface()=default
const char * to_string(const DensityType dens_type)
Convert density types to strings.
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.
const char * to_string(const ThermodynamicQuantity tq)
Convert thermodynamic quantities to strings.
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 propagat...
virtual void at_eventend(const ThermodynamicQuantity tq)
Output launched at event end.
virtual void thermodynamics_output(const GrandCanThermalizer &gct)
Output to write energy-momentum tensor and related quantities from the thermalizer class.
virtual void at_interaction(const Action &action, const double density)
Called whenever an action modified one or more particles.
virtual void at_eventstart(const Particles &particles, const int event_number, const EventInfo &info)
Output launched at event start after initialization, when particles are generated but not yet propaga...
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.
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 propaga...
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 propaga...
virtual void at_eventend(const int event_number, const ThermodynamicQuantity tq, const DensityType dens_type)
Output launched at event end.
bool is_dilepton_output() const
Get, whether this is the dilepton output?
virtual void fields_output(const std::string name1, const std::string name2, RectangularLattice< std::pair< ThreeVector, ThreeVector >> &lat)
Write fields in vtk output.
virtual void at_intermediate_time(const Particles &particles, const std::unique_ptr< Clock > &clock, const DensityParameters &dens_param, const EventInfo &info)
Output launched after every N'th timestep.
virtual void at_eventend(const Particles &particles, const int event_number, const EventInfo &info)
Output launched at event end.
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.
virtual void thermodynamics_output(const ThermodynamicQuantity tq, const DensityType dt, RectangularLattice< DensityOnLattice > &lattice)
Output to write thermodynamics from the lattice.
bool is_IC_output() const
Get, whether this is the IC output?
virtual void thermodynamics_lattice_output(RectangularLattice< DensityOnLattice > &lattice, const double current_time)
Output to write thermodynamics from the lattice.
The Particles class abstracts the storage and manipulation of particles.
Definition: particles.h:33
A container class to hold all the arrays on the lattice and access them.
Definition: lattice.h:47
ThermodynamicQuantity
Represents thermodynamic quantities that can be printed out.
#define SMASH_UNUSED(x)
Mark as unused, silencing compiler warnings.
Definition: macros.h:24
Definition: action.h:24
static constexpr int LOutput
DensityType
Allows to choose which kind of density to calculate.
Definition: density.h:36
Structure to contain custom data for output.
double total_kinetic_energy
Sum of kinetic energies of all particles.
bool empty_event
True if no collisions happened.
double modus_length
Box length in case of box simulation, otherwise dummy.
double total_energy
Kinetic + mean field energy.
int n_ensembles
Number of ensembles.
double total_mean_field_energy
Total energy in the mean field.
bool impose_kinematic_cut_for_SMASH_IC
Whether or not kinematic cuts are employed for SMASH IC.
double impact_parameter
Impact parameter for collider modus, otherwise dummy.
double current_time
Time in fm.
int test_particles
Testparticle number, see Testparticles in General.