#ifdef DEAL_II_WITH_ZLIB
if (flags.compression_level != DataOutBase::CompressionLevel::plain_text)
{
- cells.push_back(start);
- if (dim >= 1)
+ switch (dim)
{
- cells.push_back(start + d1);
- if (dim >= 2)
- {
- cells.push_back(start + d2 + d1);
- cells.push_back(start + d2);
- if (dim >= 3)
- {
- cells.push_back(start + d3);
- cells.push_back(start + d3 + d1);
- cells.push_back(start + d3 + d2 + d1);
- cells.push_back(start + d3 + d2);
- }
- }
+ case 0:
+ cells.push_back(start);
+ break;
+
+ case 1:
+ cells.push_back(start);
+ cells.push_back(start + d1);
+ break;
+
+ case 2:
+ cells.push_back(start);
+ cells.push_back(start + d1);
+ cells.push_back(start + d2 + d1);
+ cells.push_back(start + d2);
+ break;
+
+ case 3:
+ cells.push_back(start);
+ cells.push_back(start + d1);
+ cells.push_back(start + d2 + d1);
+ cells.push_back(start + d2);
+ cells.push_back(start + d3);
+ cells.push_back(start + d3 + d1);
+ cells.push_back(start + d3 + d2 + d1);
+ cells.push_back(start + d3 + d2);
+ break;
+
+ default:
+ Assert(false, ExcNotImplemented());
}
}
else
#endif
{
- stream << start;
- if (dim >= 1)
+ switch (dim)
{
- stream << '\t' << start + d1;
- if (dim >= 2)
- {
- stream << '\t' << start + d2 + d1 << '\t' << start + d2;
- if (dim >= 3)
- {
- stream << '\t' << start + d3 << '\t' << start + d3 + d1
- << '\t' << start + d3 + d2 + d1 << '\t'
- << start + d3 + d2;
- }
- }
+ case 0:
+ stream << start;
+ break;
+
+ case 1:
+ stream << start << '\t' << start + d1;
+ break;
+
+ case 2:
+ stream << start << '\t' << start + d1 << '\t' << start + d2 + d1
+ << '\t' << start + d2;
+ break;
+
+ case 3:
+ stream << start << '\t' << start + d1 << '\t' << start + d2 + d1
+ << '\t' << start + d2 << '\t' << start + d3 << '\t'
+ << start + d3 + d1 << '\t' << start + d3 + d2 + d1 << '\t'
+ << start + d3 + d2;
+ break;
+
+ default:
+ Assert(false, ExcNotImplemented());
}
stream << '\n';
}
if (flags.write_higher_order_cells)
write_high_order_cells(patches, vtu_out, /* legacy_format = */ false);
else
- write_cells(patches, vtu_out);
+ {
+ Assert(dim <= 3, ExcNotImplemented());
+ unsigned int count = 0;
+ unsigned int first_vertex_of_patch = 0;
+ for (const auto &patch : patches)
+ {
+ // special treatment of simplices since they are not subdivided
+ if (patch.reference_cell != ReferenceCells::get_hypercube<dim>())
+ {
+ vtu_out.write_cell_single(count++,
+ first_vertex_of_patch,
+ patch.data.n_cols(),
+ patch.reference_cell);
+ first_vertex_of_patch += patch.data.n_cols();
+ }
+ else
+ {
+ const unsigned int n_subdivisions = patch.n_subdivisions;
+ const unsigned int n = n_subdivisions + 1;
+ // Length of loops in all dimensions
+ const unsigned int n1 = (dim > 0) ? n_subdivisions : 1;
+ const unsigned int n2 = (dim > 1) ? n_subdivisions : 1;
+ const unsigned int n3 = (dim > 2) ? n_subdivisions : 1;
+ // Offsets of outer loops
+ const unsigned int d1 = 1;
+ const unsigned int d2 = n;
+ const unsigned int d3 = n * n;
+ for (unsigned int i3 = 0; i3 < n3; ++i3)
+ for (unsigned int i2 = 0; i2 < n2; ++i2)
+ for (unsigned int i1 = 0; i1 < n1; ++i1)
+ {
+ const unsigned int offset =
+ first_vertex_of_patch + i3 * d3 + i2 * d2 + i1 * d1;
+ // First write line in x direction
+ vtu_out.template write_cell<dim>(
+ count++, offset, d1, d2, d3);
+ }
+ // finally update the number of the first vertex of this patch
+ first_vertex_of_patch +=
+ Utilities::fixed_power<dim>(n_subdivisions + 1);
+ }
+ }
+
+ vtu_out.flush_cells();
+ }
out << " </DataArray>\n";
// XML VTU format uses offsets; this is different than the VTK format, which