14 #include "smash/config.h"
21 static constexpr
int LOutput = LogArea::Output::id;
26 base_path_(std::move(path)),
27 is_thermodynamics_output_(name ==
"Thermodynamics") {
30 <<
"Creating VTK output: There is no extended VTK format.";
61 const int event_number) {
82 const std::unique_ptr<Clock> &,
92 snprintf(filename,
sizeof(filename),
"pos_ev%05i_tstep%05i.vtk",
97 std::fprintf(file_.get(),
"# vtk DataFile Version 2.0\n");
98 std::fprintf(file_.get(),
"Generated from molecular-offset data %s\n",
100 std::fprintf(file_.get(),
"ASCII\n");
103 std::fprintf(file_.get(),
"DATASET UNSTRUCTURED_GRID\n");
104 std::fprintf(file_.get(),
"POINTS %zu double\n", particles.
size());
105 for (
const auto &
p : particles) {
106 std::fprintf(file_.get(),
"%g %g %g\n",
p.position().x1(),
107 p.position().x2(),
p.position().x3());
109 std::fprintf(file_.get(),
"CELLS %zu %zu\n", particles.size(),
110 particles.size() * 2);
111 for (
size_t point_index = 0; point_index < particles.size(); point_index++) {
112 std::fprintf(file_.get(),
"1 %zu\n", point_index);
114 std::fprintf(file_.get(),
"CELL_TYPES %zu\n", particles.size());
115 for (
size_t point_index = 0; point_index < particles.size(); point_index++) {
116 std::fprintf(file_.get(),
"1\n");
118 std::fprintf(file_.get(),
"POINT_DATA %zu\n", particles.size());
119 std::fprintf(file_.get(),
"SCALARS pdg_codes int 1\n");
120 std::fprintf(file_.get(),
"LOOKUP_TABLE default\n");
121 for (
const auto &
p : particles) {
122 std::fprintf(file_.get(),
"%s\n",
p.pdgcode().string().c_str());
124 std::fprintf(file_.get(),
"SCALARS is_formed int 1\n");
125 std::fprintf(file_.get(),
"LOOKUP_TABLE default\n");
126 double current_time = particles.time();
127 for (
const auto &
p : particles) {
128 std::fprintf(file_.get(),
"%s\n",
129 (
p.formation_time() > current_time) ?
"0" :
"1");
131 std::fprintf(file_.get(),
"SCALARS cross_section_scaling_factor double 1\n");
132 std::fprintf(file_.get(),
"LOOKUP_TABLE default\n");
133 for (
const auto &
p : particles) {
134 std::fprintf(file_.get(),
"%g\n",
p.xsec_scaling_factor());
136 std::fprintf(file_.get(),
"SCALARS mass double 1\n");
137 std::fprintf(file_.get(),
"LOOKUP_TABLE default\n");
138 for (
const auto &
p : particles) {
139 std::fprintf(file_.get(),
"%g\n",
p.effective_mass());
141 std::fprintf(file_.get(),
"SCALARS N_coll int 1\n");
142 std::fprintf(file_.get(),
"LOOKUP_TABLE default\n");
143 for (
const auto &
p : particles) {
144 std::fprintf(file_.get(),
"%i\n",
p.get_history().collisions_per_particle);
146 std::fprintf(file_.get(),
"SCALARS particle_ID int 1\n");
147 std::fprintf(file_.get(),
"LOOKUP_TABLE default\n");
148 for (
const auto &
p : particles) {
149 std::fprintf(file_.get(),
"%i\n",
p.id());
151 std::fprintf(file_.get(),
"SCALARS baryon_number int 1\n");
152 std::fprintf(file_.get(),
"LOOKUP_TABLE default\n");
153 for (
const auto &
p : particles) {
154 std::fprintf(file_.get(),
"%i\n",
p.pdgcode().baryon_number());
156 std::fprintf(file_.get(),
"SCALARS strangeness int 1\n");
157 std::fprintf(file_.get(),
"LOOKUP_TABLE default\n");
158 for (
const auto &
p : particles) {
159 std::fprintf(file_.get(),
"%i\n",
p.pdgcode().strangeness());
161 std::fprintf(file_.get(),
"VECTORS momentum double\n");
162 for (
const auto &
p : particles) {
163 std::fprintf(file_.get(),
"%g %g %g\n",
p.momentum().x1(),
164 p.momentum().x2(),
p.momentum().x3());
177 template <
typename T>
180 const std::string &description) {
183 const auto orig = lattice.
origin();
184 file <<
"# vtk DataFile Version 2.0\n"
185 << description <<
"\n"
187 <<
"DATASET STRUCTURED_POINTS\n"
188 <<
"DIMENSIONS " << dim[0] <<
" " << dim[1] <<
" " << dim[2] <<
"\n"
189 <<
"SPACING " << cs[0] <<
" " << cs[1] <<
" " << cs[2] <<
"\n"
190 <<
"ORIGIN " << orig[0] <<
" " << orig[1] <<
" " << orig[2] <<
"\n"
191 <<
"POINT_DATA " << lattice.
size() <<
"\n";
194 template <
typename T,
typename F>
197 const std::string &varname, F &&get_quantity) {
198 file <<
"SCALARS " << varname <<
" double 1\n"
199 <<
"LOOKUP_TABLE default\n";
200 file << std::setprecision(3);
204 const double f_from_node = get_quantity(node);
205 file << f_from_node <<
" ";
206 if (ix == dim[0] - 1) {
212 template <
typename T,
typename F>
215 const std::string &varname, F &&get_quantity) {
216 file <<
"VECTORS " << varname <<
" double\n";
217 file << std::setprecision(3);
222 file << v.
x1() <<
" " << v.
x2() <<
" " << v.
x3() <<
"\n";
228 snprintf(suffix,
sizeof(suffix),
"_%05i_tstep%05i.vtk",
current_event_,
230 return base_path_.string() + std::string(
"/") + descr + std::string(suffix);
235 return std::string(
to_string(dens_type)) + std::string(
"_") +
246 const std::string varname =
make_varname(tq, dens_type);
277 const std::string varname =
make_varname(tq, dens_type);
282 for (
int i = 0; i < 4; i++) {
283 for (
int j = i; j < 4; j++) {
285 varname + std::to_string(i) + std::to_string(j),
295 for (
int i = 0; i < 4; i++) {
296 for (
int j = i; j < 4; j++) {
298 varname + std::to_string(i) + std::to_string(j),