39 [[maybe_unused]]
const int num_partitions,
40 [[maybe_unused]]
const int rank)
44 ERR(
"VtuInterface::write(): No mesh specified.");
52 auto* ghost_cell_property =
55 if (ghost_cell_property)
59 ->is_for_output =
true;
68 vtkNew<MeshLib::VtkMappedMeshSource> vtkSource;
69 vtkSource->SetMesh(
_mesh);
71 vtkSmartPointer<UnstructuredGridWriter> vtuWriter =
72 vtkSmartPointer<UnstructuredGridWriter>::New();
75 vtuWriter->SetInputData(vtkSource->GetOutput());
79 vtuWriter->SetCompressorTypeToZLib();
83 vtuWriter->SetCompressorTypeToNone();
89 vtuWriter->SetEncodeAppendedData(1);
94 vtkSmartPointer<vtkUnstructuredGrid> tempGrid =
95 vtkSmartPointer<vtkUnstructuredGrid>::New();
96 tempGrid->DeepCopy(vtkSource->GetOutput());
97 vtuWriter->SetInputDataObject(tempGrid);
100 vtuWriter->SetFileName(file_name.c_str());
103 if constexpr (std::is_same_v<UnstructuredGridWriter,
104 vtkXMLPUnstructuredGridWriter>)
107 vtkSmartPointer<vtkMPICommunicator> vtk_comm =
108 vtkSmartPointer<vtkMPICommunicator>::New();
109 MPI_Comm mpi_comm = MPI_COMM_WORLD;
110 vtkMPICommunicatorOpaqueComm vtk_opaque_comm(&mpi_comm);
111 vtk_comm->InitializeExternal(&vtk_opaque_comm);
113 vtkSmartPointer<vtkMPIController> vtk_mpi_ctrl =
114 vtkSmartPointer<vtkMPIController>::New();
115 vtk_mpi_ctrl->SetCommunicator(vtk_comm);
117 vtuWriter->SetController(vtk_mpi_ctrl);
119 vtuWriter->SetGhostLevel(1);
120 vtuWriter->SetNumberOfPieces(num_partitions);
121 vtuWriter->SetStartPiece(rank);
122 vtuWriter->SetEndPiece(rank);
126#ifdef VTK_USE_64BIT_IDS
127 vtuWriter->SetHeaderTypeToUInt64();
131 return (vtuWriter->Write() > 0);