OGS
VtuInterface.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
4#pragma once
5
6#include <vtkSmartPointer.h>
7#include <vtkUnstructuredGrid.h>
8#include <vtkXMLWriter.h>
9
10#include <filesystem>
11#include <string>
12
13namespace MeshLib {
14class Mesh;
15
16namespace IO
17{
18
19#ifdef USE_PETSC
21 std::string const& file_name);
22#endif
23
29class VtuInterface final
30{
31public:
33 explicit VtuInterface(const MeshLib::Mesh* mesh,
34 int dataMode = vtkXMLWriter::Appended,
35 bool compress = false);
36
40 std::string const& file_name,
41 bool const compute_element_neighbors = false);
42
43 static vtkSmartPointer<vtkUnstructuredGrid>
44 readVtuFileToVtkUnstructuredGrid(std::string const& file_name);
45
50 std::string const& file_name,
51 bool const compute_element_neighbors = false);
52
55 bool writeToFile(std::filesystem::path const& file_path);
56
62 template <typename UnstructuredGridWriter>
63 bool writeVTU(std::string const& file_name, const int num_partitions = 1,
64 const int rank = 1);
65
66private:
70};
71
72int writeVtu(MeshLib::Mesh const& mesh, std::string const& file_name,
73 int const data_mode = vtkXMLWriter::Appended);
74
75} // end namespace IO
76} // end namespace MeshLib
77
78#include "VtuInterface-impl.h"
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)