20 #include <vtkSmartPointer.h>
21 #include <vtkUnstructuredGrid.h>
31 class vtkXMLPUnstructuredGridWriter;
37 template <
typename UnstructuredGr
idWriter>
39 [[maybe_unused]]
const int num_partitions,
40 [[maybe_unused]]
const int rank)
44 ERR(
"VtuInterface::write(): No mesh specified.");
48 vtkNew<MeshLib::VtkMappedMeshSource> vtkSource;
49 vtkSource->SetMesh(
_mesh);
51 vtkSmartPointer<UnstructuredGridWriter> vtuWriter =
52 vtkSmartPointer<UnstructuredGridWriter>::New();
55 vtuWriter->SetInputData(vtkSource->GetOutput());
59 vtuWriter->SetCompressorTypeToZLib();
63 vtuWriter->SetCompressorTypeToNone();
69 vtuWriter->SetEncodeAppendedData(1);
74 vtkSmartPointer<vtkUnstructuredGrid> tempGrid =
75 vtkSmartPointer<vtkUnstructuredGrid>::New();
76 tempGrid->DeepCopy(vtkSource->GetOutput());
77 vtuWriter->SetInputDataObject(tempGrid);
80 vtuWriter->SetFileName(file_name.c_str());
82 if constexpr (std::is_same_v<UnstructuredGridWriter,
83 vtkXMLPUnstructuredGridWriter>)
85 vtuWriter->SetGhostLevel(1);
86 vtuWriter->SetNumberOfPieces(num_partitions);
87 vtuWriter->SetStartPiece(rank);
88 vtuWriter->SetEndPiece(rank);
91 #ifdef VTK_USE_64BIT_IDS
92 vtuWriter->SetHeaderTypeToUInt64();
96 return (vtuWriter->Write() > 0);
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
VtkMappedMeshSource is a source class to transform OGS meshes into complete vtkUnstructuredGrids....
Implementation of the VtuInterface class.
bool writeVTU(std::string const &file_name, const int num_partitions=1, const int rank=1)
const MeshLib::Mesh * _mesh