19template <
class GV,
class DC>
20void UnstructuredGridWriter<GV,DC>
24 this->writeHeader(out,
"UnstructuredGrid");
25 out <<
"<UnstructuredGrid>\n";
28 <<
" NumberOfPoints=\"" << dataCollector_->numPoints() <<
"\""
29 <<
" NumberOfCells=\"" << dataCollector_->numCells() <<
"\""
34 this->writePoints(out, offsets);
39 writeCells(out, offsets);
40 writePointIds(out, offsets);
44 out <<
"<PointData" << this->getNames(pointData_) <<
">\n";
45 for (
auto const& v : pointData_)
46 this->writeData(out, offsets, v, Super::POINT_DATA);
47 out <<
"</PointData>\n";
50 out <<
"<CellData" << this->getNames(cellData_) <<
">\n";
51 for (
auto const& v : cellData_)
52 this->writeData(out, offsets, v, Super::CELL_DATA);
53 out <<
"</CellData>\n";
56 out <<
"</UnstructuredGrid>\n";
58 this->writeAppended(out, offsets);
63template <
class GV,
class DC>
64void UnstructuredGridWriter<GV,DC>
67 this->writeHeader(out,
"PUnstructuredGrid");
68 out <<
"<PUnstructuredGrid GhostLevel=\"0\">\n";
73 <<
" type=\"" <<
to_string(datatype_) <<
"\""
74 <<
" NumberOfComponents=\"3\""
76 out <<
"</PPoints>\n";
79 out <<
"<PPointData" << this->getNames(pointData_) <<
">\n";
80 for (
auto const& v : pointData_) {
82 <<
" Name=\"" << v.name() <<
"\""
83 <<
" type=\"" <<
to_string(v.dataType()) <<
"\""
84 <<
" NumberOfComponents=\"" << v.numComponents() <<
"\""
87 out <<
"</PPointData>\n";
90 out <<
"<PCellData" << this->getNames(cellData_) <<
">\n";
91 for (
auto const& v : cellData_) {
93 <<
" Name=\"" << v.name() <<
"\""
94 <<
" type=\"" <<
to_string(v.dataType()) <<
"\""
95 <<
" NumberOfComponents=\"" << v.numComponents() <<
"\""
98 out <<
"</PCellData>\n";
101 for (
int p = 0; p <
size; ++p) {
103 out <<
"<Piece Source=\"" << piece_source <<
"\" />\n";
106 out <<
"</PUnstructuredGrid>\n";
111template <
class GV,
class DC>
112void UnstructuredGridWriter<GV,DC>
121 this->writeHeader(out,
"UnstructuredGrid");
122 out <<
"<UnstructuredGrid"
126 for (
auto const& timestep : timesteps)
127 out << timestep.first << (++i % 6 != 0 ?
' ' :
'\n');
132 <<
" NumberOfPoints=\"" << dataCollector_->numPoints() <<
"\""
133 <<
" NumberOfCells=\"" << dataCollector_->numCells() <<
"\""
138 for (
std::size_t i = 0; i < timesteps.size(); ++i) {
139 this->writePoints(out, offsets[i], i);
141 out <<
"</Points>\n";
145 for (
std::size_t i = 0; i < timesteps.size(); ++i) {
146 writeCells(out, offsets[i], i);
147 writePointIds(out, offsets[i], i);
154 out <<
"<PointData" << this->getNames(pointData_) <<
">\n";
155 for (
std::size_t i = 0; i < timesteps.size(); ++i) {
156 for (
auto const& v : pointData_)
157 this->writeData(out, offsets[i], v, Super::POINT_DATA, i);
159 out <<
"</PointData>\n";
162 out <<
"<CellData" << this->getNames(cellData_) <<
">\n";
163 for (
std::size_t i = 0; i < timesteps.size(); ++i) {
164 for (
auto const& v : cellData_)
165 this->writeData(out, offsets[i], v, Super::CELL_DATA, i);
167 out <<
"</CellData>\n";
170 out <<
"</UnstructuredGrid>\n";
172 out <<
"<AppendedData encoding=\"raw\">\n_";
173 pos_type appended_pos = out.
tellp();
176 std::ifstream file_mesh(filenameMesh, std::ios_base::in | std::ios_base::binary);
177 out << file_mesh.
rdbuf();
182 for (
auto const& timestep : timesteps) {
183 std::ifstream file(timestep.second, std::ios_base::in | std::ios_base::binary);
186 out <<
"</AppendedData>\n";
192 for (
std::size_t i = 0; i < timesteps.size(); ++i) {
194 auto const& off = offsets[i];
199 out <<
'"' << offset <<
'"';
200 offset += pos_type(blocks[j]);
205 for (
std::size_t i = 0; i < timesteps.size(); ++i) {
206 auto const& off = offsets[i];
210 out <<
'"' << offset <<
'"';
211 offset += pos_type(blocks[j++]);
217template <
class GV,
class DC>
218void UnstructuredGridWriter<GV,DC>
224 this->writeHeader(out,
"PUnstructuredGrid");
225 out <<
"<PUnstructuredGrid GhostLevel=\"0\""
229 for (
auto const& timestep : timesteps)
230 out << timestep.first << (++i % 6 != 0 ?
' ' :
'\n');
235 out <<
"<PPoints>\n";
237 <<
" type=\"" <<
to_string(datatype_) <<
"\""
238 <<
" NumberOfComponents=\"3\""
240 out <<
"</PPoints>\n";
243 out <<
"<PPointData" << this->getNames(pointData_) <<
">\n";
244 for (
std::size_t i = 0; i < timesteps.size(); ++i) {
245 for (
auto const& v : pointData_) {
247 <<
" Name=\"" << v.name() <<
"\""
248 <<
" type=\"" <<
to_string(v.dataType()) <<
"\""
249 <<
" NumberOfComponents=\"" << v.numComponents() <<
"\""
250 <<
" TimeStep=\"" << i <<
"\""
254 out <<
"</PPointData>\n";
257 out <<
"<PCellData" << this->getNames(cellData_) <<
">\n";
258 for (
std::size_t i = 0; i < timesteps.size(); ++i) {
259 for (
auto const& v : cellData_) {
261 <<
" Name=\"" << v.name() <<
"\""
262 <<
" type=\"" <<
to_string(v.dataType()) <<
"\""
263 <<
" NumberOfComponents=\"" << v.numComponents() <<
"\""
264 <<
" TimeStep=\"" << i <<
"\""
268 out <<
"</PCellData>\n";
271 for (
int p = 0; p <
size; ++p) {
273 out <<
"<Piece Source=\"" << piece_source <<
"\" />\n";
276 out <<
"</PUnstructuredGrid>\n";
281template <
class GV,
class DC>
282void UnstructuredGridWriter<GV,DC>
287 auto cells = dataCollector_->cells();
288 out <<
"<DataArray type=\"Int64\" Name=\"connectivity\" format=\"ascii\"";
290 out <<
" TimeStep=\"" << *timestep <<
"\"";
292 this->writeValuesAscii(out, cells.connectivity);
293 out <<
"</DataArray>\n";
295 out <<
"<DataArray type=\"Int64\" Name=\"offsets\" format=\"ascii\"";
297 out <<
" TimeStep=\"" << *timestep <<
"\"";
299 this->writeValuesAscii(out, cells.offsets);
300 out <<
"</DataArray>\n";
302 out <<
"<DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\"";
304 out <<
" TimeStep=\"" << *timestep <<
"\"";
306 this->writeValuesAscii(out, cells.types);
307 out <<
"</DataArray>\n";
310 out <<
"<DataArray type=\"Int64\" Name=\"connectivity\" format=\"appended\"";
312 out <<
" TimeStep=\"" << *timestep <<
"\"";
318 out <<
"<DataArray type=\"Int64\" Name=\"offsets\" format=\"appended\"";
320 out <<
" TimeStep=\"" << *timestep <<
"\"";
326 out <<
"<DataArray type=\"UInt8\" Name=\"types\" format=\"appended\"";
328 out <<
" TimeStep=\"" << *timestep <<
"\"";
337template <
class GV,
class DC>
338void UnstructuredGridWriter<GV,DC>
343 auto ids = dataCollector_->pointIds();
348 out <<
"<DataArray type=\"UInt64\" Name=\"global_point_ids\" format=\"ascii\"";
350 out <<
" TimeStep=\"" << *timestep <<
"\"";
352 this->writeValuesAscii(out, ids);
353 out <<
"</DataArray>\n";
356 out <<
"<DataArray type=\"UInt64\" Name=\"global_point_ids\" format=\"appended\"";
358 out <<
" TimeStep=\"" << *timestep <<
"\"";
367template <
class GV,
class DC>
368void UnstructuredGridWriter<GV,DC>
373 Vtk::mapDataTypes<std::is_floating_point, std::is_integral>(datatype_, headertype_,
374 [&](
auto f,
auto h) {
375 using F =
typename decltype(f)::type;
376 using H =
typename decltype(h)::type;
379 blocks.
push_back(this->
template writeValuesAppended<H>(out, dataCollector_->template points<F>()));
382 auto cells = dataCollector_->cells();
383 blocks.
push_back(this->
template writeValuesAppended<H>(out, cells.connectivity));
384 blocks.
push_back(this->
template writeValuesAppended<H>(out, cells.offsets));
385 blocks.
push_back(this->
template writeValuesAppended<H>(out, cells.types));
388 auto ids = dataCollector_->pointIds();
390 blocks.
push_back(this->template writeValuesAppended<H>(out, ids));
constexpr bool is_a(E a, Integer b)
Definition enum.hh:9
std::string to_string(Vtk::FormatTypes)
Definition types.cc:11