38 const std::string &pvtu_path,
39 const std::vector<std::string> &piece_vtu_relative_paths,
40 const std::vector<PvtuPointArray> &point_arrays) {
42 std::ofstream os(pvtu_path);
44 throw std::runtime_error(
"writePvtuCollectionFile: could not open " +
47 os <<
"<?xml version=\"1.0\"?>\n";
48 os <<
"<VTKFile type=\"PUnstructuredGrid\" version=\"0.1\" "
49 "byte_order=\"LittleEndian\">\n";
50 os <<
" <PUnstructuredGrid GhostLevel=\"0\">\n";
52 os <<
" <PDataArray type=\"Float32\" NumberOfComponents=\"3\"/>\n";
53 os <<
" </PPoints>\n";
54 if (!point_arrays.empty()) {
55 os <<
" <PPointData>\n";
56 for (
const auto &a : point_arrays) {
57 os <<
" <PDataArray type=\"" << a.type <<
"\" Name=\"" << a.name
59 if (a.number_of_components > 1)
60 os <<
" NumberOfComponents=\"" << a.number_of_components <<
"\"";
63 os <<
" </PPointData>\n";
65 for (
const auto &piece : piece_vtu_relative_paths) {
66 os <<
" <Piece Source=\"" << piece <<
"\"/>\n";
68 os <<
" </PUnstructuredGrid>\n";
void writePvdCollectionFile(const std::string &pvd_path, const std::vector< std::pair< double, std::string > > &time_and_vtu_relative_path)
Write a ParaView VTK collection (.pvd) that lists VTU files with timesteps.
void writePvtuCollectionFile(const std::string &pvtu_path, const std::vector< std::string > &piece_vtu_relative_paths, const std::vector< PvtuPointArray > &point_arrays)
Write a ParaView parallel VTU (.pvtu) that lists per-rank .vtu pieces.