OGS 6.2.0-97-g4a610c866
PVDFile.cpp
Go to the documentation of this file.
1 
10 #include "PVDFile.h"
11 
12 #include <fstream>
13 #include <iomanip>
14 #include <limits>
15 #include <logog/include/logog.hpp>
16 #include "BaseLib/Error.h"
17 
18 namespace MeshLib
19 {
20 namespace IO
21 {
22 
23 void PVDFile::addVTUFile(const std::string &vtu_fname, double timestep)
24 {
25  _datasets.emplace_back(timestep, vtu_fname);
26 
27  std::ofstream fh(_pvd_filename.c_str());
28  if (!fh) {
29  OGS_FATAL("could not open file `%s'", _pvd_filename.c_str());
30  }
31 
32  fh << std::setprecision(std::numeric_limits<double>::digits10);
33 
34  fh << "<?xml version=\"1.0\"?>\n"
35  "<VTKFile type=\"Collection\" version=\"0.1\" byte_order=\"LittleEndian\""
36  " compressor=\"vtkZLibDataCompressor\">\n"
37  " <Collection>\n";
38 
39  for (auto const& pair : _datasets)
40  {
41  fh << " <DataSet timestep=\"" << pair.first
42  << "\" group=\"\" part=\"0\" file=\"" << pair.second << "\"/>\n";
43  }
44 
45  fh << " </Collection>\n</VTKFile>\n";
46 }
47 
48 } // namespace IO
49 } // namespace MeshLib
void addVTUFile(std::string const &vtu_fname, double timestep)
Add a VTU file to this PVD file.
Definition: PVDFile.cpp:23
std::string const _pvd_filename
Definition: PVDFile.h:37
std::vector< std::pair< double, std::string > > _datasets
Definition: PVDFile.h:38
Interface for heuristic search length strategy.
Definition: ProjectData.h:29
#define OGS_FATAL(fmt,...)
Definition: Error.h:63