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 <set>
12#include <string>
13
14namespace MeshLib
15{
16class Mesh;
17
18namespace IO
19{
20
21#ifdef USE_PETSC
23 std::string const& file_name);
24#endif
25
31class VtuInterface final
32{
33public:
35 explicit VtuInterface(
36 const MeshLib::Mesh* mesh,
37 std::set<std::string> const& output_variable_names = {},
38 int dataMode = vtkXMLWriter::Appended,
39 bool compress = false);
40
44 std::string const& file_name,
45 bool const compute_element_neighbors = false);
46
47 static vtkSmartPointer<vtkUnstructuredGrid>
48 readVtuFileToVtkUnstructuredGrid(std::string const& file_name);
49
54 std::string const& file_name,
55 bool const compute_element_neighbors = false);
56
59 bool writeToFile(std::filesystem::path const& file_path);
60
66 template <typename UnstructuredGridWriter>
67 bool writeVTU(std::string const& file_name, const int num_partitions = 1,
68 const int rank = 1);
69
70private:
72 std::set<std::string> _output_variable_names;
75};
76
77} // end namespace IO
78} // end namespace MeshLib
79
80#include "VtuInterface-impl.h"
std::set< std::string > _output_variable_names
VtuInterface(const MeshLib::Mesh *mesh, std::set< std::string > const &output_variable_names={}, 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
std::string getVtuFileNameForPetscOutputWithoutExtension(std::string const &file_name)