15 #include <boost/filesystem.hpp> 
   18 #include "smash/config.h" 
  185     const bf::path &path, 
const std::string &name,
 
  187     const bool enable_binary)
 
  190       base_path_(std::move(path)),
 
  191       enable_ascii_(enable_ascii),
 
  192       enable_binary_(enable_binary) {
 
  201           std::make_shared<std::ofstream>(
nullptr);
 
  205           std::make_shared<std::ofstream>(
nullptr);
 
  209           std::make_shared<std::ofstream>(
nullptr);
 
  213           std::make_shared<std::ofstream>(
nullptr);
 
  217           std::make_shared<std::ofstream>(
nullptr);
 
  223           std::make_shared<std::ofstream>(
nullptr);
 
  227           std::make_shared<std::ofstream>(
nullptr);
 
  231           std::make_shared<std::ofstream>(
nullptr);
 
  235           std::make_shared<std::ofstream>(
nullptr);
 
  239           std::make_shared<std::ofstream>(
nullptr);
 
  256   const auto dim = lattice.
n_cells();
 
  258   const auto orig = lattice.
origin();
 
  259   for (
int l = 0; l < 3; l++) {
 
  264   std::shared_ptr<std::ofstream> fp(
nullptr);
 
  266   std::string filename;
 
  273             filename, std::ios::out);
 
  274       } 
catch (std::ofstream::failure &e) {
 
  275         logg[LogArea::Main::id].fatal()
 
  276             << 
"Error in opening " << filename << std::endl;
 
  277         throw std::runtime_error(
 
  278             "Not possible to write thermodynamic " 
  279             "lattice output to file.");
 
  288             filename, std::ios::out | std::ios::binary);
 
  289       } 
catch (std::ofstream::failure &e) {
 
  290         logg[LogArea::Main::id].fatal()
 
  291             << 
"Error in opening " << filename << std::endl;
 
  292         throw std::runtime_error(
 
  293             "Not possible to write thermodynamic " 
  294             "lattice output to file.");
 
  305       } 
catch (std::ofstream::failure &e) {
 
  306         logg[LogArea::Main::id].fatal()
 
  307             << 
"Error in opening " << filename << std::endl;
 
  308         throw std::runtime_error(
 
  309             "Not possible to write thermodynamic " 
  310             "lattice output to file.");
 
  319             filename, std::ios::out | std::ios::binary);
 
  320       } 
catch (std::ofstream::failure &e) {
 
  321         logg[LogArea::Main::id].fatal()
 
  322             << 
"Error in opening " << filename << std::endl;
 
  323         throw std::runtime_error(
 
  324             "Not possible to write thermodynamic " 
  325             "lattice output to file.");
 
  340   const auto dim = lattice.
n_cells();
 
  342   const auto orig = lattice.
origin();
 
  343   for (
int l = 0; l < 3; l++) {
 
  348   std::shared_ptr<std::ofstream> fp(
nullptr);
 
  350   std::string filename;
 
  357             filename, std::ios::out);
 
  358       } 
catch (std::ofstream::failure &e) {
 
  359         logg[LogArea::Main::id].fatal()
 
  360             << 
"Error in opening " << filename << std::endl;
 
  361         throw std::runtime_error(
 
  362             "Not possible to write thermodynamic " 
  363             "lattice output to file.");
 
  370       } 
catch (std::ofstream::failure &e) {
 
  371         logg[LogArea::Main::id].fatal()
 
  372             << 
"Error in opening " << filename << std::endl;
 
  373         throw std::runtime_error(
 
  374             "Not possible to write thermodynamic " 
  375             "lattice output to file.");
 
  381             filename, std::ios::out);
 
  382       } 
catch (std::ofstream::failure &e) {
 
  383         logg[LogArea::Main::id].fatal()
 
  384             << 
"Error in opening " << filename << std::endl;
 
  385         throw std::runtime_error(
 
  386             "Not possible to write thermodynamic " 
  387             "lattice output to file.");
 
  394       } 
catch (std::ofstream::failure &e) {
 
  395         logg[LogArea::Main::id].fatal()
 
  396             << 
"Error in opening " << filename << std::endl;
 
  397         throw std::runtime_error(
 
  398             "Not possible to write thermodynamic " 
  399             "lattice output to file.");
 
  409             filename, std::ios::out | std::ios::binary);
 
  410       } 
catch (std::ofstream::failure &e) {
 
  411         logg[LogArea::Main::id].fatal()
 
  412             << 
"Error in opening " << filename << std::endl;
 
  413         throw std::runtime_error(
 
  414             "Not possible to write thermodynamic " 
  415             "lattice output to file.");
 
  421             filename, std::ios::out | std::ios::binary);
 
  422       } 
