21template <
class GV,
class DC>
22void UnstructuredGridWriter<GV,DC>
26 this->writeHeader(out,
"UnstructuredGrid");
27 out <<
"<UnstructuredGrid>\n";
30 <<
" NumberOfPoints=\"" << dataCollector_->numPoints() <<
"\""
31 <<
" NumberOfCells=\"" << dataCollector_->numCells() <<
"\""
36 this->writePoints(out, offsets);
41 writeCells(out, offsets);
42 writePointIds(out, offsets);
46 out <<
"<PointData" << this->getNames(pointData_) <<
">\n";
47 for (
auto const& v : pointData_)
48 this->writeData(out, offsets, v, Super::POINT_DATA);
49 out <<
"</PointData>\n";
52 out <<
"<CellData" << this->getNames(cellData_) <<
">\n";
53 for (
auto const& v : cellData_)
54 this->writeData(out, offsets, v, Super::CELL_DATA);
55 out <<
"</CellData>\n";
58 out <<
"</UnstructuredGrid>\n";
60 this->writeAppended(out, offsets);
65template <
class GV,
class DC>
66void UnstructuredGridWriter<GV,DC>
69 this->writeHeader(out,
"PUnstructuredGrid");
70 out <<
"<PUnstructuredGrid GhostLevel=\"0\">\n";
75 <<
" type=\"" <<
to_string(datatype_) <<
"\""
76 <<
" NumberOfComponents=\"3\""
78 out <<
"</PPoints>\n";
81 out <<
"<PPointData" << this->getNames(pointData_) <<
">\n";
82 for (
auto const& v : pointData_) {
84 <<
" Name=\"" << v.name() <<
"\""
85 <<
" type=\"" <<
to_string(v.dataType()) <<
"\""
86 <<
" NumberOfComponents=\"" << v.numComponents() <<
"\""
89 out <<
"</PPointData>\n";
92 out <<
"<PCellData" << this->getNames(cellData_) <<
">\n";
93 for (
auto const& v : cellData_) {
95 <<
" Name=\"" << v.name() <<
"\""
96 <<
" type=\"" <<
to_string(v.dataType()) <<
"\""
97 <<
" NumberOfComponents=\"" << v.numComponents() <<
"\""
100 out <<
"</PCellData>\n";
103 for (
int p = 0; p <
size; ++p) {
105 out <<
"<Piece Source=\"" << piece_source <<
"\" />\n";
108 out <<
"</PUnstructuredGrid>\n";
113template <
class GV,
class DC>
114void UnstructuredGridWriter<GV,DC>
123 this->writeHeader(out,
"UnstructuredGrid");
124 out <<
"<UnstructuredGrid"
128 for (
auto const& timestep : timesteps)
129 out << timestep.first << (++i % 6 != 0 ?
' ' :
'\n');
134 <<
" NumberOfPoints=\"" << dataCollector_->numPoints() <<
"\""
135 <<
" NumberOfCells=\"" << dataCollector_->numCells() <<
"\""
140 for (
std::size_t i = 0; i < timesteps.size(); ++i) {
141 this->writePoints(out, offsets[i], i);
143 out <<
"</Points>\n";
147 for (
std::size_t i = 0; i < timesteps.size(); ++i) {
148 writeCells(out, offsets[i], i);
149 writePointIds(out, offsets[i], i);
156 out <<
"<PointData" << this->getNames(pointData_) <<
">\n";
157 for (
std::size_t i = 0; i < timesteps.size(); ++i) {
158 for (
auto const& v : pointData_)
159 this->writeData(out, offsets[i], v, Super::POINT_DATA, i);
161 out <<
"</PointData>\n";
164 out <<
"<CellData" << this->getNames(cellData_) <<
">\n";
165 for (
std::size_t i = 0; i < timesteps.size(); ++i) {
166 for (
auto const& v : cellData_)
167 this->writeData(out, offsets[i], v, Super::CELL_DATA, i);
169 out <<
"</CellData>\n";
172 out <<
"</UnstructuredGrid>\n";
174 out <<
"<AppendedData encoding=\"raw\">\n_";
175 [[maybe_unused]] pos_type appended_pos = out.
tellp();
178 std::ifstream file_mesh(filenameMesh, std::ios_base::in | std::ios_base::binary);
179 out << file_mesh.
rdbuf();
184 for (
auto const& timestep : timesteps) {
185 std::ifstream file(timestep.second, std::ios_base::in | std::ios_base::binary);
188 out <<
"</AppendedData>\n";
194 for (
std::size_t i = 0; i < timesteps.size(); ++i) {
196 auto const& off = offsets[i];
201 out <<
'"' << offset <<
'"';
202 offset += pos_type(blocks[j]);
207 for (
std::size_t i = 0; i < timesteps.size(); ++i) {
208 auto const& off = offsets[i];
212 out <<
'"' << offset <<
'"';
213 offset += pos_type(blocks[j++]);
219template <
class GV,
class DC>
220void UnstructuredGridWriter<GV,DC>
226 this->writeHeader(out,
"PUnstructuredGrid");
227 out <<
"<PUnstructuredGrid GhostLevel=\"0\""
231 for (
auto const& timestep : timesteps)
232 out << timestep.first << (++i % 6 != 0 ?
' ' :
'\n');
237 out <<
"<PPoints>\n";
239 <<
" type=\"" <<
to_string(datatype_) <<
"\""
240 <<
" NumberOfComponents=\"3\""
242 out <<
"</PPoints>\n";
245 out <<
"<PPointData" << this->getNames(pointData_) <<
">\n";
246 for (
std::size_t i = 0; i < timesteps.size(); ++i) {
247 for (
auto const& v : pointData_) {
249 <<
" Name=\"" << v.name() <<
"\""
250 <<
" type=\"" <<
to_string(v.dataType()) <<
"\""
251 <<
" NumberOfComponents=\"" << v.numComponents() <<
"\""
252 <<
" TimeStep=\"" << i <<
"\""
256 out <<
"</PPointData>\n";
259 out <<
"<PCellData" << this->getNames(cellData_) <<
">\n";
260 for (
std::size_t i = 0; i < timesteps.size(); ++i) {
261 for (
auto const& v : cellData_) {
263 <<
" Name=\"" << v.name() <<
"\""
264 <<
" type=\"" <<
to_string(v.dataType()) <<
"\""
265 <<
" NumberOfComponents=\"" << v.numComponents() <<
"\""
266 <<
" TimeStep=\"" << i <<
"\""
270 out <<
"</PCellData>\n";
273 for (
int p = 0; p <
size; ++p) {
275 out <<
"<Piece Source=\"" << piece_source <<
"\" />\n";
278 out <<
"</PUnstructuredGrid>\n";
283template <
class GV,
class DC>
284void UnstructuredGridWriter<GV,DC>
289 auto cells = dataCollector_->cells();
290 out <<
"<DataArray type=\"Int64\" Name=\"connectivity\" format=\"ascii\"";
292 out <<
" TimeStep=\"" << *timestep <<
"\"";
295 out <<
"</DataArray>\n";
297 out <<
"<DataArray type=\"Int64\" Name=\"offsets\" format=\"ascii\"";
299 out <<
" TimeStep=\"" << *timestep <<
"\"";
302 out <<
"</DataArray>\n";
304 out <<
"<DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\"";
306 out <<
" TimeStep=\"" << *timestep <<
"\"";
309 out <<
"</DataArray>\n";
312 out <<
"<DataArray type=\"Int64\" Name=\"connectivity\" format=\"appended\"";
314 out <<
" TimeStep=\"" << *timestep <<
"\"";
320 out <<
"<DataArray type=\"Int64\" Name=\"offsets\" format=\"appended\"";
322 out <<
" TimeStep=\"" << *timestep <<
"\"";
328 out <<
"<DataArray type=\"UInt8\" Name=\"types\" format=\"appended\"";
330 out <<
" TimeStep=\"" << *timestep <<
"\"";
339template <
class GV,
class DC>
340void UnstructuredGridWriter<GV,DC>
345 auto ids = dataCollector_->pointIds();
350 out <<
"<DataArray type=\"UInt64\" Name=\"global_point_ids\" format=\"ascii\"";
352 out <<
" TimeStep=\"" << *timestep <<
"\"";
354 this->writeValuesAscii(out, ids);
355 out <<
"</DataArray>\n";
358 out <<
"<DataArray type=\"UInt64\" Name=\"global_point_ids\" format=\"appended\"";
360 out <<
" TimeStep=\"" << *timestep <<
"\"";
369template <
class GV,
class DC>
370void UnstructuredGridWriter<GV,DC>
375 Vtk::mapDataTypes<std::is_floating_point, std::is_integral>(datatype_, headertype_,
376 [&](
auto f,
auto h) {
377 using F =
typename decltype(f)::type;
378 using H =
typename decltype(h)::type;
381 blocks.
push_back(this->
template writeValuesAppended<H>(out, dataCollector_->template points<F>()));
384 auto cells = dataCollector_->cells();
390 auto ids = dataCollector_->pointIds();
392 blocks.
push_back(this->template writeValuesAppended<H>(out, ids));
Definition datacollector.hh:19
constexpr bool is_a(E a, Integer b)
Definition enum.hh:11
std::string to_string(Vtk::FormatTypes)
Definition types.cc:13
std::vector< std::int64_t > offsets
Definition unstructureddatacollector.hh:16
std::vector< std::int64_t > connectivity
Definition unstructureddatacollector.hh:17
std::vector< std::uint8_t > types
Definition unstructureddatacollector.hh:15
Cells cells() const
Return cell types, offsets, and connectivity.
Definition unstructureddatacollector.hh:47