OGS
VtuInterface.h
Go to the documentation of this file.
1 
15 #pragma once
16 
17 #include <string>
18 #include <filesystem>
19 #include <vtkXMLWriter.h>
20 
21 namespace MeshLib {
22 class Mesh;
23 
24 namespace IO
25 {
26 
27 #ifdef USE_PETSC
29  std::string const& file_name);
30 #endif
31 
37 class VtuInterface final
38 {
39 public:
41  explicit VtuInterface(const MeshLib::Mesh* mesh,
42  int dataMode = vtkXMLWriter::Appended,
43  bool compressed = false);
44 
47  static MeshLib::Mesh* readVTUFile(std::string const &file_name);
48 
52  static MeshLib::Mesh* readVTKFile(std::string const& file_name);
53 
56  bool writeToFile(std::filesystem::path const& file_path);
57 
63  template <typename UnstructuredGridWriter>
64  bool writeVTU(std::string const& file_name, const int num_partitions = 1,
65  const int rank = 1);
66 
67 private:
71 };
72 
73 int writeVtu(MeshLib::Mesh const& mesh, std::string const& file_name,
74  int const data_mode = vtkXMLWriter::Appended);
75 
76 } // end namespace IO
77 } // end namespace MeshLib
78 
79 #include "VtuInterface-impl.h"
Implementation of the VtuInterface class.
Reads and writes VtkXMLUnstructuredGrid-files (vtu) to and from OGS data structures....
Definition: VtuInterface.h:38
static MeshLib::Mesh * readVTKFile(std::string const &file_name)
static MeshLib::Mesh * readVTUFile(std::string const &file_name)
VtuInterface(const MeshLib::Mesh *mesh, int dataMode=vtkXMLWriter::Appended, bool compressed=false)
Provide the mesh to write and set if compression should be used.
bool writeVTU(std::string const &file_name, const int num_partitions=1, const int rank=1)
bool writeToFile(std::filesystem::path const &file_path)
const MeshLib::Mesh * _mesh
Definition: VtuInterface.h:68
int writeVtu(MeshLib::Mesh const &mesh, std::string const &file_name, int const data_mode)
std::string getVtuFileNameForPetscOutputWithoutExtension(std::string const &file_name)