Version: SMASH-3.1
thermodynamiclatticeoutput.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_THERMODYNAMICLATTICEOUTPUT_H_
11 #define SRC_INCLUDE_SMASH_THERMODYNAMICLATTICEOUTPUT_H_
12 
13 #include <filesystem>
14 #include <map>
15 #include <memory>
16 #include <set>
17 #include <string>
18 #include <vector>
19 
20 #include "density.h"
21 #include "experimentparameters.h"
22 #include "file.h"
23 #include "forwarddeclarations.h"
24 #include "logging.h"
25 #include "outputinterface.h"
26 #include "outputparameters.h"
27 #include "threevector.h"
28 
29 namespace smash {
30 
43  public:
45  static const double_t version;
46 
55  ThermodynamicLatticeOutput(const std::filesystem::path &path,
56  const std::string &name,
57  const OutputParameters &out_par,
58  const bool enable_ascii, const bool enable_binary);
69  void at_eventstart(
70  const int event_number, const ThermodynamicQuantity tq,
71  const DensityType dens_type,
72  const RectangularLattice<DensityOnLattice> lattice) override;
81  void at_eventstart(
82  const int event_number, const ThermodynamicQuantity tq,
83  const DensityType dens_type,
84  const RectangularLattice<EnergyMomentumTensor> lattice) override;
85 
91  void at_eventend(const ThermodynamicQuantity tq) override;
92 
100  double current_time) override;
101 
114  RectangularLattice<DensityOnLattice> &lattice, const double current_time,
115  const std::vector<Particles> &ensembles,
116  const DensityParameters &dens_param) override;
117 
128  const ThermodynamicQuantity tq,
130  double current_time) override;
131 
132  private:
135 
143  std::string make_filename(const std::string &description,
144  const int event_number, const char type);
145 
152  std::string make_varname(const ThermodynamicQuantity tq,
153  const DensityType dens_type);
154 
162  void write_therm_lattice_ascii_header(std::shared_ptr<std::ofstream> file,
163  const ThermodynamicQuantity &tq);
164 
172  void write_therm_lattice_binary_header(std::shared_ptr<std::ofstream> file,
173  const ThermodynamicQuantity &tq);
174 
180  int to_int(const ThermodynamicQuantity &tq);
181 
183  const std::filesystem::path base_path_;
184 
186  std::map<ThermodynamicQuantity, std::shared_ptr<std::ofstream>>
188 
190  std::map<ThermodynamicQuantity, std::shared_ptr<std::ofstream>>
192 
194  std::array<int, 3> nodes_;
195 
197  std::array<double, 3> sizes_;
198 
202  std::array<double, 3> origin_;
203 
206 
209 
212 };
213 
214 } // namespace smash
215 
216 #endif // SRC_INCLUDE_SMASH_THERMODYNAMICLATTICEOUTPUT_H_
A class to pre-calculate and store parameters relevant for density calculation.
Definition: density.h:108
Abstraction of generic output.
A container class to hold all the arrays on the lattice and access them.
Definition: lattice.h:47
Writes the thermodynamic quantities at lattice points versus time.
std::array< int, 3 > nodes_
number of nodes in the lattice along the three axes
std::map< ThermodynamicQuantity, std::shared_ptr< std::ofstream > > output_ascii_files_
map of output file handlers for ASCII format
bool enable_binary_
enable output type Binary
void at_eventstart(const int event_number, const ThermodynamicQuantity tq, const DensityType dens_type, const RectangularLattice< DensityOnLattice > lattice) override
Output launched at event start after initialization, when particles are generated but not yet propaga...
std::string make_filename(const std::string &description, const int event_number, const char type)
Makes a file name given a description and a counter.
static const double_t version
Version of the thermodynamic lattice output.
std::map< ThermodynamicQuantity, std::shared_ptr< std::ofstream > > output_binary_files_
map of output file handlers for binary format
int to_int(const ThermodynamicQuantity &tq)
Convert a ThermodynamicQuantity into an int.
void write_therm_lattice_binary_header(std::shared_ptr< std::ofstream > file, const ThermodynamicQuantity &tq)
Writes the header for the binary output files.
void write_therm_lattice_ascii_header(std::shared_ptr< std::ofstream > file, const ThermodynamicQuantity &tq)
Writes the header for the ASCII output files.
const std::filesystem::path base_path_
filesystem path for output
void thermodynamics_lattice_output(RectangularLattice< DensityOnLattice > &lattice, double current_time) override
Prints the density lattice on a grid.
void at_eventend(const ThermodynamicQuantity tq) override
Final actions at the end of each event (it closes the output files).
const OutputParameters out_par_
Structure that holds all the information about what to printout.
bool enable_output_
enable output, of any kind (if False, the object does nothing)
std::string make_varname(const ThermodynamicQuantity tq, const DensityType dens_type)
Makes a variable name given quantity and density type.
bool enable_ascii_
enable output type ASCII
std::array< double, 3 > sizes_
lattice resolution along the three axes
ThermodynamicLatticeOutput(const std::filesystem::path &path, const std::string &name, const OutputParameters &out_par, const bool enable_ascii, const bool enable_binary)
Construct Output.
std::array< double, 3 > origin_
lattice origin orientation: if 0,0,0 is the origin of a cube with face widths 10, the center is at 5,...
ThermodynamicQuantity
Represents thermodynamic quantities that can be printed out See user guide description for more infor...
Definition: action.h:24
DensityType
Allows to choose which kind of density to calculate.
Definition: density.h:36
Helper structure for Experiment to hold output options and parameters.