OGS 6.1.0-1721-g6382411ad
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.push_back(std::make_pair(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  fh << " <DataSet timestep=\"" << pair.first << "\" group=\"\" part=\"0\" file=\"" << pair.second << "\"/>\n";
41 
42  fh << " </Collection>\n</VTKFile>\n";
43 }
44 
45 } // IO
46 } // 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:28
#define OGS_FATAL(fmt,...)
Definition: Error.h:71