3563 const std::vector<std::string> &data_names,
3565 std::tuple<
unsigned int,
3574#ifndef DEAL_II_WITH_MPI
3584 if (patches.empty())
3588 const unsigned int n_data_sets = data_names.size();
3592 out <<
"# This file was generated by the deal.II library." <<
'\n'
3596 <<
"# For a description of the GNUPLOT format see the GNUPLOT manual."
3603 for (
unsigned int spacedim_n = 0; spacedim_n < spacedim; ++spacedim_n)
3608 for (
const auto &data_name : data_names)
3609 out <<
'<' << data_name <<
"> ";
3615 for (
const auto &patch : patches)
3618 const unsigned int n_points_per_direction = n_subdivisions + 1;
3620 Assert((patch.
data.n_rows() == n_data_sets &&
3622 (patch.
data.n_rows() == n_data_sets + spacedim &&
3625 (n_data_sets + spacedim) :
3627 patch.
data.n_rows()));
3629 auto output_point_data =
3630 [&out, &patch, n_data_sets](
const unsigned int point_index)
mutable {
3631 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
3632 out << patch.data(data_set, point_index) <<
' ';
3641 Assert(patch.data.n_cols() == 1,
3643 n_subdivisions + 1));
3647 out << get_equispaced_location(patch, {}, n_subdivisions)
3649 output_point_data(0);
3659 Assert(patch.data.n_cols() ==
3660 Utilities::fixed_power<dim>(n_points_per_direction),
3662 n_subdivisions + 1));
3664 for (
unsigned int i1 = 0; i1 < n_points_per_direction; ++i1)
3667 out << get_equispaced_location(patch, {i1}, n_subdivisions)
3670 output_point_data(i1);
3683 Assert(patch.data.n_cols() == Utilities::fixed_power<dim>(
3684 n_points_per_direction),
3686 n_subdivisions + 1));
3688 for (
unsigned int i2 = 0; i2 < n_points_per_direction; ++i2)
3690 for (
unsigned int i1 = 0; i1 < n_points_per_direction;
3694 out << get_equispaced_location(patch,
3699 output_point_data(i1 + i2 * n_points_per_direction);
3724 out << get_node_location(patch, 0) <<
' ';
3725 output_point_data(0);
3728 out << get_node_location(patch, 1) <<
' ';
3729 output_point_data(1);
3733 out << get_node_location(patch, 2) <<
' ';
3734 output_point_data(2);
3737 out << get_node_location(patch, 2) <<
' ';
3738 output_point_data(2);
3758 Assert(patch.data.n_cols() == Utilities::fixed_power<dim>(
3759 n_points_per_direction),
3761 n_subdivisions + 1));
3766 for (
unsigned int i3 = 0; i3 < n_points_per_direction; ++i3)
3767 for (
unsigned int i2 = 0; i2 < n_points_per_direction;
3769 for (
unsigned int i1 = 0; i1 < n_points_per_direction;
3774 get_equispaced_location(patch,
3778 if (i1 < n_subdivisions)
3781 out << this_point <<
' ';
3782 output_point_data(i1 +
3783 i2 * n_points_per_direction +
3784 i3 * n_points_per_direction *
3785 n_points_per_direction);
3789 out << get_equispaced_location(patch,
3794 output_point_data((i1 + 1) +
3795 i2 * n_points_per_direction +
3796 i3 * n_points_per_direction *
3797 n_points_per_direction);
3801 out <<
'\n' <<
'\n';
3805 if (i2 < n_subdivisions)
3808 out << this_point <<
' ';
3809 output_point_data(i1 +
3810 i2 * n_points_per_direction +
3811 i3 * n_points_per_direction *
3812 n_points_per_direction);
3816 out << get_equispaced_location(patch,
3822 i1 + (i2 + 1) * n_points_per_direction +
3823 i3 * n_points_per_direction *
3824 n_points_per_direction);
3828 out <<
'\n' <<
'\n';
3832 if (i3 < n_subdivisions)
3835 out << this_point <<
' ';
3836 output_point_data(i1 +
3837 i2 * n_points_per_direction +
3838 i3 * n_points_per_direction *
3839 n_points_per_direction);
3843 out << get_equispaced_location(patch,
3849 i1 + i2 * n_points_per_direction +
3850 (i3 + 1) * n_points_per_direction *
3851 n_points_per_direction);
3854 out <<
'\n' <<
'\n';
3863 for (
const unsigned int v : {0, 1, 2, 0, 3, 2})
3865 out << get_node_location(patch, v) <<
' ';
3866 output_point_data(v);
3871 for (
const unsigned int v : {3, 1})
3873 out << get_node_location(patch, v) <<
' ';
3874 output_point_data(v);
3884 for (
const unsigned int v : {0, 1, 3, 2, 0, 4, 1})
3886 out << get_node_location(patch, v) <<
' ';
3887 output_point_data(v);
3892 for (
const unsigned int v : {2, 4, 3})
3894 out << get_node_location(patch, v) <<
' ';
3895 output_point_data(v);
3909 for (
const unsigned int v : {0, 1, 2, 0, 3, 4, 5, 3})
3911 out << get_node_location(patch, v) <<
' ';
3912 output_point_data(v);
3917 for (
const unsigned int v : {1, 4})
3919 out << get_node_location(patch, v) <<
' ';
3920 output_point_data(v);
3925 for (
const unsigned int v : {2, 5})
3927 out << get_node_location(patch, v) <<
' ';
3928 output_point_data(v);
4335 const std::vector<std::string> & ,
4337 std::tuple<
unsigned int,
4346#ifndef DEAL_II_WITH_MPI
4355 if (patches.empty())
4365 std::multiset<EpsCell2d> cells;
4369 float min_color_value = std::numeric_limits<float>::max();
4370 float max_color_value = std::numeric_limits<float>::min();
4374 double heights[4] = {0, 0, 0, 0};
4378 for (
const auto &patch : patches)
4381 const unsigned int n = n_subdivisions + 1;
4382 const unsigned int d1 = 1;
4383 const unsigned int d2 = n;
4385 for (
unsigned int i2 = 0; i2 < n_subdivisions; ++i2)
4386 for (
unsigned int i1 = 0; i1 < n_subdivisions; ++i1)
4390 get_equispaced_location(patch, {i1, i2}, n_subdivisions);
4392 get_equispaced_location(patch, {i1 + 1, i2}, n_subdivisions);
4394 get_equispaced_location(patch, {i1, i2 + 1}, n_subdivisions);
4395 points[3] = get_equispaced_location(patch,
4403 patch.
data.n_rows() == 0,
4406 patch.
data.n_rows()));
4408 patch.
data.n_rows() != 0 ?
4412 heights[1] = patch.
data.n_rows() != 0 ?
4414 (i1 + 1) * d1 + i2 * d2) *
4417 heights[2] = patch.
data.n_rows() != 0 ?
4419 i1 * d1 + (i2 + 1) * d2) *
4422 heights[3] = patch.
data.n_rows() != 0 ?
4424 (i1 + 1) * d1 + (i2 + 1) * d2) *
4431 for (
unsigned int i = 0; i < 4; ++i)
4432 heights[i] = points[i][2];
4457 for (
unsigned int vertex = 0; vertex < 4; ++vertex)
4459 const double x = points[vertex][0], y = points[vertex][1],
4460 z = -heights[vertex];
4462 eps_cell.vertices[vertex][0] = -cz * x + sz * y;
4463 eps_cell.vertices[vertex][1] =
4464 -cx * sz * x - cx * cz * y - sx * z;
4488 (points[0] + points[1] + points[2] + points[3]) / 4;
4489 const double center_height =
4490 -(heights[0] + heights[1] + heights[2] + heights[3]) / 4;
4493 eps_cell.depth = -sx * sz * center_point[0] -
4494 sx * cz * center_point[1] + cx * center_height;
4499 patch.
data.n_rows() == 0,
4502 patch.
data.n_rows()));
4503 const double color_values[4] = {
4504 patch.
data.n_rows() != 0 ?
4508 patch.
data.n_rows() != 0 ?
4512 patch.
data.n_rows() != 0 ?
4516 patch.
data.n_rows() != 0 ?
4518 (i1 + 1) * d1 + (i2 + 1) * d2) :
4522 eps_cell.color_value = (color_values[0] + color_values[1] +
4523 color_values[3] + color_values[2]) /
4528 std::min(min_color_value, eps_cell.color_value);
4530 std::max(max_color_value, eps_cell.color_value);
4534 cells.insert(eps_cell);
4540 double x_min = cells.begin()->vertices[0][0];
4541 double x_max = x_min;
4542 double y_min = cells.begin()->vertices[0][1];
4543 double y_max = y_min;
4545 for (
const auto &cell : cells)
4546 for (
const auto &vertex : cell.vertices)
4548 x_min =
std::min(x_min, vertex[0]);
4549 x_max =
std::max(x_max, vertex[0]);
4550 y_min =
std::min(y_min, vertex[1]);
4551 y_max =
std::max(y_max, vertex[1]);
4556 const double scale =
4560 const Point<2> offset(x_min, y_min);
4565 out <<
"%!PS-Adobe-2.0 EPSF-1.2" <<
'\n'
4566 <<
"%%Title: deal.II Output" <<
'\n'
4567 <<
"%%Creator: the deal.II library" <<
'\n'
4570 <<
"%%BoundingBox: "
4574 <<
static_cast<unsigned int>((x_max - x_min) * scale + 0.5) <<
' '
4575 <<
static_cast<unsigned int>((y_max - y_min) * scale + 0.5) <<
'\n';
4584 out <<
"/m {moveto} bind def" <<
'\n'
4585 <<
"/l {lineto} bind def" <<
'\n'
4586 <<
"/s {setrgbcolor} bind def" <<
'\n'
4587 <<
"/sg {setgray} bind def" <<
'\n'
4588 <<
"/lx {lineto closepath stroke} bind def" <<
'\n'
4589 <<
"/lf {lineto closepath fill} bind def" <<
'\n';
4591 out <<
"%%EndProlog" <<
'\n' <<
'\n';
4593 out << flags.
line_width <<
" setlinewidth" <<
'\n';
4601 if (max_color_value == min_color_value)
4602 max_color_value = min_color_value + 1;
4606 for (
const auto &cell : cells)
4619 out << rgb_values.
red <<
" sg ";
4621 out << rgb_values.
red <<
' ' << rgb_values.
green <<
' '
4622 << rgb_values.
blue <<
" s ";
4627 out << (cell.vertices[0] - offset) * scale <<
" m "
4628 << (cell.vertices[1] - offset) * scale <<
" l "
4629 << (cell.vertices[3] - offset) * scale <<
" l "
4630 << (cell.vertices[2] - offset) * scale <<
" lf" <<
'\n';
4635 << (cell.vertices[0] - offset) * scale <<
" m "
4636 << (cell.vertices[1] - offset) * scale <<
" l "
4637 << (cell.vertices[3] - offset) * scale <<
" l "
4638 << (cell.vertices[2] - offset) * scale <<
" lx" <<
'\n';
4640 out <<
"showpage" <<
'\n';
4939 const std::vector<std::string> &data_names,
4941 std::tuple<
unsigned int,
4945 &nonscalar_data_ranges,
4951#ifndef DEAL_II_WITH_MPI
4960 if (patches.empty())
4964 VtkStream vtk_out(out, flags);
4966 const unsigned int n_data_sets = data_names.size();
4968 if (patches[0].points_are_available)
4980 out <<
"# vtk DataFile Version 3.0" <<
'\n'
4981 <<
"#This file was generated by the deal.II library";
4989 out <<
'\n' <<
"ASCII" <<
'\n';
4991 out <<
"DATASET UNSTRUCTURED_GRID\n" <<
'\n';
4998 const unsigned int n_metadata =
4999 ((flags.
cycle != std::numeric_limits<unsigned int>::min() ? 1 : 0) +
5000 (flags.
time != std::numeric_limits<double>::min() ? 1 : 0));
5003 out <<
"FIELD FieldData " << n_metadata <<
'\n';
5005 if (flags.
cycle != std::numeric_limits<unsigned int>::min())
5007 out <<
"CYCLE 1 1 int\n" << flags.
cycle <<
'\n';
5009 if (flags.
time != std::numeric_limits<double>::min())
5011 out <<
"TIME 1 1 double\n" << flags.
time <<
'\n';
5017 unsigned int n_nodes;
5018 unsigned int n_cells;
5019 unsigned int n_points_and_n_cells;
5020 std::tie(n_nodes, n_cells, n_points_and_n_cells) =
5036 [&patches]() {
return create_global_data_table(patches); });
5042 out <<
"POINTS " << n_nodes <<
" double" <<
'\n';
5047 out <<
"CELLS " << n_cells <<
' ' << n_points_and_n_cells <<
'\n';
5055 out <<
"CELL_TYPES " << n_cells <<
'\n';
5059 for (
const auto &patch : patches)
5061 const auto vtk_cell_id =
5064 for (
unsigned int i = 0; i < vtk_cell_id[1]; ++i)
5065 out <<
' ' << vtk_cell_id[0];
5074 std::move(*create_global_data_table_task.
return_value());
5079 out <<
"POINT_DATA " << n_nodes <<
'\n';
5083 std::vector<bool> data_set_written(n_data_sets,
false);
5084 for (
const auto &nonscalar_data_range : nonscalar_data_ranges)
5089 "The VTK writer does not currently support outputting "
5090 "tensor data. Use the VTU writer instead."));
5093 std::get<0>(nonscalar_data_range),
5095 std::get<0>(nonscalar_data_range)));
5096 AssertThrow(std::get<1>(nonscalar_data_range) < n_data_sets,
5100 AssertThrow(std::get<1>(nonscalar_data_range) + 1 -
5101 std::get<0>(nonscalar_data_range) <=
5104 "Can't declare a vector with more than 3 components "
5108 for (
unsigned int i = std::get<0>(nonscalar_data_range);
5109 i <= std::get<1>(nonscalar_data_range);
5111 data_set_written[i] =
true;
5117 if (!std::get<2>(nonscalar_data_range).empty())
5118 out << std::get<2>(nonscalar_data_range);
5121 for (
unsigned int i = std::get<0>(nonscalar_data_range);
5122 i < std::get<1>(nonscalar_data_range);
5124 out << data_names[i] <<
"__";
5125 out << data_names[std::get<1>(nonscalar_data_range)];
5128 out <<
" double" <<
'\n';
5131 for (
unsigned int n = 0; n < n_nodes; ++n)
5133 switch (std::get<1>(nonscalar_data_range) -
5134 std::get<0>(nonscalar_data_range))
5137 out << data_vectors(std::get<0>(nonscalar_data_range), n)
5142 out << data_vectors(std::get<0>(nonscalar_data_range), n)
5144 << data_vectors(std::get<0>(nonscalar_data_range) + 1, n)
5148 out << data_vectors(std::get<0>(nonscalar_data_range), n)
5150 << data_vectors(std::get<0>(nonscalar_data_range) + 1, n)
5152 << data_vectors(std::get<0>(nonscalar_data_range) + 2, n)
5165 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
5166 if (data_set_written[data_set] ==
false)
5168 out <<
"SCALARS " << data_names[data_set] <<
" double 1" <<
'\n'
5169 <<
"LOOKUP_TABLE default" <<
'\n';
5170 std::copy(data_vectors[data_set].begin(),
5171 data_vectors[data_set].end(),
5172 std::ostream_iterator<double>(out,
" "));
5257 const std::vector<std::string> &data_names,
5259 std::tuple<
unsigned int,
5263 &nonscalar_data_ranges,
5277 unit.second.find(
'\"') == std::string::npos,
5279 "A physical unit you provided, <" + unit.second +
5280 ">, contained a quotation mark character. This is not allowed."));
5283#ifndef DEAL_II_WITH_MPI
5292 if (patches.empty())
5297 out <<
"<Piece NumberOfPoints=\"0\" NumberOfCells=\"0\" >\n"
5299 <<
"<DataArray type=\"UInt8\" Name=\"types\"></DataArray>\n"
5301 <<
" <PointData Scalars=\"scalars\">\n";
5302 std::vector<bool> data_set_written(data_names.size(),
false);
5303 for (
const auto &nonscalar_data_range : nonscalar_data_ranges)
5306 for (
unsigned int i = std::get<0>(nonscalar_data_range);
5307 i <= std::get<1>(nonscalar_data_range);
5309 data_set_written[i] =
true;
5313 out <<
" <DataArray type=\"Float32\" Name=\"";
5315 if (!std::get<2>(nonscalar_data_range).empty())
5316 out << std::get<2>(nonscalar_data_range);
5319 for (
unsigned int i = std::get<0>(nonscalar_data_range);
5320 i < std::get<1>(nonscalar_data_range);
5322 out << data_names[i] <<
"__";
5323 out << data_names[std::get<1>(nonscalar_data_range)];
5326 out <<
"\" NumberOfComponents=\"3\"></DataArray>\n";
5329 for (
unsigned int data_set = 0; data_set < data_names.size();
5331 if (data_set_written[data_set] ==
false)
5333 out <<
" <DataArray type=\"Float32\" Name=\""
5334 << data_names[data_set] <<
"\"></DataArray>\n";
5337 out <<
" </PointData>\n";
5338 out <<
"</Piece>\n";
5352 const unsigned int n_metadata =
5353 ((flags.
cycle != std::numeric_limits<unsigned int>::min() ? 1 : 0) +
5354 (flags.
time != std::numeric_limits<double>::min() ? 1 : 0));
5356 out <<
"<FieldData>\n";
5358 if (flags.
cycle != std::numeric_limits<unsigned int>::min())
5361 <<
"<DataArray type=\"Float32\" Name=\"CYCLE\" NumberOfTuples=\"1\" format=\"ascii\">"
5362 << flags.
cycle <<
"</DataArray>\n";
5364 if (flags.
time != std::numeric_limits<double>::min())
5367 <<
"<DataArray type=\"Float32\" Name=\"TIME\" NumberOfTuples=\"1\" format=\"ascii\">"
5368 << flags.
time <<
"</DataArray>\n";
5372 out <<
"</FieldData>\n";
5376 const unsigned int n_data_sets = data_names.size();
5379 if (patches[0].points_are_available)
5388 const char *ascii_or_binary =
5389 (deal_ii_with_zlib &&
5396 unsigned int n_nodes;
5397 unsigned int n_cells;
5398 std::tie(n_nodes, n_cells, std::ignore) =
5406 const auto stringize_vertex_information = [&patches,
5410 ascii_or_binary]() {
5411 std::ostringstream o;
5413 o <<
" <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\""
5414 << ascii_or_binary <<
"\">\n";
5415 const std::vector<Point<spacedim>> node_positions =
5420 std::vector<float> node_coordinates_3d;
5421 node_coordinates_3d.reserve(node_positions.size() * 3);
5422 for (
const auto &node_position : node_positions)
5424 for (
unsigned int d = 0; d < 3; ++d)
5426 node_coordinates_3d.emplace_back(node_position[d]);
5428 node_coordinates_3d.emplace_back(0.0f);
5430 o << vtu_stringize_array(node_coordinates_3d,
5434 o <<
" </DataArray>\n";
5435 o <<
" </Points>\n\n";
5444 const auto stringize_cell_to_vertex_information = [&patches,
5448 out.precision()]() {
5449 std::ostringstream o;
5452 o <<
" <DataArray type=\"Int32\" Name=\"connectivity\" format=\""
5453 << ascii_or_binary <<
"\">\n";
5455 std::vector<int32_t> cells;
5458 unsigned int first_vertex_of_patch = 0;
5460 for (
const auto &patch : patches)
5472 const unsigned int n_points = patch.
data.n_cols();
5473 Assert((dim == 2 && n_points == 6) ||
5474 (dim == 3 && n_points == 10),
5477 if (deal_ii_with_zlib &&
5481 for (
unsigned int i = 0; i < n_points; ++i)
5482 cells.push_back(first_vertex_of_patch + i);
5486 for (
unsigned int i = 0; i < n_points; ++i)
5487 o <<
'\t' << first_vertex_of_patch + i;
5491 first_vertex_of_patch += n_points;
5496 else if (patch.
reference_cell != ReferenceCells::get_hypercube<dim>())
5500 const unsigned int n_points = patch.
data.n_cols();
5502 if (deal_ii_with_zlib &&
5506 for (
unsigned int i = 0; i < n_points; ++i)
5508 first_vertex_of_patch +
5513 for (
unsigned int i = 0; i < n_points; ++i)
5515 << (first_vertex_of_patch +
5520 first_vertex_of_patch += n_points;
5525 const unsigned int n_points_per_direction = n_subdivisions + 1;
5527 std::vector<unsigned> local_vertex_order;
5531 const auto flush_current_cell = [&flags,
5534 first_vertex_of_patch,
5535 &local_vertex_order]() {
5536 if (deal_ii_with_zlib &&
5540 for (
const auto &c : local_vertex_order)
5541 cells.push_back(first_vertex_of_patch + c);
5545 for (
const auto &c : local_vertex_order)
5546 o <<
'\t' << first_vertex_of_patch + c;
5550 local_vertex_order.clear();
5555 local_vertex_order.reserve(Utilities::fixed_power<dim>(2));
5561 local_vertex_order.emplace_back(0);
5562 flush_current_cell();
5568 for (
unsigned int i1 = 0; i1 < n_subdivisions; ++i1)
5570 const unsigned int starting_offset = i1;
5571 local_vertex_order.emplace_back(starting_offset);
5572 local_vertex_order.emplace_back(starting_offset +
5574 flush_current_cell();
5581 for (
unsigned int i2 = 0; i2 < n_subdivisions; ++i2)
5582 for (
unsigned int i1 = 0; i1 < n_subdivisions; ++i1)
5584 const unsigned int starting_offset =
5585 i2 * n_points_per_direction + i1;
5586 local_vertex_order.emplace_back(
5588 local_vertex_order.emplace_back(
5589 starting_offset + 1);
5590 local_vertex_order.emplace_back(
5591 starting_offset + n_points_per_direction + 1);
5592 local_vertex_order.emplace_back(
5593 starting_offset + n_points_per_direction);
5594 flush_current_cell();
5601 for (
unsigned int i3 = 0; i3 < n_subdivisions; ++i3)
5602 for (
unsigned int i2 = 0; i2 < n_subdivisions; ++i2)
5603 for (
unsigned int i1 = 0; i1 < n_subdivisions;
5606 const unsigned int starting_offset =
5607 i3 * n_points_per_direction *
5608 n_points_per_direction +
5609 i2 * n_points_per_direction + i1;
5610 local_vertex_order.emplace_back(
5612 local_vertex_order.emplace_back(
5613 starting_offset + 1);
5614 local_vertex_order.emplace_back(
5615 starting_offset + n_points_per_direction +
5617 local_vertex_order.emplace_back(
5618 starting_offset + n_points_per_direction);
5619 local_vertex_order.emplace_back(
5620 starting_offset + n_points_per_direction *
5621 n_points_per_direction);
5622 local_vertex_order.emplace_back(
5624 n_points_per_direction *
5625 n_points_per_direction +
5627 local_vertex_order.emplace_back(
5629 n_points_per_direction *
5630 n_points_per_direction +
5631 n_points_per_direction + 1);
5632 local_vertex_order.emplace_back(
5634 n_points_per_direction *
5635 n_points_per_direction +
5636 n_points_per_direction);
5637 flush_current_cell();
5648 local_vertex_order.resize(
5649 Utilities::fixed_power<dim>(n_points_per_direction));
5657 "Point-like cells should not be possible "
5658 "when writing higher-order cells."));
5663 for (
unsigned int i1 = 0; i1 < n_subdivisions + 1;
5666 const unsigned int local_index = i1;
5667 const unsigned int connectivity_index =
5669 .template vtk_lexicographic_to_node_index<1>(
5673 local_vertex_order[connectivity_index] =
5675 flush_current_cell();
5682 for (
unsigned int i2 = 0; i2 < n_subdivisions + 1;
5684 for (
unsigned int i1 = 0; i1 < n_subdivisions + 1;
5687 const unsigned int local_index =
5688 i2 * n_points_per_direction + i1;
5689 const unsigned int connectivity_index =
5691 .template vtk_lexicographic_to_node_index<
5693 {{n_subdivisions, n_subdivisions}},
5695 local_vertex_order[connectivity_index] =
5698 flush_current_cell();
5704 for (
unsigned int i3 = 0; i3 < n_subdivisions + 1;
5706 for (
unsigned int i2 = 0; i2 < n_subdivisions + 1;
5708 for (
unsigned int i1 = 0; i1 < n_subdivisions + 1;
5711 const unsigned int local_index =
5712 i3 * n_points_per_direction *
5713 n_points_per_direction +
5714 i2 * n_points_per_direction + i1;
5715 const unsigned int connectivity_index =
5717 .template vtk_lexicographic_to_node_index<
5723 local_vertex_order[connectivity_index] =
5727 flush_current_cell();
5737 first_vertex_of_patch +=
5746 o << vtu_stringize_array(cells,
5751 o <<
" </DataArray>\n";
5771 const auto stringize_cell_offset_and_type_information =
5776 output_precision = out.precision()]() {
5777 std::ostringstream o;
5779 o <<
" <DataArray type=\"Int32\" Name=\"offsets\" format=\""
5780 << ascii_or_binary <<
"\">\n";
5782 std::vector<int32_t> offsets;
5783 offsets.reserve(n_cells);
5787 std::vector<unsigned int> cell_types;
5788 cell_types.reserve(n_cells);
5790 unsigned int first_vertex_of_patch = 0;
5792 for (
const auto &patch : patches)
5794 const auto vtk_cell_id =
5797 for (
unsigned int i = 0; i < vtk_cell_id[1]; ++i)
5799 cell_types.push_back(vtk_cell_id[0]);
5800 first_vertex_of_patch += vtk_cell_id[2];
5801 offsets.push_back(first_vertex_of_patch);
5805 o << vtu_stringize_array(offsets,
5809 o <<
" </DataArray>\n";
5811 o <<
" <DataArray type=\"UInt8\" Name=\"types\" format=\""
5812 << ascii_or_binary <<
"\">\n";
5814 if (deal_ii_with_zlib &&
5817 std::vector<uint8_t> cell_types_uint8_t(cell_types.size());
5818 for (
unsigned int i = 0; i < cell_types.size(); ++i)
5819 cell_types_uint8_t[i] =
static_cast<std::uint8_t
>(cell_types[i]);
5821 o << vtu_stringize_array(cell_types_uint8_t,
5827 o << vtu_stringize_array(cell_types,
5833 o <<
" </DataArray>\n";
5843 const auto stringize_nonscalar_data_range =
5849 output_precision = out.precision()](
const Table<2, float> &data_vectors,
5850 const auto &range) {
5851 std::ostringstream o;
5853 const auto first_component = std::get<0>(range);
5854 const auto last_component = std::get<1>(range);
5855 const auto &name = std::get<2>(range);
5856 const bool is_tensor =
5857 (std::get<3>(range) ==
5859 const unsigned int n_components = (is_tensor ? 9 : 3);
5866 AssertThrow((last_component + 1 - first_component <= 9),
5868 "Can't declare a tensor with more than 9 components "
5869 "in VTK/VTU format."));
5873 AssertThrow((last_component + 1 - first_component <= 3),
5875 "Can't declare a vector with more than 3 components "
5876 "in VTK/VTU format."));
5881 o <<
" <DataArray type=\"Float32\" Name=\"";
5887 for (
unsigned int i = first_component; i < last_component; ++i)
5888 o << data_names[i] <<
"__";
5889 o << data_names[last_component];
5892 o <<
"\" NumberOfComponents=\"" << n_components <<
"\" format=\""
5893 << ascii_or_binary <<
"\"";
5912 std::vector<float> data;
5913 data.reserve(n_nodes * n_components);
5915 for (
unsigned int n = 0; n < n_nodes; ++n)
5919 switch (last_component - first_component)
5922 data.push_back(data_vectors(first_component, n));
5928 data.push_back(data_vectors(first_component, n));
5929 data.push_back(data_vectors(first_component + 1, n));
5934 data.push_back(data_vectors(first_component, n));
5935 data.push_back(data_vectors(first_component + 1, n));
5936 data.push_back(data_vectors(first_component + 2, n));
5949 const unsigned int size = last_component - first_component + 1;
5953 vtk_data[0][0] = data_vectors(first_component, n);
5958 for (
unsigned int c = 0; c < size; ++c)
5962 vtk_data[ind[0]][ind[1]] =
5963 data_vectors(first_component + c, n);
5969 for (
unsigned int c = 0; c < size; ++c)
5973 vtk_data[ind[0]][ind[1]] =
5974 data_vectors(first_component + c, n);
5985 for (
unsigned int i = 0; i < 3; ++i)
5986 for (
unsigned int j = 0; j < 3; ++j)
5987 data.push_back(vtk_data[i][j]);
5991 o << vtu_stringize_array(data,
5995 o <<
" </DataArray>\n";
6000 const auto stringize_scalar_data_set =
6004 output_precision = out.precision()](
const Table<2, float> &data_vectors,
6005 const unsigned int data_set) {
6006 std::ostringstream o;
6008 o <<
" <DataArray type=\"Float32\" Name=\"" << data_names[data_set]
6009 <<
"\" format=\"" << ascii_or_binary <<
"\"";
6013 o <<
" units=\"" << flags.
physical_units.at(data_names[data_set])
6018 const std::vector<float> data(data_vectors[data_set].begin(),
6019 data_vectors[data_set].end());
6020 o << vtu_stringize_array(data,
6024 o <<
" </DataArray>\n";
6043 return create_global_data_table<dim, spacedim, float>(patches);
6057 std::move(*create_global_data_table_task.
return_value());
6063 std::vector<bool> data_set_handled(n_data_sets,
false);
6064 for (
const auto &range : nonscalar_data_ranges)
6067 const auto first_component = std::get<0>(range);
6068 const auto last_component = std::get<1>(range);
6069 for (
unsigned int i = first_component; i <= last_component; ++i)
6070 data_set_handled[i] =
true;
6073 return stringize_nonscalar_data_range(data_vectors, range);
6078 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
6079 if (data_set_handled[data_set] ==
false)
6082 return stringize_scalar_data_set(data_vectors, data_set);
6088 out <<
"<Piece NumberOfPoints=\"" << n_nodes <<
"\" NumberOfCells=\""
6089 << n_cells <<
"\" >\n";
6090 for (
const auto &s : mesh_tasks.return_values())
6092 out <<
" <PointData Scalars=\"scalars\">\n";
6095 out <<
" </PointData>\n";
6096 out <<
" </Piece>\n";