3564 const std::vector<std::string> &data_names,
3566 std::tuple<
unsigned int,
3575#ifndef DEAL_II_WITH_MPI
3585 if (patches.empty())
3589 const unsigned int n_data_sets = data_names.size();
3593 out <<
"# This file was generated by the deal.II library." <<
'\n'
3597 <<
"# For a description of the GNUPLOT format see the GNUPLOT manual."
3604 for (
unsigned int spacedim_n = 0; spacedim_n < spacedim; ++spacedim_n)
3609 for (
const auto &data_name : data_names)
3610 out <<
'<' << data_name <<
"> ";
3616 for (
const auto &patch : patches)
3619 const unsigned int n_points_per_direction = n_subdivisions + 1;
3621 Assert((patch.
data.n_rows() == n_data_sets &&
3623 (patch.
data.n_rows() == n_data_sets + spacedim &&
3626 (n_data_sets + spacedim) :
3628 patch.
data.n_rows()));
3630 auto output_point_data =
3631 [&out, &patch, n_data_sets](
const unsigned int point_index)
mutable {
3632 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
3633 out << patch.data(data_set, point_index) <<
' ';
3642 Assert(patch.data.n_cols() == 1,
3644 n_subdivisions + 1));
3648 out << get_equispaced_location(patch, {}, n_subdivisions)
3650 output_point_data(0);
3660 Assert(patch.data.n_cols() ==
3661 Utilities::fixed_power<dim>(n_points_per_direction),
3663 n_subdivisions + 1));
3665 for (
unsigned int i1 = 0; i1 < n_points_per_direction; ++i1)
3668 out << get_equispaced_location(patch, {i1}, n_subdivisions)
3671 output_point_data(i1);
3684 Assert(patch.data.n_cols() == Utilities::fixed_power<dim>(
3685 n_points_per_direction),
3687 n_subdivisions + 1));
3689 for (
unsigned int i2 = 0; i2 < n_points_per_direction; ++i2)
3691 for (
unsigned int i1 = 0; i1 < n_points_per_direction;
3695 out << get_equispaced_location(patch,
3700 output_point_data(i1 + i2 * n_points_per_direction);
3725 out << get_node_location(patch, 0) <<
' ';
3726 output_point_data(0);
3729 out << get_node_location(patch, 1) <<
' ';
3730 output_point_data(1);
3734 out << get_node_location(patch, 2) <<
' ';
3735 output_point_data(2);
3738 out << get_node_location(patch, 2) <<
' ';
3739 output_point_data(2);
3759 Assert(patch.data.n_cols() == Utilities::fixed_power<dim>(
3760 n_points_per_direction),
3762 n_subdivisions + 1));
3767 for (
unsigned int i3 = 0; i3 < n_points_per_direction; ++i3)
3768 for (
unsigned int i2 = 0; i2 < n_points_per_direction;
3770 for (
unsigned int i1 = 0; i1 < n_points_per_direction;
3775 get_equispaced_location(patch,
3779 if (i1 < n_subdivisions)
3782 out << this_point <<
' ';
3783 output_point_data(i1 +
3784 i2 * n_points_per_direction +
3785 i3 * n_points_per_direction *
3786 n_points_per_direction);
3790 out << get_equispaced_location(patch,
3795 output_point_data((i1 + 1) +
3796 i2 * n_points_per_direction +
3797 i3 * n_points_per_direction *
3798 n_points_per_direction);
3802 out <<
'\n' <<
'\n';
3806 if (i2 < n_subdivisions)
3809 out << this_point <<
' ';
3810 output_point_data(i1 +
3811 i2 * n_points_per_direction +
3812 i3 * n_points_per_direction *
3813 n_points_per_direction);
3817 out << get_equispaced_location(patch,
3823 i1 + (i2 + 1) * n_points_per_direction +
3824 i3 * n_points_per_direction *
3825 n_points_per_direction);
3829 out <<
'\n' <<
'\n';
3833 if (i3 < n_subdivisions)
3836 out << this_point <<
' ';
3837 output_point_data(i1 +
3838 i2 * n_points_per_direction +
3839 i3 * n_points_per_direction *
3840 n_points_per_direction);
3844 out << get_equispaced_location(patch,
3850 i1 + i2 * n_points_per_direction +
3851 (i3 + 1) * n_points_per_direction *
3852 n_points_per_direction);
3855 out <<
'\n' <<
'\n';
3864 for (
const unsigned int v : {0, 1, 2, 0, 3, 2})
3866 out << get_node_location(patch, v) <<
' ';
3867 output_point_data(v);
3872 for (
const unsigned int v : {3, 1})
3874 out << get_node_location(patch, v) <<
' ';
3875 output_point_data(v);
3885 for (
const unsigned int v : {0, 1, 3, 2, 0, 4, 1})
3887 out << get_node_location(patch, v) <<
' ';
3888 output_point_data(v);
3893 for (
const unsigned int v : {2, 4, 3})
3895 out << get_node_location(patch, v) <<
' ';
3896 output_point_data(v);
3910 for (
const unsigned int v : {0, 1, 2, 0, 3, 4, 5, 3})
3912 out << get_node_location(patch, v) <<
' ';
3913 output_point_data(v);
3918 for (
const unsigned int v : {1, 4})
3920 out << get_node_location(patch, v) <<
' ';
3921 output_point_data(v);
3926 for (
const unsigned int v : {2, 5})
3928 out << get_node_location(patch, v) <<
' ';
3929 output_point_data(v);
4336 const std::vector<std::string> & ,
4338 std::tuple<
unsigned int,
4347#ifndef DEAL_II_WITH_MPI
4356 if (patches.empty())
4366 std::multiset<EpsCell2d> cells;
4370 float min_color_value = std::numeric_limits<float>::max();
4371 float max_color_value = std::numeric_limits<float>::min();
4375 double heights[4] = {0, 0, 0, 0};
4379 for (
const auto &patch : patches)
4382 const unsigned int n = n_subdivisions + 1;
4383 const unsigned int d1 = 1;
4384 const unsigned int d2 = n;
4386 for (
unsigned int i2 = 0; i2 < n_subdivisions; ++i2)
4387 for (
unsigned int i1 = 0; i1 < n_subdivisions; ++i1)
4391 get_equispaced_location(patch, {i1, i2}, n_subdivisions);
4393 get_equispaced_location(patch, {i1 + 1, i2}, n_subdivisions);
4395 get_equispaced_location(patch, {i1, i2 + 1}, n_subdivisions);
4396 points[3] = get_equispaced_location(patch,
4404 patch.
data.n_rows() == 0,
4407 patch.
data.n_rows()));
4409 patch.
data.n_rows() != 0 ?
4413 heights[1] = patch.
data.n_rows() != 0 ?
4415 (i1 + 1) * d1 + i2 * d2) *
4418 heights[2] = patch.
data.n_rows() != 0 ?
4420 i1 * d1 + (i2 + 1) * d2) *
4423 heights[3] = patch.
data.n_rows() != 0 ?
4425 (i1 + 1) * d1 + (i2 + 1) * d2) *
4432 for (
unsigned int i = 0; i < 4; ++i)
4433 heights[i] = points[i][2];
4458 for (
unsigned int vertex = 0; vertex < 4; ++vertex)
4460 const double x = points[vertex][0], y = points[vertex][1],
4461 z = -heights[vertex];
4463 eps_cell.vertices[vertex][0] = -cz * x + sz * y;
4464 eps_cell.vertices[vertex][1] =
4465 -cx * sz * x - cx * cz * y - sx * z;
4489 (points[0] + points[1] + points[2] + points[3]) / 4;
4490 const double center_height =
4491 -(heights[0] + heights[1] + heights[2] + heights[3]) / 4;
4494 eps_cell.depth = -sx * sz * center_point[0] -
4495 sx * cz * center_point[1] + cx * center_height;
4500 patch.
data.n_rows() == 0,
4503 patch.
data.n_rows()));
4504 const double color_values[4] = {
4505 patch.
data.n_rows() != 0 ?
4509 patch.
data.n_rows() != 0 ?
4513 patch.
data.n_rows() != 0 ?
4517 patch.
data.n_rows() != 0 ?
4519 (i1 + 1) * d1 + (i2 + 1) * d2) :
4523 eps_cell.color_value = (color_values[0] + color_values[1] +
4524 color_values[3] + color_values[2]) /
4529 std::min(min_color_value, eps_cell.color_value);
4531 std::max(max_color_value, eps_cell.color_value);
4535 cells.insert(eps_cell);
4541 double x_min = cells.begin()->vertices[0][0];
4542 double x_max = x_min;
4543 double y_min = cells.begin()->vertices[0][1];
4544 double y_max = y_min;
4546 for (
const auto &cell : cells)
4547 for (
const auto &vertex : cell.vertices)
4549 x_min =
std::min(x_min, vertex[0]);
4550 x_max =
std::max(x_max, vertex[0]);
4551 y_min =
std::min(y_min, vertex[1]);
4552 y_max =
std::max(y_max, vertex[1]);
4557 const double scale =
4561 const Point<2> offset(x_min, y_min);
4566 out <<
"%!PS-Adobe-2.0 EPSF-1.2" <<
'\n'
4567 <<
"%%Title: deal.II Output" <<
'\n'
4568 <<
"%%Creator: the deal.II library" <<
'\n'
4571 <<
"%%BoundingBox: "
4575 <<
static_cast<unsigned int>((x_max - x_min) * scale + 0.5) <<
' '
4576 <<
static_cast<unsigned int>((y_max - y_min) * scale + 0.5) <<
'\n';
4585 out <<
"/m {moveto} bind def" <<
'\n'
4586 <<
"/l {lineto} bind def" <<
'\n'
4587 <<
"/s {setrgbcolor} bind def" <<
'\n'
4588 <<
"/sg {setgray} bind def" <<
'\n'
4589 <<
"/lx {lineto closepath stroke} bind def" <<
'\n'
4590 <<
"/lf {lineto closepath fill} bind def" <<
'\n';
4592 out <<
"%%EndProlog" <<
'\n' <<
'\n';
4594 out << flags.
line_width <<
" setlinewidth" <<
'\n';
4602 if (max_color_value == min_color_value)
4603 max_color_value = min_color_value + 1;
4607 for (
const auto &cell : cells)
4620 out << rgb_values.
red <<
" sg ";
4622 out << rgb_values.
red <<
' ' << rgb_values.
green <<
' '
4623 << rgb_values.
blue <<
" s ";
4628 out << (cell.vertices[0] - offset) * scale <<
" m "
4629 << (cell.vertices[1] - offset) * scale <<
" l "
4630 << (cell.vertices[3] - offset) * scale <<
" l "
4631 << (cell.vertices[2] - offset) * scale <<
" lf" <<
'\n';
4636 << (cell.vertices[0] - offset) * scale <<
" m "
4637 << (cell.vertices[1] - offset) * scale <<
" l "
4638 << (cell.vertices[3] - offset) * scale <<
" l "
4639 << (cell.vertices[2] - offset) * scale <<
" lx" <<
'\n';
4641 out <<
"showpage" <<
'\n';
4940 const std::vector<std::string> &data_names,
4942 std::tuple<
unsigned int,
4946 &nonscalar_data_ranges,
4952#ifndef DEAL_II_WITH_MPI
4961 if (patches.empty())
4965 VtkStream vtk_out(out, flags);
4967 const unsigned int n_data_sets = data_names.size();
4969 if (patches[0].points_are_available)
4981 out <<
"# vtk DataFile Version 3.0" <<
'\n'
4982 <<
"#This file was generated by the deal.II library";
4990 out <<
'\n' <<
"ASCII" <<
'\n';
4992 out <<
"DATASET UNSTRUCTURED_GRID\n" <<
'\n';
4999 const unsigned int n_metadata =
5000 ((flags.
cycle != std::numeric_limits<unsigned int>::min() ? 1 : 0) +
5001 (flags.
time != std::numeric_limits<double>::min() ? 1 : 0));
5004 out <<
"FIELD FieldData " << n_metadata <<
'\n';
5006 if (flags.
cycle != std::numeric_limits<unsigned int>::min())
5008 out <<
"CYCLE 1 1 int\n" << flags.
cycle <<
'\n';
5010 if (flags.
time != std::numeric_limits<double>::min())
5012 out <<
"TIME 1 1 double\n" << flags.
time <<
'\n';
5018 unsigned int n_nodes;
5019 unsigned int n_cells;
5020 unsigned int n_points_and_n_cells;
5021 std::tie(n_nodes, n_cells, n_points_and_n_cells) =
5037 [&patches]() {
return create_global_data_table(patches); });
5043 out <<
"POINTS " << n_nodes <<
" double" <<
'\n';
5048 out <<
"CELLS " << n_cells <<
' ' << n_points_and_n_cells <<
'\n';
5056 out <<
"CELL_TYPES " << n_cells <<
'\n';
5060 for (
const auto &patch : patches)
5062 const auto vtk_cell_id =
5065 for (
unsigned int i = 0; i < vtk_cell_id[1]; ++i)
5066 out <<
' ' << vtk_cell_id[0];
5075 std::move(*create_global_data_table_task.
return_value());
5080 out <<
"POINT_DATA " << n_nodes <<
'\n';
5084 std::vector<bool> data_set_written(n_data_sets,
false);
5085 for (
const auto &nonscalar_data_range : nonscalar_data_ranges)
5090 "The VTK writer does not currently support outputting "
5091 "tensor data. Use the VTU writer instead."));
5094 std::get<0>(nonscalar_data_range),
5096 std::get<0>(nonscalar_data_range)));
5097 AssertThrow(std::get<1>(nonscalar_data_range) < n_data_sets,
5101 AssertThrow(std::get<1>(nonscalar_data_range) + 1 -
5102 std::get<0>(nonscalar_data_range) <=
5105 "Can't declare a vector with more than 3 components "
5109 for (
unsigned int i = std::get<0>(nonscalar_data_range);
5110 i <= std::get<1>(nonscalar_data_range);
5112 data_set_written[i] =
true;
5118 if (!std::get<2>(nonscalar_data_range).empty())
5119 out << std::get<2>(nonscalar_data_range);
5122 for (
unsigned int i = std::get<0>(nonscalar_data_range);
5123 i < std::get<1>(nonscalar_data_range);
5125 out << data_names[i] <<
"__";
5126 out << data_names[std::get<1>(nonscalar_data_range)];
5129 out <<
" double" <<
'\n';
5132 for (
unsigned int n = 0; n < n_nodes; ++n)
5134 switch (std::get<1>(nonscalar_data_range) -
5135 std::get<0>(nonscalar_data_range))
5138 out << data_vectors(std::get<0>(nonscalar_data_range), n)
5143 out << data_vectors(std::get<0>(nonscalar_data_range), n)
5145 << data_vectors(std::get<0>(nonscalar_data_range) + 1, n)
5149 out << data_vectors(std::get<0>(nonscalar_data_range), n)
5151 << data_vectors(std::get<0>(nonscalar_data_range) + 1, n)
5153 << data_vectors(std::get<0>(nonscalar_data_range) + 2, n)
5166 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
5167 if (data_set_written[data_set] ==
false)
5169 out <<
"SCALARS " << data_names[data_set] <<
" double 1" <<
'\n'
5170 <<
"LOOKUP_TABLE default" <<
'\n';
5171 std::copy(data_vectors[data_set].begin(),
5172 data_vectors[data_set].end(),
5173 std::ostream_iterator<double>(out,
" "));
5258 const std::vector<std::string> &data_names,
5260 std::tuple<
unsigned int,
5264 &nonscalar_data_ranges,
5278 unit.second.find(
'\"') == std::string::npos,
5280 "A physical unit you provided, <" + unit.second +
5281 ">, contained a quotation mark character. This is not allowed."));
5284#ifndef DEAL_II_WITH_MPI
5293 if (patches.empty())
5298 out <<
"<Piece NumberOfPoints=\"0\" NumberOfCells=\"0\" >\n"
5300 <<
"<DataArray type=\"UInt8\" Name=\"types\"></DataArray>\n"
5302 <<
" <PointData Scalars=\"scalars\">\n";
5303 std::vector<bool> data_set_written(data_names.size(),
false);
5304 for (
const auto &nonscalar_data_range : nonscalar_data_ranges)
5307 for (
unsigned int i = std::get<0>(nonscalar_data_range);
5308 i <= std::get<1>(nonscalar_data_range);
5310 data_set_written[i] =
true;
5314 out <<
" <DataArray type=\"Float32\" Name=\"";
5316 if (!std::get<2>(nonscalar_data_range).empty())
5317 out << std::get<2>(nonscalar_data_range);
5320 for (
unsigned int i = std::get<0>(nonscalar_data_range);
5321 i < std::get<1>(nonscalar_data_range);
5323 out << data_names[i] <<
"__";
5324 out << data_names[std::get<1>(nonscalar_data_range)];
5327 out <<
"\" NumberOfComponents=\"3\"></DataArray>\n";
5330 for (
unsigned int data_set = 0; data_set < data_names.size();
5332 if (data_set_written[data_set] ==
false)
5334 out <<
" <DataArray type=\"Float32\" Name=\""
5335 << data_names[data_set] <<
"\"></DataArray>\n";
5338 out <<
" </PointData>\n";
5339 out <<
"</Piece>\n";
5353 const unsigned int n_metadata =
5354 ((flags.
cycle != std::numeric_limits<unsigned int>::min() ? 1 : 0) +
5355 (flags.
time != std::numeric_limits<double>::min() ? 1 : 0));
5357 out <<
"<FieldData>\n";
5359 if (flags.
cycle != std::numeric_limits<unsigned int>::min())
5362 <<
"<DataArray type=\"Float32\" Name=\"CYCLE\" NumberOfTuples=\"1\" format=\"ascii\">"
5363 << flags.
cycle <<
"</DataArray>\n";
5365 if (flags.
time != std::numeric_limits<double>::min())
5368 <<
"<DataArray type=\"Float32\" Name=\"TIME\" NumberOfTuples=\"1\" format=\"ascii\">"
5369 << flags.
time <<
"</DataArray>\n";
5373 out <<
"</FieldData>\n";
5377 const unsigned int n_data_sets = data_names.size();
5380 if (patches[0].points_are_available)
5389 const char *ascii_or_binary =
5390 (deal_ii_with_zlib &&
5397 unsigned int n_nodes;
5398 unsigned int n_cells;
5399 std::tie(n_nodes, n_cells, std::ignore) =
5407 const auto stringize_vertex_information = [&patches,
5411 ascii_or_binary]() {
5412 std::ostringstream o;
5414 o <<
" <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\""
5415 << ascii_or_binary <<
"\">\n";
5416 const std::vector<Point<spacedim>> node_positions =
5421 std::vector<float> node_coordinates_3d;
5422 node_coordinates_3d.reserve(node_positions.size() * 3);
5423 for (
const auto &node_position : node_positions)
5425 for (
unsigned int d = 0; d < 3; ++d)
5427 node_coordinates_3d.emplace_back(node_position[d]);
5429 node_coordinates_3d.emplace_back(0.0f);
5431 o << vtu_stringize_array(node_coordinates_3d,
5435 o <<
" </DataArray>\n";
5436 o <<
" </Points>\n\n";
5445 const auto stringize_cell_to_vertex_information = [&patches,
5449 out.precision()]() {
5450 std::ostringstream o;
5453 o <<
" <DataArray type=\"Int32\" Name=\"connectivity\" format=\""
5454 << ascii_or_binary <<
"\">\n";
5456 std::vector<int32_t> cells;
5459 unsigned int first_vertex_of_patch = 0;
5461 for (
const auto &patch : patches)
5473 const unsigned int n_points = patch.
data.n_cols();
5474 Assert((dim == 2 && n_points == 6) ||
5475 (dim == 3 && n_points == 10),
5478 if (deal_ii_with_zlib &&
5482 for (
unsigned int i = 0; i < n_points; ++i)
5483 cells.push_back(first_vertex_of_patch + i);
5487 for (
unsigned int i = 0; i < n_points; ++i)
5488 o <<
'\t' << first_vertex_of_patch + i;
5492 first_vertex_of_patch += n_points;
5497 else if (patch.
reference_cell != ReferenceCells::get_hypercube<dim>())
5501 const unsigned int n_points = patch.
data.n_cols();
5503 if (deal_ii_with_zlib &&
5507 for (
unsigned int i = 0; i < n_points; ++i)
5509 first_vertex_of_patch +
5514 for (
unsigned int i = 0; i < n_points; ++i)
5516 << (first_vertex_of_patch +
5521 first_vertex_of_patch += n_points;
5526 const unsigned int n_points_per_direction = n_subdivisions + 1;
5528 std::vector<unsigned> local_vertex_order;
5532 const auto flush_current_cell = [&flags,
5535 first_vertex_of_patch,
5536 &local_vertex_order]() {
5537 if (deal_ii_with_zlib &&
5541 for (
const auto &c : local_vertex_order)
5542 cells.push_back(first_vertex_of_patch + c);
5546 for (
const auto &c : local_vertex_order)
5547 o <<
'\t' << first_vertex_of_patch + c;
5551 local_vertex_order.clear();
5556 local_vertex_order.reserve(Utilities::fixed_power<dim>(2));
5562 local_vertex_order.emplace_back(0);
5563 flush_current_cell();
5569 for (
unsigned int i1 = 0; i1 < n_subdivisions; ++i1)
5571 const unsigned int starting_offset = i1;
5572 local_vertex_order.emplace_back(starting_offset);
5573 local_vertex_order.emplace_back(starting_offset +
5575 flush_current_cell();
5582 for (
unsigned int i2 = 0; i2 < n_subdivisions; ++i2)
5583 for (
unsigned int i1 = 0; i1 < n_subdivisions; ++i1)
5585 const unsigned int starting_offset =
5586 i2 * n_points_per_direction + i1;
5587 local_vertex_order.emplace_back(
5589 local_vertex_order.emplace_back(
5590 starting_offset + 1);
5591 local_vertex_order.emplace_back(
5592 starting_offset + n_points_per_direction + 1);
5593 local_vertex_order.emplace_back(
5594 starting_offset + n_points_per_direction);
5595 flush_current_cell();
5602 for (
unsigned int i3 = 0; i3 < n_subdivisions; ++i3)
5603 for (
unsigned int i2 = 0; i2 < n_subdivisions; ++i2)
5604 for (
unsigned int i1 = 0; i1 < n_subdivisions;
5607 const unsigned int starting_offset =
5608 i3 * n_points_per_direction *
5609 n_points_per_direction +
5610 i2 * n_points_per_direction + i1;
5611 local_vertex_order.emplace_back(
5613 local_vertex_order.emplace_back(
5614 starting_offset + 1);
5615 local_vertex_order.emplace_back(
5616 starting_offset + n_points_per_direction +
5618 local_vertex_order.emplace_back(
5619 starting_offset + n_points_per_direction);
5620 local_vertex_order.emplace_back(
5621 starting_offset + n_points_per_direction *
5622 n_points_per_direction);
5623 local_vertex_order.emplace_back(
5625 n_points_per_direction *
5626 n_points_per_direction +
5628 local_vertex_order.emplace_back(
5630 n_points_per_direction *
5631 n_points_per_direction +
5632 n_points_per_direction + 1);
5633 local_vertex_order.emplace_back(
5635 n_points_per_direction *
5636 n_points_per_direction +
5637 n_points_per_direction);
5638 flush_current_cell();
5649 local_vertex_order.resize(
5650 Utilities::fixed_power<dim>(n_points_per_direction));
5658 "Point-like cells should not be possible "
5659 "when writing higher-order cells."));
5664 for (
unsigned int i1 = 0; i1 < n_subdivisions + 1;
5667 const unsigned int local_index = i1;
5668 const unsigned int connectivity_index =
5670 .template vtk_lexicographic_to_node_index<1>(
5674 local_vertex_order[connectivity_index] =
5676 flush_current_cell();
5683 for (
unsigned int i2 = 0; i2 < n_subdivisions + 1;
5685 for (
unsigned int i1 = 0; i1 < n_subdivisions + 1;
5688 const unsigned int local_index =
5689 i2 * n_points_per_direction + i1;
5690 const unsigned int connectivity_index =
5692 .template vtk_lexicographic_to_node_index<
5694 {{n_subdivisions, n_subdivisions}},
5696 local_vertex_order[connectivity_index] =
5699 flush_current_cell();
5705 for (
unsigned int i3 = 0; i3 < n_subdivisions + 1;
5707 for (
unsigned int i2 = 0; i2 < n_subdivisions + 1;
5709 for (
unsigned int i1 = 0; i1 < n_subdivisions + 1;
5712 const unsigned int local_index =
5713 i3 * n_points_per_direction *
5714 n_points_per_direction +
5715 i2 * n_points_per_direction + i1;
5716 const unsigned int connectivity_index =
5718 .template vtk_lexicographic_to_node_index<
5724 local_vertex_order[connectivity_index] =
5728 flush_current_cell();
5738 first_vertex_of_patch +=
5747 o << vtu_stringize_array(cells,
5752 o <<
" </DataArray>\n";
5772 const auto stringize_cell_offset_and_type_information =
5777 output_precision = out.precision()]() {
5778 std::ostringstream o;
5780 o <<
" <DataArray type=\"Int32\" Name=\"offsets\" format=\""
5781 << ascii_or_binary <<
"\">\n";
5783 std::vector<int32_t> offsets;
5784 offsets.reserve(n_cells);
5788 std::vector<unsigned int> cell_types;
5789 cell_types.reserve(n_cells);
5791 unsigned int first_vertex_of_patch = 0;
5793 for (
const auto &patch : patches)
5795 const auto vtk_cell_id =
5798 for (
unsigned int i = 0; i < vtk_cell_id[1]; ++i)
5800 cell_types.push_back(vtk_cell_id[0]);
5801 first_vertex_of_patch += vtk_cell_id[2];
5802 offsets.push_back(first_vertex_of_patch);
5806 o << vtu_stringize_array(offsets,
5810 o <<
" </DataArray>\n";
5812 o <<
" <DataArray type=\"UInt8\" Name=\"types\" format=\""
5813 << ascii_or_binary <<
"\">\n";
5815 if (deal_ii_with_zlib &&
5818 std::vector<uint8_t> cell_types_uint8_t(cell_types.size());
5819 for (
unsigned int i = 0; i < cell_types.size(); ++i)
5820 cell_types_uint8_t[i] =
static_cast<std::uint8_t
>(cell_types[i]);
5822 o << vtu_stringize_array(cell_types_uint8_t,
5828 o << vtu_stringize_array(cell_types,
5834 o <<
" </DataArray>\n";
5844 const auto stringize_nonscalar_data_range =
5850 output_precision = out.precision()](
const Table<2, float> &data_vectors,
5851 const auto &range) {
5852 std::ostringstream o;
5854 const auto first_component = std::get<0>(range);
5855 const auto last_component = std::get<1>(range);
5856 const auto &name = std::get<2>(range);
5857 const bool is_tensor =
5858 (std::get<3>(range) ==
5860 const unsigned int n_components = (is_tensor ? 9 : 3);
5867 AssertThrow((last_component + 1 - first_component <= 9),
5869 "Can't declare a tensor with more than 9 components "
5870 "in VTK/VTU format."));
5874 AssertThrow((last_component + 1 - first_component <= 3),
5876 "Can't declare a vector with more than 3 components "
5877 "in VTK/VTU format."));
5882 o <<
" <DataArray type=\"Float32\" Name=\"";
5888 for (
unsigned int i = first_component; i < last_component; ++i)
5889 o << data_names[i] <<
"__";
5890 o << data_names[last_component];
5893 o <<
"\" NumberOfComponents=\"" << n_components <<
"\" format=\""
5894 << ascii_or_binary <<
"\"";
5913 std::vector<float>
data;
5914 data.reserve(n_nodes * n_components);
5916 for (
unsigned int n = 0; n < n_nodes; ++n)
5920 switch (last_component - first_component)
5923 data.push_back(data_vectors(first_component, n));
5929 data.push_back(data_vectors(first_component, n));
5930 data.push_back(data_vectors(first_component + 1, n));
5935 data.push_back(data_vectors(first_component, n));
5936 data.push_back(data_vectors(first_component + 1, n));
5937 data.push_back(data_vectors(first_component + 2, n));
5950 const unsigned int size = last_component - first_component + 1;
5954 vtk_data[0][0] = data_vectors(first_component, n);
5959 for (
unsigned int c = 0; c <
size; ++c)
5963 vtk_data[ind[0]][ind[1]] =
5964 data_vectors(first_component + c, n);
5970 for (
unsigned int c = 0; c <
size; ++c)
5974 vtk_data[ind[0]][ind[1]] =
5975 data_vectors(first_component + c, n);
5986 for (
unsigned int i = 0; i < 3; ++i)
5987 for (
unsigned int j = 0; j < 3; ++j)
5988 data.push_back(vtk_data[i][j]);
5992 o << vtu_stringize_array(
data,
5996 o <<
" </DataArray>\n";
6001 const auto stringize_scalar_data_set =
6005 output_precision = out.precision()](
const Table<2, float> &data_vectors,
6006 const unsigned int data_set) {
6007 std::ostringstream o;
6009 o <<
" <DataArray type=\"Float32\" Name=\"" << data_names[data_set]
6010 <<
"\" format=\"" << ascii_or_binary <<
"\"";
6014 o <<
" units=\"" << flags.
physical_units.at(data_names[data_set])
6019 const std::vector<float>
data(data_vectors[data_set].begin(),
6020 data_vectors[data_set].end());
6021 o << vtu_stringize_array(
data,
6025 o <<
" </DataArray>\n";
6044 return create_global_data_table<dim, spacedim, float>(patches);
6058 std::move(*create_global_data_table_task.
return_value());
6064 std::vector<bool> data_set_handled(n_data_sets,
false);
6065 for (
const auto &range : nonscalar_data_ranges)
6068 const auto first_component = std::get<0>(range);
6069 const auto last_component = std::get<1>(range);
6070 for (
unsigned int i = first_component; i <= last_component; ++i)
6071 data_set_handled[i] =
true;
6074 return stringize_nonscalar_data_range(data_vectors, range);
6079 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
6080 if (data_set_handled[data_set] ==
false)
6083 return stringize_scalar_data_set(data_vectors, data_set);
6089 out <<
"<Piece NumberOfPoints=\"" << n_nodes <<
"\" NumberOfCells=\""
6090 << n_cells <<
"\" >\n";
6091 for (
const auto &s : mesh_tasks.return_values())
6093 out <<
" <PointData Scalars=\"scalars\">\n";
6096 out <<
" </PointData>\n";
6097 out <<
" </Piece>\n";