20 #include <vtkSmartPointer.h>
21 #include <vtkUnstructuredGrid.h>
31 template <
typename UnstructuredGr
idWriter>
33 const int num_partitions,
const int rank)
37 ERR(
"VtuInterface::write(): No mesh specified.");
41 vtkNew<MeshLib::VtkMappedMeshSource> vtkSource;
42 vtkSource->SetMesh(
_mesh);
44 vtkSmartPointer<UnstructuredGridWriter> vtuWriter =
45 vtkSmartPointer<UnstructuredGridWriter>::New();
48 vtuWriter->SetInputData(vtkSource->GetOutput());
52 vtuWriter->SetCompressorTypeToZLib();
56 vtuWriter->SetCompressorTypeToNone();
62 vtuWriter->SetEncodeAppendedData(1);
67 vtkSmartPointer<vtkUnstructuredGrid> tempGrid =
68 vtkSmartPointer<vtkUnstructuredGrid>::New();
69 tempGrid->DeepCopy(vtkSource->GetOutput());
70 vtuWriter->SetInputDataObject(tempGrid);
73 vtuWriter->SetFileName(file_name.c_str());
75 vtuWriter->SetGhostLevel(1);
76 vtuWriter->SetNumberOfPieces(num_partitions);
77 vtuWriter->SetStartPiece(rank);
78 vtuWriter->SetEndPiece(rank);
85 #ifdef VTK_USE_64BIT_IDS
86 vtuWriter->SetHeaderTypeToUInt64();
90 return (vtuWriter->Write() > 0);
void ERR(char const *fmt, Args const &... 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