Version: SMASH-2.1
outputinterface.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (c) 2014-2021
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;
57 };
58 
71  public:
76  explicit OutputInterface(std::string name)
77  : is_dilepton_output_(name == "Dileptons"),
78  is_photon_output_(name == "Photons"),
79  is_IC_output_(name == "SMASH_IC") {}
80  virtual ~OutputInterface() = default;
81 
89  virtual void at_eventstart(const Particles &particles, const int event_number,
90  const EventInfo &info) {
91  SMASH_UNUSED(particles);
92  SMASH_UNUSED(event_number);
93  SMASH_UNUSED(info);
94  }
101  virtual void at_eventstart(const std::vector<Particles> &ensembles,
102  int event_number) {
103  SMASH_UNUSED(ensembles);
104  SMASH_UNUSED(event_number);
105  }
106 
115  virtual void at_eventstart(const int event_number,
116  const ThermodynamicQuantity tq,
117  const DensityType dens_type,
119  SMASH_UNUSED(event_number);
120  SMASH_UNUSED(tq);
121  SMASH_UNUSED(dens_type);
122  SMASH_UNUSED(lattice);
123  }
124 
133  virtual void at_eventstart(const int event_number,
134  const ThermodynamicQuantity tq,
135  const DensityType dens_type,
137  SMASH_UNUSED(event_number);
138  SMASH_UNUSED(tq);
139  SMASH_UNUSED(dens_type);
140  SMASH_UNUSED(lattice);
141  }
142 
151  virtual void at_eventend(const int event_number,
152  const ThermodynamicQuantity tq,
153  const DensityType dens_type) {
154  SMASH_UNUSED(event_number);
155  SMASH_UNUSED(tq);
156  SMASH_UNUSED(dens_type);
157  }
158 
164  virtual void at_eventend(const ThermodynamicQuantity tq) { SMASH_UNUSED(tq); }
165 
173  virtual void at_eventend(const Particles &particles, const int event_number,
174  const EventInfo &info) {
175  SMASH_UNUSED(particles);
176  SMASH_UNUSED(event_number);
177  SMASH_UNUSED(info);
178  }
185  virtual void at_eventend(const std::vector<Particles> &ensembles,
186  const int event_number) {
187  SMASH_UNUSED(ensembles);
188  SMASH_UNUSED(event_number);
189  }
190 
198  virtual void at_interaction(const Action &action, const double density) {
199  SMASH_UNUSED(action);
200  SMASH_UNUSED(density);
201  }
202 
210  virtual void at_intermediate_time(const Particles &particles,
211  const std::unique_ptr<Clock> &clock,
212  const DensityParameters &dens_param,
213  const EventInfo &info) {
214  SMASH_UNUSED(particles);
215  SMASH_UNUSED(clock);
216  SMASH_UNUSED(dens_param);
217  SMASH_UNUSED(info);
218  }
225  virtual void at_intermediate_time(const std::vector<Particles> &ensembles,
226  const std::unique_ptr<Clock> &clock,
227  const DensityParameters &dens_param) {
228  SMASH_UNUSED(ensembles);
229  SMASH_UNUSED(clock);
230  SMASH_UNUSED(dens_param);
231  }
232 
241  virtual void thermodynamics_output(
242  const ThermodynamicQuantity tq, const DensityType dt,
244  SMASH_UNUSED(tq);
245  SMASH_UNUSED(dt);
246  SMASH_UNUSED(lattice);
247  }
248 
258  virtual void thermodynamics_output(
259  const ThermodynamicQuantity tq, const DensityType dt,
261  SMASH_UNUSED(tq);
262  SMASH_UNUSED(dt);
263  SMASH_UNUSED(lattice);
264  }
265 
275  const double current_time) {
276  SMASH_UNUSED(lattice);
277  SMASH_UNUSED(current_time);
278  }
279 
293  RectangularLattice<DensityOnLattice> &lattice, const double current_time,
294  const std::vector<Particles> &ensembles,
295  const DensityParameters &dens_param) {
296  SMASH_UNUSED(lattice);
297  SMASH_UNUSED(current_time);
298  SMASH_UNUSED(ensembles);
299  SMASH_UNUSED(dens_param);
300  }
301 
312  const ThermodynamicQuantity tq,
314  const double current_time) {
315  SMASH_UNUSED(tq);
316  SMASH_UNUSED(lattice);
317  SMASH_UNUSED(current_time);
318  }
319 
327  virtual void thermodynamics_output(const GrandCanThermalizer &gct) {
328  SMASH_UNUSED(gct);
329  }
330 
340  virtual void fields_output(
341  const std::string name1, const std::string name2,
342  RectangularLattice<std::pair<ThreeVector, ThreeVector>> &lat) {
343  SMASH_UNUSED(name1);
344  SMASH_UNUSED(name2);
345  SMASH_UNUSED(lat);
346  }
347 
349  bool is_dilepton_output() const { return is_dilepton_output_; }
350 
352  bool is_photon_output() const { return is_photon_output_; }
353 
355  bool is_IC_output() const { return is_IC_output_; }
356 
362  const char *to_string(const ThermodynamicQuantity tq) {
363  switch (tq) {
365  return "rho_eckart";
367  return "tmn";
369  return "tmn_landau";
371  return "v_landau";
373  return "j_QBS";
374  }
375  throw std::invalid_argument("Unknown thermodynamic quantity.");
376  }
377 
383  const char *to_string(const DensityType dens_type) {
384  switch (dens_type) {
385  case DensityType::Hadron:
386  return "hadron";
387  case DensityType::Baryon:
388  return "net_baryon";
390  return "net_baryonI3";
391  case DensityType::Pion:
392  return "pion";
394  return "tot_isospin3";
395  case DensityType::Charge:
396  return "charge";
398  return "strangeness";
399  case DensityType::None:
400  return "none";
401  }
402  throw std::invalid_argument("Unknown density type.");
403  }
404 
405  protected:
408 
410  const bool is_photon_output_;
411 
413  const bool is_IC_output_;
414 };
415 
416 } // namespace smash
417 
418 #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
#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.
double impact_parameter
Impact parameter for collider modus, otherwise dummy.
double current_time
Time in fm/c.
int test_particles
Testparticle number, see Testparticles in General.