21template <
class GV,
class DC>
22void RectilinearGridWriter<GV,DC>
26 this->writeHeader(out,
"RectilinearGrid");
28 auto const& wholeExtent = dataCollector_->wholeExtent();
29 out <<
"<RectilinearGrid"
30 <<
" WholeExtent=\"" <<
Vtk::join(wholeExtent.begin(), wholeExtent.end()) <<
"\""
33 dataCollector_->writeLocalPiece([&out](
auto const& extent) {
34 out <<
"<Piece Extent=\"" <<
Vtk::join(extent.begin(), extent.end()) <<
"\">\n";
38 out <<
"<Coordinates>\n";
39 writeCoordinates(out, offsets);
40 out <<
"</Coordinates>\n";
43 out <<
"<PointData" << this->getNames(pointData_) <<
">\n";
44 for (
auto const& v : pointData_)
45 this->writeData(out, offsets, v, Super::POINT_DATA);
46 out <<
"</PointData>\n";
49 out <<
"<CellData" << this->getNames(cellData_) <<
">\n";
50 for (
auto const& v : cellData_)
51 this->writeData(out, offsets, v, Super::CELL_DATA);
52 out <<
"</CellData>\n";
55 out <<
"</RectilinearGrid>\n";
57 this->writeAppended(out, offsets);
62template <
class GV,
class DC>
63void RectilinearGridWriter<GV,DC>
66 this->writeHeader(out,
"PRectilinearGrid");
68 auto const& wholeExtent = dataCollector_->wholeExtent();
69 out <<
"<PRectilinearGrid"
70 <<
" GhostLevel=\"" << dataCollector_->ghostLevel() <<
"\""
71 <<
" WholeExtent=\"" <<
Vtk::join(wholeExtent.begin(), wholeExtent.end()) <<
"\""
75 out <<
"<PCoordinates>\n";
76 out <<
"<PDataArray Name=\"x\" type=\"" <<
to_string(datatype_) <<
"\" />\n";
77 out <<
"<PDataArray Name=\"y\" type=\"" <<
to_string(datatype_) <<
"\" />\n";
78 out <<
"<PDataArray Name=\"z\" type=\"" <<
to_string(datatype_) <<
"\" />\n";
79 out <<
"</PCoordinates>\n";
82 out <<
"<PPointData" << this->getNames(pointData_) <<
">\n";
83 for (
auto const& v : pointData_) {
85 <<
" Name=\"" << v.name() <<
"\""
86 <<
" type=\"" <<
to_string(v.dataType()) <<
"\""
87 <<
" NumberOfComponents=\"" << v.numComponents() <<
"\""
90 out <<
"</PPointData>\n";
93 out <<
"<PCellData" << this->getNames(cellData_) <<
">\n";
94 for (
auto const& v : cellData_) {
96 <<
" Name=\"" << v.name() <<
"\""
97 <<
" type=\"" <<
to_string(v.dataType()) <<
"\""
98 <<
" NumberOfComponents=\"" << v.numComponents() <<
"\""
101 out <<
"</PCellData>\n";
104 dataCollector_->writePieces([&out,pfilename,ext=this->fileExtension()](
int p,
auto const& extent,
bool write_extent)
107 out <<
"<Piece Source=\"" << piece_source <<
"\"";
109 out <<
" Extent=\"" <<
Vtk::join(extent.begin(), extent.end()) <<
"\"";
113 out <<
"</PRectilinearGrid>\n";
118template <
class GV,
class DC>
119void RectilinearGridWriter<GV,DC>
125 auto coordinates = dataCollector_->template coordinates<double>();
127 out <<
"<DataArray type=\"" <<
to_string(datatype_) <<
"\" Name=\"" << names[d] <<
"\" format=\"ascii\"";
129 out <<
" TimeStep=\"" << *timestep <<
"\"";
131 this->writeValuesAscii(out, coordinates[d]);
132 out <<
"</DataArray>\n";
137 out <<
"<DataArray type=\"" <<
to_string(datatype_) <<
"\" Name=\"" << names[j] <<
"\" format=\"appended\"";
139 out <<
" TimeStep=\"" << *timestep <<
"\"";
149template <
class GV,
class DC>
150void RectilinearGridWriter<GV,DC>
156 Vtk::mapDataTypes<std::is_floating_point, std::is_integral>(datatype_, headertype_,
157 [&](
auto f,
auto h) {
158 using F =
typename decltype(f)::type;
159 using H =
typename decltype(h)::type;
160 auto coordinates = dataCollector_->template coordinates<F>();
161 blocks.
push_back(this->
template writeValuesAppended<H>(out, coordinates[0]));
162 blocks.
push_back(this->
template writeValuesAppended<H>(out, coordinates[1]));
163 blocks.
push_back(this->
template writeValuesAppended<H>(out, coordinates[2]));
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::string join(InputIter first, InputIter end, std::string sep=" ")
Join all entries in the range [first,end) into a single string separated by sep
Definition string.hh:111