30 [[maybe_unused]]
const int num_partitions,
31 [[maybe_unused]]
const int rank)
35 ERR(
"VtuInterface::write(): No mesh specified.");
40 if (
_mesh->getProperties().existsPropertyVector<
unsigned char>(
43 auto* ghost_cell_property =
44 _mesh->getProperties().getPropertyVector<
unsigned char>(
46 if (ghost_cell_property)
50 ->is_for_output =
true;
55 DBUG(
"No vtkGhostType data in mesh '{}'.",
_mesh->getName());
59 vtkNew<MeshLib::VtkMappedMeshSource> vtkSource;
60 vtkSource->SetMesh(
_mesh);
62 vtkSmartPointer<UnstructuredGridWriter> vtuWriter =
63 vtkSmartPointer<UnstructuredGridWriter>::New();
66 vtuWriter->SetInputData(vtkSource->GetOutput());
70 vtuWriter->SetCompressorTypeToZLib();
74 vtuWriter->SetCompressorTypeToNone();
80 vtuWriter->SetEncodeAppendedData(1);
85 vtkSmartPointer<vtkUnstructuredGrid> tempGrid =
86 vtkSmartPointer<vtkUnstructuredGrid>::New();
87 tempGrid->DeepCopy(vtkSource->GetOutput());
88 vtuWriter->SetInputDataObject(tempGrid);
91 vtuWriter->SetFileName(file_name.c_str());
94 if constexpr (std::is_same_v<UnstructuredGridWriter,
95 vtkXMLPUnstructuredGridWriter>)
98 vtkSmartPointer<vtkMPICommunicator> vtk_comm =
99 vtkSmartPointer<vtkMPICommunicator>::New();
101 vtkMPICommunicatorOpaqueComm vtk_opaque_comm(&mpi_comm);
102 vtk_comm->InitializeExternal(&vtk_opaque_comm);
104 vtkSmartPointer<vtkMPIController> vtk_mpi_ctrl =
105 vtkSmartPointer<vtkMPIController>::New();
106 vtk_mpi_ctrl->SetCommunicator(vtk_comm);
108 vtuWriter->SetController(vtk_mpi_ctrl);
110 vtuWriter->SetGhostLevel(1);
111 vtuWriter->SetNumberOfPieces(num_partitions);
112 vtuWriter->SetStartPiece(rank);
113 vtuWriter->SetEndPiece(rank);
117#ifdef VTK_USE_64BIT_IDS
118 vtuWriter->SetHeaderTypeToUInt64();
122 return (vtuWriter->Write() > 0);