OGS
VtuInterface.h
Go to the documentation of this file.
1
15#pragma once
16
17#include <vtkSmartPointer.h>
18#include <vtkUnstructuredGrid.h>
19#include <vtkXMLWriter.h>
20
21#include <filesystem>
22#include <string>
23
24namespace MeshLib {
25class Mesh;
26
27namespace IO
28{
29
30#ifdef USE_PETSC
32 std::string const& file_name);
33#endif
34
40class VtuInterface final
41{
42public:
44 explicit VtuInterface(const MeshLib::Mesh* mesh,
45 int dataMode = vtkXMLWriter::Appended,
46 bool compress = false);
47
51 std::string const& file_name,
52 bool const compute_element_neighbors = false);
53
54 static vtkSmartPointer<vtkUnstructuredGrid>
55 readVtuFileToVtkUnstructuredGrid(std::string const& file_name);
56
61 std::string const& file_name,
62 bool const compute_element_neighbors = false);
63
66 bool writeToFile(std::filesystem::path const& file_path);
67
73 template <typename UnstructuredGridWriter>
74 bool writeVTU(std::string const& file_name, const int num_partitions = 1,
75 const int rank = 1);
76
77private:
81};
82
83int writeVtu(MeshLib::Mesh const& mesh, std::string const& file_name,
84 int const data_mode = vtkXMLWriter::Appended);
85
86} // end namespace IO
87} // end namespace MeshLib
88
89#include "VtuInterface-impl.h"
Implementation of the VtuInterface class.
Reads and writes VtkXMLUnstructuredGrid-files (vtu) to and from OGS data structures....
VtuInterface(const MeshLib::Mesh *mesh, int dataMode=vtkXMLWriter::Appended, bool compress=false)
Provide the mesh to write and set if compression should be used.
static MeshLib::Mesh * readVTUFile(std::string const &file_name, bool const compute_element_neighbors=false)
static MeshLib::Mesh * readVTKFile(std::string const &file_name, bool const compute_element_neighbors=false)
static vtkSmartPointer< vtkUnstructuredGrid > readVtuFileToVtkUnstructuredGrid(std::string const &file_name)
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
int writeVtu(MeshLib::Mesh const &mesh, std::string const &file_name, int const data_mode)
std::string getVtuFileNameForPetscOutputWithoutExtension(std::string const &file_name)