catch (std::ofstream::failure &e) {
 
  423         logg[LogArea::Main::id].fatal()
 
  424             << 
"Error in opening " << filename << std::endl;
 
  425         throw std::runtime_error(
 
  426             "Not possible to write thermodynamic " 
  427             "lattice output to file.");
 
  433             filename, std::ios::out | std::ios::binary);
 
  434       } 
catch (std::ofstream::failure &e) {
 
  435         logg[LogArea::Main::id].fatal()
 
  436             << 
"Error in opening " << filename << std::endl;
 
  437         throw std::runtime_error(
 
  438             "Not possible to write thermodynamic " 
  439             "lattice output to file.");
 
  446       } 
catch (std::ofstream::failure &e) {
 
  447         logg[LogArea::Main::id].fatal()
 
  448             << 
"Error in opening " << filename << std::endl;
 
  449         throw std::runtime_error(
 
  450             "Not possible to write thermodynamic " 
  451             "lattice output to file.");
 
  512   const auto dim = lattice.
n_cells();
 
  513   std::shared_ptr<std::ofstream> fp(
nullptr);
 
  516     *fp << std::setprecision(14);
 
  517     *fp << std::scientific;
 
  518     *fp << ctime << std::endl;
 
  522     assert(
sizeof(ctime) == 
sizeof(
double));
 
  523     fp->write(
reinterpret_cast<char *
>(&ctime), 
sizeof(ctime));
 
  528           *fp << node.rho() << 
" ";
 
  529           if (ix == dim[0] - 1) {
 
  535           fp->write(
reinterpret_cast<char *
>(&result), 
sizeof(
double));
 
  542     const std::vector<Particles> &ensembles,
 
  548   const auto dim = lattice.
n_cells();
 
  549   std::shared_ptr<std::ofstream> fp(
nullptr);
 
  551   constexpr 
bool compute_gradient = 
false;
 
  554     *fp << std::setprecision(14);
 
  555     *fp << std::scientific;
 
  556     *fp << ctime << std::endl;
 
  560     assert(
sizeof(ctime) == 
sizeof(
double));
 
  561     fp->write(
reinterpret_cast<char *
>(&ctime), 
sizeof(ctime));
 
  569         for (
const Particles &particles : ensembles) {
 
  582           for (
int l = 1; l < 4; l++) {
 
  585           for (
int l = 0; l < 4; l++) {
 
  588           for (
int l = 0; l < 4; l++) {
 
  594           for (
int l = 0; l < 4; l++) {
 
  596             fp->write(
reinterpret_cast<char *
>(&result), 
sizeof(
double));
 
  598           for (
int l = 0; l < 4; l++) {
 
  600             fp->write(
reinterpret_cast<char *
>(&result), 
sizeof(
double));
 
  602           for (
int l = 0; l < 4; l++) {
 
  604             fp->write(
reinterpret_cast<char *
>(&result), 
sizeof(
double));
 
  617   const auto dim = lattice.
n_cells();
 
  618   std::shared_ptr<std::ofstream> fp(
nullptr);
 
  633     *fp << std::setprecision(14);
 
  634     *fp << std::scientific;
 
  635     *fp << ctime << std::endl;
 
  651     assert(
sizeof(ctime) == 
sizeof(
double));
 
  652     fp->write(
reinterpret_cast<char *
>(&ctime), 
sizeof(
double));
 
  656       for (
int i = 0; i < 4; i++) {
 
  657         for (
int j = i; j < 4; j++) {
 
  663                   if (ix == dim[0] - 1) {
 
  669                   fp->write(
reinterpret_cast<char *
>(&result), 
sizeof(
double));
 
  676       for (
int i = 0; i < 4; i++) {
 
  677         for (
int j = i; j < 4; j++) {
 
  682                   const FourVector u = node.landau_frame_4velocity();
 
  685                   if (ix == dim[0] - 1) {
 
  690                   const FourVector u = node.landau_frame_4velocity();
 
  693                   fp->write(
reinterpret_cast<char *
>(&result), 
sizeof(
double));
 
  703               const FourVector u = node.landau_frame_4velocity();
 
  705               *fp << v.
x1() << 
" " << v.
x2() << 
" " << v.
x3() << 
"\n";
 
  708               const FourVector u = node.landau_frame_4velocity();
 
  710               fp->write(
reinterpret_cast<char *
>(&v), 3 * 
sizeof(double));
 
  732       throw std::runtime_error(
 
  733           "Error when converting a thermodynamic quantity " 
  734           "to an int, unknown quantity.");
 
  739                                                       const int event_number,
 
  742   assert((type == 
'a') || (type == 
'b'));
 
  744     snprintf(suffix, 
sizeof(suffix), 
"_%07i.dat", event_number);
 
  746     snprintf(suffix, 
sizeof(suffix), 
"_%07i.bin", event_number);
 
  748   return base_path_.string() + std::string(
"/") + descr + std::string(suffix);
 
  753   return std::string(
to_string(dens_type)) + std::string(
"_") +
 
  759   *fp << std::setprecision(2);
 
  761   *fp << 
"#Thermodynamic Lattice Output version: " 
  763   *fp << std::setprecision(6);
 
  765       << 
" " << std::string(
to_string(tq)) << std::endl;
 
  766   *fp << 
"#Grid dimensions: " << 
nodes_[0] << 
" " << 
nodes_[1] << 
" " 
  767       << 
nodes_[2] << std::endl;
 
  776   auto variable_id = 
to_int(tq);
 
  780   fp->write(
reinterpret_cast<char *
>(&variable_id), 
sizeof(
int));
 
  781   fp->write(
reinterpret_cast<char *
>(&
nodes_), 
sizeof(
nodes_));
 
  782   fp->write(
reinterpret_cast<char *
>(&
sizes_), 
sizeof(
sizes_));
 
A class for time-efficient (time-memory trade-off) calculation of density on the lattice.
 
A class to pre-calculate and store parameters relevant for density calculation.
 
The EnergyMomentumTensor class represents a symmetric positive semi-definite energy-momentum tensor .
 
EnergyMomentumTensor boosted(const FourVector &u) const
Boost to a given 4-velocity.
 
static std::int8_t tmn_index(std::int8_t mu, std::int8_t nu)
Access the index of component .
 
The FourVector class holds relevant values in Minkowski spacetime with (+, −, −, −) metric signature.
 
void reset()
Set all the 4-vector components to 0.
 
ThreeVector velocity() const
Get the velocity (3-vector divided by zero component).
 
Abstraction of generic output.
 
const char * to_string(const ThermodynamicQuantity tq)
Convert thermodynamic quantities to strings.
 
The Particles class abstracts the storage and manipulation of particles.
 
A container class to hold all the arrays on the lattice and access them.
 
const std::array< double, 3 > & origin() const
 
const std::array< int, 3 > & n_cells() const
 
void iterate_sublattice(const std::array< int, 3 > &lower_bounds, const std::array< int, 3 > &upper_bounds, F &&func)
A sub-lattice iterator, which iterates in a 3D-structured manner and calls a function on every cell.
 
ThreeVector cell_center(int ix, int iy, int iz) const
Find the coordinates of a given cell.
 
const std::array< double, 3 > & cell_sizes() const
 
const bf::path base_path_
filesystem path for output
 
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.
 
~ThermodynamicLatticeOutput()
Default destructor.
 
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.
 
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)
 
ThermodynamicLatticeOutput(const bf::path &path, const std::string &name, const OutputParameters &out_par, const bool enable_ascii, const bool enable_binary)
Construct Output.
 
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
 
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,...
 
The ThreeVector class represents a physical three-vector  with the components .
 
ThermodynamicQuantity
Represents thermodynamic quantities that can be printed out.
 
std::array< einhard::Logger<>, std::tuple_size< LogArea::AreaTuple >::value > logg
An array that stores all pre-configured Logger objects.
 
std::tuple< double, FourVector, ThreeVector, ThreeVector, FourVector, FourVector, FourVector, FourVector > current_eckart(const ThreeVector &r, const ParticleList &plist, const DensityParameters &par, DensityType dens_type, bool compute_gradient, bool smearing)
Calculates Eckart rest frame density and 4-current of a given density type and optionally the gradien...
 
DensityType
Allows to choose which kind of density to calculate.
 
Helper structure for Experiment to hold output options and parameters.
 
bool td_v_landau
Print out Landau velocity of type td_dens_type or not?
 
bool td_tmn_landau
Print out energy-momentum tensor in Landau rest frame (of type td_dens_type) or not?
 
bool td_jQBS
Print out QBS 4-currents or not?
 
bool td_tmn
Print out energy-momentum tensor of type td_dens_type or not?
 
bool td_smearing
Whether smearing is on or off; WARNING : if smearing is off, then final result is in GeV instead of G...
 
bool td_rho_eckart
Print out Eckart rest frame density of type td_dens_type or not?