10#include <dune/geometry/referenceelements.hh>
11#include <dune/geometry/type.hh>
19template <
class GV,
class DC>
20void VtkImageDataWriter<GV,DC>
21 ::writeSerialFile (std::ofstream& out)
const
23 std::vector<pos_type> offsets;
24 this->writeHeader(out,
"ImageData");
26 auto const& wholeExtent = dataCollector_->wholeExtent();
27 auto const& origin = dataCollector_->origin();
28 auto const& spacing = dataCollector_->spacing();
30 <<
" WholeExtent=\"" <<
Vtk::join(wholeExtent.begin(), wholeExtent.end()) <<
"\""
31 <<
" Origin=\"" <<
Vtk::join(origin.begin(), origin.end()) <<
"\""
32 <<
" Spacing=\"" <<
Vtk::join(spacing.begin(), spacing.end()) <<
"\""
35 dataCollector_->writeLocalPiece([&out](
auto const& extent) {
36 out <<
"<Piece Extent=\"" <<
Vtk::join(extent.begin(), extent.end()) <<
"\">\n";
40 out <<
"<PointData" << this->getNames(pointData_) <<
">\n";
41 for (
auto const& v : pointData_)
42 this->writeData(out, offsets, v, Super::POINT_DATA);
43 out <<
"</PointData>\n";
46 out <<
"<CellData" << this->getNames(cellData_) <<
">\n";
47 for (
auto const& v : cellData_)
48 this->writeData(out, offsets, v, Super::CELL_DATA);
49 out <<
"</CellData>\n";
52 out <<
"</ImageData>\n";
54 this->writeAppended(out, offsets);
59template <
class GV,
class DC>
60void VtkImageDataWriter<GV,DC>
61 ::writeParallelFile (std::ofstream& out, std::string
const& pfilename,
int )
const
63 this->writeHeader(out,
"PImageData");
65 auto const& wholeExtent = dataCollector_->wholeExtent();
66 auto const& origin = dataCollector_->origin();
67 auto const& spacing = dataCollector_->spacing();
69 <<
" GhostLevel=\"" << dataCollector_->ghostLevel() <<
"\""
70 <<
" WholeExtent=\"" <<
Vtk::join(wholeExtent.begin(), wholeExtent.end()) <<
"\""
71 <<
" Origin=\"" <<
Vtk::join(origin.begin(), origin.end()) <<
"\""
72 <<
" Spacing=\"" <<
Vtk::join(spacing.begin(), spacing.end()) <<
"\""
76 out <<
"<PPointData" << this->getNames(pointData_) <<
">\n";
77 for (
auto const& v : pointData_) {
79 <<
" Name=\"" << v.name() <<
"\""
80 <<
" type=\"" <<
to_string(v.dataType()) <<
"\""
81 <<
" NumberOfComponents=\"" << v.numComponents() <<
"\""
84 out <<
"</PPointData>\n";
87 out <<
"<PCellData" << this->getNames(cellData_) <<
">\n";
88 for (
auto const& v : cellData_) {
90 <<
" Name=\"" << v.name() <<
"\""
91 <<
" type=\"" <<
to_string(v.dataType()) <<
"\""
92 <<
" NumberOfComponents=\"" << v.numComponents() <<
"\""
95 out <<
"</PCellData>\n";
98 dataCollector_->writePieces([&out,pfilename,ext=this->fileExtension()](
int p,
auto const& extent,
bool write_extent)
100 std::string piece_source = pfilename +
"_p" + std::to_string(p) +
"." + ext;
101 out <<
"<Piece Source=\"" << piece_source <<
"\"";
103 out <<
" Extent=\"" <<
Vtk::join(extent.begin(), extent.end()) <<
"\"";
107 out <<
"</PImageData>\n";
std::string to_string(Vtk::FormatTypes type)
Definition: types.cc:12
std::string join(InputIter first, InputIter end, std::string sep=" ")
Definition: string.hh:110