Version: SMASH-3.1
vtkoutput.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_VTKOUTPUT_H_
11 #define SRC_INCLUDE_SMASH_VTKOUTPUT_H_
12 
13 #include <filesystem>
14 #include <memory>
15 #include <string>
16 #include <utility>
17 
18 #include "density.h"
19 #include "forwarddeclarations.h"
20 #include "outputinterface.h"
21 #include "outputparameters.h"
22 
23 namespace smash {
24 
29 class VtkOutput : public OutputInterface {
30  public:
38  VtkOutput(const std::filesystem::path &path, const std::string &name,
39  const OutputParameters &out_par);
40  ~VtkOutput();
41 
50  void at_eventstart(const Particles &particles, const int event_number,
51  const EventInfo &event) override;
52 
62  void at_eventend(const Particles &particles, const int event_number,
63  const EventInfo &event) override;
64 
73  void at_intermediate_time(const Particles &particles,
74  const std::unique_ptr<Clock> &clock,
75  const DensityParameters &dens_param,
76  const EventInfo &event) override;
77 
87  const ThermodynamicQuantity tq, const DensityType dt,
88  RectangularLattice<DensityOnLattice> &lattice) override;
89 
99  const ThermodynamicQuantity tq, const DensityType dt,
100  RectangularLattice<EnergyMomentumTensor> &lattice) override;
101 
108  void thermodynamics_output(const GrandCanThermalizer &gct) override;
109 
111  void fields_output(
112  const std::string name1, const std::string name2,
113  RectangularLattice<std::pair<ThreeVector, ThreeVector>> &lat) override;
114 
115  private:
121  void write(const Particles &particles);
122 
129  std::string make_filename(const std::string &description, int counter);
130 
137  std::string make_varname(const ThermodynamicQuantity tq,
138  const DensityType dens_type);
139 
147  template <typename T>
148  void write_vtk_header(std::ofstream &file, RectangularLattice<T> &lat,
149  const std::string &description);
150 
159  template <typename T, typename F>
160  void write_vtk_scalar(std::ofstream &file, RectangularLattice<T> &lat,
161  const std::string &varname, F &&function);
162 
171  template <typename T, typename F>
172  void write_vtk_vector(std::ofstream &file, RectangularLattice<T> &lat,
173  const std::string &varname, F &&function);
174 
176  const std::filesystem::path base_path_;
177 
179  int current_event_ = 0;
182 
199 };
200 
201 } // namespace smash
202 
203 #endif // SRC_INCLUDE_SMASH_VTKOUTPUT_H_
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.
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
SMASH output in a paraview format, intended for simple visualization.
Definition: vtkoutput.h:29
void write_vtk_scalar(std::ofstream &file, RectangularLattice< T > &lat, const std::string &varname, F &&function)
Write a VTK scalar.
Definition: vtkoutput.cc:196
void at_eventend(const Particles &particles, const int event_number, const EventInfo &event) override
Writes the final particle information list of an event to the VTK output.
Definition: vtkoutput.cc:78
int vtk_density_output_counter_
Number of density lattice vtk output in current event.
Definition: vtkoutput.h:184
void fields_output(const std::string name1, const std::string name2, RectangularLattice< std::pair< ThreeVector, ThreeVector >> &lat) override
Write fields in vtk output Fields are a pair of threevectors for example electric and magnetic field.
Definition: vtkoutput.cc:319
bool is_fields_output_
Is the VTK output an output for fields.
Definition: vtkoutput.h:198
int vtk_output_counter_
Number of vtk output in current event.
Definition: vtkoutput.h:181
void write(const Particles &particles)
Write the given particles to the output.
Definition: vtkoutput.cc:91
int vtk_fluidization_counter_
Number of fluidization output.
Definition: vtkoutput.h:192
int current_event_
Event number.
Definition: vtkoutput.h:179
VtkOutput(const std::filesystem::path &path, const std::string &name, const OutputParameters &out_par)
Create a new VTK output.
Definition: vtkoutput.cc:24
void write_vtk_header(std::ofstream &file, RectangularLattice< T > &lat, const std::string &description)
Write the VTK header.
Definition: vtkoutput.cc:179
int vtk_fields_output_counter_
Number of fields output in current event.
Definition: vtkoutput.h:194
void write_vtk_vector(std::ofstream &file, RectangularLattice< T > &lat, const std::string &varname, F &&function)
Write a VTK vector.
Definition: vtkoutput.cc:214
std::string make_varname(const ThermodynamicQuantity tq, const DensityType dens_type)
Make a variable name given quantity and density type.
Definition: vtkoutput.cc:234
bool is_thermodynamics_output_
Is the VTK output a thermodynamics output.
Definition: vtkoutput.h:196
int vtk_tmn_landau_output_counter_
Number of Landau frame energy-momentum tensor vtk output in current event.
Definition: vtkoutput.h:188
void at_intermediate_time(const Particles &particles, const std::unique_ptr< Clock > &clock, const DensityParameters &dens_param, const EventInfo &event) override
Writes out all current particles.
Definition: vtkoutput.cc:81
void thermodynamics_output(const ThermodynamicQuantity tq, const DensityType dt, RectangularLattice< DensityOnLattice > &lattice) override
Prints the density lattice in VTK format on a grid.
Definition: vtkoutput.cc:240
int vtk_v_landau_output_counter_
Number of Landau rest frame velocity vtk output in current event.
Definition: vtkoutput.h:190
void at_eventstart(const Particles &particles, const int event_number, const EventInfo &event) override
Writes the initial particle information list of an event to the VTK output.
Definition: vtkoutput.cc:62
const std::filesystem::path base_path_
filesystem path for output
Definition: vtkoutput.h:176
std::string make_filename(const std::string &description, int counter)
Make a file name given a description and a counter.
Definition: vtkoutput.cc:227
int vtk_tmn_output_counter_
Number of energy-momentum tensor lattice vtk output in current event.
Definition: vtkoutput.h:186
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
Structure to contain custom data for output.
Helper structure for Experiment to hold output options and parameters.