OGS
MeshLib::IO::PVDFile Class Reference

Detailed Description

Writes a basic PVD file for use with Paraview.

Definition at line 24 of file PVDFile.h.

#include <PVDFile.h>

Public Member Functions

 PVDFile (std::string pvd_fname)
 Set a PVD file path. More...
 
void addVTUFile (std::string const &vtu_fname, double timestep)
 Add a VTU file to this PVD file. More...
 

Public Attributes

std::string const pvd_filename
 

Private Attributes

std::vector< std::pair< double, std::string > > _datasets
 

Constructor & Destructor Documentation

◆ PVDFile()

MeshLib::IO::PVDFile::PVDFile ( std::string  pvd_fname)
inlineexplicit

Set a PVD file path.

Definition at line 28 of file PVDFile.h.

29  : pvd_filename(std::move(pvd_fname))
30  {
31  }
std::string const pvd_filename
Definition: PVDFile.h:36

Member Function Documentation

◆ addVTUFile()

void MeshLib::IO::PVDFile::addVTUFile ( std::string const &  vtu_fname,
double  timestep 
)

Add a VTU file to this PVD file.

Definition at line 24 of file PVDFile.cpp.

25 {
26 #ifdef USE_PETSC
27  auto const vtu_file_name =
29 
30  _datasets.emplace_back(timestep, vtu_file_name + ".pvtu");
31 #else
32  _datasets.emplace_back(timestep, vtu_fname);
33 #endif
34 
35  std::ofstream fh(pvd_filename.c_str());
36  if (!fh)
37  {
38  OGS_FATAL("could not open file `{:s}'", pvd_filename);
39  }
40 
41  fh << std::setprecision(std::numeric_limits<double>::digits10);
42 
43  fh << "<?xml version=\"1.0\"?>\n"
44  "<VTKFile type=\"Collection\" version=\"0.1\" "
45  "byte_order=\"LittleEndian\""
46  " compressor=\"vtkZLibDataCompressor\">\n"
47  " <Collection>\n";
48 
49  for (auto const& pair : _datasets)
50  {
51  fh << " <DataSet timestep=\"" << pair.first
52  << "\" group=\"\" part=\"0\" file=\"" << pair.second << "\"/>\n";
53  }
54 
55  fh << " </Collection>\n</VTKFile>\n";
56 }
#define OGS_FATAL(...)
Definition: Error.h:26
std::vector< std::pair< double, std::string > > _datasets
Definition: PVDFile.h:40
std::string getVtuFileNameForPetscOutputWithoutExtension(std::string const &file_name)

References _datasets, MeshLib::IO::getVtuFileNameForPetscOutputWithoutExtension(), OGS_FATAL, and pvd_filename.

Referenced by ProcessLib::Output::outputMesh().

Member Data Documentation

◆ _datasets

std::vector<std::pair<double, std::string> > MeshLib::IO::PVDFile::_datasets
private

Definition at line 40 of file PVDFile.h.

Referenced by addVTUFile().

◆ pvd_filename

std::string const MeshLib::IO::PVDFile::pvd_filename

Definition at line 36 of file PVDFile.h.

Referenced by addVTUFile().


The documentation for this class was generated from the following files: